Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Remove version command, introduce --version option
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Sep 17, 2019
1 parent c9eb813 commit 28789cc
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 88 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ coverage: coverage-test-unit coverage-test-e2e ## run tests with coverage
go tool cover -html _build/cov/all.out -o _build/cov/coverage.html

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

fossa-test:
docker run -i --rm -e FOSSA_API_KEY=$(FOSSA_API_KEY) \
docker run -i --rm -e FOSSA_API_KEY \
-v $(CURDIR)/$*:/go/src/github.com/docker/app \
-w /go/src/github.com/docker/app \
$(BUILD_ANALYZER) test --debug
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ Commands:
uninstall Uninstall an application
upgrade Upgrade an installed application
validate Checks the rendered application is syntactically correct
version Print version information
Run 'docker app COMMAND --help' for more information on a command.
```
Expand Down
37 changes: 0 additions & 37 deletions e2e/base_invocation_image_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestMain(m *testing.M) {

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

cmd := exec.Command(dockerApp, "app", "version")
cmd := exec.Command(dockerApp, "app", "--version")
output, err := cmd.CombinedOutput()
if err != nil {
panic(err)
Expand Down
6 changes: 4 additions & 2 deletions e2e/testdata/plugin-usage-experimental.golden
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

Usage: docker app COMMAND
Usage: docker app [OPTIONS] COMMAND

A tool to build and manage Docker Applications.

Options:
--version Print version information

Commands:
bundle Create a CNAB invocation image and `bundle.json` for the application
init Initialize Docker Application definition
Expand All @@ -16,6 +19,5 @@ Commands:
uninstall Uninstall an application
upgrade Upgrade an installed application
validate Checks the rendered application is syntactically correct
version Print version information

Run 'docker app COMMAND --help' for more information on a command.
6 changes: 4 additions & 2 deletions e2e/testdata/plugin-usage.golden
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

Usage: docker app COMMAND
Usage: docker app [OPTIONS] COMMAND

A tool to build and manage Docker Applications.

Options:
--version Print version information

Commands:
bundle Create a CNAB invocation image and `bundle.json` for the application
init Initialize Docker Application definition
Expand All @@ -16,6 +19,5 @@ Commands:
uninstall Uninstall an application
upgrade Upgrade an installed application
validate Checks the rendered application is syntactically correct
version Print version information

Run 'docker app COMMAND --help' for more information on a command.
14 changes: 11 additions & 3 deletions internal/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"io/ioutil"
"os"

"github.com/docker/app/internal"

"github.com/docker/app/internal/store"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/config"
Expand All @@ -13,7 +15,8 @@ import (
)

var (
completion string
completion string
showversion bool
)

// NewRootCmd returns the base root command.
Expand All @@ -24,6 +27,11 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {
Use: use,
Annotations: map[string]string{"experimentalCLI": "true"},
RunE: func(cmd *cobra.Command, args []string) error {
if showversion {
fmt.Fprintln(os.Stdout, internal.FullVersion()) //nolint:errcheck
return nil
}

switch completion {
case "bash":
return cmd.GenBashCompletion(dockerCli.Out())
Expand All @@ -41,10 +49,11 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {

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

cmd.Flags().BoolVar(&showversion, "version", false, "Print version information")
return cmd
}

Expand All @@ -59,7 +68,6 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
inspectCmd(dockerCli),
renderCmd(dockerCli),
validateCmd(),
versionCmd(dockerCli),
bundleCmd(dockerCli),
pushCmd(dockerCli),
pullCmd(dockerCli),
Expand Down
37 changes: 0 additions & 37 deletions internal/commands/version.go

This file was deleted.

9 changes: 6 additions & 3 deletions internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ var (
)

// FullVersion returns a string of version information.
func FullVersion(invocationBaseImage string) string {
func FullVersion() string {
res := []string{
fmt.Sprintf("Version: %s", Version),
fmt.Sprintf("Git commit: %s", GitCommit),
fmt.Sprintf("Built: %s", reformatDate(BuildTime)),
fmt.Sprintf("OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH),
fmt.Sprintf("Experimental: %s", Experimental),
fmt.Sprintf("Invocation Base Image: %s", invocationBaseImage),
}

if Experimental == "on" {
res = append(res, fmt.Sprintf("Experimental: %s", Experimental))
}

return strings.Join(res, "\n")
}

Expand Down

0 comments on commit 28789cc

Please sign in to comment.