Skip to content

Commit 4493070

Browse files
committed
Add --version flag
1 parent 5c09cac commit 4493070

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/git-sync/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,11 @@ import (
4040
"github.com/go-logr/glogr"
4141
"github.com/prometheus/client_golang/prometheus"
4242
"github.com/prometheus/client_golang/prometheus/promhttp"
43+
"k8s.io/git-sync/pkg/version"
4344
)
4445

46+
var flVer = flag.Bool("version", false, "print the version and exit")
47+
4548
var flRepo = flag.String("repo", envString("GIT_SYNC_REPO", ""),
4649
"the git repository to clone")
4750
var flBranch = flag.String("branch", envString("GIT_SYNC_BRANCH", "master"),
@@ -184,6 +187,12 @@ func main() {
184187
setFlagDefaults()
185188

186189
flag.Parse()
190+
191+
if *flVer {
192+
fmt.Println(version.VERSION)
193+
os.Exit(0)
194+
}
195+
187196
if *flRepo == "" {
188197
fmt.Fprintf(os.Stderr, "ERROR: --repo or $GIT_SYNC_REPO must be provided\n")
189198
flag.Usage()

0 commit comments

Comments
 (0)