feat: replace mockEnvVars bool with RenderEnvVarsMode in GetContentFromFiles#444
feat: replace mockEnvVars bool with RenderEnvVarsMode in GetContentFromFiles#444
Conversation
Replace the manual getContentWithoutEnvExpansion helper and the bool mockEnvVars parameter with the new file.RenderEnvVarsMode enum (EnvVarsExpand, EnvVarsMock, EnvVarsSkip) introduced in Kong/go-database-reconciler#444. - convert.Convert now takes file.RenderEnvVarsMode instead of bool - --no-expand-env-vars passes file.EnvVarsSkip (template skipped entirely) - file render passes file.EnvVarsMock or file.EnvVarsExpand as before - All other GetContentFromFiles call sites updated to file.EnvVarsExpand Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #444 +/- ##
==========================================
+ Coverage 28.81% 28.90% +0.09%
==========================================
Files 121 121
Lines 16517 16524 +7
==========================================
+ Hits 4760 4777 +17
+ Misses 11138 11129 -9
+ Partials 619 618 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
5aaf038 to
cd74a1c
Compare
We will have to push for major version release in that case, which would require a lot of changes. Is this really worth the effort? |
|
@Prashansa-K I don't think we need the major version bump here. There is only one consumer (deck) which we also own. If you feel strongly, I can add a new method which has the new signature and make the old one an alias |
|
What if we make a new config struct for this or utilise the existing We use a similar model for dumpConfig too. This would make the implementation future-proof as well. |
This works too. Whatever is easy and not confusing can be done. |
Add EnvVarsExpand, EnvVarsMock, and EnvVarsSkip modes to allow callers to skip template rendering entirely when env variable expansion is not desired.
cd74a1c to
9c97094
Compare
Summary
Adds new
GetContentFromFilesWithEnvVarsmethod with a typedRenderEnvVarsMode, adding a newEnvVarsSkipmode that skips template rendering entirely.Changes
RenderEnvVarsModetype with three constants topkg/file/template.go:EnvVarsExpand— expands env vars (replacesfalse)EnvVarsMock— returns var names as values (replacestrue)EnvVarsSkip— skips template rendering entirely (new)GetContentFromFilesWithEnvVars,getContent,readContent, andrenderTemplateto use the new typeUsage