Skip to content

Commit

Permalink
Disable validation of the Replicas in the Worker definition
Browse files Browse the repository at this point in the history
Effectively allowing to have 0 Replicas configured for initial cluster
setup, for later export and versioning in infra repositories.

Signed-off-by: Artiom Diomin <[email protected]>
  • Loading branch information
kron4eg committed Jan 15, 2020
1 parent 8f47866 commit f5c008f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pkg/apis/kubeone/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ func ValidateWorkerConfig(workerset []kubeone.WorkerConfig, fldPath *field.Path)
if w.Name == "" {
allErrs = append(allErrs, field.Invalid(fldPath, w.Name, "no name given"))
}
if w.Replicas == nil || *w.Replicas < 1 {
allErrs = append(allErrs, field.Invalid(fldPath, w.Replicas, "replicas must be specified and >= 1"))
if w.Replicas == nil || *w.Replicas < 0 {
allErrs = append(allErrs, field.Invalid(fldPath, w.Replicas, "replicas must be specified and >= 0"))
}
}

Expand Down
18 changes: 4 additions & 14 deletions pkg/apis/kubeone/validation/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ func TestValidateWorkerConfig(t *testing.T) {
Name: "test-2",
Replicas: intPtr(5),
},
{
Name: "test-3",
Replicas: intPtr(0),
},
},
expectedError: false,
},
Expand All @@ -352,20 +356,6 @@ func TestValidateWorkerConfig(t *testing.T) {
workerConfig: []kubeone.WorkerConfig{},
expectedError: false,
},
{
name: "invalid worker config (zero replicas)",
workerConfig: []kubeone.WorkerConfig{
{
Name: "test-1",
Replicas: intPtr(0),
},
{
Name: "test-2",
Replicas: intPtr(5),
},
},
expectedError: true,
},
{
name: "invalid worker config (replicas not provided)",
workerConfig: []kubeone.WorkerConfig{
Expand Down

0 comments on commit f5c008f

Please sign in to comment.