From eccac696f557388c8b9066c93d5d0cd72704a7c2 Mon Sep 17 00:00:00 2001 From: huabing zhao Date: Wed, 28 Feb 2024 08:53:33 +0800 Subject: [PATCH] fix lint Signed-off-by: huabing zhao --- internal/k8s/secret_controller.go | 3 ++- internal/k8s/secret_controller_lifecycle_test.go | 3 +-- internal/k8s/secret_controller_reconcile_test.go | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/k8s/secret_controller.go b/internal/k8s/secret_controller.go index 1b57a14..840acec 100644 --- a/internal/k8s/secret_controller.go +++ b/internal/k8s/secret_controller.go @@ -94,7 +94,8 @@ func (s *SecretController) PreRun() error { // Load the current namespace from the service account directory if s.namespace == "" { const namespaceFile = "/var/run/secrets/kubernetes.io/serviceaccount/namespace" - data, err := os.ReadFile(namespaceFile) + var data []byte + data, err = os.ReadFile(namespaceFile) if err != nil { return fmt.Errorf("error reading namespace file %s: %w", namespaceFile, err) } diff --git a/internal/k8s/secret_controller_lifecycle_test.go b/internal/k8s/secret_controller_lifecycle_test.go index bbf0978..b393eb8 100644 --- a/internal/k8s/secret_controller_lifecycle_test.go +++ b/internal/k8s/secret_controller_lifecycle_test.go @@ -16,7 +16,6 @@ package k8s import ( "context" - "fmt" "sync" "testing" "time" @@ -57,7 +56,7 @@ func TestController(t *testing.T) { wg.Add(1) go func() { defer wg.Done() - err := g.Run("", "--config-path", fmt.Sprintf("testdata/oidc-with-secret-ref.json")) + err := g.Run("", "--config-path", "testdata/oidc-with-secret-ref.json") require.NoError(t, err) }() diff --git a/internal/k8s/secret_controller_reconcile_test.go b/internal/k8s/secret_controller_reconcile_test.go index d285f74..7899bc4 100644 --- a/internal/k8s/secret_controller_reconcile_test.go +++ b/internal/k8s/secret_controller_reconcile_test.go @@ -44,7 +44,9 @@ func TestOIDCProcessWithKubernetesSecret(t *testing.T) { {"secret ref without data", "oidc-with-secret-ref-without-data", ""}, {"secret ref deleting", "oidc-with-secret-ref-deleting", ""}, {"secret ref not found", "oidc-with-secret-ref-not-found", ""}, - {"cross namespace secret ref", "oidc-with-cross-ns-secret-ref", "cross-namespace secret reference is not allowed: secret reference namespace test does not match the current namespace default"}, + {"cross namespace secret ref", "oidc-with-cross-ns-secret-ref", + "cross-namespace secret reference is not allowed: secret reference " + + "namespace test does not match the current namespace default"}, } for _, tt := range tests { @@ -69,7 +71,7 @@ func TestOIDCProcessWithKubernetesSecret(t *testing.T) { // reconcile the secrets for _, secret := range secrets.Items { - _, err := controller.Reconcile(context.Background(), ctrl.Request{ + _, err = controller.Reconcile(context.Background(), ctrl.Request{ NamespacedName: types.NamespacedName{ Namespace: secret.Namespace, Name: secret.Name,