Add --version flag
This commit is contained in:
parent
5c09cac67c
commit
4493070350
|
|
@ -40,8 +40,11 @@ import (
|
||||||
"github.com/go-logr/glogr"
|
"github.com/go-logr/glogr"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"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", ""),
|
var flRepo = flag.String("repo", envString("GIT_SYNC_REPO", ""),
|
||||||
"the git repository to clone")
|
"the git repository to clone")
|
||||||
var flBranch = flag.String("branch", envString("GIT_SYNC_BRANCH", "master"),
|
var flBranch = flag.String("branch", envString("GIT_SYNC_BRANCH", "master"),
|
||||||
|
|
@ -184,6 +187,12 @@ func main() {
|
||||||
setFlagDefaults()
|
setFlagDefaults()
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *flVer {
|
||||||
|
fmt.Println(version.VERSION)
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
if *flRepo == "" {
|
if *flRepo == "" {
|
||||||
fmt.Fprintf(os.Stderr, "ERROR: --repo or $GIT_SYNC_REPO must be provided\n")
|
fmt.Fprintf(os.Stderr, "ERROR: --repo or $GIT_SYNC_REPO must be provided\n")
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue