Skip to content

Commit

Permalink
remove helm secrets based on type using slices
Browse files Browse the repository at this point in the history
  • Loading branch information
Yonah Dissen committed Aug 8, 2023
1 parent dbceee1 commit e15ecb7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/kor/secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
_ "k8s.io/client-go/plugin/pkg/client/auth/oidc"
"k8s.io/utils/strings/slices"
)

var exceptionSecretTypes = []string{
`helm.sh/release.v1`,
}

func getSATokens(clientset *kubernetes.Clientset, namespace string) ([]string, error) {
// Retrieve secrets in all namespaces with type "kubernetes.io/service-account-token"
secrets, err := clientset.CoreV1().Secrets(namespace).List(context.TODO(), metav1.ListOptions{
Expand Down Expand Up @@ -106,7 +111,7 @@ func retrieveSecretNames(kubeClient *kubernetes.Clientset, namespace string) ([]
}
names := make([]string, 0, len(secrets.Items))
for _, secret := range secrets.Items {
if secret.Type != "helm.sh/release.v1" {
if !slices.Contains(exceptionSecretTypes, string(secret.Type)) {
names = append(names, secret.Name)
}
}
Expand Down

0 comments on commit e15ecb7

Please sign in to comment.