mirror of
https://github.com/docker/compose.git
synced 2026-08-30 05:29:30 +00:00
Merge pull request #207 from docker/version_cli
version command adding azure integration beta version in textual output
This commit is contained in:
commit
336df897c1
5 changed files with 57 additions and 2 deletions
|
|
@ -6,10 +6,11 @@ import (
|
|||
|
||||
"github.com/docker/api/context/store"
|
||||
|
||||
_ "github.com/docker/api/example"
|
||||
"github.com/docker/api/tests/framework"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
_ "github.com/docker/api/example"
|
||||
"github.com/docker/api/tests/framework"
|
||||
)
|
||||
|
||||
type PsSuite struct {
|
||||
|
|
|
|||
40
cli/cmd/version.go
Normal file
40
cli/cmd/version.go
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/docker/api/cli/dockerclassic"
|
||||
)
|
||||
|
||||
const cliVersion = "1.0.0-beta"
|
||||
|
||||
// VersionCommand command to display version
|
||||
func VersionCommand() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Show the Docker version information",
|
||||
Args: cobra.MaximumNArgs(0),
|
||||
RunE: runVersion,
|
||||
}
|
||||
// define flags for backward compatibility with docker-classic
|
||||
flags := cmd.Flags()
|
||||
flags.String("format", "", "Format the output using the given Go template")
|
||||
flags.String("kubeconfig", "", "Kubernetes config file")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func runVersion(cmd *cobra.Command, args []string) error {
|
||||
versionResult, _ := dockerclassic.ExecSilent(cmd.Context())
|
||||
// we don't want to fail on error, there is an error if the engine is not available but it displays client version info
|
||||
// Still, technically the [] byte versionResult could be nil, just let the original command display what it has to display
|
||||
if versionResult == nil {
|
||||
return dockerclassic.ExecCmd(cmd)
|
||||
}
|
||||
var s string = string(versionResult)
|
||||
fmt.Print(strings.Replace(s, "\n Version:", "\n Azure integration "+cliVersion+"\n Version:", 1))
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue