2019-07-21 02:00:04 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"runtime"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2019-08-09 05:28:31 +00:00
|
|
|
// This is the current version of the client. It is set by goreleaser.
|
|
|
|
version string
|
2019-07-21 02:00:04 +00:00
|
|
|
|
2019-07-23 11:10:34 +00:00
|
|
|
// The program name
|
|
|
|
programName = "Portainer Stack Utils"
|
|
|
|
|
2019-07-21 02:00:04 +00:00
|
|
|
// commitHash contains the current Git revision. Use Go Releaser to make sure this gets set.
|
|
|
|
commitHash string
|
|
|
|
|
|
|
|
// buildDate contains the date of the current build.
|
|
|
|
buildDate string
|
|
|
|
)
|
|
|
|
|
|
|
|
func BuildVersionString() string {
|
|
|
|
osArch := runtime.GOOS + "/" + runtime.GOARCH
|
|
|
|
|
2019-08-09 05:39:01 +00:00
|
|
|
if version == "" {
|
|
|
|
return fmt.Sprintf("%s SNAPSHOT %s", programName, osArch)
|
|
|
|
}
|
|
|
|
|
|
|
|
if commitHash != "" {
|
|
|
|
version += "+" + strings.ToUpper(commitHash)
|
2019-07-21 02:00:04 +00:00
|
|
|
}
|
|
|
|
|
2019-08-09 05:39:01 +00:00
|
|
|
return fmt.Sprintf("%s %s %s BuildDate: %s", programName, version, osArch, buildDate)
|
2019-07-21 02:00:04 +00:00
|
|
|
}
|