Update pull command to use filter arguments

Signed-off-by: Derek McGowan <derek@mcg.dev>
This commit is contained in:
Derek McGowan 2022-09-15 22:37:44 -07:00
parent 40d3fa3afd
commit b991c71e90
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB

View File

@ -97,8 +97,36 @@ command. As part of this process, we do the following:
if err != nil { if err != nil {
return err return err
} }
var sopts []image.StoreOpt
if !context.Bool("all-platforms") {
var p []ocispec.Platform
for _, s := range context.StringSlice("platform") {
ps, err := platforms.Parse(s)
if err != nil {
return fmt.Errorf("unable to parse platform %s: %w", s, err)
}
p = append(p, ps)
}
if len(p) == 0 {
p = append(p, platforms.DefaultSpec())
}
sopts = append(sopts, image.WithPlatforms(p...))
}
// TODO: Support unpack for all platforms..?
// Pass in a *?
if context.Bool("metadata-only") {
sopts = append(sopts, image.WithAllMetadata)
// Any with an empty set is None
// TODO: Specify way to specify not default platorm
//config.PlatformMatcher = platforms.Any()
} else if context.Bool("all-metadata") {
sopts = append(sopts, image.WithAllMetadata)
}
reg := image.NewOCIRegistry(ref, nil, ch) reg := image.NewOCIRegistry(ref, nil, ch)
is := image.NewStore(ref) is := image.NewStore(ref, sopts...)
pf, done := ProgressHandler(ctx, os.Stdout) pf, done := ProgressHandler(ctx, os.Stdout)
defer done() defer done()