Skip to content

Commit

Permalink
Merge component 'cli' from [email protected]:docker/cli master
Browse files Browse the repository at this point in the history
  • Loading branch information
GordonTheTurtle committed Jun 15, 2020
2 parents fec0ac0 + 9392fc3 commit a3d3958
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions components/cli/cli/command/manifest/annotate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type annotateOptions struct {
os string
arch string
osFeatures []string
osVersion string
}

// NewAnnotateCommand creates a new `docker manifest annotate` command
Expand All @@ -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")

Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions components/cli/cli/command/manifest/annotate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"platform": {
"architecture": "arm",
"os": "freebsd",
"os.version": "1",
"os.features": [
"feature1"
],
Expand Down
1 change: 1 addition & 0 deletions components/cli/docs/reference/commandline/manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit a3d3958

Please sign in to comment.