mirror of https://github.com/docker/cli.git
Move versioning variables to a separate package.
This helps to avoid circular includes, by separating the pure data out from the actual functionality in the cli subpackage, allowing other code which is imported to access the data. Signed-off-by: Ian Campbell <ijc@docker.com>
This commit is contained in:
parent
c5168117af
commit
20c19830a9
|
@ -8,7 +8,6 @@ import (
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/docker/cli/cli"
|
|
||||||
"github.com/docker/cli/cli/config"
|
"github.com/docker/cli/cli/config"
|
||||||
cliconfig "github.com/docker/cli/cli/config"
|
cliconfig "github.com/docker/cli/cli/config"
|
||||||
"github.com/docker/cli/cli/config/configfile"
|
"github.com/docker/cli/cli/config/configfile"
|
||||||
|
@ -22,6 +21,7 @@ import (
|
||||||
registryclient "github.com/docker/cli/cli/registry/client"
|
registryclient "github.com/docker/cli/cli/registry/client"
|
||||||
"github.com/docker/cli/cli/streams"
|
"github.com/docker/cli/cli/streams"
|
||||||
"github.com/docker/cli/cli/trust"
|
"github.com/docker/cli/cli/trust"
|
||||||
|
"github.com/docker/cli/cli/version"
|
||||||
"github.com/docker/cli/internal/containerizedengine"
|
"github.com/docker/cli/internal/containerizedengine"
|
||||||
dopts "github.com/docker/cli/opts"
|
dopts "github.com/docker/cli/opts"
|
||||||
clitypes "github.com/docker/cli/types"
|
clitypes "github.com/docker/cli/types"
|
||||||
|
@ -472,7 +472,7 @@ func getServerHost(hosts []string, tlsOptions *tlsconfig.Options) (string, error
|
||||||
|
|
||||||
// UserAgent returns the user agent string used for making API requests
|
// UserAgent returns the user agent string used for making API requests
|
||||||
func UserAgent() string {
|
func UserAgent() string {
|
||||||
return "Docker-Client/" + cli.Version + " (" + runtime.GOOS + ")"
|
return "Docker-Client/" + version.Version + " (" + runtime.GOOS + ")"
|
||||||
}
|
}
|
||||||
|
|
||||||
// resolveContextName resolves the current context name with the following rules:
|
// resolveContextName resolves the current context name with the following rules:
|
||||||
|
|
|
@ -12,6 +12,7 @@ import (
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
kubecontext "github.com/docker/cli/cli/context/kubernetes"
|
kubecontext "github.com/docker/cli/cli/context/kubernetes"
|
||||||
|
"github.com/docker/cli/cli/version"
|
||||||
"github.com/docker/cli/kubernetes"
|
"github.com/docker/cli/kubernetes"
|
||||||
"github.com/docker/cli/templates"
|
"github.com/docker/cli/templates"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
@ -135,13 +136,13 @@ func runVersion(dockerCli command.Cli, opts *versionOptions) error {
|
||||||
|
|
||||||
vd := versionInfo{
|
vd := versionInfo{
|
||||||
Client: clientVersion{
|
Client: clientVersion{
|
||||||
Platform: struct{ Name string }{cli.PlatformName},
|
Platform: struct{ Name string }{version.PlatformName},
|
||||||
Version: cli.Version,
|
Version: version.Version,
|
||||||
APIVersion: dockerCli.Client().ClientVersion(),
|
APIVersion: dockerCli.Client().ClientVersion(),
|
||||||
DefaultAPIVersion: dockerCli.DefaultVersion(),
|
DefaultAPIVersion: dockerCli.DefaultVersion(),
|
||||||
GoVersion: runtime.Version(),
|
GoVersion: runtime.Version(),
|
||||||
GitCommit: cli.GitCommit,
|
GitCommit: version.GitCommit,
|
||||||
BuildTime: reformatDate(cli.BuildTime),
|
BuildTime: reformatDate(version.BuildTime),
|
||||||
Os: runtime.GOOS,
|
Os: runtime.GOOS,
|
||||||
Arch: runtime.GOARCH,
|
Arch: runtime.GOARCH,
|
||||||
Experimental: dockerCli.ClientInfo().HasExperimental,
|
Experimental: dockerCli.ClientInfo().HasExperimental,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package cli
|
package version
|
||||||
|
|
||||||
// Default build-time variable.
|
// Default build-time variable.
|
||||||
// These values are overridden via ldflags
|
// These values are overridden via ldflags
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/cli/cli/command/commands"
|
"github.com/docker/cli/cli/command/commands"
|
||||||
cliflags "github.com/docker/cli/cli/flags"
|
cliflags "github.com/docker/cli/cli/flags"
|
||||||
|
"github.com/docker/cli/cli/version"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -41,7 +42,7 @@ func newDockerCommand(dockerCli *command.DockerCli) *cobra.Command {
|
||||||
}
|
}
|
||||||
return isSupported(cmd, dockerCli)
|
return isSupported(cmd, dockerCli)
|
||||||
},
|
},
|
||||||
Version: fmt.Sprintf("%s, build %s", cli.Version, cli.GitCommit),
|
Version: fmt.Sprintf("%s, build %s", version.Version, version.GitCommit),
|
||||||
DisableFlagsInUseLine: true,
|
DisableFlagsInUseLine: true,
|
||||||
}
|
}
|
||||||
opts, flags = cli.SetupRootCommand(cmd)
|
opts, flags = cli.SetupRootCommand(cmd)
|
||||||
|
|
|
@ -8,15 +8,15 @@ BUILDTIME=${BUILDTIME:-$(date --utc --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/'
|
||||||
|
|
||||||
PLATFORM_LDFLAGS=
|
PLATFORM_LDFLAGS=
|
||||||
if test -n "${PLATFORM}"; then
|
if test -n "${PLATFORM}"; then
|
||||||
PLATFORM_LDFLAGS="-X \"github.com/docker/cli/cli.PlatformName=${PLATFORM}\""
|
PLATFORM_LDFLAGS="-X \"github.com/docker/cli/cli/version.PlatformName=${PLATFORM}\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export LDFLAGS="\
|
export LDFLAGS="\
|
||||||
-w \
|
-w \
|
||||||
${PLATFORM_LDFLAGS} \
|
${PLATFORM_LDFLAGS} \
|
||||||
-X \"github.com/docker/cli/cli.GitCommit=${GITCOMMIT}\" \
|
-X \"github.com/docker/cli/cli/version.GitCommit=${GITCOMMIT}\" \
|
||||||
-X \"github.com/docker/cli/cli.BuildTime=${BUILDTIME}\" \
|
-X \"github.com/docker/cli/cli/version.BuildTime=${BUILDTIME}\" \
|
||||||
-X \"github.com/docker/cli/cli.Version=${VERSION}\" \
|
-X \"github.com/docker/cli/cli/version.Version=${VERSION}\" \
|
||||||
${LDFLAGS:-} \
|
${LDFLAGS:-} \
|
||||||
"
|
"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue