Skip to content

Commit 49b7015

Browse files
committed
Declaratively validate RC...Replicas optionality
The existing test run both declarative and manual validation and it still passes.
1 parent 8e74d72 commit 49b7015

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

pkg/apis/core/v1/zz_generated.validations.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/core/validation/validation.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6191,10 +6191,10 @@ func ValidateReplicationControllerSpec(spec, oldSpec *core.ReplicationController
61916191
allErrs := field.ErrorList{}
61926192
allErrs = append(allErrs, ValidateNonnegativeField(int64(spec.MinReadySeconds), fldPath.Child("minReadySeconds"))...)
61936193
allErrs = append(allErrs, ValidateNonEmptySelector(spec.Selector, fldPath.Child("selector"))...)
6194-
if spec.Replicas == nil {
6195-
allErrs = append(allErrs, field.Required(fldPath.Child("replicas"), ""))
6196-
} else {
6197-
if !utilfeature.DefaultFeatureGate.Enabled(features.DeclarativeValidation) {
6194+
if !utilfeature.DefaultFeatureGate.Enabled(features.DeclarativeValidation) {
6195+
if spec.Replicas == nil {
6196+
allErrs = append(allErrs, field.Required(fldPath.Child("replicas"), ""))
6197+
} else {
61986198
allErrs = append(allErrs, ValidateNonnegativeField(int64(*spec.Replicas), fldPath.Child("replicas"))...)
61996199
}
62006200
}

staging/src/k8s.io/api/core/v1/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5101,7 +5101,9 @@ type ReplicationControllerSpec struct {
51015101
// Defaults to 1.
51025102
// More info: https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller#what-is-a-replicationcontroller
51035103
// +optional
5104+
// +k8s:optional
51045105
// +default=1
5106+
// FIXME: should we convert to +k8s:default ?
51055107
// +k8s:minimum=0
51065108
Replicas *int32 `json:"replicas,omitempty" protobuf:"varint,1,opt,name=replicas"`
51075109

0 commit comments

Comments
 (0)