Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions cli/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,16 @@ func runVersion(cmd *cobra.Command) error {
var versionString string
var err error
format := strings.ToLower(strings.ReplaceAll(cmd.Flag(formatOpt).Value.String(), " ", ""))
displayedVersion := strings.TrimPrefix(internal.Version, "v")
// Replace is preferred in this case to keep the order.
switch format {
case formatter.PRETTY, "":
versionString, err = getOutFromMoby(cmd, fixedPrettyArgs(os.Args[1:])...)
versionString = strings.Replace(versionString,
"\n Version:", "\n Cloud integration: "+displayedVersion+"\n Version:", 1)
"\n Version:", "\n Cloud integration: "+internal.Version+"\n Version:", 1)
case formatter.JSON, formatter.TemplateLegacyJSON: // Try to catch full JSON formats
versionString, err = getOutFromMoby(cmd, fixedJSONArgs(os.Args[1:])...)
versionString = strings.Replace(versionString,
`"Version":`, fmt.Sprintf(`"CloudIntegration":%q,"Version":`, displayedVersion), 1)
`"Version":`, fmt.Sprintf(`"CloudIntegration":%q,"Version":`, internal.Version), 1)
default:
versionString, err = getOutFromMoby(cmd)
}
Expand Down
8 changes: 3 additions & 5 deletions cmd/compose/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package compose

import (
"fmt"
"strings"

"github.com/spf13/cobra"

Expand Down Expand Up @@ -52,14 +51,13 @@ func versionCommand() *cobra.Command {
}

func runVersion(opts versionOptions) {
displayedVersion := strings.TrimPrefix(internal.Version, "v")
if opts.short {
fmt.Println(displayedVersion)
fmt.Println(internal.Version)
return
}
if opts.format == formatter.JSON {
fmt.Printf(`{"version":"%s"}\n`, displayedVersion)
fmt.Printf(`{"version":%q}\n`, internal.Version)
return
}
fmt.Printf("Docker Compose version %s\n", displayedVersion)
fmt.Println("Docker Compose version", internal.Version)
}
4 changes: 1 addition & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package main

import (
"strings"

dockercli "github.com/docker/cli/cli"
"github.com/docker/cli/cli-plugins/manager"
"github.com/docker/cli/cli-plugins/plugin"
Expand Down Expand Up @@ -58,6 +56,6 @@ func main() {
manager.Metadata{
SchemaVersion: "0.1.0",
Vendor: "Docker Inc.",
Version: strings.TrimPrefix(internal.Version, "v"),
Version: internal.Version,
})
}