Skip to content

Commit bc5a91b

Browse files
authored
enable staticcheck and disable all occurances (#58)
1 parent 1085534 commit bc5a91b

File tree

14 files changed

+38
-8
lines changed

14 files changed

+38
-8
lines changed

.golangci.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ linters:
8080
- legacy
8181
- std-error-handling
8282
rules:
83-
- linters:
84-
- staticcheck
85-
text: 'SA1019:' # Excludes messages where deprecated variables are used
8683
- linters:
8784
- gosec
8885
path: _test\.go

pkg/apis/stackit/validation/cloudprofile.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func ValidateCloudProfileConfig(cloudProfile *stackitv1alpha1.CloudProfileConfig
2727

2828
floatingPoolPath := fldPath.Child("constraints", "floatingPools")
2929
combinationFound := sets.NewString()
30+
//nolint:staticcheck // SA1019: needed for migration purposes
3031
for i, pool := range cloudProfile.Constraints.FloatingPools {
3132
idxPath := floatingPoolPath.Index(i)
3233
if len(pool.Name) == 0 {
@@ -66,6 +67,7 @@ func ValidateCloudProfileConfig(cloudProfile *stackitv1alpha1.CloudProfileConfig
6667
allErrs = append(allErrs, ValidateProviderMachineImage(idxPath, machineImage)...)
6768
}
6869
allErrs = append(allErrs, validateMachineImageMapping(machineImages, cloudProfile, field.NewPath("spec").Child("machineImages"))...)
70+
//nolint:staticcheck // SA1019: needed for migration purposes
6971
if ca := cloudProfile.KeyStoneCACert; ca != nil && len(*ca) > 0 {
7072
_, err := utils.DecodeCertificate([]byte(*ca))
7173
if err != nil {
@@ -74,6 +76,7 @@ func ValidateCloudProfileConfig(cloudProfile *stackitv1alpha1.CloudProfileConfig
7476
}
7577

7678
regionsFound := sets.NewString()
79+
//nolint:staticcheck // SA1019: needed for migration purposes
7780
for i, val := range cloudProfile.KeyStoneURLs {
7881
idxPath := fldPath.Child("keyStoneURLs").Index(i)
7982

@@ -104,11 +107,13 @@ func ValidateCloudProfileConfig(cloudProfile *stackitv1alpha1.CloudProfileConfig
104107
}
105108
}
106109

110+
//nolint:staticcheck // SA1019: needed for migration purposes
107111
if cloudProfile.DHCPDomain != nil && len(*cloudProfile.DHCPDomain) == 0 {
108112
allErrs = append(allErrs, field.Required(fldPath.Child("dhcpDomain"), "must provide a dhcp domain when the key is specified"))
109113
}
110114

111115
serverGroupPath := fldPath.Child("serverGroupPolicies")
116+
//nolint:staticcheck // SA1019: needed for migration purposes
112117
for i, policy := range cloudProfile.ServerGroupPolicies {
113118
idxPath := serverGroupPath.Index(i)
114119

pkg/apis/stackit/validation/cloudprofile_test.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ var _ = Describe("CloudProfileConfig validation", func() {
7474

7575
Context("floating pools constraints", func() {
7676
It("should forbid unsupported pools", func() {
77+
//nolint:staticcheck // SA1019: needed for migration purposes
7778
cloudProfileConfig.Constraints.FloatingPools = []stackitv1alpha1.FloatingPool{
7879
{
7980
Name: "",
@@ -97,6 +98,7 @@ var _ = Describe("CloudProfileConfig validation", func() {
9798
})
9899

99100
It("should forbid duplicates regions and domains in pools", func() {
101+
//nolint:staticcheck // SA1019: needed for migration purposes
100102
cloudProfileConfig.Constraints.FloatingPools = []stackitv1alpha1.FloatingPool{
101103
{
102104
Name: "foo",
@@ -149,9 +151,10 @@ var _ = Describe("CloudProfileConfig validation", func() {
149151

150152
Context("keystone url validation", func() {
151153
It("should forbid keystone urls with missing keys", func() {
154+
//nolint:staticcheck // SA1019: needed for migration purposes
152155
cloudProfileConfig.KeyStoneURL = ""
156+
//nolint:staticcheck // SA1019: needed for migration purposes
153157
cloudProfileConfig.KeyStoneURLs = []stackitv1alpha1.KeyStoneURL{{}}
154-
155158
errorList := ValidateCloudProfileConfig(cloudProfileConfig, machineImages, fldPath)
156159

157160
Expect(errorList).To(ConsistOf(PointTo(MatchFields(IgnoreExtras, Fields{
@@ -164,7 +167,9 @@ var _ = Describe("CloudProfileConfig validation", func() {
164167
})
165168

166169
It("should forbid duplicate regions for keystone urls", func() {
170+
//nolint:staticcheck // SA1019: needed for migration purposes
167171
cloudProfileConfig.KeyStoneURL = ""
172+
//nolint:staticcheck // SA1019: needed for migration purposes
168173
cloudProfileConfig.KeyStoneURLs = []stackitv1alpha1.KeyStoneURL{
169174
{
170175
Region: "foo",
@@ -186,8 +191,8 @@ var _ = Describe("CloudProfileConfig validation", func() {
186191
})
187192

188193
It("should forbid invalid keystone CA Certs", func() {
194+
//nolint:staticcheck // SA1019: needed for migration purposes
189195
cloudProfileConfig.KeyStoneCACert = ptr.To("foo")
190-
191196
errorList := ValidateCloudProfileConfig(cloudProfileConfig, machineImages, fldPath)
192197
Expect(errorList).To(ConsistOf(PointTo(MatchFields(IgnoreExtras, Fields{
193198
"Type": Equal(field.ErrorTypeInvalid),
@@ -211,8 +216,8 @@ var _ = Describe("CloudProfileConfig validation", func() {
211216

212217
Context("dhcp domain validation", func() {
213218
It("should forbid not specifying a value when the key is present", func() {
219+
//nolint:staticcheck // SA1019: needed for migration purposes
214220
cloudProfileConfig.DHCPDomain = ptr.To("")
215-
216221
errorList := ValidateCloudProfileConfig(cloudProfileConfig, machineImages, fldPath)
217222

218223
Expect(errorList).To(ConsistOf(PointTo(MatchFields(IgnoreExtras, Fields{
@@ -393,6 +398,7 @@ var _ = Describe("CloudProfileConfig validation", func() {
393398

394399
Context("server group policy validation", func() {
395400
It("should forbid empty server group policy", func() {
401+
//nolint:staticcheck // SA1019: needed for migration purposes
396402
cloudProfileConfig.ServerGroupPolicies = []string{
397403
"affinity",
398404
"",

pkg/apis/stackit/validation/infrastructure.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,18 @@ func ValidateInfrastructureConfig(infra *stackitv1alpha1.InfrastructureConfig, n
3030
}
3131

3232
networksPath := fldPath.Child("networks")
33+
//nolint:staticcheck // SA1019: needed for migration purposes
3334
if len(infra.Networks.Worker) == 0 && len(infra.Networks.Workers) == 0 {
3435
allErrs = append(allErrs, field.Required(networksPath.Child("workers"), "must specify the network range for the worker network"))
3536
}
3637

3738
var workerCIDR cidrvalidation.CIDR
39+
//nolint:staticcheck // SA1019: needed for migration purposes
3840
if infra.Networks.Worker != "" {
41+
//nolint:staticcheck // SA1019: needed for migration purposes
3942
workerCIDR = cidrvalidation.NewCIDR(infra.Networks.Worker, networksPath.Child("worker"))
4043
allErrs = append(allErrs, cidrvalidation.ValidateCIDRParse(workerCIDR)...)
44+
//nolint:staticcheck // SA1019: needed for migration purposes
4145
allErrs = append(allErrs, cidrvalidation.ValidateCIDRIsCanonical(networksPath.Child("worker"), infra.Networks.Worker)...)
4246
}
4347
if infra.Networks.Workers != "" {
@@ -98,6 +102,7 @@ func ValidateInfrastructureConfigAgainstCloudProfile(oldInfra, infra *stackitv1a
98102
allErrs := field.ErrorList{}
99103

100104
if oldInfra == nil || oldInfra.FloatingPoolName != infra.FloatingPoolName {
105+
//nolint:staticcheck // SA1019: needed for migration purposes
101106
allErrs = append(allErrs, validateFloatingPoolNameConstraints(cloudProfileConfig.Constraints.FloatingPools, infra.FloatingPoolName, fldPath.Child("floatingPoolName")))
102107
}
103108

pkg/cmd/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ func (c *Config) ApplyETCDStorage(etcdStorage *config.ETCDStorage) {
6969

7070
// ApplyRegistryCaches sets the given Registry Cache configurations.
7171
func (c *Config) ApplyRegistryCaches(regCaches *[]config.RegistryCacheConfiguration) {
72+
//nolint:staticcheck // SA1019: needed for migration purposes
7273
if len(c.Config.RegistryCaches) == 0 {
7374
return
7475
}
76+
//nolint:staticcheck // SA1019: needed for migration purposes
7577
*regCaches = c.Config.RegistryCaches
7678
}
7779

pkg/controller/controlplane/valuesprovider.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,9 @@ func getConfigChartValues(
641641
values["applicationCredentialName"] = osCredentials.ApplicationCredentialName
642642
values["applicationCredentialSecret"] = osCredentials.ApplicationCredentialSecret
643643
values["region"] = cp.Spec.Region
644+
//nolint:staticcheck // SA1019: needed for migration purposes
644645
values["requestTimeout"] = cloudProfileConfig.RequestTimeout
646+
//nolint:staticcheck // SA1019: needed for migration purposes
645647
values["ignoreVolumeAZ"] = cloudProfileConfig.IgnoreVolumeAZ != nil && *cloudProfileConfig.IgnoreVolumeAZ
646648
// detect internal network.
647649
// See https://github.com/kubernetes/cloud-provider-openstack/blob/v1.22.1/docs/openstack-cloud-controller-manager/using-openstack-cloud-controller-manager.md#networking
@@ -1196,7 +1198,8 @@ func (vp *valuesProvider) getControlPlaneShootChartCSIValues(ctx context.Context
11961198
values := map[string]any{
11971199
"enabled": getCSIDriver(cpConfig) == stackitv1alpha1.OPENSTACK,
11981200
"rescanBlockStorageOnResize": cloudProfileConfig.RescanBlockStorageOnResize != nil && *cloudProfileConfig.RescanBlockStorageOnResize,
1199-
"nodeVolumeAttachLimit": cloudProfileConfig.NodeVolumeAttachLimit,
1201+
//nolint:staticcheck // SA1019: needed for migration purposes
1202+
"nodeVolumeAttachLimit": cloudProfileConfig.NodeVolumeAttachLimit,
12001203
}
12011204

12021205
if userAgentHeader != nil {

pkg/controller/infrastructure/openstack/infraflow/context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ func (fctx *FlowContext) computeInfrastructureStatus() *stackitv1alpha1.Infrastr
188188
status.Networks.Router.ExternalFixedIPs = fctx.state.GetObject(IdentifierEgressCIDRs).([]string)
189189
// backwards compatibility change for the deprecated field
190190
if len(status.Networks.Router.ExternalFixedIPs) > 0 {
191+
//nolint:staticcheck // SA1019: needed for migration purposes
191192
status.Networks.Router.IP = status.Networks.Router.ExternalFixedIPs[0]
192193
}
193194

pkg/controller/infrastructure/openstack/infraflow/reconcile.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ func (fctx *FlowContext) ensureNewRouter(ctx context.Context, externalNetworkID
162162
desired := &access.Router{
163163
Name: fctx.defaultRouterName(),
164164
ExternalNetworkID: externalNetworkID,
165-
EnableSNAT: fctx.cloudProfileConfig.UseSNAT,
165+
//nolint:staticcheck // SA1019: needed for migration purposes
166+
EnableSNAT: fctx.cloudProfileConfig.UseSNAT,
166167
}
167168
current, err := fctx.findExistingRouter(ctx)
168169
if err != nil {
@@ -209,6 +210,7 @@ func (fctx *FlowContext) findFloatingPoolSubnetName() *string {
209210
}
210211

211212
// Second: Check if the CloudProfile contains a default floating subnet and use it.
213+
//nolint:staticcheck // SA1019: needed for migration purposes
212214
if floatingPool, err := helper.FindFloatingPool(fctx.cloudProfileConfig.Constraints.FloatingPools, fctx.config.FloatingPoolName, fctx.infra.Spec.Region, nil); err == nil && floatingPool.DefaultFloatingSubnet != nil {
213215
return floatingPool.DefaultFloatingSubnet
214216
}

pkg/controller/infrastructure/openstack/infraflow/utils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func (fctx *FlowContext) defaultSecurityGroupName() string {
5959
}
6060

6161
func (fctx *FlowContext) workerCIDR() string {
62+
//nolint:staticcheck // SA1019: needed for migration purposes
6263
s := fctx.config.Networks.Worker
6364
if workers := fctx.config.Networks.Workers; workers != "" {
6465
s = workers

pkg/controller/infrastructure/stackit/infraflow/context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ func (fctx *FlowContext) computeInfrastructureStatus() *stackitv1alpha1.Infrastr
168168
status.Networks.Router.ExternalFixedIPs = fctx.state.GetObject(IdentifierEgressCIDRs).([]string)
169169
// backwards compatibility change for the deprecated field
170170
if len(status.Networks.Router.ExternalFixedIPs) > 0 {
171+
//nolint:staticcheck // SA1019: needed for migration purposes
171172
status.Networks.Router.IP = status.Networks.Router.ExternalFixedIPs[0]
172173
}
173174

0 commit comments

Comments
 (0)