зеркало из https://github.com/Azure/ARO-RP.git
Replace hardcoded nsg values with constants
This commit is contained in:
Родитель
b315c1d329
Коммит
c86e8d3d11
|
@ -214,7 +214,7 @@ func (i *Installer) deployStorageTemplate(ctx context.Context, installConfig *in
|
|||
},
|
||||
},
|
||||
},
|
||||
Name: to.StringPtr(infraID + "-controlplane-nsg"),
|
||||
Name: to.StringPtr(infraID + subnet.NSGControlPlaneSuffix),
|
||||
Type: to.StringPtr("Microsoft.Network/networkSecurityGroups"),
|
||||
Location: &installConfig.Config.Azure.Region,
|
||||
},
|
||||
|
@ -222,7 +222,7 @@ func (i *Installer) deployStorageTemplate(ctx context.Context, installConfig *in
|
|||
},
|
||||
{
|
||||
Resource: &mgmtnetwork.SecurityGroup{
|
||||
Name: to.StringPtr(infraID + "-node-nsg"),
|
||||
Name: to.StringPtr(infraID + subnet.NSGNodeSuffix),
|
||||
Type: to.StringPtr("Microsoft.Network/networkSecurityGroups"),
|
||||
Location: &installConfig.Config.Azure.Region,
|
||||
},
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package subnet
|
||||
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the Apache License 2.0.
|
||||
|
||||
// Network security group constants
|
||||
const (
|
||||
NSGControlPlaneSuffix = "-controlplane-nsg"
|
||||
NSGNodeSuffix = "-node-nsg"
|
||||
)
|
|
@ -86,9 +86,9 @@ func NetworkSecurityGroupID(oc *api.OpenShiftCluster, subnetID string) (string,
|
|||
|
||||
switch {
|
||||
case strings.EqualFold(subnetID, oc.Properties.MasterProfile.SubnetID):
|
||||
return oc.Properties.ClusterProfile.ResourceGroupID + "/providers/Microsoft.Network/networkSecurityGroups/" + infraID + "-controlplane-nsg", nil
|
||||
return oc.Properties.ClusterProfile.ResourceGroupID + "/providers/Microsoft.Network/networkSecurityGroups/" + infraID + NSGControlPlaneSuffix, nil
|
||||
case strings.EqualFold(subnetID, oc.Properties.WorkerProfiles[0].SubnetID):
|
||||
return oc.Properties.ClusterProfile.ResourceGroupID + "/providers/Microsoft.Network/networkSecurityGroups/" + infraID + "-node-nsg", nil
|
||||
return oc.Properties.ClusterProfile.ResourceGroupID + "/providers/Microsoft.Network/networkSecurityGroups/" + infraID + NSGNodeSuffix, nil
|
||||
default:
|
||||
return "", fmt.Errorf("unknown subnetID %q", subnetID)
|
||||
}
|
||||
|
|
|
@ -178,13 +178,13 @@ func TestNetworkSecurityGroupID(t *testing.T) {
|
|||
{
|
||||
name: "master",
|
||||
subnetID: "/subscriptions/subscriptionId/resourceGroups/vnetResourceGroup/providers/Microsoft.Network/virtualNetworks/vnet/subnets/master",
|
||||
wantNSGID: "/subscriptions/subscriptionId/resourceGroups/clusterResourceGroup/providers/Microsoft.Network/networkSecurityGroups/aro-controlplane-nsg",
|
||||
wantNSGID: "/subscriptions/subscriptionId/resourceGroups/clusterResourceGroup/providers/Microsoft.Network/networkSecurityGroups/aro" + NSGControlPlaneSuffix,
|
||||
},
|
||||
{
|
||||
name: "worker",
|
||||
infraID: "test-1234",
|
||||
subnetID: "/subscriptions/subscriptionId/resourceGroups/vnetResourceGroup/providers/Microsoft.Network/virtualNetworks/vnet/subnets/worker",
|
||||
wantNSGID: "/subscriptions/subscriptionId/resourceGroups/clusterResourceGroup/providers/Microsoft.Network/networkSecurityGroups/test-1234-node-nsg",
|
||||
wantNSGID: "/subscriptions/subscriptionId/resourceGroups/clusterResourceGroup/providers/Microsoft.Network/networkSecurityGroups/test-1234" + NSGNodeSuffix,
|
||||
},
|
||||
{
|
||||
name: "invalid",
|
||||
|
|
Загрузка…
Ссылка в новой задаче