Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: huabing zhao <[email protected]>
  • Loading branch information
zhaohuabing committed Feb 28, 2024
1 parent 082c3cb commit eccac69
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion internal/k8s/secret_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/k8s/secret_controller_lifecycle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package k8s

import (
"context"
"fmt"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -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)
}()

Expand Down
6 changes: 4 additions & 2 deletions internal/k8s/secret_controller_reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down

0 comments on commit eccac69

Please sign in to comment.