Skip to content

Commit

Permalink
Adding OS version to Crane for better Windows support. (#1173)
Browse files Browse the repository at this point in the history
* Adding OS version to Crane for better Windows support.

Windows images present some unique challenges and one of those challenges is being able to pull a specific OS version. This especially comes into play when working with a manifest like the k8s.gcr.io/pause:3.6 which doesn't offer tags specific to Windows OS version. 

Here is an example use case:

crane pull --platform windows/amd64 --osversion 10.0.17763.2114 k8s.gcr.io/pause:3.6 windows-1809.tar

Without the version specified Windows Server 2022 would have been pulled.

Signed-off-by: Jamie Phillips <cphill11@gmail.com>

* Updating the help docs.

Generating the docs after adding the CLI flag.

Signed-off-by: Jamie Phillips <cphill11@gmail.com>
  • Loading branch information
phillipsj committed Nov 10, 2021
1 parent f337ecf commit 6cb23fb
Show file tree
Hide file tree
Showing 24 changed files with 29 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cmd/crane/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()
Expand Down Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions cmd/crane/doc/crane.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_append.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_auth.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_auth_get.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_auth_login.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_blob.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_catalog.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_config.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_copy.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_delete.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_digest.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_export.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_flatten.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_ls.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_manifest.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_mutate.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_pull.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_push.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_rebase.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_tag.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_validate.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/crane/doc/crane_version.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/v1/remote/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 6cb23fb

Please sign in to comment.