Skip to content

Commit 490c537

Browse files
authored
Version Flag (#70)
* Test ldflags Signed-off-by: Hengyuan <[email protected]> * add version flag to rootCmd Signed-off-by: Hengyuan <[email protected]> * cleanup Signed-off-by: Hengyuan <[email protected]>
1 parent 97938bc commit 490c537

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

.goreleaser.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ before:
2020
- go mod download
2121
builds:
2222
- binary: getenvoy
23+
ldflags: "-s -w -X github.com/tetratelabs/getenvoy/pkg/cmd.cliVersion={{.Version}}"
2324
main: ./cmd/getenvoy/main.go
2425
env:
2526
- CGO_ENABLED=0

pkg/cmd/root.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import (
1919
"github.com/tetratelabs/getenvoy/pkg/manifest"
2020
)
2121

22+
// cliVersion exposed by goreleaser
23+
var cliVersion string
24+
2225
// NewRoot create a new root command and sets the cliVersion to the passed variable
2326
// TODO: Add version support on the command
2427
func NewRoot() *cobra.Command {
@@ -39,6 +42,7 @@ var (
3942
Short: "Fetch, deploy and debug Envoy",
4043
Long: `Manage full lifecycle of Envoy including fetching binaries,
4144
bootstrap generation and automated collection of access logs, Envoy state and machine state.`,
45+
Version: cliVersion,
4246
}
4347

4448
manifestURL string

0 commit comments

Comments
 (0)