mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-09 00:16:46 +00:00
Pass version from main
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
parent
17a5e2c625
commit
03fe48db99
2
Makefile
2
Makefile
@ -1,6 +1,6 @@
|
|||||||
Version := $(shell git describe --tags --dirty)
|
Version := $(shell git describe --tags --dirty)
|
||||||
GitCommit := $(shell git rev-parse HEAD)
|
GitCommit := $(shell git rev-parse HEAD)
|
||||||
LDFLAGS := "-s -w -X pkg.Version=$(Version) -X pkg.GitCommit=$(GitCommit)"
|
LDFLAGS := "-s -w -X main.Version=$(Version) -X main.GitCommit=$(GitCommit)"
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: local
|
all: local
|
||||||
|
11
cmd/root.go
11
cmd/root.go
@ -13,7 +13,16 @@ func init() {
|
|||||||
rootCommand.AddCommand(installCmd)
|
rootCommand.AddCommand(installCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Execute() error {
|
var (
|
||||||
|
// GitCommit Git Commit SHA
|
||||||
|
GitCommit string
|
||||||
|
// Version version of the CLI
|
||||||
|
Version string
|
||||||
|
)
|
||||||
|
|
||||||
|
func Execute(gitCommit, version string) error {
|
||||||
|
GitCommit = gitCommit
|
||||||
|
Version = version
|
||||||
|
|
||||||
if err := rootCommand.Execute(); err != nil {
|
if err := rootCommand.Execute(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -21,10 +21,26 @@ func parseBaseCommand(_ *cobra.Command, _ []string) {
|
|||||||
`faasd
|
`faasd
|
||||||
Commit: %s
|
Commit: %s
|
||||||
Version: %s
|
Version: %s
|
||||||
`, pkg.GitCommit, pkg.GetVersion())
|
`, GitCommit, GetVersion())
|
||||||
}
|
}
|
||||||
|
|
||||||
func printLogo() {
|
func printLogo() {
|
||||||
logoText := aec.WhiteF.Apply(pkg.Logo)
|
logoText := aec.WhiteF.Apply(pkg.Logo)
|
||||||
fmt.Println(logoText)
|
fmt.Println(logoText)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetVersion get latest version
|
||||||
|
func GetVersion() string {
|
||||||
|
if len(Version) == 0 {
|
||||||
|
return "dev"
|
||||||
|
}
|
||||||
|
return Version
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logo for version and root command
|
||||||
|
const Logo = ` __ _
|
||||||
|
/ _| __ _ __ _ ___ __| |
|
||||||
|
| |_ / _` + "`" + ` |/ _` + "`" + ` / __|/ _` + "`" + ` |
|
||||||
|
| _| (_| | (_| \__ \ (_| |
|
||||||
|
|_| \__,_|\__,_|___/\__,_|
|
||||||
|
`
|
||||||
|
9
main.go
9
main.go
@ -6,8 +6,15 @@ import (
|
|||||||
"github.com/alexellis/faasd/cmd"
|
"github.com/alexellis/faasd/cmd"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// GitCommit Git Commit SHA
|
||||||
|
GitCommit string
|
||||||
|
// Version version of the CLI
|
||||||
|
Version string
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if err := cmd.Execute(); err != nil {
|
if err := cmd.Execute(GitCommit, Version); err != nil {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -1,24 +1 @@
|
|||||||
package pkg
|
package pkg
|
||||||
|
|
||||||
var (
|
|
||||||
// GitCommit Git Commit SHA
|
|
||||||
GitCommit string
|
|
||||||
// Version version of the CLI
|
|
||||||
Version string
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetVersion get latest version
|
|
||||||
func GetVersion() string {
|
|
||||||
if len(Version) == 0 {
|
|
||||||
return "dev"
|
|
||||||
}
|
|
||||||
return Version
|
|
||||||
}
|
|
||||||
|
|
||||||
// Logo for version and root command
|
|
||||||
const Logo = ` __ _
|
|
||||||
/ _| __ _ __ _ ___ __| |
|
|
||||||
| |_ / _` + "`" + ` |/ _` + "`" + ` / __|/ _` + "`" + ` |
|
|
||||||
| _| (_| | (_| \__ \ (_| |
|
|
||||||
|_| \__,_|\__,_|___/\__,_|
|
|
||||||
`
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user