Add --version flag

This commit is contained in:
Tim Hockin 2019-03-22 10:21:17 -07:00
parent 5c09cac67c
commit 4493070350
1 changed files with 9 additions and 0 deletions

View File

@ -40,8 +40,11 @@ import (
"github.com/go-logr/glogr"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"k8s.io/git-sync/pkg/version"
)
var flVer = flag.Bool("version", false, "print the version and exit")
var flRepo = flag.String("repo", envString("GIT_SYNC_REPO", ""),
"the git repository to clone")
var flBranch = flag.String("branch", envString("GIT_SYNC_BRANCH", "master"),
@ -184,6 +187,12 @@ func main() {
setFlagDefaults()
flag.Parse()
if *flVer {
fmt.Println(version.VERSION)
os.Exit(0)
}
if *flRepo == "" {
fmt.Fprintf(os.Stderr, "ERROR: --repo or $GIT_SYNC_REPO must be provided\n")
flag.Usage()