Skip to content

Commit f82dbfe

Browse files
Upgrade golangci-lint to 1.64.8
- All above these version: github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.1 github.com/daixiang0/gci@v0.11.2 sigs.k8s.io/kustomize/kustomize/v5@v5.2.1 gosec => 2.22.2 kustomize => 5.6. - Upgrade golang to 1.23 ref: https://issues.redhat.com/browse/ACM-8341 Signed-off-by: yiraeChristineKim <yikim@redhat.com>
1 parent a2769fe commit f82dbfe

32 files changed

+169
-174
lines changed

Diff for: api/v1/policy_webhook.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (r *Policy) validateName() error {
100100

101101
// 1 character for "."
102102
if (utf8.RuneCountInString(r.Name) + utf8.RuneCountInString(r.Namespace)) > 62 {
103-
log.Info(fmt.Sprintf("Invalid policy name/namespace: %s", errName.Error()))
103+
log.Info("Invalid policy name/namespace: " + errName.Error())
104104

105105
return errName
106106
}
@@ -126,7 +126,7 @@ func (r *Policy) validateRemediationAction() error {
126126
if objUnstruct.GroupVersionKind().Kind == "ConfigurationPolicy" {
127127
_, found, _ := unstructured.NestedString(objUnstruct.Object, "spec", "remediationAction")
128128
if !found {
129-
log.Info(fmt.Sprintf("Invalid remediationAction configuration: %s", errRemediation.Error()))
129+
log.Info("Invalid remediationAction configuration: " + errRemediation.Error())
130130

131131
return errRemediation
132132
}

Diff for: api/v1beta1/policyautomation_types.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func init() {
134134
// ReplicatedComplianceHistory defines the replicated policy compliance details history.
135135
type ReplicatedComplianceHistory struct {
136136
LastTimestamp metav1.Time `json:"lastTimestamp,omitempty" protobuf:"bytes,7,opt,name=lastTimestamp"`
137-
Message string `json:"message,omitempty" protobuf:"bytes,4,opt,name=message"`
137+
Message string `json:"message,omitempty" protobuf:"bytes,4,opt,name=message"`
138138
}
139139

140140
// ReplicatedDetailsPerTemplate defines the replicated policy compliance details and history.
@@ -153,10 +153,10 @@ type ReplicatedPolicyStatus struct {
153153
// ViolationContext defines the noncompliant replicated policy information that is sent to the
154154
// AnsibleJob through the extra_vars parameter.
155155
type ViolationContext struct {
156-
TargetClusters []string `json:"targetClusters" ansibleJob:"target_clusters"`
157-
PolicyName string `json:"policyName" ansibleJob:"policy_name"`
158-
PolicyNamespace string `json:"policyNamespace" ansibleJob:"policy_namespace"`
159-
HubCluster string `json:"hubCluster" ansibleJob:"hub_cluster"`
160-
PolicySets []string `json:"policySets" ansibleJob:"policy_sets"`
161-
PolicyViolations map[string]ReplicatedPolicyStatus `json:"policyViolations" ansibleJob:"policy_violations"`
156+
TargetClusters []string `ansibleJob:"target_clusters" json:"targetClusters"`
157+
PolicyName string `ansibleJob:"policy_name" json:"policyName"`
158+
PolicyNamespace string `ansibleJob:"policy_namespace" json:"policyNamespace"`
159+
HubCluster string `ansibleJob:"hub_cluster" json:"hubCluster"`
160+
PolicySets []string `ansibleJob:"policy_sets" json:"policySets"`
161+
PolicyViolations map[string]ReplicatedPolicyStatus `ansibleJob:"policy_violations" json:"policyViolations"`
162162
}

Diff for: build/common/Makefile.common.mk

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
# https://github.com/kubernetes-sigs/controller-tools/releases/latest
66
CONTROLLER_GEN_VERSION := v0.16.3
77
# https://github.com/kubernetes-sigs/kustomize/releases/latest
8-
KUSTOMIZE_VERSION := v5.4.3
8+
KUSTOMIZE_VERSION := v5.6.0
99
# https://github.com/golangci/golangci-lint/releases/latest
10-
GOLANGCI_VERSION := v1.52.2
10+
GOLANGCI_VERSION := v1.64.8
1111
# https://github.com/mvdan/gofumpt/releases/latest
1212
GOFUMPT_VERSION := v0.7.0
1313
# https://github.com/daixiang0/gci/releases/latest
1414
GCI_VERSION := v0.13.5
1515
# https://github.com/securego/gosec/releases/latest
16-
GOSEC_VERSION := v2.21.3
16+
GOSEC_VERSION := v2.22.2
1717
# https://github.com/kubernetes-sigs/kubebuilder/releases/latest
1818
KBVERSION := 3.15.1
1919
# https://github.com/kubernetes/kubernetes/releases/latest

Diff for: build/common/config/.golangci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ run:
2424
linters:
2525
enable-all: true
2626
disable:
27+
- mnd # Disabled as tech debt: Magic number detection
2728
- bodyclose
2829
- contextcheck # New linter to consider
2930
- cyclop

Diff for: controllers/automation/PolicyAutomationPredicate.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var policyAuomtationPredicateFuncs = predicate.Funcs{
3434

3535
return policyAutomationNew.Spec.PolicyRef != ""
3636
},
37-
DeleteFunc: func(e event.DeleteEvent) bool {
37+
DeleteFunc: func(_ event.DeleteEvent) bool {
3838
return false
3939
},
4040
}

Diff for: controllers/automation/ansible.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,18 @@ func CreateAnsibleJob(policyAutomation *policyv1beta1.PolicyAutomation,
122122
typesOf := values.Type()
123123
// add every violationContext fields into mapExtraVars as well as the empty values,
124124
// or when the whole violationContext is empty
125-
for i := 0; i < values.NumField(); i++ {
125+
for i := range values.NumField() {
126126
tag := typesOf.Field(i).Tag
127127
value := values.Field(i).Interface()
128128

129129
var fieldName string
130-
if tag.Get("ansibleJob") != "" {
130+
131+
switch {
132+
case tag.Get("ansibleJob") != "":
131133
fieldName = tag.Get("ansibleJob")
132-
} else if tag.Get("json") != "" {
134+
case tag.Get("json") != "":
133135
fieldName = strings.SplitN(tag.Get("json"), ",", 2)[0]
134-
} else {
136+
default:
135137
fieldName = typesOf.Field(i).Name
136138
}
137139

Diff for: controllers/automation/policyPredicate.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ var policyPredicateFuncs = predicate.Funcs{
2424

2525
return !cmp.Equal(plcObjNew.Status.Status, plcObjOld.Status.Status)
2626
},
27-
CreateFunc: func(e event.CreateEvent) bool {
27+
CreateFunc: func(_ event.CreateEvent) bool {
2828
return false
2929
},
30-
DeleteFunc: func(e event.DeleteEvent) bool {
30+
DeleteFunc: func(_ event.DeleteEvent) bool {
3131
return false
3232
},
3333
}

0 commit comments

Comments
 (0)