From 6d492c4e95b6c739ec721ec8b6fbd65d62101096 Mon Sep 17 00:00:00 2001 From: Steve Scaffidi Date: Sat, 12 Oct 2024 22:04:06 -0400 Subject: [PATCH] Make the linters happy --- .golangci.yml | 2 +- Makefile | 10 +++++----- cmd/main.go | 5 ++++- internal/util/istio/tags/test_test.go | 2 +- internal/util/k8s/rollout/rollout.go | 15 ++++++++++++--- test/e2e/e2e_suite_test.go | 2 +- test/utils/utils.go | 24 ++++++------------------ 7 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index ca69a11..17db13d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -21,7 +21,7 @@ linters: enable: - dupl - errcheck - - exportloopref + - copyloopvar - goconst - gocyclo - gofmt diff --git a/Makefile b/Makefile index 0c4069f..9e7c754 100644 --- a/Makefile +++ b/Makefile @@ -28,8 +28,8 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL) # This variable is used to construct full image tags for bundle and catalog images. # # For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both -# sscaffidi/istio-fortsa-bundle:$VERSION and sscaffidi/istio-fortsa-catalog:$VERSION. -IMAGE_TAG_BASE ?= sscaffidi/istio-fortsa +# ghcr.io/hercynium/istio-fortsa-bundle:$VERSION and ghcr.io/hercynium/istio-fortsa-catalog:$VERSION. +IMAGE_TAG_BASE ?= ghcr.io/hercynium/istio-fortsa # BUNDLE_IMG defines the image:tag used for the bundle. # You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=/:) @@ -209,10 +209,10 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest-$(ENVTEST_VERSION) GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION) ## Tool Versions -KUSTOMIZE_VERSION ?= v5.3.0 -CONTROLLER_TOOLS_VERSION ?= v0.14.0 +KUSTOMIZE_VERSION ?= v5.4.3 +CONTROLLER_TOOLS_VERSION ?= v0.16.4 # v0.14.0 ENVTEST_VERSION ?= release-0.17 -GOLANGCI_LINT_VERSION ?= v1.57.2 +GOLANGCI_LINT_VERSION ?= v1.61.0 .PHONY: kustomize kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. diff --git a/cmd/main.go b/cmd/main.go index dce91f7..fdaec81 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -174,7 +174,10 @@ func main() { //+kubebuilder:scaffold:builder // populate the Istio Data before even starting the controllers - istioData.RefreshIstioData(context.TODO(), kubeClient) + if err := istioData.RefreshIstioData(context.TODO(), kubeClient); err != nil { + setupLog.Error(err, "unable to get initial istio data") + os.Exit(1) + } if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil { setupLog.Error(err, "unable to set up health check") diff --git a/internal/util/istio/tags/test_test.go b/internal/util/istio/tags/test_test.go index e15094c..6f166c7 100644 --- a/internal/util/istio/tags/test_test.go +++ b/internal/util/istio/tags/test_test.go @@ -66,7 +66,7 @@ func TestGetTags(t *testing.T) { []runtime.Object{ invalidWebhook("invalid", "foo"), namespace("default", "canary"), - namespace("test1", "canary"), + namespace("test1", "stable"), }, }, { diff --git a/internal/util/k8s/rollout/rollout.go b/internal/util/k8s/rollout/rollout.go index b2fb472..42b2889 100644 --- a/internal/util/k8s/rollout/rollout.go +++ b/internal/util/k8s/rollout/rollout.go @@ -31,7 +31,10 @@ func DoRolloutRestart(ctx context.Context, client ctrlclient.Client, obj ctrlcli switch obj.GetObjectKind().GroupVersionKind().Kind { case "Deployment": objX := &appsv1.Deployment{} - client.Get(ctx, types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()}, objX) + err := client.Get(ctx, types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()}, objX) + if err != nil { + return err + } patch := ctrlclient.StrategicMergeFrom(objX.DeepCopy()) if objX.Spec.Template.ObjectMeta.Annotations == nil { objX.Spec.Template.ObjectMeta.Annotations = make(map[string]string) @@ -44,7 +47,10 @@ func DoRolloutRestart(ctx context.Context, client ctrlclient.Client, obj ctrlcli return client.Patch(ctx, objX, patch) case "DaemonSet": objX := &appsv1.DaemonSet{} - client.Get(ctx, types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()}, objX) + err := client.Get(ctx, types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()}, objX) + if err != nil { + return err + } patch := ctrlclient.StrategicMergeFrom(objX.DeepCopy()) if objX.Spec.Template.ObjectMeta.Annotations == nil { objX.Spec.Template.ObjectMeta.Annotations = make(map[string]string) @@ -55,7 +61,10 @@ func DoRolloutRestart(ctx context.Context, client ctrlclient.Client, obj ctrlcli return client.Patch(ctx, objX, patch) case "StatefulSet": objX := &appsv1.StatefulSet{} - client.Get(ctx, types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()}, objX) + err := client.Get(ctx, types.NamespacedName{Namespace: obj.GetNamespace(), Name: obj.GetName()}, objX) + if err != nil { + return err + } patch := ctrlclient.StrategicMergeFrom(objX.DeepCopy()) if objX.Spec.Template.ObjectMeta.Annotations == nil { objX.Spec.Template.ObjectMeta.Annotations = make(map[string]string) diff --git a/test/e2e/e2e_suite_test.go b/test/e2e/e2e_suite_test.go index a1df919..b4a3e4e 100644 --- a/test/e2e/e2e_suite_test.go +++ b/test/e2e/e2e_suite_test.go @@ -27,6 +27,6 @@ import ( // Run e2e tests using the Ginkgo runner. func TestE2E(t *testing.T) { RegisterFailHandler(Fail) - fmt.Fprintf(GinkgoWriter, "Starting istio-fortsa suite\n") + _, _ = fmt.Fprintf(GinkgoWriter, "Starting istio-fortsa suite\n") RunSpecs(t, "e2e suite") } diff --git a/test/utils/utils.go b/test/utils/utils.go index a87b915..40334ef 100644 --- a/test/utils/utils.go +++ b/test/utils/utils.go @@ -33,25 +33,13 @@ const ( certmanagerVersion = "v1.14.4" certmanagerURLTmpl = "https://github.com/jetstack/cert-manager/releases/download/%s/cert-manager.yaml" - istio1Version = "1.22.4" - istioHelmChartRepo = "https://istio-release.storage.googleapis.com/charts" - istio2Version = "1.23.1" + //istio1Version = "1.22.4" + //istioHelmChartRepo = "https://istio-release.storage.googleapis.com/charts" + //istio2Version = "1.23.1" ) -/* -kind delete cluster -kind create cluster --config kind-config.yaml - -kubectl create ns istio-system - -helm install istio-base-v1-22-4 https://istio-release.storage.googleapis.com/charts/base-1.22.4.tgz -n istio-system --set revision=test-1 -helm install istio-istiod-v1-22-4 https://istio-release.storage.googleapis.com/charts/istiod-1.22.4.tgz -n istio-system --set pilot.resources.requests.cpu=100m --set pilot.resources.requests.memory=128m --set revision=test-1 -helm install istio-istiod-v1-23-1 https://istio-release.storage.googleapis.com/charts/istiod-1.23.1.tgz -n istio-system --set pilot.resources.requests.cpu=100m --set pilot.resources.requests.memory=256m --set revision=test-2 - -*/ - func warnError(err error) { - fmt.Fprintf(GinkgoWriter, "warning: %v\n", err) + _, _ = fmt.Fprintf(GinkgoWriter, "warning: %v\n", err) } // InstallPrometheusOperator installs the prometheus Operator to be used to export the enabled metrics. @@ -68,12 +56,12 @@ func Run(cmd *exec.Cmd) ([]byte, error) { cmd.Dir = dir if err := os.Chdir(cmd.Dir); err != nil { - fmt.Fprintf(GinkgoWriter, "chdir dir: %s\n", err) + _, _ = fmt.Fprintf(GinkgoWriter, "chdir dir: %s\n", err) } cmd.Env = append(os.Environ(), "GO111MODULE=on") command := strings.Join(cmd.Args, " ") - fmt.Fprintf(GinkgoWriter, "running: %s\n", command) + _, _ = fmt.Fprintf(GinkgoWriter, "running: %s\n", command) output, err := cmd.CombinedOutput() if err != nil { return output, fmt.Errorf("%s failed with error: (%v) %s", command, err, string(output))