Skip to content

Commit b186e6a

Browse files
committed
Add version flag
1 parent 398f157 commit b186e6a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
HELM_HOME ?= $(shell helm home)
22
HAS_GLIDE := $(shell command -v glide;)
3+
VERSION := $(shell sed -n -e 's/version:[ "]*\([^"]*\).*/\1/p' plugin.yaml)
4+
5+
LDFLAGS := -X main.Version=$(VERSION)
36

47
.PHONY: install
58
install: bootstrap build
@@ -9,7 +12,7 @@ install: bootstrap build
912

1013
.PHONY: build
1114
build:
12-
go build -o diff
15+
go build -o diff -ldflags="$(LDFLAGS)"
1316

1417
.PHONY: bootstrap
1518
bootstrap:

main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ This can be used visualize what changes a helm upgrade will
2828
perform.
2929
`
3030

31+
var Version string = "HEAD"
32+
3133
type diffCmd struct {
3234
release string
3335
chart string
@@ -64,6 +66,10 @@ func main() {
6466
Short: "Show manifest differences",
6567
Long: globalUsage,
6668
RunE: func(cmd *cobra.Command, args []string) error {
69+
if v, _ := cmd.Flags().GetBool("version"); v {
70+
fmt.Println(Version)
71+
return nil
72+
}
6773
if err := checkArgsLength(len(args), "release name", "chart path"); err != nil {
6874
return err
6975
}
@@ -77,6 +83,7 @@ func main() {
7783
},
7884
}
7985
f := cmd.Flags()
86+
f.BoolP("version", "v", false, "show version")
8087
f.VarP(&diff.valueFiles, "values", "f", "specify values in a YAML file (can specify multiple)")
8188
f.StringArrayVar(&diff.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
8289

0 commit comments

Comments
 (0)