Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change default nat gateway IP name #3424

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/v1beta1/azurecluster_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (c *AzureCluster) setSubnetDefaults() {
subnet.NatGateway.Name = withIndex(generateNatGatewayName(c.ObjectMeta.Name), nodeSubnetCounter)
}
if subnet.NatGateway.NatGatewayIP.Name == "" {
subnet.NatGateway.NatGatewayIP.Name = generateNatGatewayIPName(c.ObjectMeta.Name, subnet.Name)
subnet.NatGateway.NatGatewayIP.Name = generateNatGatewayIPName(subnet.NatGateway.Name)
}
}

Expand Down Expand Up @@ -453,8 +453,8 @@ func generateNatGatewayName(clusterName string) string {
}

// generateNatGatewayIPName generates a NAT gateway IP name.
func generateNatGatewayIPName(clusterName, subnetName string) string {
return fmt.Sprintf("pip-%s-%s-natgw", clusterName, subnetName)
func generateNatGatewayIPName(natGatewayName string) string {
return fmt.Sprintf("pip-%s", natGatewayName)
}

// withIndex appends the index as suffix to a generated name.
Expand Down
8 changes: 4 additions & 4 deletions api/v1beta1/azurecluster_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ func TestSubnetDefaults(t *testing.T) {
Name: "foo-natgw",
},
NatGatewayIP: PublicIPSpec{
Name: "pip-cluster-test-my-node-subnet-natgw",
Name: "pip-foo-natgw",
},
},
},
Expand Down Expand Up @@ -434,7 +434,7 @@ func TestSubnetDefaults(t *testing.T) {
Name: "cluster-test-node-natgw-1",
},
NatGatewayIP: PublicIPSpec{
Name: "pip-cluster-test-cluster-test-node-subnet-natgw",
Name: "pip-cluster-test-node-natgw-1",
},
},
},
Expand Down Expand Up @@ -500,7 +500,7 @@ func TestSubnetDefaults(t *testing.T) {
Name: "cluster-test-node-natgw-1",
},
NatGatewayIP: PublicIPSpec{
Name: "pip-cluster-test-cluster-test-node-subnet-natgw",
Name: "pip-cluster-test-node-natgw-1",
},
},
},
Expand Down Expand Up @@ -549,7 +549,7 @@ func TestSubnetDefaults(t *testing.T) {
Name: "cluster-test-node-natgw-1",
},
NatGatewayIP: PublicIPSpec{
Name: "pip-cluster-test-my-node-subnet-natgw",
Name: "pip-cluster-test-node-natgw-1",
},
},
},
Expand Down
5 changes: 0 additions & 5 deletions azure/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ func GenerateFrontendIPConfigName(lbName string) string {
return fmt.Sprintf("%s-%s", lbName, "frontEnd")
}

// GenerateNatGatewayIPName generates a NAT gateway IP name.
func GenerateNatGatewayIPName(clusterName, subnetName string) string {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dead code

return fmt.Sprintf("pip-%s-%s-natgw", clusterName, subnetName)
}

// GenerateNodeOutboundIPName generates a public IP name, based on the cluster name.
func GenerateNodeOutboundIPName(clusterName string) string {
return fmt.Sprintf("pip-%s-node-outbound", clusterName)
Expand Down