@@ -19,13 +19,15 @@ import (
19
19
"fmt"
20
20
"os"
21
21
22
+ "github.com/prometheus/common/version"
22
23
"github.com/spf13/pflag"
23
24
"sigs.k8s.io/controller-tools/pkg/genall"
24
25
"sigs.k8s.io/controller-tools/pkg/genall/help"
25
26
prettyhelp "sigs.k8s.io/controller-tools/pkg/genall/help/pretty"
26
27
"sigs.k8s.io/controller-tools/pkg/loader"
27
28
"sigs.k8s.io/controller-tools/pkg/markers"
28
29
30
+ "k8s.io/klog/v2"
29
31
"k8s.io/kube-state-metrics/v2/exp/metric-gen/generator"
30
32
)
31
33
39
41
)
40
42
41
43
func main () {
42
- var whichMarkersFlag bool
44
+ var whichMarkersFlag , versionFlag bool
43
45
44
- pflag .CommandLine .BoolVarP (& whichMarkersFlag , "which-markers" , "w" , false , "print out all markers available with the requested generators" )
46
+ pflag .CommandLine .BoolVarP (& whichMarkersFlag , "which-markers" , "w" , false , "Print out all markers available with the requested generators." )
47
+ pflag .CommandLine .BoolVarP (& versionFlag , "version" , "v" , false , "Print verison information." )
45
48
46
49
pflag .Usage = func () {
47
50
fmt .Fprintf (os .Stderr , "Usage of %s:\n \n " , os .Args [0 ])
@@ -53,6 +56,11 @@ func main() {
53
56
54
57
pflag .Parse ()
55
58
59
+ if versionFlag {
60
+ fmt .Printf ("%s\n " , version .Print ("metric-gen" ))
61
+ klog .FlushAndExit (klog .ExitFlushTimeout , 0 )
62
+ }
63
+
56
64
// Register the metric generator itself as marker so genall.FromOptions is able to initialize the runtime properly.
57
65
// This also registers the markers inside the optionsRegistry so its available to print the marker docs.
58
66
metricGenerator := generator.CustomResourceConfigGenerator {}
0 commit comments