Skip to content

Fix bugsink.secret.create helper always evaluating to true#11

Merged
vanschelven merged 1 commit into
bugsink:mainfrom
GerritErpenstein:fix-secret-create-helper
Jun 26, 2026
Merged

Fix bugsink.secret.create helper always evaluating to true#11
vanschelven merged 1 commit into
bugsink:mainfrom
GerritErpenstein:fix-secret-create-helper

Conversation

@GerritErpenstein

Copy link
Copy Markdown
Contributor

Hi,

while deploying Bugsink in a Kubernetes cluster with strict policies that disallow Secret creation by default, I noticed that the chart always generates a Secret, even when all sensitive values are provided from existing Secrets. In most setups this is likely a cosmetic issue, but in my case it caused the deployment to fail.

The bugsink.secret.create helper in templates/_helpers.tpl used ternary true false (...) to signal whether the chart-managed Secret should be created. The problem is that include in Helm always returns a string, so both outcomes (boolean true and boolean false) become the strings "true" and "false" respectively. Since any non-empty string is truthy in a Helm if block, the condition {{- if (include "bugsink.secret.create" .) }} always evaluated to true, unconditionally rendering the Secret and the corresponding envFrom.secretRef.

The fix is to replace ternary with an if/end block that outputs "true" when the Secret should be created and nothing (empty string) otherwise. An empty string is falsy in Helm, which gives the helper the correct semantics. As a minor cleanup, the double negation (not (not .Values.extraEnv.secrets)) is simplified to .Values.extraEnv.secrets.

To validate the fix, use helm template. With all existing Secret references configured, no chart-managed Secret or envFrom.secretRef should appear in the output:

helm template test charts/bugsink \
  --set secretKey.existingSecret=signing \
  --set secretKey.existingSecretKey=key \
  --set admin.existingSecret=admin \
  --set admin.existingSecretKey=auth \
  --set postgresql.enabled=false \
  --set externalDatabase.existingSecret=psqldb-bugsink-user-ddl-connection-secret \
  --set externalDatabase.existingSecretKey=connectionString

The helper used `ternary true false (...)`, which caused `include` to always return a non-empty string ("true" or "false"). Since `include` always returns a string in Helm, and any non-empty string is truthy in an `if` block, the condition `{{- if (include "bugsink.secret.create" .) }}` always rendered the Secret and its envFrom secretRef, even when all sensitive values were sourced from existing Secrets.

Replace `ternary` with an `if`/`end` block that outputs "true" when the Secret should be created and nothing (empty string) otherwise. Also simplify `(not (not .Values.extraEnv.secrets))` to `.Values.extraEnv.secrets`.
@vanschelven
vanschelven merged commit a747505 into bugsink:main Jun 26, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants