Add a platform.ParseAll helper

Signed-off-by: Jin Dong <djdongjin95@gmail.com>
This commit is contained in:
Jin Dong
2023-06-26 20:34:37 +00:00
parent b6abda73b8
commit 0a92661e69
7 changed files with 35 additions and 64 deletions

View File

@@ -101,13 +101,9 @@ command. As part of this process, we do the following:
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)
p, err := platforms.ParseAll(context.StringSlice("platform"))
if err != nil {
return err
}
if len(p) == 0 {
p = append(p, platforms.DefaultSpec())
@@ -168,12 +164,9 @@ command. As part of this process, we do the following:
return fmt.Errorf("unable to resolve image platforms: %w", err)
}
} else {
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)
p, err = platforms.ParseAll(context.StringSlice("platform"))
if err != nil {
return err
}
}
if len(p) == 0 {