Skip to content

Commit

Permalink
fix(pkg/utils): check secret is of service-account-token type
Browse files Browse the repository at this point in the history
Signed-off-by: Massimiliano Giovagnoli <me@maxgio.it>
  • Loading branch information
maxgio92 committed Jun 10, 2023
1 parent 4d3f637 commit 1e96f4c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ package main
import (
"flag"
"fmt"
"github.com/pkg/errors"
"os"

"github.com/pkg/errors"
"k8s.io/client-go/kubernetes"

"github.com/maxgio92/proxy-kubeconfig-generator/pkg/generator"
Expand Down
9 changes: 9 additions & 0 deletions pkg/utils/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package utils

import (
"github.com/pkg/errors"
)

var (
ErrSecretTypeNotServiceAccountToken = errors.New("the secret is not of type service-account-token")
)
4 changes: 4 additions & 0 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func GetServiceAccountSecret(clientSet *kubernetes.Clientset, serviceAccountName
return nil, err
}

if saSecret.Type != corev1.SecretTypeServiceAccountToken {
return nil, ErrSecretTypeNotServiceAccountToken
}

return saSecret, nil
}

Expand Down

0 comments on commit 1e96f4c

Please sign in to comment.