Conversation
The `global.licence.createSecret` flag was defined in values but no template implemented it, causing Membership and Stargate to receive the licence token as a plain-text environment variable. This adds: - A new licence-secret.yaml template that creates a K8s Secret when createSecret=true and token is non-empty - Updated core.licence.env helper with 3-tier resolution: existingSecret, createSecret, or plain value fallback - LICENCE_ISSUER is now also read from the Secret when available - Improved values.yaml documentation explaining Operator sharing mode
WalkthroughThis pull request adds secret-based token handling to the licence environment template in the Helm chart. It introduces logic to resolve and use Kubernetes secrets for licence credentials, with fallback support for direct value configuration. The changes update template defaults and enable conditional secret creation based on configuration. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
charts/core/templates/_licence.tpl (1)
45-49: Consider making issuer secret key configurable for symmetry.
LICENCE_TOKENkey is configurable, but Line 49 hardcodes"issuer". Addinglicence.secretKeys.issuerwould keep token/issuer behavior consistent and reduce coupling to secret-template internals.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@charts/core/templates/_licence.tpl` around lines 45 - 49, The template hardcodes the secret key "issuer" while LICENCE_TOKEN is configurable; add a chart value (e.g., licence.secretKeys.issuer) and use it instead of the literal to keep behavior symmetric. Update the template conditional that references $secretName to read the new value (e.g., $issuerKey or .Values.licence.secretKeys.issuer) and replace the hardcoded "issuer" under secretKeyRef.key so the key is configurable alongside LICENCE_TOKEN.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed. Inline comments: In `@charts/core/templates/_licence.tpl`: - Around line 30-31: $secretName and the emitted secretKeyRef must be gated on both $createSecret == "true" and a non-empty $token to avoid referencing a Secret that is never created; update the conditional that sets $secretName (currently using $createSecret and printing "%s-licence") to also require the token be non-empty (or else leave $secretName unset/empty), and wrap the block that emits the secretKeyRef (the template code around the secretKeyRef emission) with the same check (e.g., only render secretKeyRef when both $createSecret == "true" and $token is non-empty) so the pod spec never references a missing Secret. --- Nitpick comments: In `@charts/core/templates/_licence.tpl`: - Around line 45-49: The template hardcodes the secret key "issuer" while LICENCE_TOKEN is configurable; add a chart value (e.g., licence.secretKeys.issuer) and use it instead of the literal to keep behavior symmetric. Update the template conditional that references $secretName to read the new value (e.g., $issuerKey or .Values.licence.secretKeys.issuer) and replace the hardcoded "issuer" under secretKeyRef.key so the key is configurable alongside LICENCE_TOKEN. ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (5)
charts/formance/Chart.lockis excluded by!**/*.lock,!**/*.lockcharts/formance/templates/licence-secret.yamlis excluded by!**/*.yamlcharts/formance/values.yamlis excluded by!**/*.yamlcharts/membership/Chart.lockis excluded by!**/*.lock,!**/*.lockcharts/regions/Chart.lockis excluded by!**/*.lock,!**/*.lock
📒 Files selected for processing (1)
charts/core/templates/_licence.tpl
| {{- else if eq $createSecret "true" -}} | ||
| {{- $secretName = printf "%s-licence" .Release.Name -}} |
There was a problem hiding this comment.
Gate auto-secret resolution on non-empty token to avoid broken secretKeyRefs.
At Line 30–31, $secretName is set whenever createSecret == "true". But the Secret is only created when token is non-empty, so Line 34–49 can emit secretKeyRef to a non-existent Secret and block pod startup.
Proposed fix
{{- $existingSecret := include "resolveGlobalOrServiceValue" (dict "Context" . "Key" "licence.existingSecret" "Default" "") -}} {{- $createSecret := include "resolveGlobalOrServiceValue" (dict "Context" . "Key" "licence.createSecret" "Default" "false") -}} +{{- $token := include "resolveGlobalOrServiceValue" (dict "Context" . "Key" "licence.token" "Default" "") -}} {{- $secretName := "" -}} {{- if $existingSecret -}} {{- $secretName = $existingSecret -}} -{{- else if eq $createSecret "true" -}} +{{- else if and (eq $createSecret "true") $token -}} {{- $secretName = printf "%s-licence" .Release.Name -}} {{- end }} - name: LICENCE_TOKEN {{- if $secretName }} valueFrom: secretKeyRef: name: {{ $secretName | quote }} key: {{ include "resolveGlobalOrServiceValue" (dict "Context" . "Key" "licence.secretKeys.token" "Default" "token") | quote }} {{- else }} - value: {{ include "resolveGlobalOrServiceValue" (dict "Context" . "Key" "licence.token" "Default" "") | quote }} + value: {{ $token | quote }} {{- end }}Also applies to: 34-49
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@charts/core/templates/_licence.tpl` around lines 30 - 31, $secretName and the emitted secretKeyRef must be gated on both $createSecret == "true" and a non-empty $token to avoid referencing a Secret that is never created; update the conditional that sets $secretName (currently using $createSecret and printing "%s-licence") to also require the token be non-empty (or else leave $secretName unset/empty), and wrap the block that emits the secretKeyRef (the template code around the secretKeyRef emission) with the same check (e.g., only render secretKeyRef when both $createSecret == "true" and $token is non-empty) so the pod spec never references a missing Secret. | valueFrom: | ||
| secretKeyRef: | ||
| name: {{ $secretName | quote }} | ||
| key: "issuer" |
There was a problem hiding this comment.
Why ? The issuer is not a secret ?
Summary
licence-secret.yaml: creates a K8s Secret (<release>-licence) containingtokenandissuerwhenglobal.licence.createSecret=trueandtokenis non-emptycore.licence.envhelper: 3-tier resolution forLICENCE_TOKENandLICENCE_ISSUER—existingSecret>createSecretauto-name > plain value fallbackexistingSecretUsage modes
createSecret: true,token: xxx<release>-licence, Operator creates its owncreateSecret: true,token: xxx,existingSecret: <release>-licence<release>-licence, Operator reuses itcreateSecret: false,existingSecret: my-secretmy-secretcreateSecret: false,token: xxxTest plan
helm templatewithcreateSecret=true+token→ Secret rendered withsecretKeyRefin env varshelm templatewithexistingSecretset → Secret uses custom namehelm templatewithout token → no Secret createdhelm templatewithcreateSecret=false→ legacy plain value fallbackhelm lintpasses in both CE and EE modes