Skip to content

Commit

Permalink
Set AllowInvalidLabelValueInSelector to true in LabelSelectorValida…
Browse files Browse the repository at this point in the history
…tionOptions for backwards compatibility

See kubernetes/kubernetes#113699 for more details
  • Loading branch information
shafeeqes committed Dec 20, 2022
1 parent 3e99688 commit c1d709d
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/core/validation/cloudprofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func ValidateCloudProfileSpec(spec *core.CloudProfileSpec, fldPath *field.Path)
allErrs = append(allErrs, validateVolumeTypes(spec.VolumeTypes, fldPath.Child("volumeTypes"))...)
allErrs = append(allErrs, validateRegions(spec.Regions, fldPath.Child("regions"))...)
if spec.SeedSelector != nil {
allErrs = append(allErrs, metav1validation.ValidateLabelSelector(&spec.SeedSelector.LabelSelector, fldPath.Child("seedSelector"))...)
allErrs = append(allErrs, metav1validation.ValidateLabelSelector(&spec.SeedSelector.LabelSelector, metav1validation.LabelSelectorValidationOptions{AllowInvalidLabelValueInSelector: true}, fldPath.Child("seedSelector"))...)
}

if spec.CABundle != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/core/validation/controllerregistration.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func ValidateControllerRegistrationSpec(spec *core.ControllerRegistrationSpec, f
allErrs = append(allErrs, field.Forbidden(deploymentPath.Child("seedSelector"), "specifying a seed selector is not allowed when controlling resources primarily"))
}

allErrs = append(allErrs, metav1validation.ValidateLabelSelector(deployment.SeedSelector, deploymentPath.Child("seedSelector"))...)
allErrs = append(allErrs, metav1validation.ValidateLabelSelector(deployment.SeedSelector, metav1validation.LabelSelectorValidationOptions{AllowInvalidLabelValueInSelector: true}, deploymentPath.Child("seedSelector"))...)
}

deploymentRefsCount := len(deployment.DeploymentRefs)
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/core/validation/exposureclass.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func ValidateExposureClass(exposureClass *core.ExposureClass) field.ErrorList {

if exposureClass.Scheduling != nil {
if exposureClass.Scheduling.SeedSelector != nil {
allErrs = append(allErrs, metav1validation.ValidateLabelSelector(&exposureClass.Scheduling.SeedSelector.LabelSelector, field.NewPath("scheduling", "seedSelector"))...)
allErrs = append(allErrs, metav1validation.ValidateLabelSelector(&exposureClass.Scheduling.SeedSelector.LabelSelector, metav1validation.LabelSelectorValidationOptions{AllowInvalidLabelValueInSelector: true}, field.NewPath("scheduling", "seedSelector"))...)
}
allErrs = append(allErrs, ValidateTolerations(exposureClass.Scheduling.Tolerations, field.NewPath("scheduling", "tolerations"))...)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/core/validation/shoot.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func ValidateShootSpec(meta metav1.ObjectMeta, spec *core.ShootSpec, fldPath *fi
allErrs = append(allErrs, field.Invalid(fldPath.Child("seedName"), spec.SeedName, "seed name must not be empty when providing the key"))
}
if spec.SeedSelector != nil {
allErrs = append(allErrs, metav1validation.ValidateLabelSelector(&spec.SeedSelector.LabelSelector, fldPath.Child("seedSelector"))...)
allErrs = append(allErrs, metav1validation.ValidateLabelSelector(&spec.SeedSelector.LabelSelector, metav1validation.LabelSelectorValidationOptions{AllowInvalidLabelValueInSelector: true}, fldPath.Child("seedSelector"))...)
}
if purpose := spec.Purpose; purpose != nil {
allowedShootPurposes := availableShootPurposes
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/seedmanagement/validation/managedseedset.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func ValidateManagedSeedSetSpec(spec *seedmanagement.ManagedSeedSetSpec, fldPath
if len(spec.Selector.MatchLabels) == 0 && len(spec.Selector.MatchExpressions) == 0 {
allErrs = append(allErrs, field.Invalid(selectorPath, spec.Selector, "empty selector is invalid for ManagedSeedSet"))
} else {
allErrs = append(allErrs, metav1validation.ValidateLabelSelector(&spec.Selector, selectorPath)...)
allErrs = append(allErrs, metav1validation.ValidateLabelSelector(&spec.Selector, metav1validation.LabelSelectorValidationOptions{AllowInvalidLabelValueInSelector: true}, selectorPath)...)
var err error
if selector, err = metav1.LabelSelectorAsSelector(&spec.Selector); err != nil {
allErrs = append(allErrs, field.Invalid(selectorPath, spec.Selector, err.Error()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func ValidateClusterOpenIDConnectPresetUpdate(new, old *settings.ClusterOpenIDCo

func validateClusterOpenIDConnectPresetSpec(spec *settings.ClusterOpenIDConnectPresetSpec, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
allErrs = append(allErrs, metav1validation.ValidateLabelSelector(spec.ProjectSelector, fldPath.Child("projectSelector"))...)
allErrs = append(allErrs, metav1validation.ValidateLabelSelector(spec.ProjectSelector, metav1validation.LabelSelectorValidationOptions{AllowInvalidLabelValueInSelector: true}, fldPath.Child("projectSelector"))...)
allErrs = append(allErrs, validateOpenIDConnectPresetSpec(&spec.OpenIDConnectPresetSpec, fldPath)...)
return allErrs
}
2 changes: 1 addition & 1 deletion pkg/apis/settings/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
func validateOpenIDConnectPresetSpec(spec *settings.OpenIDConnectPresetSpec, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}

allErrs = append(allErrs, metav1validation.ValidateLabelSelector(spec.ShootSelector, fldPath.Child("shootSelector"))...)
allErrs = append(allErrs, metav1validation.ValidateLabelSelector(spec.ShootSelector, metav1validation.LabelSelectorValidationOptions{AllowInvalidLabelValueInSelector: true}, fldPath.Child("shootSelector"))...)
if spec.Weight <= 0 || spec.Weight > 100 {
allErrs = append(allErrs, field.Invalid(fldPath.Child("weight"), spec.Weight, "must be in the range 1-100"))
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllermanager/apis/config/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ func validateProjectControllerConfiguration(conf *config.ProjectControllerConfig
func validateProjectQuotaConfiguration(conf config.QuotaConfiguration, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}

allErrs = append(allErrs, metav1validation.ValidateLabelSelector(conf.ProjectSelector, fldPath.Child("projectSelector"))...)
allErrs = append(allErrs, metav1validation.ValidateLabelSelector(conf.ProjectSelector, metav1validation.LabelSelectorValidationOptions{AllowInvalidLabelValueInSelector: true}, fldPath.Child("projectSelector"))...)

if conf.Config == nil {
allErrs = append(allErrs, field.Required(fldPath.Child("config"), "must provide a quota config"))
Expand Down

0 comments on commit c1d709d

Please sign in to comment.