var internalPackages … var _ … // newEnvVarFeatureGates creates a feature gate that allows for registration // of features and checking if the features are enabled. // // On the first call to Enabled, the effective state of all known features is loaded from // environment variables. The environment variable read for a given feature is formed by // concatenating the prefix "KUBE_FEATURE_" with the feature's name. // // For example, if you have a feature named "MyFeature" // setting an environmental variable "KUBE_FEATURE_MyFeature" // will allow you to configure the state of that feature. // // Please note that environmental variables can only be set to the boolean value. // Incorrect values will be ignored and logged. // // Features can also be set directly via the Set method. // In that case, these features take precedence over // features set via environmental variables. func newEnvVarFeatureGates(features map[Feature]FeatureSpec) *envVarFeatureGates { … } type envVarFeatureGates … // Enabled returns true if the key is enabled. If the key is not known, this call will panic. func (f *envVarFeatureGates) Enabled(key Feature) bool { … } // Set sets the given feature to the given value. // // Features set via this method take precedence over // the features set via environment variables. func (f *envVarFeatureGates) Set(featureName Feature, featureValue bool) error { … } // getEnabledMapFromEnvVar will fill the enabled map on the first call. // This is the only time a known feature can be set to a value // read from the corresponding environmental variable. func (f *envVarFeatureGates) getEnabledMapFromEnvVar() map[Feature]bool { … } func (f *envVarFeatureGates) wasFeatureEnabledViaSetMethod(key Feature) (bool, bool) { … } func (f *envVarFeatureGates) hasAlreadyReadEnvVar() bool { … }