(fix) path on windows
ci on canary build, version should show "0.0.0-dev" Signed-off-by: Quan TRAN <account@itscaro.me>
This commit is contained in:
parent
a4b914abc7
commit
9884e4fdb1
|
|
@ -19,7 +19,7 @@ func RootCommand() *cli.App {
|
|||
cliApp := cli.NewApp()
|
||||
cliApp.Name = "helmfile"
|
||||
cliApp.Usage = ""
|
||||
cliApp.Version = version.Version
|
||||
cliApp.Version = version.GetVersion()
|
||||
cliApp.EnableBashCompletion = true
|
||||
cliApp.Before = configureLogging
|
||||
setRootCommandFlags(cliApp)
|
||||
|
|
|
|||
1
go.mod
1
go.mod
|
|
@ -32,6 +32,7 @@ require (
|
|||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
gotest.tools v2.2.0+incompatible
|
||||
k8s.io/apimachinery v0.23.4
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,28 @@
|
|||
// Package version is used to get the version of the Helmfile CLI.
|
||||
package version
|
||||
|
||||
import "fmt"
|
||||
|
||||
// Version is the version of Helmfile
|
||||
var Version string
|
||||
|
||||
// Commit is the git revision
|
||||
var Commit string
|
||||
|
||||
func GetVersion() string {
|
||||
if Version == "" {
|
||||
Version = "0.0.0-dev"
|
||||
}
|
||||
return Version
|
||||
}
|
||||
|
||||
func GetCommit() string {
|
||||
if Commit == "" {
|
||||
Commit = "unknown_commit"
|
||||
}
|
||||
return Commit
|
||||
}
|
||||
|
||||
func GetVersionWithCommit() string {
|
||||
return fmt.Sprintf("%s-%s", GetVersion(), GetCommit())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"gotest.tools/assert"
|
||||
)
|
||||
|
||||
func TestGetVersion(t *testing.T) {
|
||||
current := Version
|
||||
Version = ""
|
||||
assert.Equal(t, "0.0.0-dev", GetVersion())
|
||||
Version = "1.2.3"
|
||||
assert.Equal(t, "1.2.3", GetVersion())
|
||||
Version = current
|
||||
}
|
||||
|
||||
func TestGetCommit(t *testing.T) {
|
||||
current := Commit
|
||||
Commit = ""
|
||||
assert.Equal(t, "unknown_commit", GetCommit())
|
||||
Commit = "abc123xyz"
|
||||
assert.Equal(t, "abc123xyz", GetCommit())
|
||||
Commit = current
|
||||
}
|
||||
|
||||
func TestGetVersionWithCommit(t *testing.T) {
|
||||
currentVersion := Version
|
||||
currentCommit := Commit
|
||||
Version = ""
|
||||
Commit = ""
|
||||
assert.Equal(t, "0.0.0-dev-unknown_commit", GetVersionWithCommit())
|
||||
Version = "1.2.3"
|
||||
Commit = "abc123xyz"
|
||||
assert.Equal(t, "1.2.3-abc123xyz", GetVersionWithCommit())
|
||||
Version = currentVersion
|
||||
Commit = currentCommit
|
||||
}
|
||||
Loading…
Reference in New Issue