Skip to content

Commit a235cc6

Browse files
committed
add version flag
1 parent 7b4bba5 commit a235cc6

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

cmd/operator-helm-gen/main.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,35 @@ import (
55
"fmt"
66
"io"
77
"os"
8+
"runtime/debug"
89
"strings"
9-
"time"
1010

1111
"github.com/DIPSAS/operator-helm-gen/pkg/helmgen"
1212
)
1313

14+
func Version() string {
15+
info, ok := debug.ReadBuildInfo()
16+
if !ok || info.Main.Version == "" {
17+
return "(unknown)"
18+
}
19+
20+
return info.Main.Version
21+
}
22+
1423
func main() {
15-
println(time.Now().UTC().Format(time.RFC3339))
1624
var keep string
1725
var dir string
26+
var showVersion bool
1827
flag.StringVar(&keep, "keep", "", "Specify which resources to keep, separated by comma.")
1928
flag.StringVar(&dir, "dir", "", "Specify output dir")
29+
flag.BoolVar(&showVersion, "version", false, "Prints the version and exits.")
2030
flag.Parse()
2131

32+
if showVersion {
33+
fmt.Printf("Version: %s\n", Version())
34+
return
35+
}
36+
2237
fmt.Printf("Generating for resources: %s, output dir %s\n", keep, dir)
2338

2439
var data []byte

0 commit comments

Comments
 (0)