Documentation ¶
Overview ¶
Package version is a convenience utility that provides SDK consumers with a ready-to-use version command that produces apps versioning information based on flags passed at compile time.
Configure the version command ¶
The version command can be just added to your cobra root command. At build time, the variables Name, Version, Commit, and BuildTags can be passed as build flags as shown in the following example:
go build -X github.com/T-ragon/cosmos-sdk/version.Name=gaia \ -X github.com/T-ragon/cosmos-sdk/version.AppName=gaiad \ -X github.com/T-ragon/cosmos-sdk/version.Version=1.0 \ -X github.com/T-ragon/cosmos-sdk/version.Commit=f0f7b7dab7e36c20b757cebce0e8f4fc5b95de60 \ -X "github.com/T-ragon/cosmos-sdk/version.BuildTags=linux darwin amd64"
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // application's name Name = "" // application binary name AppName = "<appd>" // application's version string Version = "" // commit Commit = "" // build tags BuildTags = "" )
Functions ¶
func NewVersionCommand ¶ added in v0.50.9
NewVersionCommand returns a CLI command to interactively print the application binary version information. Note: When seeking to add the extra info to the context The below can be added to the initRootCmd to include the extraInfo field
cmdContext := context.WithValue(context.Background(), version.ContextKey{}, extraInfo) rootCmd.SetContext(cmdContext)
Types ¶
type ContextKey ¶ added in v0.50.9
type ContextKey struct{}
ContextKey is used to store the ExtraInfo in the context.
type Info ¶ added in v0.50.9
type Info struct { Name string `json:"name" yaml:"name"` AppName string `json:"server_name" yaml:"server_name"` Version string `json:"version" yaml:"version"` GitCommit string `json:"commit" yaml:"commit"` BuildTags string `json:"build_tags" yaml:"build_tags"` GoVersion string `json:"go" yaml:"go"` BuildDeps []buildDep `json:"build_deps" yaml:"build_deps"` CosmosSdkVersion string `json:"cosmos_sdk_version" yaml:"cosmos_sdk_version"` ExtraInfo ExtraInfo `json:"extra_info,omitempty" yaml:"extra_info,omitempty"` }
Info defines the application version information.