mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-13 11:25:19 +00:00
Refactor show-hidden-metric-for-version flag
This commit is contained in:
committed by
Marek Siarkowicz
parent
3c3fc800df
commit
24321b2d4e
@@ -125,6 +125,7 @@ go_test(
|
||||
"//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library",
|
||||
"//staging/src/k8s.io/apiserver/pkg/server/options:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/config:go_default_library",
|
||||
"//staging/src/k8s.io/component-base/metrics:go_default_library",
|
||||
"//vendor/github.com/spf13/pflag:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -87,6 +87,7 @@ type KubeControllerManagerOptions struct {
|
||||
InsecureServing *apiserveroptions.DeprecatedInsecureServingOptionsWithLoopback
|
||||
Authentication *apiserveroptions.DelegatingAuthenticationOptions
|
||||
Authorization *apiserveroptions.DelegatingAuthorizationOptions
|
||||
Metrics *metrics.Options
|
||||
|
||||
Master string
|
||||
Kubeconfig string
|
||||
@@ -177,6 +178,7 @@ func NewKubeControllerManagerOptions() (*KubeControllerManagerOptions, error) {
|
||||
}).WithLoopback(),
|
||||
Authentication: apiserveroptions.NewDelegatingAuthenticationOptions(),
|
||||
Authorization: apiserveroptions.NewDelegatingAuthorizationOptions(),
|
||||
Metrics: metrics.NewOptions(),
|
||||
}
|
||||
|
||||
s.Authentication.RemoteKubeConfigFileOptional = true
|
||||
@@ -246,20 +248,13 @@ func (s *KubeControllerManagerOptions) Flags(allControllers []string, disabledBy
|
||||
s.ResourceQuotaController.AddFlags(fss.FlagSet("resourcequota controller"))
|
||||
s.SAController.AddFlags(fss.FlagSet("serviceaccount controller"))
|
||||
s.TTLAfterFinishedController.AddFlags(fss.FlagSet("ttl-after-finished controller"))
|
||||
s.Metrics.AddFlags(fss.FlagSet("metrics"))
|
||||
|
||||
fs := fss.FlagSet("misc")
|
||||
fs.StringVar(&s.Master, "master", s.Master, "The address of the Kubernetes API server (overrides any value in kubeconfig).")
|
||||
fs.StringVar(&s.Kubeconfig, "kubeconfig", s.Kubeconfig, "Path to kubeconfig file with authorization and master location information.")
|
||||
utilfeature.DefaultMutableFeatureGate.AddFlag(fss.FlagSet("generic"))
|
||||
|
||||
mfs := fss.FlagSet("metrics")
|
||||
mfs.StringVar(&s.ShowHiddenMetricsForVersion, "show-hidden-metrics-for-version", s.ShowHiddenMetricsForVersion,
|
||||
"The previous version for which you want to show hidden metrics. "+
|
||||
"Only the previous minor version is meaningful, other values will not be allowed. "+
|
||||
"The format is <major>.<minor>, e.g.: '1.16'. "+
|
||||
"The purpose of this format is make sure you have the opportunity to notice if the next release hides additional metrics, "+
|
||||
"rather than being surprised when they are permanently removed in the release after that.")
|
||||
|
||||
return fss
|
||||
}
|
||||
|
||||
@@ -392,7 +387,7 @@ func (s *KubeControllerManagerOptions) Validate(allControllers []string, disable
|
||||
errs = append(errs, s.InsecureServing.Validate()...)
|
||||
errs = append(errs, s.Authentication.Validate()...)
|
||||
errs = append(errs, s.Authorization.Validate()...)
|
||||
errs = append(errs, metrics.ValidateShowHiddenMetricsVersion(s.ShowHiddenMetricsForVersion)...)
|
||||
errs = append(errs, s.Metrics.Validate()...)
|
||||
|
||||
// TODO: validate component config, master and kubeconfig
|
||||
|
||||
@@ -440,10 +435,7 @@ func (s KubeControllerManagerOptions) Config(allControllers []string, disabledBy
|
||||
if err := s.ApplyTo(c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(s.ShowHiddenMetricsForVersion) > 0 {
|
||||
metrics.SetShowHidden()
|
||||
}
|
||||
s.Metrics.Apply()
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/diff"
|
||||
apiserveroptions "k8s.io/apiserver/pkg/server/options"
|
||||
componentbaseconfig "k8s.io/component-base/config"
|
||||
"k8s.io/component-base/metrics"
|
||||
cmoptions "k8s.io/kubernetes/cmd/controller-manager/app/options"
|
||||
kubecontrollerconfig "k8s.io/kubernetes/cmd/kube-controller-manager/app/config"
|
||||
kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config"
|
||||
@@ -381,6 +382,7 @@ func TestAddFlags(t *testing.T) {
|
||||
},
|
||||
Kubeconfig: "/kubeconfig",
|
||||
Master: "192.168.4.20",
|
||||
Metrics: &metrics.Options{},
|
||||
}
|
||||
|
||||
// Sort GCIgnoredResources because it's built from a map, which means the
|
||||
|
||||
Reference in New Issue
Block a user