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,