Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support specifying osversion in the --platform flag #1206

Merged
merged 1 commit into from
Dec 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions cmd/crane/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ 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 @@ -64,10 +63,6 @@ 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 := remote.DefaultTransport.Clone()
Expand Down Expand Up @@ -118,8 +113,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.")
root.PersistentFlags().Var(platform, "platform", "Specifies the platform in the form os/arch[/variant][:osversion] (e.g. linux/amd64).")

return root
}
Expand Down
8 changes: 7 additions & 1 deletion cmd/crane/cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,13 @@ func parsePlatform(platform string) (*v1.Platform, error) {
}

p := &v1.Platform{}
parts := strings.Split(platform, "/")

parts := strings.SplitN(platform, ":", 2)
if len(parts) == 2 {
p.OSVersion = parts[1]
}

parts = strings.Split(parts[0], "/")

if len(parts) < 2 {
return nil, fmt.Errorf("failed to parse platform '%s': expected format os/arch[/variant]", platform)
Expand Down
3 changes: 1 addition & 2 deletions cmd/crane/doc/crane.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_append.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_auth.md

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

3 changes: 1 addition & 2 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.

3 changes: 1 addition & 2 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.

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_blob.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_catalog.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_config.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_copy.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_delete.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_digest.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_export.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_flatten.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_ls.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_manifest.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_mutate.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_pull.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_push.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_rebase.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_tag.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_validate.md

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

3 changes: 1 addition & 2 deletions cmd/crane/doc/crane_version.md

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