Skip to content

Commit 689a1f5

Browse files
committed
fix --version flag
1 parent 63db483 commit 689a1f5

File tree

2 files changed

+6
-64
lines changed

2 files changed

+6
-64
lines changed

internal/wrapper.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ package internal
1919
import (
2020
"context"
2121
"errors"
22+
"fmt"
2223
"os"
2324
"path/filepath"
2425
"time"
2526

2627
"github.com/fsnotify/fsnotify"
28+
"github.com/prometheus/common/version"
2729
"github.com/spf13/viper"
2830
"gopkg.in/yaml.v3"
2931
"k8s.io/klog/v2"
@@ -34,6 +36,10 @@ import (
3436

3537
// RunKubeStateMetricsWrapper is a wrapper around KSM, delegated to the root command.
3638
func RunKubeStateMetricsWrapper(opts *options.Options) {
39+
if opts.Version {
40+
fmt.Printf("%s\n", version.Print("kube-state-metrics"))
41+
klog.FlushAndExit(klog.ExitFlushTimeout, 0)
42+
}
3743

3844
KSMRunOrDie := func(ctx context.Context) {
3945
if err := app.RunKubeStateMetricsWrapper(ctx, opts); err != nil {

pkg/version/version.go

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)