@@ -22,7 +22,6 @@ import (
22
22
23
23
"github.com/apache/cloudstack-go/v2/cloudstack"
24
24
capcv1 "github.com/aws/cluster-api-provider-cloudstack/api/v1beta1"
25
- infrav1 "github.com/aws/cluster-api-provider-cloudstack/api/v1beta1"
26
25
"github.com/hashicorp/go-multierror"
27
26
"github.com/pkg/errors"
28
27
)
@@ -38,7 +37,7 @@ type IsoNetworkIface interface {
38
37
39
38
AssignVMToLoadBalancerRule (isoNet * capcv1.CloudStackIsolatedNetwork , instanceID string ) error
40
39
DeleteNetwork (capcv1.Network ) error
41
- DisposeIsoNetResources (* capcv1.CloudStackZone , * infrav1 .CloudStackIsolatedNetwork , * infrav1 .CloudStackCluster ) error
40
+ DisposeIsoNetResources (* capcv1.CloudStackZone , * capcv1 .CloudStackIsolatedNetwork , * capcv1 .CloudStackCluster ) error
42
41
}
43
42
44
43
// getOfferingID fetches an offering id.
@@ -61,7 +60,7 @@ func (c *client) AssociatePublicIPAddress(
61
60
// Check specified IP address is available or get an unused one if not specified.
62
61
publicAddress , err := c .GetPublicIP (zone , isoNet , csCluster )
63
62
if err != nil {
64
- return errors .Wrapf (err , "fetching a public IP address: " )
63
+ return errors .Wrapf (err , "fetching a public IP address" )
65
64
}
66
65
isoNet .Spec .ControlPlaneEndpoint .Host = publicAddress .Ipaddress
67
66
csCluster .Spec .ControlPlaneEndpoint .Host = publicAddress .Ipaddress
@@ -78,14 +77,14 @@ func (c *client) AssociatePublicIPAddress(
78
77
p .SetNetworkid (isoNet .Spec .ID )
79
78
if _ , err := c .cs .Address .AssociateIpAddress (p ); err != nil {
80
79
return errors .Wrapf (err ,
81
- "associating public IP address with ID %s to netowrk with ID %s: " ,
80
+ "associating public IP address with ID %s to network with ID %s" ,
82
81
publicAddress .Id , isoNet .Spec .ID )
83
82
} else if err := c .AddClusterTag (ResourceTypeIPAddress , publicAddress .Id , csCluster ); err != nil {
84
83
return errors .Wrapf (err ,
85
- "adding tag to public IP address with ID %s: " , publicAddress .Id )
84
+ "adding tag to public IP address with ID %s" , publicAddress .Id )
86
85
} else if err := c .AddCreatedByCAPCTag (ResourceTypeIPAddress , isoNet .Status .PublicIPID ); err != nil {
87
86
return errors .Wrapf (err ,
88
- "adding tag to public IP address with ID %s: " , publicAddress .Id )
87
+ "adding tag to public IP address with ID %s" , publicAddress .Id )
89
88
}
90
89
return nil
91
90
}
@@ -102,7 +101,7 @@ func (c *client) CreateIsolatedNetwork(zone *capcv1.CloudStackZone, isoNet *capc
102
101
p := c .cs .Network .NewCreateNetworkParams (isoNet .Spec .Name , isoNet .Spec .Name , offeringID , zone .Spec .ID )
103
102
resp , err := c .cs .Network .CreateNetwork (p )
104
103
if err != nil {
105
- return errors .Wrapf (err , "creating network with name %s: " , isoNet .Spec .Name )
104
+ return errors .Wrapf (err , "creating network with name %s" , isoNet .Spec .Name )
106
105
}
107
106
isoNet .Spec .ID = resp .Id
108
107
return c .AddCreatedByCAPCTag (ResourceTypeNetwork , isoNet .Spec .ID )
@@ -186,7 +185,7 @@ func (c *client) ResolveLoadBalancerRuleDetails(
186
185
p .SetPublicipid (isoNet .Status .PublicIPID )
187
186
loadBalancerRules , err := c .cs .LoadBalancer .ListLoadBalancerRules (p )
188
187
if err != nil {
189
- return errors .Wrap (err , "listing load balancer rules: " )
188
+ return errors .Wrap (err , "listing load balancer rules" )
190
189
}
191
190
for _ , rule := range loadBalancerRules .LoadBalancerRules {
192
191
if rule .Publicport == strconv .Itoa (int (isoNet .Spec .ControlPlaneEndpoint .Port )) {
@@ -218,7 +217,7 @@ func (c *client) GetOrCreateLoadBalancerRule(
218
217
// Check if rule exists.
219
218
if err := c .ResolveLoadBalancerRuleDetails (zone , isoNet , csCluster ); err == nil ||
220
219
! strings .Contains (strings .ToLower (err .Error ()), "no load balancer rule found" ) {
221
- return errors .Wrap (err , "resolving load balancer rule details: " )
220
+ return errors .Wrap (err , "resolving load balancer rule details" )
222
221
}
223
222
224
223
p := c .cs .LoadBalancer .NewCreateLoadBalancerRuleParams (
@@ -240,35 +239,35 @@ func (c *client) GetOrCreateLoadBalancerRule(
240
239
func (c * client ) GetOrCreateIsolatedNetwork (
241
240
zone * capcv1.CloudStackZone ,
242
241
isoNet * capcv1.CloudStackIsolatedNetwork ,
243
- csCluster * infrav1 .CloudStackCluster ,
242
+ csCluster * capcv1 .CloudStackCluster ,
244
243
) error {
245
244
// Get or create the isolated network itself and resolve details into passed custom resources.
246
245
net := isoNet .Network ()
247
246
if err := c .ResolveNetwork (net ); err != nil { // Doesn't exist, create isolated network.
248
247
if err = c .CreateIsolatedNetwork (zone , isoNet ); err != nil {
249
- return errors .Wrap (err , "creating a new isolated network: " )
248
+ return errors .Wrap (err , "creating a new isolated network" )
250
249
}
251
250
}
252
251
isoNet .Spec .ID = net .ID
253
252
254
253
// Tag the created network.
255
254
networkID := isoNet .Spec .ID
256
255
if err := c .AddClusterTag (ResourceTypeNetwork , networkID , csCluster ); err != nil {
257
- return errors .Wrapf (err , "tagging network with id %s: " , networkID )
256
+ return errors .Wrapf (err , "tagging network with id %s" , networkID )
258
257
}
259
258
260
259
// Associate Public IP with CloudStackIsolatedNetwork
261
260
if err := c .AssociatePublicIPAddress (zone , isoNet , csCluster ); err != nil {
262
- return errors .Wrapf (err , "associating public IP address to csCluster: " )
261
+ return errors .Wrapf (err , "associating public IP address to csCluster" )
263
262
}
264
263
265
264
// Setup a load balancing rule to map VMs to Public IP.
266
265
if err := c .GetOrCreateLoadBalancerRule (zone , isoNet , csCluster ); err != nil {
267
- return errors .Wrap (err , "getting or creating load balancing rule: " )
266
+ return errors .Wrap (err , "getting or creating load balancing rule" )
268
267
}
269
268
270
269
// Open the Isolated Network on endopint port.
271
- return errors .Wrap (c .OpenFirewallRules (isoNet ), "opening the isolated network's firewall: " )
270
+ return errors .Wrap (c .OpenFirewallRules (isoNet ), "opening the isolated network's firewall" )
272
271
}
273
272
274
273
// AssignVMToLoadBalancerRule assigns a VM instance to a load balancing rule (specifying lb membership).
@@ -296,14 +295,14 @@ func (c *client) AssignVMToLoadBalancerRule(isoNet *capcv1.CloudStackIsolatedNet
296
295
// DeleteNetwork deletes an isolated network.
297
296
func (c * client ) DeleteNetwork (net capcv1.Network ) error {
298
297
_ , err := c .cs .Network .DeleteNetwork (c .cs .Network .NewDeleteNetworkParams (net .ID ))
299
- return errors .Wrapf (err , "deleting network with id %s: " , net .ID )
298
+ return errors .Wrapf (err , "deleting network with id %s" , net .ID )
300
299
}
301
300
302
301
// DisposeIsoNetResources cleans up isolated network resources.
303
302
func (c * client ) DisposeIsoNetResources (
304
- zone * infrav1 .CloudStackZone ,
305
- isoNet * infrav1 .CloudStackIsolatedNetwork ,
306
- csCluster * infrav1 .CloudStackCluster ,
303
+ zone * capcv1 .CloudStackZone ,
304
+ isoNet * capcv1 .CloudStackIsolatedNetwork ,
305
+ csCluster * capcv1 .CloudStackCluster ,
307
306
) (retError error ) {
308
307
if isoNet .Status .PublicIPID != "" {
309
308
if err := c .DeleteClusterTag (ResourceTypeIPAddress , csCluster .Status .PublicIPID , csCluster ); err != nil {
0 commit comments