Skip to content

Commit

Permalink
Merge pull request #103365 from liggitt/podsecurity-feature-test
Browse files Browse the repository at this point in the history
PodSecurity: make failure integration tests feature-aware

Kubernetes-commit: dbfea1e2aa22b7726ab2477fdff99a9a65da874a
  • Loading branch information
k8s-publishing-bot committed Jul 1, 2021
2 parents 2b6184b + 56fde14 commit 0b46b07
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions featuregate/feature_gate.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ type MutableFeatureGate interface {
SetFromMap(m map[string]bool) error
// Add adds features to the featureGate.
Add(features map[Feature]FeatureSpec) error
// GetAll returns a copy of the map of known feature names to feature specs.
GetAll() map[Feature]FeatureSpec
}

// featureGate implements FeatureGate as well as pflag.Value for flag parsing.
Expand Down Expand Up @@ -290,6 +292,15 @@ func (f *featureGate) Add(features map[Feature]FeatureSpec) error {
return nil
}

// GetAll returns a copy of the map of known feature names to feature specs.
func (f *featureGate) GetAll() map[Feature]FeatureSpec {
retval := map[Feature]FeatureSpec{}
for k, v := range f.known.Load().(map[Feature]FeatureSpec) {
retval[k] = v
}
return retval
}

// Enabled returns true if the key is enabled. If the key is not known, this call will panic.
func (f *featureGate) Enabled(key Feature) bool {
if v, ok := f.enabled.Load().(map[Feature]bool)[key]; ok {
Expand Down

0 comments on commit 0b46b07

Please sign in to comment.