Skip to content

Commit

Permalink
add version flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dips-cbr committed Jul 23, 2024
1 parent 7b4bba5 commit a235cc6
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions cmd/operator-helm-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,35 @@ import (
"fmt"
"io"
"os"
"runtime/debug"
"strings"
"time"

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

func Version() string {
info, ok := debug.ReadBuildInfo()
if !ok || info.Main.Version == "" {
return "(unknown)"
}

return info.Main.Version
}

func main() {
println(time.Now().UTC().Format(time.RFC3339))
var keep string
var dir string
var showVersion bool
flag.StringVar(&keep, "keep", "", "Specify which resources to keep, separated by comma.")
flag.StringVar(&dir, "dir", "", "Specify output dir")
flag.BoolVar(&showVersion, "version", false, "Prints the version and exits.")
flag.Parse()

if showVersion {
fmt.Printf("Version: %s\n", Version())
return
}

fmt.Printf("Generating for resources: %s, output dir %s\n", keep, dir)

var data []byte
Expand Down

0 comments on commit a235cc6

Please sign in to comment.