enhance version info

This commit is contained in:
Benjamin Elder
2019-10-21 16:25:40 -07:00
parent 7704075f4e
commit be110fa786
2 changed files with 21 additions and 6 deletions

View File

@@ -19,8 +19,11 @@ package version
import (
"fmt"
"runtime"
"github.com/spf13/cobra"
"sigs.k8s.io/kind/pkg/globals"
)
// Version returns the kind CLI Semantic Version
@@ -38,8 +41,14 @@ func Version() string {
return v
}
// DisplayVersion is Version() display formatted, this is what the version
// subcommand prints
func DisplayVersion() string {
return "kind v" + Version() + " " + runtime.Version() + " " + runtime.GOOS + "/" + runtime.GOARCH
}
// VersionCore is the core portion of the kind CLI version per Semantic Versioning 2.0.0
const VersionCore = "v0.6.0"
const VersionCore = "0.6.0"
// VersionPreRelease is the pre-release portion of the kind CLI version per
// Semantic Versioning 2.0.0
@@ -57,7 +66,13 @@ func NewCommand() *cobra.Command {
Short: "prints the kind CLI version",
Long: "prints the kind CLI version",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Println(Version())
// if not -q / --quiet, show lots of info
if globals.GetLogger().V(0).Enabled() {
fmt.Println(DisplayVersion())
} else { // otherwise only show semver
fmt.Println(Version())
}
return nil
},
}

View File

@@ -16,7 +16,7 @@
# creates a release and following pre-release commit for `kind`
# builds binaries between the commits
# Use like: create.sh <release-version> <next-prerelease-version>
# EG: create.sh v0.3.0 v0.4.0
# EG: create.sh 0.3.0 0.4.0
set -o errexit -o nounset -o pipefail
# cd to the repo root
@@ -63,14 +63,14 @@ add_tag() {
# create the first version, tag and build it
set_version "${1}" ""
make_commit "${1}"
add_tag "${1}"
make_commit "v${1}"
add_tag "v${1}"
echo "Building ..."
make clean && ./hack/release/build/cross.sh
# update to the second version
set_version "${2}" "alpha"
make_commit "${2}"
make_commit "v${2}-alpha"
# print follow-up instructions
echo ""