Skip to content

Commit

Permalink
validate worker Profile status is nil in input request
Browse files Browse the repository at this point in the history
  • Loading branch information
gniranjan committed Jul 27, 2023
1 parent 6018b46 commit aef1db6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/api/v20230904/openshiftcluster_validatestatic.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ func (sv openShiftClusterStaticValidator) validateProperties(path string, p *Ope
if err := sv.validateAPIServerProfile(path+".apiserverProfile", &p.APIServerProfile); err != nil {
return err
}
if len(p.WorkerProfilesStatus) != 0 {
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".workerProfilesStatus", "Worker Profile Status must be set to nil.")
}

if isCreate {
if len(p.WorkerProfiles) != 1 {
Expand Down
16 changes: 16 additions & 0 deletions pkg/api/v20230904/openshiftcluster_validatestatic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,22 @@ func TestOpenShiftClusterStaticValidateProperties(t *testing.T) {
},
wantErr: "400: InvalidParameter: properties.provisioningState: The provided provisioning state 'invalid' is invalid.",
},
{
name: "workerProfileStatus nonNil",
modify: func(oc *OpenShiftCluster) {
oc.Properties.WorkerProfilesStatus = []WorkerProfile{
{
Name: "worker",
VMSize: "Standard_D4s_v3",
EncryptionAtHost: EncryptionAtHostDisabled,
DiskSizeGB: 128,
SubnetID: fmt.Sprintf("/subscriptions/%s/resourceGroups/vnet/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/worker", subscriptionID),
Count: 3,
},
}
},
wantErr: "400: InvalidParameter: properties.workerProfilesStatus: Worker Profile Status must be set to nil.",
},
}
createTests := []*validateTest{
{
Expand Down

0 comments on commit aef1db6

Please sign in to comment.