-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Implement windowsDiff.Compare to allow outputting OCI images #4399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b399e2e
149fa36
a64a768
c750498
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,19 @@ | |
|
|
||
| package archive | ||
|
|
||
| import ( | ||
| "context" | ||
| "io" | ||
|
|
||
| "github.com/Microsoft/hcsshim/pkg/ociwclayer" | ||
| ) | ||
|
|
||
| // applyWindowsLayer applies a tar stream of an OCI style diff tar of a Windows layer | ||
| // See https://github.com/opencontainers/image-spec/blob/master/layer.md#applying-changesets | ||
| func applyWindowsLayer(ctx context.Context, root string, r io.Reader, options ApplyOptions) (size int64, err error) { | ||
| return ociwclayer.ImportLayerFromTar(ctx, r, root, options.Parents) | ||
| } | ||
|
|
||
| // AsWindowsContainerLayer indicates that the tar stream to apply is that of | ||
| // a Windows Container Layer. The caller must be holding SeBackupPrivilege and | ||
| // SeRestorePrivilege. | ||
|
|
@@ -27,3 +40,33 @@ func AsWindowsContainerLayer() ApplyOpt { | |
| return nil | ||
| } | ||
| } | ||
|
|
||
| // writeDiffWindowsLayers writes a tar stream of the computed difference between the | ||
| // provided Windows layers | ||
| // | ||
| // Produces a tar using OCI style file markers for deletions. Deleted | ||
| // files will be prepended with the prefix ".wh.". This style is | ||
| // based off AUFS whiteouts. | ||
| // See https://github.com/opencontainers/image-spec/blob/master/layer.md | ||
| func writeDiffWindowsLayers(ctx context.Context, w io.Writer, _, layer string, options WriteDiffOptions) error { | ||
| return ociwclayer.ExportLayerToTar(ctx, w, layer, options.ParentLayers) | ||
| } | ||
|
|
||
| // AsWindowsContainerLayerPair indicates that the paths to diff are a pair of | ||
| // Windows Container Layers. The caller must be holding SeBackupPrivilege. | ||
| func AsWindowsContainerLayerPair() WriteDiffOpt { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually dont understand this one? What does this mean to you :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The place that we actually use this config option, we've already verified the two paths are layers. IMO it makes more sense to make this generic, such as
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm. I could refactor However, that means that anyone else trying to use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe as a clarifying question, how "public" is Apart from
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overall, I'd prefer not to mix such refactorings into this simply because the current approach implements Compare to match Apply, and any further changes should be done to both at once, and as an API change that affects an existing public API, be clearly distinguished as-such. |
||
| return func(options *WriteDiffOptions) error { | ||
| options.writeDiffFunc = writeDiffWindowsLayers | ||
| return nil | ||
| } | ||
| } | ||
|
|
||
| // WithParentLayers provides the Windows Container Layers that are the parents | ||
| // of the target (right-hand, "upper") layer, if any. The source (left-hand, "lower") | ||
| // layer passed to WriteDiff should be "" in this case. | ||
| func WithParentLayers(p []string) WriteDiffOpt { | ||
| return func(options *WriteDiffOptions) error { | ||
| options.ParentLayers = p | ||
| return nil | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.