diff --git a/cli/command/manifest/annotate.go b/cli/command/manifest/annotate.go index e6c47394e0..c12b69d823 100644 --- a/cli/command/manifest/annotate.go +++ b/cli/command/manifest/annotate.go @@ -18,6 +18,7 @@ type annotateOptions struct { os string arch string osFeatures []string + osVersion string } // NewAnnotateCommand creates a new `docker manifest annotate` command @@ -39,6 +40,7 @@ func newAnnotateCommand(dockerCli command.Cli) *cobra.Command { flags.StringVar(&opts.os, "os", "", "Set operating system") flags.StringVar(&opts.arch, "arch", "", "Set architecture") + flags.StringVar(&opts.osVersion, "os-version", "", "Set operating system version") flags.StringSliceVar(&opts.osFeatures, "os-features", []string{}, "Set operating system feature") flags.StringVar(&opts.variant, "variant", "", "Set architecture variant") @@ -80,6 +82,9 @@ func runManifestAnnotate(dockerCli command.Cli, opts annotateOptions) error { if opts.variant != "" { imageManifest.Descriptor.Platform.Variant = opts.variant } + if opts.osVersion != "" { + imageManifest.Descriptor.Platform.OSVersion = opts.osVersion + } if !isValidOSArch(imageManifest.Descriptor.Platform.OS, imageManifest.Descriptor.Platform.Architecture) { return errors.Errorf("manifest entry for image has unsupported os/arch combination: %s/%s", opts.os, opts.arch) diff --git a/cli/command/manifest/annotate_test.go b/cli/command/manifest/annotate_test.go index bf7339295f..ce6e9101af 100644 --- a/cli/command/manifest/annotate_test.go +++ b/cli/command/manifest/annotate_test.go @@ -58,6 +58,7 @@ func TestManifestAnnotate(t *testing.T) { cmd.SetArgs([]string{"example.com/list:v1", "example.com/alpine:3.0"}) cmd.Flags().Set("os", "freebsd") cmd.Flags().Set("arch", "fake") + cmd.Flags().Set("os-version", "1") cmd.Flags().Set("os-features", "feature1") cmd.Flags().Set("variant", "v7") expectedError = "manifest entry for image has unsupported os/arch combination" diff --git a/cli/command/manifest/testdata/inspect-annotate.golden b/cli/command/manifest/testdata/inspect-annotate.golden index 4d65b729f1..5fe5bd5a9b 100644 --- a/cli/command/manifest/testdata/inspect-annotate.golden +++ b/cli/command/manifest/testdata/inspect-annotate.golden @@ -7,6 +7,7 @@ "platform": { "architecture": "arm", "os": "freebsd", + "os.version": "1", "os.features": [ "feature1" ], diff --git a/docs/reference/commandline/manifest.md b/docs/reference/commandline/manifest.md index d8232a1fec..73c60a8cc8 100644 --- a/docs/reference/commandline/manifest.md +++ b/docs/reference/commandline/manifest.md @@ -77,6 +77,7 @@ Options: --arch string Set architecture --help Print usage --os string Set operating system + --os-version string Set operating system version --os-features stringSlice Set operating system feature --variant string Set architecture variant