add Image content converter#4881
Conversation
|
cc @ktock |
cbe4dbf to
e7f8c59
Compare
e7f8c59 to
a94bac9
Compare
a94bac9 to
8120d53
Compare
|
Build succeeded.
|
|
CI failure is unrelated |
There was a problem hiding this comment.
The package comment should be updated.
There was a problem hiding this comment.
I don't see a need for this to be added in the top level package. It is an image utility function which can operate entirely from a client instance. I realize there are a few other functions which we could categorize like that, but don't see that as a reason to continue to add more.
There was a problem hiding this comment.
Moved the function to images/converter pkg.
convert_test.go still remains in the top level pkg as it depends on the private functions in the top pkg.
3576a07 to
b8c590b
Compare
|
Build succeeded.
|
b8c590b to
e2b1216
Compare
|
@dmcgowan PTAL |
e2b1216 to
f21113f
Compare
f21113f to
6720120
Compare
|
rebased |
|
Build succeeded.
|
|
Two small changes then looks good |
Go example:
```go
opts := []converter.Opt{
// convert Docker media types to OCI ones
converter.WithDocker2OCI(true),
// convert tar.gz layers to uncompressed tar layers
converter.WithLayerConvertFunc(uncompress.LayerConvertFunc),
}
srcRef := "example.com/foo:orig"
dstRef := "example.com/foo:converted"
dstImg, err = converter.Convert(ctx, client, dstRef, srcRef, opts...)
fmt.Println(dstImg.Target)
```
ctr example: `ctr images convert --oci --uncompress example.com/foo:orig example.com/foo:converted`
Go test: `go test -exec sudo -test.root -test.run TestConvert`
The implementation is from containerd/stargz-snapshotter#224,
but eStargz-specific functions are not included in this PR.
eStargz converter can be specified by importing `estargz` package and using `WithLayerConvertFunc(estargz.LayerConvertFunc)` option.
This converter interface will be potentially useful for converting zstd and ocicrypt layers as well.
Signed-off-by: Akihiro Suda <[email protected]>
6720120 to
5ca3ac6
Compare
|
Updated to apply containerd/stargz-snapshotter#246 |
|
Build succeeded.
|
Go example:
ctr example:
ctr images convert --oci --uncompress example.com/foo:orig example.com/foo:convertedGo test:
go test -exec sudo -test.root -test.run TestConvertThe implementation is from containerd/stargz-snapshotter#224, but eStargz-specific functions are not included in this PR.
eStargz converter can be specified by importing
estargzpackage and usingWithLayerConvertFunc(estargz.LayerConvertFunc)option.This converter interface will be potentially useful for converting zstd and ocicrypt layers as well.