diff --git a/cmd/crane/cmd/root.go b/cmd/crane/cmd/root.go index d0bc6429a..b692e91e2 100644 --- a/cmd/crane/cmd/root.go +++ b/cmd/crane/cmd/root.go @@ -38,6 +38,7 @@ func New(use, short string, options []crane.Option) *cobra.Command { verbose := false insecure := false platform := &platformValue{} + var osVersion string root := &cobra.Command{ Use: use, @@ -62,6 +63,10 @@ func New(use, short string, options []crane.Option) *cobra.Command { options = append(options, crane.WithUserAgent(fmt.Sprintf("%s/%s", binary, Version))) } + if osVersion != "" { + platform.platform.OSVersion = osVersion + } + options = append(options, crane.WithPlatform(platform.platform)) transport := http.DefaultTransport.(*http.Transport).Clone() @@ -111,6 +116,7 @@ func New(use, short string, options []crane.Option) *cobra.Command { root.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable debug logs") root.PersistentFlags().BoolVar(&insecure, "insecure", false, "Allow image references to be fetched without TLS") root.PersistentFlags().Var(platform, "platform", "Specifies the platform in the form os/arch[/variant] (e.g. linux/amd64).") + root.PersistentFlags().StringVar(&osVersion, "osversion", "", "Specifies the OS version.") return root } diff --git a/pkg/v1/remote/index.go b/pkg/v1/remote/index.go index 49c5404e1..989857918 100644 --- a/pkg/v1/remote/index.go +++ b/pkg/v1/remote/index.go @@ -214,7 +214,7 @@ func (r *remoteIndex) childByPlatform(platform v1.Platform) (*Descriptor, error) return r.childDescriptor(childDesc, platform) } } - return nil, fmt.Errorf("no child with platform %s/%s in index %s", platform.OS, platform.Architecture, r.Ref) + return nil, fmt.Errorf("no child with platform %+v in index %s", platform, r.Ref) } func (r *remoteIndex) childByHash(h v1.Hash) (*Descriptor, error) {