add disclaimer to CLI help text

Change-Id: I32e52e97ec6bc7514a0030c8d83ad74bc346f7d5
This commit is contained in:
Han Kang 2021-02-18 16:01:32 -08:00
parent 0e32c43e07
commit 51be88a845
2 changed files with 9 additions and 6 deletions

View File

@ -61,19 +61,20 @@ func (o *Options) AddFlags(fs *pflag.FlagSet) {
"disabled-metrics", "disabled-metrics",
o.DisabledMetrics, o.DisabledMetrics,
"This flag provides an escape hatch for misbehaving metrics. "+ "This flag provides an escape hatch for misbehaving metrics. "+
"You must provide the fully qualified metric name in order to disable it.") "You must provide the fully qualified metric name in order to disable it. "+
"Disclaimer: disabling metrics is higher in precedence than showing hidden metrics.")
} }
// Apply applies parameters into global configuration of metrics. // Apply applies parameters into global configuration of metrics.
func (o *Options) Apply() { func (o *Options) Apply() {
if o != nil && len(o.ShowHiddenMetricsForVersion) > 0 { if o != nil && len(o.ShowHiddenMetricsForVersion) > 0 {
SetShowHidden() SetShowHidden()
}
// set disabled metrics // set disabled metrics
for _, metricName := range o.DisabledMetrics { for _, metricName := range o.DisabledMetrics {
SetDisabledMetric(metricName) SetDisabledMetric(metricName)
} }
} }
}
func validateShowHiddenMetricsVersion(currentVersion semver.Version, targetVersionStr string) error { func validateShowHiddenMetricsVersion(currentVersion semver.Version, targetVersionStr string) error {
if targetVersionStr == "" { if targetVersionStr == "" {

View File

@ -517,7 +517,9 @@ func TestRegistryReset(t *testing.T) {
} }
func TestDisabledMetrics(t *testing.T) { func TestDisabledMetrics(t *testing.T) {
SetDisabledMetric("should_be_disabled") o := NewOptions()
o.DisabledMetrics = []string{"should_be_disabled"}
o.Apply()
currentVersion := apimachineryversion.Info{ currentVersion := apimachineryversion.Info{
Major: "1", Major: "1",
Minor: "17", Minor: "17",