File tree Expand file tree Collapse file tree
etcd/vendor/github.com/openshift/microshift/pkg/config Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -187,13 +187,18 @@ func (fg FeatureGates) GoString() string {
187187// 4. If FeatureSet is CustomNoUpgrade, CustomNoUpgrade.Enabled/Disabled lists may be set but are not required.
188188// 5. Required feature gates cannot be disabled.
189189// 6. Feature gates cannot be both enabled and disabled within the same object.
190+ // 7. If FeatureSet is empty, CustomNoUpgrade and SpecialHandlingSupportExceptionRequired lists must also be empty.
190191func (fg * FeatureGates ) validateFeatureGates () error {
191192 if fg == nil || reflect .DeepEqual (* fg , FeatureGates {}) {
192193 return nil
193194 }
194195
195196 switch fg .FeatureSet {
196197 case "" :
198+ if len (fg .CustomNoUpgrade .Enabled ) > 0 || len (fg .CustomNoUpgrade .Disabled ) > 0 ||
199+ len (fg .SpecialHandlingSupportExceptionRequired .Enabled ) > 0 || len (fg .SpecialHandlingSupportExceptionRequired .Disabled ) > 0 {
200+ return fmt .Errorf ("CustomNoUpgrade and SpecialHandlingSupportExceptionRequired enabled/disabled lists must be empty when FeatureSet is empty" )
201+ }
197202 return nil
198203 case FeatureSetCustomNoUpgrade :
199204 // Valid - continue with validation
Original file line number Diff line number Diff line change @@ -827,7 +827,18 @@ func TestValidate(t *testing.T) {
827827 c .ApiServer .FeatureGates .CustomNoUpgrade .Disabled = []string {"feature2" }
828828 return c
829829 }(),
830- expectErr : false ,
830+ expectErr : true ,
831+ },
832+ {
833+ name : "feature-gates-special-handling-with-feature-set-empty" ,
834+ config : func () * Config {
835+ c := mkDefaultConfig ()
836+ c .ApiServer .FeatureGates .FeatureSet = ""
837+ c .ApiServer .FeatureGates .SpecialHandlingSupportExceptionRequired .Enabled = []string {"feature1" }
838+ c .ApiServer .FeatureGates .SpecialHandlingSupportExceptionRequired .Disabled = []string {"feature2" }
839+ return c
840+ }(),
841+ expectErr : true ,
831842 },
832843 {
833844 name : "feature-gates-custom-no-upgrade-valid" ,
You can’t perform that action at this time.
0 commit comments