digitalocean / clusterlint

A best practices checker for Kubernetes clusters. 🤠
Apache License 2.0
542 stars 45 forks source link

Check env vars for secret key references #102

Closed stephenpaulger closed 3 years ago

stephenpaulger commented 3 years ago

Clusterlint has a bug where secrets that are referenced only by a secretKeyRef are listed as unused.

    spec:
      containers:
          env:
            - name: APP_ENV_VAR_NAME
              valueFrom:
                secretKeyRef:
                  key: SECRET_KEY_NAME
                  name: secret-shown-as-unused

This bug isn't present for config maps so I have added a test based on the equivalent config map test and extended the function that finds which secrets are used to also identify secrets based on secretKeyRefs.

stephenpaulger commented 3 years ago

I'm closing this PR temporarily as I'd like to put the changes on a branch on my fork as I have another change I'd like to submit.