-
Notifications
You must be signed in to change notification settings - Fork 116
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
containerd-native converter #224
Conversation
036448e
to
963d9aa
Compare
7df7cdc
to
2eaefb5
Compare
2eaefb5
to
bbc936b
Compare
func readPathsFromRecordFile(filename string) ([]string, error) { | ||
r, err := os.Open(filename) | ||
if err != nil { | ||
return nil, err | ||
} | ||
defer r.Close() | ||
dec := json.NewDecoder(r) | ||
var paths []string | ||
added := make(map[string]struct{}) | ||
for dec.More() { | ||
var e recorder.Entry | ||
if err := dec.Decode(&e); err != nil { | ||
return nil, err | ||
} | ||
if _, ok := added[e.Path]; !ok { | ||
paths = append(paths, e.Path) | ||
added[e.Path] = struct{}{} | ||
} | ||
} | ||
return paths, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should make it per layer in the future.
bbc936b
to
dd0f43f
Compare
dd0f43f
to
ffc4cb8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
cfg DualConfig | ||
cfgAsOCI ocispec.Image // read only, used for parsing cfg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍👍
The `nativeconverter` package provides containerd-native converter that does not depend on GGCR. Usage: `ctr images convert --oci --estargz SRC DST` Specifying `--oci` is highly recommended, otherwise "containerd.io/snapshot/stargz/toc.digest" will be lost, unless the original image has already OCI mediatype. Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
ffc4cb8
to
8ef2943
Compare
ready to merge? |
Yes! |
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 <akihiro.suda.cz@hco.ntt.co.jp>
The
nativeconverter
package provides containerd-native converter that does not depend on GGCR.Usage:
ctr images convert --oci --estargz SRC DST
Specifying
--oci
is highly recommended, otherwise "containerd.io/snapshot/stargz/toc.digest" will be lost, unless the original image has already OCI mediatype.Close #223