diff --git a/go.mod b/go.mod index 965b1bcaea..8e45889a6b 100644 --- a/go.mod +++ b/go.mod @@ -22,6 +22,7 @@ require ( k8s.io/apimachinery v0.25.2 k8s.io/autoscaler/vertical-pod-autoscaler v0.12.0 k8s.io/client-go v0.25.2 + k8s.io/component-base v0.25.2 k8s.io/klog/v2 v2.80.1 k8s.io/sample-controller v0.25.2 k8s.io/utils v0.0.0-20220922133306-665eaaec4324 @@ -40,7 +41,7 @@ require ( github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect github.com/alecthomas/units v0.0.0-20211218093645-b94a6e3cc137 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/blang/semver v3.5.0+incompatible // indirect + github.com/blang/semver/v4 v4.0.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.8.0 // indirect diff --git a/go.sum b/go.sum index f1ba051715..08186905a8 100644 --- a/go.sum +++ b/go.sum @@ -93,6 +93,7 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/boombuler/barcode v1.0.0/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8= @@ -984,6 +985,8 @@ k8s.io/client-go v0.25.2/go.mod h1:i7cNU7N+yGQmJkewcRD2+Vuj4iz7b30kI8OcL3horQ4= k8s.io/code-generator v0.25.0/go.mod h1:B6jZgI3DvDFAualltPitbYMQ74NjaCFxum3YeKZZ+3w= k8s.io/code-generator v0.25.2/go.mod h1:f61OcU2VqVQcjt/6TrU0sta1TA5hHkOO6ZZPwkL9Eys= k8s.io/component-base v0.25.0/go.mod h1:F2Sumv9CnbBlqrpdf7rKZTmmd2meJq0HizeyY/yAFxk= +k8s.io/component-base v0.25.2 h1:Nve/ZyHLUBHz1rqwkjXm/Re6IniNa5k7KgzxZpTfSQY= +k8s.io/component-base v0.25.2/go.mod h1:90W21YMr+Yjg7MX+DohmZLzjsBtaxQDDwaX4YxDkl60= k8s.io/gengo v0.0.0-20210813121822-485abfe95c7c/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/gengo v0.0.0-20211129171323-c02415ce4185/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= diff --git a/internal/store/node.go b/internal/store/node.go index 354abf25ca..b5bcbdbce4 100644 --- a/internal/store/node.go +++ b/internal/store/node.go @@ -20,10 +20,10 @@ import ( "context" "strings" + basemetrics "k8s.io/component-base/metrics" "k8s.io/kube-state-metrics/v2/pkg/constant" "k8s.io/kube-state-metrics/v2/pkg/metric" generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator" - basemetrics "k8s.io/component-base/metrics" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/metric_generator/generator.go b/pkg/metric_generator/generator.go index e8330fab04..f482e04c43 100644 --- a/pkg/metric_generator/generator.go +++ b/pkg/metric_generator/generator.go @@ -20,8 +20,8 @@ import ( "fmt" "strings" - "k8s.io/kube-state-metrics/v2/pkg/metric" basemetrics "k8s.io/component-base/metrics" + "k8s.io/kube-state-metrics/v2/pkg/metric" ) // FamilyGenerator provides everything needed to generate a metric family with a @@ -38,7 +38,7 @@ type FamilyGenerator struct { GenerateFunc func(obj interface{}) *metric.Family } -// NewFamilyGenerator creates new FamilyGenerator instances with metric +// NewFamilyGeneratorWithStability creates new FamilyGenerator instances with metric // stabilityLevel. func NewFamilyGeneratorWithStability(name string, help string, metricType metric.Type, stabilityLevel basemetrics.StabilityLevel, deprecatedVersion string, generateFunc func(obj interface{}) *metric.Family) *FamilyGenerator { f := &FamilyGenerator{ @@ -84,10 +84,10 @@ func (g *FamilyGenerator) generateHeader() string { header.WriteString("# HELP ") header.WriteString(g.Name) header.WriteByte(' ') - // Will remove if-else after all metrics are attached with right + // TODO(#1833): remove if-else after all metrics are attached with right // StabilityLevel. if g.StabilityLevel == basemetrics.STABLE { - header.WriteString(fmt.Sprintf("[%v] %v", g.StabilityLevel, g.Help)) + header.WriteString(fmt.Sprintf("[%v] %v", g.StabilityLevel, g.Help)) } else { header.WriteString(g.Help) }