Skip to content

Commit aa3252d

Browse files
authored
Merge pull request #415 from shapeblue/fixup-linting-issues
Fix linting issues reported by golanci-lint
2 parents 7b87895 + a5a6e99 commit aa3252d

40 files changed

+1051
-1072
lines changed

api/v1beta1/cloudstackaffinitygroup_conversion.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ func (dst *CloudStackAffinityGroup) ConvertFrom(srcRaw conversion.Hub) error { /
4747
}
4848

4949
// Preserve Hub data on down-conversion
50-
if err := utilconversion.MarshalData(src, dst); err != nil {
51-
return err
52-
}
53-
return nil
50+
err := utilconversion.MarshalData(src, dst)
51+
return err
5452
}
5553

5654
func Convert_v1beta3_CloudStackAffinityGroupSpec_To_v1beta1_CloudStackAffinityGroupSpec(in *v1beta3.CloudStackAffinityGroupSpec, out *CloudStackAffinityGroupSpec, s machineryconversion.Scope) error { // nolint

api/v1beta1/cloudstackisolatednetwork_conversion.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,8 @@ func (dst *CloudStackIsolatedNetwork) ConvertFrom(srcRaw conversion.Hub) error {
4747
}
4848

4949
// Preserve Hub data on down-conversion
50-
if err := utilconversion.MarshalData(src, dst); err != nil {
51-
return err
52-
}
53-
return nil
50+
err := utilconversion.MarshalData(src, dst)
51+
return err
5452
}
5553

5654
func Convert_v1beta3_CloudStackIsolatedNetworkSpec_To_v1beta1_CloudStackIsolatedNetworkSpec(in *v1beta3.CloudStackIsolatedNetworkSpec, out *CloudStackIsolatedNetworkSpec, s machineryconversion.Scope) error { // nolint

api/v1beta1/cloudstackmachine_conversion.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ func (dst *CloudStackMachine) ConvertFrom(srcRaw conversion.Hub) error { // noli
5656
}
5757

5858
// Preserve Hub data on down-conversion
59-
if err := utilconversion.MarshalData(src, dst); err != nil {
60-
return err
61-
}
62-
return nil
59+
err := utilconversion.MarshalData(src, dst)
60+
return err
6361
}
6462

6563
func Convert_v1beta3_CloudStackMachineSpec_To_v1beta1_CloudStackMachineSpec(in *v1beta3.CloudStackMachineSpec, out *CloudStackMachineSpec, s machineryconversion.Scope) error { // nolint

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/cloudstackmachinetemplate_conversion.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ func (dst *CloudStackMachineTemplate) ConvertFrom(srcRaw conversion.Hub) error {
5353
}
5454

5555
// Preserve Hub data on down-conversion
56-
if err := utilconversion.MarshalData(src, dst); err != nil {
57-
return err
58-
}
59-
return nil
56+
err := utilconversion.MarshalData(src, dst)
57+
return err
6058
}
6159

6260
func Convert_v1beta1_CloudStackMachineTemplateSpec_To_v1beta3_CloudStackMachineTemplateSpec(in *CloudStackMachineTemplateSpec, out *v1beta3.CloudStackMachineTemplateSpec, s machineryconversion.Scope) error { // nolint

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
})

0 commit comments

Comments
 (0)