From 6032d0177ffaf234d584aff9419f420fdaf614d4 Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Tue, 17 Sep 2024 09:20:42 +0200 Subject: [PATCH 1/7] bump golint version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 64f41aab..ab3b5112 100644 --- a/Makefile +++ b/Makefile @@ -204,7 +204,7 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest ## Tool Versions KUSTOMIZE_VERSION ?= v5.0.0 CONTROLLER_TOOLS_VERSION ?= v0.16.1 -GOLANG_CI_LINT_VERSION ?= v1.57 +GOLANG_CI_LINT_VERSION ?= v1.60.1 KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" .PHONY: kustomize From 58dc0b212ff6d21dcd0c4f8da2f4976e3080d88c Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Tue, 17 Sep 2024 09:25:52 +0200 Subject: [PATCH 2/7] bump golint version --- .github/workflows/lint-go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint-go.yml b/.github/workflows/lint-go.yml index 24b7f117..a6fc9e25 100644 --- a/.github/workflows/lint-go.yml +++ b/.github/workflows/lint-go.yml @@ -40,4 +40,4 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6.1.0 with: - version: v1.57 + version: v1.60.1 From 689497e2536d1c10fd07bedc3cb8ecb16aa93a08 Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Tue, 17 Sep 2024 09:34:47 +0200 Subject: [PATCH 3/7] fix lint issues --- .golangci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.golangci.yaml b/.golangci.yaml index 7d92e801..0392c307 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -236,6 +236,9 @@ linters-settings: - js *JetStream issues: exclude-rules: + - path: "hack/e2e" + linters: + - mnd - path: "_test\\.go" linters: - wrapcheck From a4ea0574376b3c4fffe2e5b22d1a0064de97821c Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Tue, 17 Sep 2024 09:42:03 +0200 Subject: [PATCH 4/7] updated --- .golangci.yaml | 3 --- hack/e2e/common/fixtures/fixtures.go | 2 +- .../eventing/subscription/jetstream/reconciler.go | 2 +- test/utils/utils.go | 2 +- testing/test_helpers.go | 6 +++--- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 0392c307..7d92e801 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -236,9 +236,6 @@ linters-settings: - js *JetStream issues: exclude-rules: - - path: "hack/e2e" - linters: - - mnd - path: "_test\\.go" linters: - wrapcheck diff --git a/hack/e2e/common/fixtures/fixtures.go b/hack/e2e/common/fixtures/fixtures.go index 9b156bd0..47d5815c 100644 --- a/hack/e2e/common/fixtures/fixtures.go +++ b/hack/e2e/common/fixtures/fixtures.go @@ -1,4 +1,4 @@ -//nolint:gomnd // used in tests +//nolint:mnd // used in tests package fixtures import ( diff --git a/internal/controller/eventing/subscription/jetstream/reconciler.go b/internal/controller/eventing/subscription/jetstream/reconciler.go index 0aedf564..9a45e10f 100644 --- a/internal/controller/eventing/subscription/jetstream/reconciler.go +++ b/internal/controller/eventing/subscription/jetstream/reconciler.go @@ -344,7 +344,7 @@ func (r *Reconciler) updateStatus(ctx context.Context, oldSubscription, } // addFinalizer appends the eventing finalizer to the subscription and updates it in k8s. -func (r *Reconciler) addFinalizer(ctx context.Context, sub *eventingv1alpha2.Subscription) (kctrl.Result, error) { +func (r *Reconciler) addFinalizer(ctx context.Context, sub *eventingv1alpha2.Subscription) (kctrl.Result, error) { //nolint: unparam sub.ObjectMeta.Finalizers = append(sub.ObjectMeta.Finalizers, eventingv1alpha2.Finalizer) // update the subscription's finalizers in k8s diff --git a/test/utils/utils.go b/test/utils/utils.go index cb2aa60d..b91cc6db 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -1,4 +1,4 @@ -//nolint:gomnd // magic numbers here are used only in context of the function +//nolint:mnd // magic numbers here are used only in context of the function package utils import ( diff --git a/testing/test_helpers.go b/testing/test_helpers.go index 1f527edd..12d12aa6 100644 --- a/testing/test_helpers.go +++ b/testing/test_helpers.go @@ -186,7 +186,7 @@ func NewAPIRule(subscription *eventingv1alpha2.Subscription, opts ...APIRuleOpti func WithService(name, host string) APIRuleOption { return func(r *apigatewayv1beta1.APIRule) { - port := uint32(443) //nolint:gomnd // tests + port := uint32(443) //nolint:mnd // tests isExternal := true r.Spec.Host = &host r.Spec.Service = &apigatewayv1beta1.Service{ @@ -531,9 +531,9 @@ func NewSubscriberSvc(name, namespace string) *kcorev1.Service { Ports: []kcorev1.ServicePort{ { Protocol: "TCP", - Port: 443, //nolint:gomnd // tests + Port: 443, //nolint:mnd // tests TargetPort: intstr.IntOrString{ - IntVal: 8080, //nolint:gomnd // tests + IntVal: 8080, //nolint:mnd // tests }, }, }, From 532cefed230cc88739f2914ffe5c5b2ddf99b798 Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Tue, 17 Sep 2024 09:50:17 +0200 Subject: [PATCH 5/7] updated --- .golangci.yaml | 1 + .../eventing/subscription/jetstream/reconciler.go | 2 +- .../integrationtests/validation/integration_test.go | 4 ++-- pkg/ems/api/events/client/client.go | 2 +- pkg/eventing/utils.go | 6 +++--- pkg/tracing/tracing.go | 1 + pkg/tracing/tracing_test.go | 1 + testing/test_helpers.go | 1 + 8 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 7d92e801..eedac303 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -28,6 +28,7 @@ linters: - paralleltest - copyloopvar - perfsprint + - gomnd linters-settings: stylecheck: diff --git a/internal/controller/eventing/subscription/jetstream/reconciler.go b/internal/controller/eventing/subscription/jetstream/reconciler.go index 9a45e10f..3cb63be3 100644 --- a/internal/controller/eventing/subscription/jetstream/reconciler.go +++ b/internal/controller/eventing/subscription/jetstream/reconciler.go @@ -344,7 +344,7 @@ func (r *Reconciler) updateStatus(ctx context.Context, oldSubscription, } // addFinalizer appends the eventing finalizer to the subscription and updates it in k8s. -func (r *Reconciler) addFinalizer(ctx context.Context, sub *eventingv1alpha2.Subscription) (kctrl.Result, error) { //nolint: unparam +func (r *Reconciler) addFinalizer(ctx context.Context, sub *eventingv1alpha2.Subscription) (kctrl.Result, error) { //nolint:unparam sub.ObjectMeta.Finalizers = append(sub.ObjectMeta.Finalizers, eventingv1alpha2.Finalizer) // update the subscription's finalizers in k8s diff --git a/internal/controller/operator/eventing/integrationtests/validation/integration_test.go b/internal/controller/operator/eventing/integrationtests/validation/integration_test.go index 84ce6ead..f463037e 100644 --- a/internal/controller/operator/eventing/integrationtests/validation/integration_test.go +++ b/internal/controller/operator/eventing/integrationtests/validation/integration_test.go @@ -54,8 +54,8 @@ const ( wrongSecret = "gibberish" publisher = "publisher" replicas = "replicas" - max = "max" - min = "min" + max = "max" //nolint:predeclared // used in tests + min = "min" //nolint:predeclared // used in tests resources = "resources" limits = "limits" requests = "requests" diff --git a/pkg/ems/api/events/client/client.go b/pkg/ems/api/events/client/client.go index 59966e83..bf144480 100644 --- a/pkg/ems/api/events/client/client.go +++ b/pkg/ems/api/events/client/client.go @@ -65,7 +65,7 @@ func (c Client) Publish(event cloudevents.Event, qos types.Qos) (*types.PublishR } // set required headers - req.Header.Set("qos", string(qos)) + req.Header.Set("qos", string(qos)) //nolint:canonicalheader // used as required. var response types.PublishResponse status, responseBody, err := c.client.Do(req, &response) diff --git a/pkg/eventing/utils.go b/pkg/eventing/utils.go index 2722c304..9b929e2e 100644 --- a/pkg/eventing/utils.go +++ b/pkg/eventing/utils.go @@ -42,7 +42,7 @@ func GetPublisherClusterRoleBindingName(eventing v1alpha1.Eventing) string { return fmt.Sprintf("%s-%s", eventing.GetName(), publisherProxySuffix) } -func newHorizontalPodAutoscaler(name, namespace string, min, max, cpuUtilization, memoryUtilization int32, +func newHorizontalPodAutoscaler(name, namespace string, minReplicas, maxReplicas, cpuUtilization, memoryUtilization int32, labels map[string]string, ) *kautoscalingv2.HorizontalPodAutoscaler { return &kautoscalingv2.HorizontalPodAutoscaler{ @@ -61,8 +61,8 @@ func newHorizontalPodAutoscaler(name, namespace string, min, max, cpuUtilization Name: name, APIVersion: "apps/v1", }, - MinReplicas: &min, - MaxReplicas: max, + MinReplicas: &minReplicas, + MaxReplicas: maxReplicas, Metrics: []kautoscalingv2.MetricSpec{ { Type: kautoscalingv2.ResourceMetricSourceType, diff --git a/pkg/tracing/tracing.go b/pkg/tracing/tracing.go index ef3cdc98..3e3db37e 100644 --- a/pkg/tracing/tracing.go +++ b/pkg/tracing/tracing.go @@ -1,3 +1,4 @@ +//nolint:canonicalheader // used as required in tracing. package tracing import ( diff --git a/pkg/tracing/tracing_test.go b/pkg/tracing/tracing_test.go index a1bdcd2d..2c3d60a2 100644 --- a/pkg/tracing/tracing_test.go +++ b/pkg/tracing/tracing_test.go @@ -1,3 +1,4 @@ +//nolint:canonicalheader // used as required in tracing. package tracing import ( diff --git a/testing/test_helpers.go b/testing/test_helpers.go index 12d12aa6..383ec099 100644 --- a/testing/test_helpers.go +++ b/testing/test_helpers.go @@ -1,3 +1,4 @@ +//nolint:canonicalheader // used in testing. package testing import ( From d7f782fbffe7cef1b7be6a0e65f9a3a5e91972c3 Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Tue, 17 Sep 2024 09:53:14 +0200 Subject: [PATCH 6/7] updated --- .../controller/eventing/subscription/jetstream/reconciler.go | 4 ++-- testing/test_helpers.go | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/controller/eventing/subscription/jetstream/reconciler.go b/internal/controller/eventing/subscription/jetstream/reconciler.go index 3cb63be3..98c84817 100644 --- a/internal/controller/eventing/subscription/jetstream/reconciler.go +++ b/internal/controller/eventing/subscription/jetstream/reconciler.go @@ -239,7 +239,7 @@ func (r *Reconciler) enqueueReconciliationForSubscriptions(subs []eventingv1alph // handleSubscriptionDeletion deletes the JetStream subscription and removes its finalizer if it is set. func (r *Reconciler) handleSubscriptionDeletion(ctx context.Context, subscription *eventingv1alpha2.Subscription, log *zap.SugaredLogger, -) (kctrl.Result, error) { +) (kctrl.Result, error) { //nolint:unparam // used as needed. // delete the JetStream subscription/consumer if !utils.ContainsString(subscription.ObjectMeta.Finalizers, eventingv1alpha2.Finalizer) { return kctrl.Result{}, nil @@ -344,7 +344,7 @@ func (r *Reconciler) updateStatus(ctx context.Context, oldSubscription, } // addFinalizer appends the eventing finalizer to the subscription and updates it in k8s. -func (r *Reconciler) addFinalizer(ctx context.Context, sub *eventingv1alpha2.Subscription) (kctrl.Result, error) { //nolint:unparam +func (r *Reconciler) addFinalizer(ctx context.Context, sub *eventingv1alpha2.Subscription) (kctrl.Result, error) { //nolint:unparam // used as needed. sub.ObjectMeta.Finalizers = append(sub.ObjectMeta.Finalizers, eventingv1alpha2.Finalizer) // update the subscription's finalizers in k8s diff --git a/testing/test_helpers.go b/testing/test_helpers.go index 383ec099..12d12aa6 100644 --- a/testing/test_helpers.go +++ b/testing/test_helpers.go @@ -1,4 +1,3 @@ -//nolint:canonicalheader // used in testing. package testing import ( From e57e59386dcde2dd188faf4a437bfa6cac56ae8e Mon Sep 17 00:00:00 2001 From: Muhammad Faizan Date: Tue, 17 Sep 2024 09:55:21 +0200 Subject: [PATCH 7/7] updated --- testing/test_helpers.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testing/test_helpers.go b/testing/test_helpers.go index 12d12aa6..a8ea74ef 100644 --- a/testing/test_helpers.go +++ b/testing/test_helpers.go @@ -155,10 +155,10 @@ func GetStructuredMessageHeaders() http.Header { func GetBinaryMessageHeaders() http.Header { headers := make(http.Header) - headers.Add(CeIDHeader, EventID) - headers.Add(CeTypeHeader, CloudEventType) - headers.Add(CeSourceHeader, CloudEventSource) - headers.Add(CeSpecVersionHeader, CloudEventSpecVersion) + headers.Add(CeIDHeader, EventID) //nolint:canonicalheader // used in testing. + headers.Add(CeTypeHeader, CloudEventType) //nolint:canonicalheader // used in testing. + headers.Add(CeSourceHeader, CloudEventSource) //nolint:canonicalheader // used in testing. + headers.Add(CeSpecVersionHeader, CloudEventSpecVersion) //nolint:canonicalheader // used in testing. return headers }