mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
complish feature gate dependency in kubeadm
This commit is contained in:
parent
3df3c580b7
commit
51fe9299f6
@ -155,5 +155,22 @@ func NewFeatureGate(f *FeatureList, value string) (map[string]bool, error) {
|
|||||||
featureGate[k] = boolValue
|
featureGate[k] = boolValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResolveFeatureGateDependencies(featureGate)
|
||||||
|
|
||||||
return featureGate, nil
|
return featureGate, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResolveFeatureGateDependencies resolve dependencies between feature gates
|
||||||
|
func ResolveFeatureGateDependencies(featureGate map[string]bool) {
|
||||||
|
|
||||||
|
// if StoreCertsInSecrets enabled, SelfHosting should enabled
|
||||||
|
if Enabled(featureGate, StoreCertsInSecrets) {
|
||||||
|
featureGate[SelfHosting] = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// if HighAvailability enabled, both StoreCertsInSecrets and SelfHosting should enabled
|
||||||
|
if Enabled(featureGate, HighAvailability) && !Enabled(featureGate, StoreCertsInSecrets) {
|
||||||
|
featureGate[SelfHosting] = true
|
||||||
|
featureGate[StoreCertsInSecrets] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -156,3 +156,36 @@ func TestValidateVersion(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestResolveFeatureGateDependencies(t *testing.T) {
|
||||||
|
|
||||||
|
var tests = []struct {
|
||||||
|
inputFeatures map[string]bool
|
||||||
|
expectedFeatures map[string]bool
|
||||||
|
}{
|
||||||
|
{ // no flags
|
||||||
|
inputFeatures: map[string]bool{},
|
||||||
|
expectedFeatures: map[string]bool{},
|
||||||
|
},
|
||||||
|
{ // others flags
|
||||||
|
inputFeatures: map[string]bool{"SupportIPVSProxyMode": true},
|
||||||
|
expectedFeatures: map[string]bool{"SupportIPVSProxyMode": true},
|
||||||
|
},
|
||||||
|
{ // just StoreCertsInSecrets flags
|
||||||
|
inputFeatures: map[string]bool{"StoreCertsInSecrets": true},
|
||||||
|
expectedFeatures: map[string]bool{"StoreCertsInSecrets": true, "SelfHosting": true},
|
||||||
|
},
|
||||||
|
{ // just HighAvailability flags
|
||||||
|
inputFeatures: map[string]bool{"HighAvailability": true},
|
||||||
|
expectedFeatures: map[string]bool{"HighAvailability": true, "StoreCertsInSecrets": true, "SelfHosting": true},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
ResolveFeatureGateDependencies(test.inputFeatures)
|
||||||
|
if !reflect.DeepEqual(test.inputFeatures, test.expectedFeatures) {
|
||||||
|
t.Errorf("ResolveFeatureGateDependencies failed, expected: %v, got: %v", test.inputFeatures, test.expectedFeatures)
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user