[transfer] update export to use image store references

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan
2023-02-28 22:15:44 -08:00
parent e2283edefb
commit 13bf5565eb
8 changed files with 274 additions and 64 deletions

View File

@@ -98,33 +98,38 @@ When '--all-platforms' is given all images in a manifest list must be available.
pf, done := ProgressHandler(ctx, os.Stdout)
defer done()
var specified []ocispec.Platform
exportOpts := []tarchive.ExportOpt{}
if pss := context.StringSlice("platform"); len(pss) > 0 {
for _, ps := range pss {
p, err := platforms.Parse(ps)
if err != nil {
return fmt.Errorf("invalid platform %q: %w", ps, err)
}
specified = append(specified, p)
exportOpts = append(exportOpts, tarchive.WithPlatform(p))
}
}
err := client.Transfer(ctx,
image.NewStore(""), // a dummy image store
tarchive.NewImageExportStream(w, "", tarchive.ExportOptions{
Images: images,
Platforms: specified,
AllPlatforms: context.Bool("all-platforms"),
SkipNonDistributable: context.Bool("skip-non-distributable"),
SkipDockerManifest: context.Bool("skip-manifest-json"),
}),
transfer.WithProgress(pf),
)
if err != nil {
return err
if context.Bool("all-platforms") {
exportOpts = append(exportOpts, tarchive.WithAllPlatforms)
}
return nil
if context.Bool("skip-manifest-json") {
exportOpts = append(exportOpts, tarchive.WithSkipCompatibilityManifest)
}
if context.Bool("skip-non-distributable") {
exportOpts = append(exportOpts, tarchive.WithSkipNonDistributableBlobs)
}
storeOpts := []image.StoreOpt{}
for _, img := range images {
storeOpts = append(storeOpts, image.WithExtraReference(img))
}
return client.Transfer(ctx,
image.NewStore("", storeOpts...),
tarchive.NewImageExportStream(w, "", exportOpts...),
transfer.WithProgress(pf),
)
}
if pss := context.StringSlice("platform"); len(pss) > 0 {