Skip to content

Commit 15bcb23

Browse files
committed
Adding validation, test and field changes.
1 parent 7b5b1da commit 15bcb23

File tree

5 files changed

+61
-1
lines changed

5 files changed

+61
-1
lines changed

data/data/install.openshift.io_installconfigs.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5304,6 +5304,44 @@ spec:
53045304
This resource group must be empty with no other resources when trying to use it for creating a cluster.
53055305
If empty, a new resource group will created for the cluster.
53065306
type: string
5307+
subnets:
5308+
description: Subnets is the list of subnets the user can bring
5309+
into the cluster to be used.
5310+
items:
5311+
description: SubnetSpec specifies the properties the subnet
5312+
needs to be used in the cluster.
5313+
properties:
5314+
cidr:
5315+
description: |-
5316+
SubnetCIDR specifies the CIDR for the subnet if it needs to be created.
5317+
Should not be mentioned if the subnet is a bring your own subnet.
5318+
items:
5319+
type: string
5320+
type: array
5321+
name:
5322+
description: Name of the subnet.
5323+
type: string
5324+
natGateway:
5325+
description: |-
5326+
NatGatewayName specifies the name of the NAT gateway to be created for this subnet.
5327+
Can only be used if the outbound type is set to MultiZoneNatGateway.
5328+
type: string
5329+
role:
5330+
description: Role specifies the actual role which the subnet
5331+
should be used in.
5332+
type: string
5333+
zone:
5334+
description: Zone specifies the availability zone the NAT
5335+
gateway needs to be placed in.
5336+
type: string
5337+
required:
5338+
- cidr
5339+
- name
5340+
- natGateway
5341+
- role
5342+
- zone
5343+
type: object
5344+
type: array
53075345
userProvisionedDNS:
53085346
default: Disabled
53095347
description: |-

pkg/asset/installconfig/azure/validation.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ func Validate(client API, ic *types.InstallConfig) error {
7171
}
7272
allErrs = append(allErrs, validateMarketplaceImages(client, ic)...)
7373
allErrs = append(allErrs, validateBootDiagnostics(client, ic)...)
74+
// allErrs = append(allErrs, validateCustomSubnetsAndNatGateways(client, ic.Azure)...)
7475
return allErrs.ToAggregate()
7576
}
7677

pkg/explain/printer_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ resource group.
342342
This resource group must be empty with no other resources when trying to use it for creating a cluster.
343343
If empty, a new resource group will created for the cluster.
344344
345+
subnets <[]object>
346+
Subnets is the list of subnets the user can bring into the cluster to be used.
347+
SubnetSpec specifies the properties the subnet needs to be used in the cluster.
348+
345349
userProvisionedDNS <string>
346350
Default: "Disabled"
347351
Valid Values: "Enabled","Disabled"

pkg/types/azure/validation/platform.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ func ValidatePlatform(p *azure.Platform, publish types.PublishingStrategy, fldPa
127127
allErrs = append(allErrs, field.Required(fldPath.Child("clusterOSImage"), fmt.Sprintf("clusterOSImage must not be set when the cloud name is %s", cloud)))
128128
}
129129
}
130+
for index, subnet := range p.Subnets {
131+
if subnet.NatGatewayName != "" && p.OutboundType != azure.NATGatewayMultiZoneOutboundType {
132+
allErrs = append(allErrs, field.Invalid(fldPath.Child("subnet").Index(index), subnet.NatGatewayName, "cannot specify nat gateway if outbound type is not MultiZoneNatGateway"))
133+
}
134+
}
130135

131136
return allErrs
132137
}
@@ -239,6 +244,7 @@ func findDuplicateTagKeys(tagSet map[string]string) error {
239244
var (
240245
validOutboundTypes = map[azure.OutboundType]struct{}{
241246
azure.LoadbalancerOutboundType: {},
247+
azure.NATGatewayMultiZoneOutboundType: {},
242248
azure.NATGatewaySingleZoneOutboundType: {},
243249
azure.UserDefinedRoutingOutboundType: {},
244250
}

pkg/types/azure/validation/platform_test.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func TestValidatePlatform(t *testing.T) {
134134
p.OutboundType = "random-egress"
135135
return p
136136
}(),
137-
expected: `^test-path\.outboundType: Unsupported value: "random-egress": supported values: "Loadbalancer", "NATGatewaySingleZone", "UserDefinedRouting"$`,
137+
expected: `^test-path\.outboundType: Unsupported value: "random-egress": supported values: "Loadbalancer", "MultiZoneNatGateway", "NATGatewaySingleZone", "UserDefinedRouting"$`,
138138
},
139139
{
140140
name: "invalid user defined type",
@@ -217,6 +217,17 @@ func TestValidatePlatform(t *testing.T) {
217217
}(),
218218
expected: `^test-path\.customerManagedKey: Invalid value: "-": invalid user assigned identity key for encryption$`,
219219
},
220+
{
221+
name: "mentioned nat gateway when outbound type is not multi zone",
222+
platform: func() *azure.Platform {
223+
p := validPlatform()
224+
p.Subnets = []azure.SubnetSpec{{
225+
NatGatewayName: "test-invalid",
226+
}}
227+
return p
228+
}(),
229+
expected: `^test-path\.subnet\[0\]: Invalid value: "test-invalid": cannot specify nat gateway if outbound type is not MultiZoneNatGateway$`,
230+
},
220231
}
221232
ic := types.InstallConfig{}
222233
for _, tc := range cases {

0 commit comments

Comments
 (0)