Skip to content

Commit 986a68c

Browse files
committed
CORS-4259: Use the firewall rule management policy
** manifests/gcp/cluster.go Update the capg spec to pass the firewall rule management policy based on whether the user has the permissions to create firewall rules.
1 parent 8b0a8a2 commit 986a68c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pkg/asset/manifests/gcp/cluster.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@ func GenerateClusterAssets(installConfig *installconfig.InstallConfig, clusterID
135135

136136
formattedEndpoints := gcpic.FormatGCPEndpointList(installConfig.Config.GCP.ServiceEndpoints, gcpic.FormatGCPEndpointInput{SkipPath: false})
137137

138+
firewallRulesManagementPolicy := capg.RulesManagementManaged
139+
createFwRules, err := gcpic.HasPermissions(context.Background(), installConfig.Config.GCP.ProjectID, []string{gcpic.CreateGCPFirewallPermission}, installConfig.Config.GCP.ServiceEndpoints)
140+
if err != nil {
141+
return nil, fmt.Errorf("failed to verify firewall rules: %w", err)
142+
}
143+
if !createFwRules {
144+
firewallRulesManagementPolicy = capg.RulesManagementUnmanaged
145+
}
146+
138147
gcpCluster := &capg.GCPCluster{
139148
ObjectMeta: metav1.ObjectMeta{
140149
Name: clusterID.InfraID,
@@ -150,6 +159,9 @@ func GenerateClusterAssets(installConfig *installconfig.InstallConfig, clusterID
150159
Name: ptr.To(networkName),
151160
Subnets: subnets,
152161
AutoCreateSubnetworks: ptr.To(autoCreateSubnets),
162+
Firewall: capg.FirewallSpec{
163+
DefaultRulesManagement: firewallRulesManagementPolicy,
164+
},
153165
},
154166
AdditionalLabels: labels,
155167
FailureDomains: findFailureDomains(installConfig),

0 commit comments

Comments
 (0)