Skip to content

Commit 359ba16

Browse files
committed
Allow users to set the zone for NAT gateway
Allow users to set the zone they need the created NAT gateway to use. ASO allows the NAT gateway to be set to a zone so enabling that here.
1 parent 7194cbd commit 359ba16

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

azure/services/natgateways/spec.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type NatGatewaySpec struct {
3636
Location string
3737
NatGatewayIP infrav1.PublicIPSpec
3838
ClusterName string
39+
Zone string
3940
AdditionalTags infrav1.Tags
4041
IsVnetManaged bool
4142
}
@@ -79,6 +80,9 @@ func (s *NatGatewaySpec) Parameters(_ context.Context, existingNatGateway *asone
7980
Name: ptr.To(s.Name),
8081
Additional: s.AdditionalTags,
8182
})
83+
if s.Zone != "" {
84+
natGateway.Spec.Zones = []string{s.Zone}
85+
}
8286

8387
return natGateway, nil
8488
}

azure/services/natgateways/spec_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ var (
3636
ResourceGroup: "my-rg",
3737
SubscriptionID: "123",
3838
Location: "eastus",
39+
Zone: "eastus-1",
3940
NatGatewayIP: infrav1.PublicIPSpec{
4041
Name: "my-natgateway-ip",
4142
DNSName: "Standard",
@@ -59,6 +60,7 @@ var (
5960
AzureName: "my-natgateway",
6061
IdleTimeoutInMinutes: ptr.To(6),
6162
Location: locationPtr,
63+
Zones: []string{"eastus-1"},
6264
Owner: &genruntime.KnownResourceReference{
6365
Name: "my-rg",
6466
},
@@ -114,6 +116,8 @@ func TestParameters(t *testing.T) {
114116
g.Expect(parameters.Spec.Owner.Name).To(Equal("my-rg"))
115117
g.Expect(parameters.Spec.Location).NotTo(BeNil())
116118
g.Expect(parameters.Spec.Location).To(Equal(locationPtr))
119+
g.Expect(parameters.Spec.Zones).To(HaveLen(1))
120+
g.Expect(parameters.Spec.Zones[0]).To(Equal("eastus-1"))
117121
g.Expect(parameters.Spec.Sku.Name).NotTo(BeNil())
118122
g.Expect(parameters.Spec.Sku.Name).To(Equal(standardSKUPtr))
119123
g.Expect(parameters.Spec.PublicIpAddresses).To(HaveLen(1))

0 commit comments

Comments
 (0)