mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 03:41:01 +00:00
Merge branch 'origin/main' into 'next-release/main'
This commit is contained in:
commit
4197532bf9
2 changed files with 4 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue