Skip to content

Commit 67faecb

Browse files
committed
Fix: Bump golangci-lint from 1.57 to 1.64; adjusted code accordingly.
1 parent 4ac1f2b commit 67faecb

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

.github/workflows/sca.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ jobs:
4747
go-version-file: 'go.mod'
4848
- name: golangci-lint
4949
run: |
50-
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2
50+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.8
5151
make golangci-lint
5252
shell: bash

pkg/api/plugins/v1alpha1/actuator_client_stub.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func toGrpcStates(states []common.State) []*protobufs.State {
116116
func toGrpcProfile(v *common.Profile) *protobufs.Profile {
117117
return &protobufs.Profile{
118118
Key: v.Key,
119-
ProfileType: protobufs.ProfileType(v.ProfileType),
119+
ProfileType: protobufs.ProfileType(v.ProfileType), //nolint:gosec // explanation: only limited # of profile types exist.
120120
}
121121
}
122122

pkg/controller/intent_monitor.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ func NewIntentMonitor(intentClient clientSet.Interface, intentInformer informers
4242
// functions handler.
4343
_, _ = intentInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
4444
AddFunc: mon.enqueueItem,
45-
UpdateFunc: func(old, new interface{}) {
46-
if old.(*v1alpha1.Intent).ResourceVersion == new.(*v1alpha1.Intent).ResourceVersion {
45+
UpdateFunc: func(oldResource, newResource interface{}) {
46+
if oldResource.(*v1alpha1.Intent).ResourceVersion == newResource.(*v1alpha1.Intent).ResourceVersion {
4747
return
4848
}
49-
mon.enqueueItem(new)
49+
mon.enqueueItem(newResource)
5050
},
5151
DeleteFunc: func(obj interface{}) {
5252
var key string

pkg/controller/pod_monitor.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ func NewPodMonitor(podClient kubernetes.Interface, informer coreInformer.PodInfo
7272
// event handlers.
7373
_, _ = informer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
7474
// No need to AddFunc, as POD is first pending...through an update is initially gets ready.
75-
UpdateFunc: func(old, new interface{}) {
76-
if old.(*coreV1.Pod).ResourceVersion == new.(*coreV1.Pod).ResourceVersion {
75+
UpdateFunc: func(oldResource, newResource interface{}) {
76+
if oldResource.(*coreV1.Pod).ResourceVersion == newResource.(*coreV1.Pod).ResourceVersion {
7777
// no change --> nothing to do.
7878
return
7979
}
80-
mon.enqueuePod(new)
80+
mon.enqueuePod(newResource)
8181
},
8282
DeleteFunc: func(obj interface{}) {
8383
var key string

pkg/controller/profile_monitor.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ func NewKPIProfileMonitor(cfg common.MonitorConfig, profileClient clientSet.Inte
6262
// handle add, update & delete.
6363
_, _ = profileInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
6464
AddFunc: mon.enqueueItem,
65-
UpdateFunc: func(old, new interface{}) {
66-
if old.(*v1alpha1.KPIProfile).ResourceVersion == new.(*v1alpha1.KPIProfile).ResourceVersion {
65+
UpdateFunc: func(oldResource, newResource interface{}) {
66+
if oldResource.(*v1alpha1.KPIProfile).ResourceVersion == newResource.(*v1alpha1.KPIProfile).ResourceVersion {
6767
// no change --> nothing to do.
6868
return
6969
}
70-
mon.enqueueItem(new)
70+
mon.enqueueItem(newResource)
7171
},
7272
DeleteFunc: func(obj interface{}) {
7373
var key string

pkg/planner/actuators/scaling/scale_out.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func (scale ScaleOutActuator) Perform(state *common.State, plan []planner.Action
189189
return err
190190
}
191191
// conversion to int32 is ok - as we have a MaxPods defined
192-
res.Spec.Replicas = getInt32Pointer(*res.Spec.Replicas + int32(factor))
192+
res.Spec.Replicas = getInt32Pointer(*res.Spec.Replicas + int32(factor)) //nolint:gosec // explanation: casting len to int64 for API compatibility
193193
if *res.Spec.Replicas > 0 {
194194
_, updateErr := scale.apps.AppsV1().Deployments(namespace).Update(context.TODO(), res, metaV1.UpdateOptions{})
195195
return updateErr
@@ -207,7 +207,7 @@ func (scale ScaleOutActuator) Perform(state *common.State, plan []planner.Action
207207
return err
208208
}
209209
// conversion to int32 is ok - as we have a MaxPods defined
210-
res.Spec.Replicas = getInt32Pointer(*res.Spec.Replicas + int32(factor))
210+
res.Spec.Replicas = getInt32Pointer(*res.Spec.Replicas + int32(factor)) //nolint:gosec // explanation: casting len to int64 for API compatibility
211211
if *res.Spec.Replicas > 0 {
212212
_, updateErr := scale.apps.AppsV1().ReplicaSets(namespace).Update(context.TODO(), res, metaV1.UpdateOptions{})
213213
return updateErr

pkg/tests/full_framework_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ func (f *testFixture) setWorkloadState(pods map[string]map[string]interface{}, r
451451
// if deployment does not exist - add it.
452452
res, err := f.k8sClient.AppsV1().Deployments("default").Get(context.TODO(), "function-deployment", metaV1.GetOptions{})
453453
if err != nil || res == nil {
454-
repl := int32(len(pods))
454+
repl := int32(len(pods)) //nolint:gosec // explanation: casting len to int64 for API compatibility
455455
deployment := &appsV1.Deployment{
456456
ObjectMeta: metaV1.ObjectMeta{
457457
Name: "function-deployment",
@@ -628,31 +628,31 @@ func (f *testFixture) setCurrentData(vals map[string]map[string]float64) {
628628
}
629629

630630
// comparePlans compares two planes and returns false if they are not the same.
631-
func comparePlans(old []map[string]interface{}, new []planner.Action) bool {
632-
if len(new) != len(old) {
631+
func comparePlans(onePlan []map[string]interface{}, anotherPlan []planner.Action) bool {
632+
if len(anotherPlan) != len(onePlan) {
633633
return false
634634
}
635635
var oldPlan []planner.Action
636-
for _, entry := range old {
636+
for _, entry := range onePlan {
637637
tmp := planner.Action{
638638
Name: entry["name"].(string),
639639
Properties: entry["properties"],
640640
}
641641
oldPlan = append(oldPlan, tmp)
642642
}
643643
for i, item := range oldPlan {
644-
if item.Name != new[i].Name {
645-
klog.Infof("Expected action name: %v - got %v", item.Name, new[i].Name)
644+
if item.Name != anotherPlan[i].Name {
645+
klog.Infof("Expected action name: %v - got %v", item.Name, anotherPlan[i].Name)
646646
return false
647647
}
648648
one := fmt.Sprintf("%v", item.Properties)
649-
another := fmt.Sprintf("%v", new[i].Properties)
649+
another := fmt.Sprintf("%v", anotherPlan[i].Properties)
650650
if one != another && item.Name != "rmPod" {
651651
klog.Infof("Expected property: %v - got %v", one, another)
652652
return false
653653
} else if item.Name == "rmPod" {
654654
if one != another && len(one) == len(another) {
655-
klog.Warningf("Not super sure - but looks ok: %v - %v", item.Properties, new[i].Properties)
655+
klog.Warningf("Not super sure - but looks ok: %v - %v", item.Properties, anotherPlan[i].Properties)
656656
} else if one != another {
657657
klog.Infof("This does not look right; expected: %v - got %v", one, another)
658658
return false

0 commit comments

Comments
 (0)