Skip to content

Commit 7af4db6

Browse files
committed
Fix linting issues
1 parent 7b87895 commit 7af4db6

39 files changed

+1073
-1081
lines changed

api/v1beta1/cloudstackmachine_types_test.go

+11-10
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,31 @@ limitations under the License.
1717
package v1beta1_test
1818

1919
import (
20-
. "github.com/onsi/ginkgo/v2"
21-
. "github.com/onsi/gomega"
20+
"time"
21+
22+
"github.com/onsi/ginkgo/v2"
23+
"github.com/onsi/gomega"
2224
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2325
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta1"
24-
"time"
2526
)
2627

27-
var _ = Describe("CloudStackMachine types", func() {
28+
var _ = ginkgo.Describe("CloudStackMachine types", func() {
2829
var cloudStackMachine infrav1.CloudStackMachine
2930

30-
BeforeEach(func() { // Reset test vars to initial state.
31+
ginkgo.BeforeEach(func() { // Reset test vars to initial state.
3132
cloudStackMachine = infrav1.CloudStackMachine{}
3233
})
3334

34-
Context("When calculating time since state change", func() {
35-
It("Return the correct value when the last state update time is known", func() {
35+
ginkgo.Context("When calculating time since state change", func() {
36+
ginkgo.It("Return the correct value when the last state update time is known", func() {
3637
delta := time.Duration(10 * time.Minute)
3738
lastUpdated := time.Now().Add(-delta)
3839
cloudStackMachine.Status.InstanceStateLastUpdated = metav1.NewTime(lastUpdated)
39-
Ω(cloudStackMachine.Status.TimeSinceLastStateChange()).Should(BeNumerically("~", delta, time.Second))
40+
gomega.Expect(cloudStackMachine.Status.TimeSinceLastStateChange()).Should(gomega.BeNumerically("~", delta, time.Second))
4041
})
4142

42-
It("Return a negative value when the last state update time is unknown", func() {
43-
Ω(cloudStackMachine.Status.TimeSinceLastStateChange()).Should(BeNumerically("<", 0))
43+
ginkgo.It("Return a negative value when the last state update time is unknown", func() {
44+
gomega.Expect(cloudStackMachine.Status.TimeSinceLastStateChange()).Should(gomega.BeNumerically("<", 0))
4445
})
4546
})
4647
})

api/v1beta1/conversion.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func GetFailureDomains(csCluster *CloudStackCluster) ([]v1beta3.CloudStackFailur
123123
// When upgrading cluster using eks-a, a secret named global will be created by eks-a, and it is used by following
124124
// method to get zoneID by calling cloudstack API.
125125
// When upgrading cluster using clusterctl directly, zoneID is fetched directly from kubernetes cluster in cloudstackzones.
126-
func GetDefaultFailureDomainName(namespace string, clusterName string, zoneID string, zoneName string) (string, error) {
126+
func GetDefaultFailureDomainName(namespace string, _ string, zoneID string, zoneName string) (string, error) {
127127
if len(zoneID) > 0 {
128128
return zoneID, nil
129129
}

api/v1beta1/conversion_test.go

+14-14
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ limitations under the License.
1717
package v1beta1_test
1818

1919
import (
20-
. "github.com/onsi/ginkgo/v2"
21-
. "github.com/onsi/gomega"
20+
"github.com/onsi/ginkgo/v2"
21+
"github.com/onsi/gomega"
2222
corev1 "k8s.io/api/core/v1"
2323
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2424
v1beta1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta1"
2525
"sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
2626
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2727
)
2828

29-
var _ = Describe("Conversion", func() {
30-
BeforeEach(func() { // Reset test vars to initial state.
29+
var _ = ginkgo.Describe("Conversion", func() {
30+
ginkgo.BeforeEach(func() { // Reset test vars to initial state.
3131
})
3232

33-
Context("GetFailureDomains function", func() {
34-
It("Converts v1beta1 cluster spec to v1beta3 failure domains", func() {
33+
ginkgo.Context("GetFailureDomains function", func() {
34+
ginkgo.It("Converts v1beta1 cluster spec to v1beta3 failure domains", func() {
3535
csCluster := &v1beta1.CloudStackCluster{
3636
ObjectMeta: metav1.ObjectMeta{
3737
Name: "cluster1",
@@ -71,13 +71,13 @@ var _ = Describe("Conversion", func() {
7171
},
7272
},
7373
}
74-
Ω(err).ShouldNot(HaveOccurred())
75-
Ω(failureDomains).Should(Equal(expectedResult))
74+
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
75+
gomega.Expect(failureDomains).Should(gomega.Equal(expectedResult))
7676
})
7777
})
7878

79-
Context("v1beta3 to v1beta1 function", func() {
80-
It("Converts v1beta3 cluster spec to v1beta1 zone based cluster spec", func() {
79+
ginkgo.Context("v1beta3 to v1beta1 function", func() {
80+
ginkgo.It("Converts v1beta3 cluster spec to v1beta1 zone based cluster spec", func() {
8181
csCluster := &v1beta3.CloudStackCluster{
8282
ObjectMeta: metav1.ObjectMeta{
8383
Name: "cluster1",
@@ -132,11 +132,11 @@ var _ = Describe("Conversion", func() {
132132
Status: v1beta1.CloudStackClusterStatus{},
133133
}
134134

135-
Ω(err).ShouldNot(HaveOccurred())
136-
Ω(converted).Should(Equal(expectedResult))
135+
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
136+
gomega.Expect(converted).Should(gomega.Equal(expectedResult))
137137
})
138138

139-
It("Returns error when len(failureDomains) < 1", func() {
139+
ginkgo.It("Returns error when len(failureDomains) < 1", func() {
140140
csCluster := &v1beta3.CloudStackCluster{
141141
ObjectMeta: metav1.ObjectMeta{
142142
Name: "cluster1",
@@ -151,7 +151,7 @@ var _ = Describe("Conversion", func() {
151151
Status: v1beta3.CloudStackClusterStatus{},
152152
}
153153
err := v1beta1.Convert_v1beta3_CloudStackCluster_To_v1beta1_CloudStackCluster(csCluster, nil, nil)
154-
Ω(err).Should(HaveOccurred())
154+
gomega.Expect(err).Should(gomega.HaveOccurred())
155155
})
156156
})
157157
})

api/v1beta2/cloudstackmachine_types_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import (
2020
"k8s.io/utils/pointer"
2121
capcv1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta2"
2222

23-
. "github.com/onsi/ginkgo/v2"
24-
. "github.com/onsi/gomega"
23+
"github.com/onsi/ginkgo/v2"
24+
"github.com/onsi/gomega"
2525
)
2626

27-
var _ = Describe("CloudStackMachineConfig_CompressUserdata", func() {
27+
var _ = ginkgo.Describe("CloudStackMachineConfig_CompressUserdata", func() {
2828
for _, tc := range []struct {
2929
Name string
3030
Machine capcv1.CloudStackMachine
@@ -59,9 +59,9 @@ var _ = Describe("CloudStackMachineConfig_CompressUserdata", func() {
5959
},
6060
} {
6161
tc := tc
62-
It(tc.Name, func() {
62+
ginkgo.It(tc.Name, func() {
6363
result := tc.Machine.CompressUserdata()
64-
Expect(result).To(Equal(tc.Expect))
64+
gomega.Expect(result).To(gomega.Equal(tc.Expect))
6565
})
6666
}
6767
})

api/v1beta3/cloudstackcluster_webhook_test.go

+25-25
Original file line numberDiff line numberDiff line change
@@ -19,66 +19,66 @@ package v1beta3_test
1919
import (
2020
"context"
2121

22-
. "github.com/onsi/ginkgo/v2"
23-
. "github.com/onsi/gomega"
22+
"github.com/onsi/ginkgo/v2"
23+
"github.com/onsi/gomega"
2424
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
2525
dummies "sigs.k8s.io/cluster-api-provider-cloudstack/test/dummies/v1beta3"
2626
)
2727

28-
var _ = Describe("CloudStackCluster webhooks", func() {
28+
var _ = ginkgo.Describe("CloudStackCluster webhooks", func() {
2929
var ctx context.Context
3030
forbiddenRegex := "admission webhook.*denied the request.*Forbidden\\: %s"
3131
requiredRegex := "admission webhook.*denied the request.*Required value\\: %s"
3232

33-
BeforeEach(func() { // Reset test vars to initial state.
33+
ginkgo.BeforeEach(func() { // Reset test vars to initial state.
3434
ctx = context.Background()
3535
dummies.SetDummyVars() // Reset cluster var.
3636
_ = k8sClient.Delete(ctx, dummies.CSCluster) // Delete any remnants.
3737
dummies.SetDummyVars() // Reset again since the k8s client can set this on delete.
3838
})
3939

40-
Context("When creating a CloudStackCluster", func() {
41-
It("Should accept a CloudStackCluster with all attributes present", func() {
42-
Ω(k8sClient.Create(ctx, dummies.CSCluster)).Should(Succeed())
40+
ginkgo.Context("When creating a CloudStackCluster", func() {
41+
ginkgo.It("Should accept a CloudStackCluster with all attributes present", func() {
42+
gomega.Expect(k8sClient.Create(ctx, dummies.CSCluster)).Should(gomega.Succeed())
4343
})
4444

45-
It("Should reject a CloudStackCluster with missing Zones.Network attribute", func() {
45+
ginkgo.It("Should reject a CloudStackCluster with missing Zones.Network attribute", func() {
4646
dummies.CSCluster.Spec.FailureDomains = []infrav1.CloudStackFailureDomainSpec{{}}
4747
dummies.CSCluster.Spec.FailureDomains[0].Zone.Name = "ZoneWNoNetwork"
48-
Ω(k8sClient.Create(ctx, dummies.CSCluster)).Should(
49-
MatchError(MatchRegexp(requiredRegex, "each Zone requires a Network specification")))
48+
gomega.Expect(k8sClient.Create(ctx, dummies.CSCluster)).Should(
49+
gomega.MatchError(gomega.MatchRegexp(requiredRegex, "each Zone requires a Network specification")))
5050
})
5151

52-
It("Should reject a CloudStackCluster with missing Zone attribute", func() {
52+
ginkgo.It("Should reject a CloudStackCluster with missing Zone attribute", func() {
5353
dummies.CSCluster.Spec.FailureDomains[0].Zone = infrav1.CloudStackZoneSpec{}
54-
Ω(k8sClient.Create(ctx, dummies.CSCluster)).Should(MatchError(MatchRegexp(requiredRegex,
54+
gomega.Expect(k8sClient.Create(ctx, dummies.CSCluster)).Should(gomega.MatchError(gomega.MatchRegexp(requiredRegex,
5555
"each Zone requires a Network specification")))
5656
})
5757
})
5858

59-
Context("When updating a CloudStackCluster", func() {
60-
BeforeEach(func() {
61-
Ω(k8sClient.Create(ctx, dummies.CSCluster)).Should(Succeed())
59+
ginkgo.Context("When updating a CloudStackCluster", func() {
60+
ginkgo.BeforeEach(func() {
61+
gomega.Expect(k8sClient.Create(ctx, dummies.CSCluster)).Should(gomega.Succeed())
6262
})
6363

64-
It("Should reject updates to CloudStackCluster FailureDomains", func() {
64+
ginkgo.It("Should reject updates to CloudStackCluster FailureDomains", func() {
6565
dummies.CSCluster.Spec.FailureDomains[0].Zone.Name = "SomeRandomUpdate"
66-
Ω(k8sClient.Update(ctx, dummies.CSCluster)).Should(MatchError(MatchRegexp(forbiddenRegex, "Cannot change FailureDomain")))
66+
gomega.Expect(k8sClient.Update(ctx, dummies.CSCluster)).Should(gomega.MatchError(gomega.MatchRegexp(forbiddenRegex, "Cannot change FailureDomain")))
6767
})
68-
It("Should reject updates to Networks specified in CloudStackCluster Zones", func() {
68+
ginkgo.It("Should reject updates to Networks specified in CloudStackCluster Zones", func() {
6969
dummies.CSCluster.Spec.FailureDomains[0].Zone.Network.Name = "ArbitraryUpdateNetworkName"
70-
Ω(k8sClient.Update(ctx, dummies.CSCluster)).Should(MatchError(MatchRegexp(forbiddenRegex, "Cannot change FailureDomain")))
70+
gomega.Expect(k8sClient.Update(ctx, dummies.CSCluster)).Should(gomega.MatchError(gomega.MatchRegexp(forbiddenRegex, "Cannot change FailureDomain")))
7171
})
72-
It("Should reject updates to CloudStackCluster controlplaneendpoint.host", func() {
72+
ginkgo.It("Should reject updates to CloudStackCluster controlplaneendpoint.host", func() {
7373
dummies.CSCluster.Spec.ControlPlaneEndpoint.Host = "1.1.1.1"
74-
Ω(k8sClient.Update(ctx, dummies.CSCluster)).
75-
Should(MatchError(MatchRegexp(forbiddenRegex, "controlplaneendpoint\\.host")))
74+
gomega.Expect(k8sClient.Update(ctx, dummies.CSCluster)).
75+
Should(gomega.MatchError(gomega.MatchRegexp(forbiddenRegex, "controlplaneendpoint\\.host")))
7676
})
7777

78-
It("Should reject updates to CloudStackCluster controlplaneendpoint.port", func() {
78+
ginkgo.It("Should reject updates to CloudStackCluster controlplaneendpoint.port", func() {
7979
dummies.CSCluster.Spec.ControlPlaneEndpoint.Port = int32(1234)
80-
Ω(k8sClient.Update(ctx, dummies.CSCluster)).
81-
Should(MatchError(MatchRegexp(forbiddenRegex, "controlplaneendpoint\\.port")))
80+
gomega.Expect(k8sClient.Update(ctx, dummies.CSCluster)).
81+
Should(gomega.MatchError(gomega.MatchRegexp(forbiddenRegex, "controlplaneendpoint\\.port")))
8282
})
8383
})
8484
})

api/v1beta3/cloudstackmachine_webhook_test.go

+37-37
Original file line numberDiff line numberDiff line change
@@ -22,89 +22,89 @@ import (
2222
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
2323
dummies "sigs.k8s.io/cluster-api-provider-cloudstack/test/dummies/v1beta3"
2424

25-
. "github.com/onsi/ginkgo/v2"
26-
. "github.com/onsi/gomega"
25+
"github.com/onsi/ginkgo/v2"
26+
gomega "github.com/onsi/gomega"
2727
)
2828

29-
var _ = Describe("CloudStackMachine webhook", func() {
29+
var _ = ginkgo.Describe("CloudStackMachine webhook", func() {
3030
var ctx context.Context
3131
forbiddenRegex := "admission webhook.*denied the request.*Forbidden\\: %s"
3232
requiredRegex := "admission webhook.*denied the request.*Required value\\: %s"
3333

34-
BeforeEach(func() { // Reset test vars to initial state.
34+
ginkgo.BeforeEach(func() { // Reset test vars to initial state.
3535
dummies.SetDummyVars()
3636
ctx = context.Background()
3737
_ = k8sClient.Delete(ctx, dummies.CSMachine1) // Clear out any remaining machines. Ignore errors.
3838
})
3939

40-
Context("When creating a CloudStackMachine", func() {
41-
It("should accept CloudStackMachine with all attributes", func() {
42-
Expect(k8sClient.Create(ctx, dummies.CSMachine1)).Should(Succeed())
40+
ginkgo.Context("When creating a CloudStackMachine", func() {
41+
ginkgo.It("should accept CloudStackMachine with all attributes", func() {
42+
gomega.Expect(k8sClient.Create(ctx, dummies.CSMachine1)).Should(gomega.Succeed())
4343
})
4444

45-
It("should accept a CloudStackMachine with disk Offering attribute", func() {
45+
ginkgo.It("should accept a CloudStackMachine with disk Offering attribute", func() {
4646
dummies.CSMachine1.Spec.DiskOffering = dummies.DiskOffering
47-
Expect(k8sClient.Create(ctx, dummies.CSMachine1)).Should(Succeed())
47+
gomega.Expect(k8sClient.Create(ctx, dummies.CSMachine1)).Should(gomega.Succeed())
4848
})
4949

50-
It("should accept a CloudStackMachine with positive disk Offering size attribute", func() {
50+
ginkgo.It("should accept a CloudStackMachine with positive disk Offering size attribute", func() {
5151
dummies.CSMachine1.Spec.DiskOffering = dummies.DiskOffering
5252
dummies.CSMachine1.Spec.DiskOffering.CustomSize = 1
53-
Expect(k8sClient.Create(ctx, dummies.CSMachine1)).Should(Succeed())
53+
gomega.Expect(k8sClient.Create(ctx, dummies.CSMachine1)).Should(gomega.Succeed())
5454
})
5555

56-
It("should not accept a CloudStackMachine with negative disk Offering size attribute", func() {
56+
ginkgo.It("should not accept a CloudStackMachine with negative disk Offering size attribute", func() {
5757
dummies.CSMachine1.Spec.DiskOffering = dummies.DiskOffering
5858
dummies.CSMachine1.Spec.DiskOffering.CustomSize = -1
59-
Expect(k8sClient.Create(ctx, dummies.CSMachine1)).Should(MatchError(MatchRegexp(forbiddenRegex, "customSizeInGB")))
59+
gomega.Expect(k8sClient.Create(ctx, dummies.CSMachine1)).Should(gomega.MatchError(gomega.MatchRegexp(forbiddenRegex, "customSizeInGB")))
6060
})
6161

62-
It("should reject a CloudStackMachine with missing Offering attribute", func() {
62+
ginkgo.It("should reject a CloudStackMachine with missing Offering attribute", func() {
6363
dummies.CSMachine1.Spec.Offering = infrav1.CloudStackResourceIdentifier{ID: "", Name: ""}
64-
Expect(k8sClient.Create(ctx, dummies.CSMachine1)).
65-
Should(MatchError(MatchRegexp(requiredRegex, "Offering")))
64+
gomega.Expect(k8sClient.Create(ctx, dummies.CSMachine1)).
65+
Should(gomega.MatchError(gomega.MatchRegexp(requiredRegex, "Offering")))
6666
})
6767

68-
It("should reject a CloudStackMachine with missing Template attribute", func() {
68+
ginkgo.It("should reject a CloudStackMachine with missing Template attribute", func() {
6969
dummies.CSMachine1.Spec.Template = infrav1.CloudStackResourceIdentifier{ID: "", Name: ""}
70-
Expect(k8sClient.Create(ctx, dummies.CSMachine1)).
71-
Should(MatchError(MatchRegexp(requiredRegex, "Template")))
70+
gomega.Expect(k8sClient.Create(ctx, dummies.CSMachine1)).
71+
Should(gomega.MatchError(gomega.MatchRegexp(requiredRegex, "Template")))
7272
})
7373
})
7474

75-
Context("When updating a CloudStackMachine", func() {
76-
BeforeEach(func() {
77-
Ω(k8sClient.Create(ctx, dummies.CSMachine1)).Should(Succeed())
75+
ginkgo.Context("When updating a CloudStackMachine", func() {
76+
ginkgo.BeforeEach(func() {
77+
gomega.Ω(k8sClient.Create(ctx, dummies.CSMachine1)).Should(gomega.Succeed())
7878
})
7979

80-
It("should reject VM offering updates to the CloudStackMachine", func() {
80+
ginkgo.It("should reject VM offering updates to the CloudStackMachine", func() {
8181
dummies.CSMachine1.Spec.Offering = infrav1.CloudStackResourceIdentifier{Name: "ArbitraryUpdateOffering"}
82-
Ω(k8sClient.Update(ctx, dummies.CSMachine1)).
83-
Should(MatchError(MatchRegexp(forbiddenRegex, "offering")))
82+
gomega.Ω(k8sClient.Update(ctx, dummies.CSMachine1)).
83+
Should(gomega.MatchError(gomega.MatchRegexp(forbiddenRegex, "offering")))
8484
})
8585

86-
It("should reject VM template updates to the CloudStackMachine", func() {
86+
ginkgo.It("should reject VM template updates to the CloudStackMachine", func() {
8787
dummies.CSMachine1.Spec.Template = infrav1.CloudStackResourceIdentifier{Name: "ArbitraryUpdateTemplate"}
88-
Ω(k8sClient.Update(ctx, dummies.CSMachine1)).
89-
Should(MatchError(MatchRegexp(forbiddenRegex, "template")))
88+
gomega.Ω(k8sClient.Update(ctx, dummies.CSMachine1)).
89+
Should(gomega.MatchError(gomega.MatchRegexp(forbiddenRegex, "template")))
9090
})
9191

92-
It("should reject VM disk offering updates to the CloudStackMachine", func() {
92+
ginkgo.It("should reject VM disk offering updates to the CloudStackMachine", func() {
9393
dummies.CSMachine1.Spec.DiskOffering.Name = "medium"
94-
Ω(k8sClient.Update(ctx, dummies.CSMachine1)).
95-
Should(MatchError(MatchRegexp(forbiddenRegex, "diskOffering")))
94+
gomega.Ω(k8sClient.Update(ctx, dummies.CSMachine1)).
95+
Should(gomega.MatchError(gomega.MatchRegexp(forbiddenRegex, "diskOffering")))
9696
})
9797

98-
It("should reject updates to VM details of the CloudStackMachine", func() {
98+
ginkgo.It("should reject updates to VM details of the CloudStackMachine", func() {
9999
dummies.CSMachine1.Spec.Details = map[string]string{"memoryOvercommitRatio": "1.5"}
100-
Ω(k8sClient.Update(ctx, dummies.CSMachine1)).
101-
Should(MatchError(MatchRegexp(forbiddenRegex, "details")))
100+
gomega.Ω(k8sClient.Update(ctx, dummies.CSMachine1)).
101+
Should(gomega.MatchError(gomega.MatchRegexp(forbiddenRegex, "details")))
102102
})
103103

104-
It("should reject updates to the list of affinty groups of the CloudStackMachine", func() {
104+
ginkgo.It("should reject updates to the list of affinty groups of the CloudStackMachine", func() {
105105
dummies.CSMachine1.Spec.AffinityGroupIDs = []string{"28b907b8-75a7-4214-bd3d-6c61961fc2af"}
106-
Ω(k8sClient.Update(ctx, dummies.CSMachine1)).
107-
Should(MatchError(MatchRegexp(forbiddenRegex, "AffinityGroupIDs")))
106+
gomega.Ω(k8sClient.Update(ctx, dummies.CSMachine1)).
107+
Should(gomega.MatchError(gomega.MatchRegexp(forbiddenRegex, "AffinityGroupIDs")))
108108
})
109109
})
110110
})

0 commit comments

Comments
 (0)