From b991c71e90232a15634ccbfc396bfafa745d7b4a Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Thu, 15 Sep 2022 22:37:44 -0700 Subject: [PATCH] Update pull command to use filter arguments Signed-off-by: Derek McGowan --- cmd/ctr/commands/images/pull.go | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/cmd/ctr/commands/images/pull.go b/cmd/ctr/commands/images/pull.go index 666aeb69d..2728d2ba7 100644 --- a/cmd/ctr/commands/images/pull.go +++ b/cmd/ctr/commands/images/pull.go @@ -97,8 +97,36 @@ command. As part of this process, we do the following: if err != nil { 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) - is := image.NewStore(ref) + is := image.NewStore(ref, sopts...) pf, done := ProgressHandler(ctx, os.Stdout) defer done()