Merge branch 'origin/main' into 'next-release/main'

This commit is contained in:
oauth 2024-10-28 17:10:49 +00:00
commit 4197532bf9
2 changed files with 4 additions and 2 deletions

View file

@ -44,8 +44,9 @@ func ParamsToEnv(from map[string]any, to map[string]string, prefix string, upper
// sanitizeParamKey formats the environment variable key.
func sanitizeParamKey(prefix string, upper bool, k string) string {
r := strings.ReplaceAll(strings.ReplaceAll(k, ".", "_"), "-", "_")
r := k
if upper {
r = strings.ReplaceAll(strings.ReplaceAll(k, ".", "_"), "-", "_")
r = strings.ToUpper(r)
}
return prefix + r

View file

@ -110,8 +110,9 @@ func TestSanitizeParamKey(t *testing.T) {
assert.EqualValues(t, "PLUGIN_DRY_RUN", sanitizeParamKey("PLUGIN_", true, "dry-run"))
assert.EqualValues(t, "PLUGIN_DRY_RUN", sanitizeParamKey("PLUGIN_", true, "dry_Run"))
assert.EqualValues(t, "PLUGIN_DRY_RUN", sanitizeParamKey("PLUGIN_", true, "dry.run"))
assert.EqualValues(t, "PLUGIN_dry_run", sanitizeParamKey("PLUGIN_", false, "dry-run"))
assert.EqualValues(t, "PLUGIN_dry-run", sanitizeParamKey("PLUGIN_", false, "dry-run"))
assert.EqualValues(t, "PLUGIN_dry_Run", sanitizeParamKey("PLUGIN_", false, "dry_Run"))
assert.EqualValues(t, "PLUGIN_dry.run", sanitizeParamKey("PLUGIN_", false, "dry.run"))
}
func TestYAMLToParamsToEnv(t *testing.T) {