Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit e45cba1

Browse files
committed
Remove version command, introduce --version option
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent e495f22 commit e45cba1

File tree

9 files changed

+28
-88
lines changed

9 files changed

+28
-88
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,14 @@ coverage: coverage-test-unit coverage-test-e2e ## run tests with coverage
112112
go tool cover -html _build/cov/all.out -o _build/cov/coverage.html
113113

114114
fossa-analyze:
115-
docker run -i --rm -e FOSSA_API_KEY=$(FOSSA_API_KEY) \
115+
docker run -i --rm -e FOSSA_API_KEY \
116116
-e GO111MODULE=on \
117117
-v $(CURDIR)/$*:/go/src/github.com/docker/app \
118118
-w /go/src/github.com/docker/app \
119119
$(BUILD_ANALYZER) analyze $(FOSSA_OPTS) --branch $(BRANCH_NAME)
120120

121121
fossa-test:
122-
docker run -i --rm -e FOSSA_API_KEY=$(FOSSA_API_KEY) \
122+
docker run -i --rm -e FOSSA_API_KEY \
123123
-v $(CURDIR)/$*:/go/src/github.com/docker/app \
124124
-w /go/src/github.com/docker/app \
125125
$(BUILD_ANALYZER) test --debug

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ Commands:
365365
uninstall Uninstall an application
366366
upgrade Upgrade an installed application
367367
validate Checks the rendered application is syntactically correct
368-
version Print version information
369368

370369
Run 'docker app COMMAND --help' for more information on a command.
371370
```

e2e/base_invocation_image_test.go

Lines changed: 0 additions & 37 deletions
This file was deleted.

e2e/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func TestMain(m *testing.M) {
120120

121121
dockerCli = dockerCliCommand{path: dockerCliPath, cliPluginDir: cliPluginDir}
122122

123-
cmd := exec.Command(dockerApp, "app", "version")
123+
cmd := exec.Command(dockerApp, "app", "--version")
124124
output, err := cmd.CombinedOutput()
125125
if err != nil {
126126
panic(err)

e2e/testdata/plugin-usage-experimental.golden

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11

2-
Usage: docker app COMMAND
2+
Usage: docker app [OPTIONS] COMMAND
33

44
A tool to build and manage Docker Applications.
55

6+
Options:
7+
--version Print version information
8+
69
Commands:
710
bundle Create a CNAB invocation image and `bundle.json` for the application
811
init Initialize Docker Application definition
@@ -16,6 +19,5 @@ Commands:
1619
uninstall Uninstall an application
1720
upgrade Upgrade an installed application
1821
validate Checks the rendered application is syntactically correct
19-
version Print version information
2022

2123
Run 'docker app COMMAND --help' for more information on a command.

e2e/testdata/plugin-usage.golden

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11

2-
Usage: docker app COMMAND
2+
Usage: docker app [OPTIONS] COMMAND
33

44
A tool to build and manage Docker Applications.
55

6+
Options:
7+
--version Print version information
8+
69
Commands:
710
bundle Create a CNAB invocation image and `bundle.json` for the application
811
init Initialize Docker Application definition
@@ -16,6 +19,5 @@ Commands:
1619
uninstall Uninstall an application
1720
upgrade Upgrade an installed application
1821
validate Checks the rendered application is syntactically correct
19-
version Print version information
2022

2123
Run 'docker app COMMAND --help' for more information on a command.

internal/commands/root.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import (
55
"io/ioutil"
66
"os"
77

8+
"github.com/docker/app/internal"
9+
810
"github.com/docker/app/internal/store"
911
"github.com/docker/cli/cli/command"
1012
"github.com/docker/cli/cli/config"
@@ -13,7 +15,8 @@ import (
1315
)
1416

1517
var (
16-
completion string
18+
completion string
19+
showVersion bool
1720
)
1821

1922
// NewRootCmd returns the base root command.
@@ -24,6 +27,11 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {
2427
Use: use,
2528
Annotations: map[string]string{"experimentalCLI": "true"},
2629
RunE: func(cmd *cobra.Command, args []string) error {
30+
if showVersion {
31+
fmt.Fprintln(os.Stdout, internal.FullVersion()) //nolint:errcheck
32+
return nil
33+
}
34+
2735
switch completion {
2836
case "bash":
2937
return cmd.GenBashCompletion(dockerCli.Out())
@@ -41,10 +49,11 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {
4149

4250
cmd.Flags().StringVar(&completion, "completion", "", "Generates completion scripts for the specified shell (bash or zsh)")
4351
if err := cmd.Flags().MarkHidden("completion"); err != nil {
44-
_, _ = fmt.Fprintf(os.Stderr, "Failed to register command line options: %v", err.Error())
52+
fmt.Fprintf(os.Stderr, "Failed to register command line options: %v", err.Error()) //nolint:errcheck
4553
return nil
4654
}
4755

56+
cmd.Flags().BoolVar(&showVersion, "version", false, "Print version information")
4857
return cmd
4958
}
5059

@@ -59,7 +68,6 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
5968
inspectCmd(dockerCli),
6069
renderCmd(dockerCli),
6170
validateCmd(),
62-
versionCmd(dockerCli),
6371
bundleCmd(dockerCli),
6472
pushCmd(dockerCli),
6573
pullCmd(dockerCli),

internal/commands/version.go

Lines changed: 0 additions & 37 deletions
This file was deleted.

internal/version.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@ var (
1717
)
1818

1919
// FullVersion returns a string of version information.
20-
func FullVersion(invocationBaseImage string) string {
20+
func FullVersion() string {
2121
res := []string{
2222
fmt.Sprintf("Version: %s", Version),
2323
fmt.Sprintf("Git commit: %s", GitCommit),
2424
fmt.Sprintf("Built: %s", reformatDate(BuildTime)),
2525
fmt.Sprintf("OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH),
26-
fmt.Sprintf("Experimental: %s", Experimental),
27-
fmt.Sprintf("Invocation Base Image: %s", invocationBaseImage),
2826
}
27+
28+
if Experimental == "on" {
29+
res = append(res, fmt.Sprintf("Experimental app build"))
30+
}
31+
2932
return strings.Join(res, "\n")
3033
}
3134

0 commit comments

Comments
 (0)