mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +00:00
rebase: update kubernetes to v1.21.2
Updated kubernetes packages to latest release. resizefs package has been included into k8s.io/mount-utils package. updated code to use the same. Updates: #1968 Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
45
vendor/k8s.io/component-base/metrics/gauge.go
generated
vendored
45
vendor/k8s.io/component-base/metrics/gauge.go
generated
vendored
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/blang/semver"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
@ -73,6 +74,11 @@ func (g *Gauge) initializeDeprecatedMetric() {
|
||||
g.initializeMetric()
|
||||
}
|
||||
|
||||
// WithContext allows the normal Gauge metric to pass in context. The context is no-op now.
|
||||
func (g *Gauge) WithContext(ctx context.Context) GaugeMetric {
|
||||
return g.GaugeMetric
|
||||
}
|
||||
|
||||
// GaugeVec is the internal representation of our wrapping struct around prometheus
|
||||
// gaugeVecs. kubeGaugeVec implements both kubeCollector and KubeGaugeVec.
|
||||
type GaugeVec struct {
|
||||
@ -88,13 +94,20 @@ type GaugeVec struct {
|
||||
func NewGaugeVec(opts *GaugeOpts, labels []string) *GaugeVec {
|
||||
opts.StabilityLevel.setDefaults()
|
||||
|
||||
fqName := BuildFQName(opts.Namespace, opts.Subsystem, opts.Name)
|
||||
allowListLock.RLock()
|
||||
if allowList, ok := labelValueAllowLists[fqName]; ok {
|
||||
opts.LabelValueAllowLists = allowList
|
||||
}
|
||||
allowListLock.RUnlock()
|
||||
|
||||
cv := &GaugeVec{
|
||||
GaugeVec: noopGaugeVec,
|
||||
GaugeOpts: opts,
|
||||
originalLabels: labels,
|
||||
lazyMetric: lazyMetric{},
|
||||
}
|
||||
cv.lazyInit(cv, BuildFQName(opts.Namespace, opts.Subsystem, opts.Name))
|
||||
cv.lazyInit(cv, fqName)
|
||||
return cv
|
||||
}
|
||||
|
||||
@ -133,6 +146,9 @@ func (v *GaugeVec) WithLabelValues(lvs ...string) GaugeMetric {
|
||||
if !v.IsCreated() {
|
||||
return noop // return no-op gauge
|
||||
}
|
||||
if v.LabelValueAllowLists != nil {
|
||||
v.LabelValueAllowLists.ConstrainToAllowedList(v.originalLabels, lvs)
|
||||
}
|
||||
return v.GaugeVec.WithLabelValues(lvs...)
|
||||
}
|
||||
|
||||
@ -144,6 +160,9 @@ func (v *GaugeVec) With(labels map[string]string) GaugeMetric {
|
||||
if !v.IsCreated() {
|
||||
return noop // return no-op gauge
|
||||
}
|
||||
if v.LabelValueAllowLists != nil {
|
||||
v.LabelValueAllowLists.ConstrainLabelMap(labels)
|
||||
}
|
||||
return v.GaugeVec.With(labels)
|
||||
}
|
||||
|
||||
@ -191,3 +210,27 @@ func NewGaugeFunc(opts GaugeOpts, function func() float64) GaugeFunc {
|
||||
|
||||
return newGaugeFunc(opts, function, v)
|
||||
}
|
||||
|
||||
// WithContext returns wrapped GaugeVec with context
|
||||
func (v *GaugeVec) WithContext(ctx context.Context) *GaugeVecWithContext {
|
||||
return &GaugeVecWithContext{
|
||||
ctx: ctx,
|
||||
GaugeVec: *v,
|
||||
}
|
||||
}
|
||||
|
||||
// GaugeVecWithContext is the wrapper of GaugeVec with context.
|
||||
type GaugeVecWithContext struct {
|
||||
GaugeVec
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
// WithLabelValues is the wrapper of GaugeVec.WithLabelValues.
|
||||
func (vc *GaugeVecWithContext) WithLabelValues(lvs ...string) GaugeMetric {
|
||||
return vc.GaugeVec.WithLabelValues(lvs...)
|
||||
}
|
||||
|
||||
// With is the wrapper of GaugeVec.With.
|
||||
func (vc *GaugeVecWithContext) With(labels map[string]string) GaugeMetric {
|
||||
return vc.GaugeVec.With(labels)
|
||||
}
|
||||
|
Reference in New Issue
Block a user