1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-01-16 05:16:08 +02:00

Apply alias to secrets (#1802)

This commit is contained in:
Daniel Kurzynski 2020-07-15 21:05:22 +02:00 committed by GitHub
parent 5dbb7be6b6
commit 61a669778a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -213,6 +213,9 @@ func (c *Config) GetStepConfig(flagValues map[string]interface{}, paramJSON stri
for _, p := range parameters {
params = setParamValueFromAlias(params, filters.Parameters, p.Name, p.Aliases)
}
for _, s := range secrets {
params = setParamValueFromAlias(params, filters.Parameters, s.Name, s.Aliases)
}
stepConfig.mixIn(params, filters.Parameters)
}

View File

@ -274,6 +274,20 @@ steps:
assert.Equal(t, nil, stepConfig.Config["p1"])
})
t.Run("Apply alias to paramJSON", func(t *testing.T) {
var c Config
secrets := []StepSecrets{
StepSecrets{Name: "p0", Type: "string", Aliases: []Alias{{Name: "p1/subParam"}}}}
testConf := ""
paramJSON := "{\"p1\":{\"subParam\":\"p1_value\"}}"
stepConfig, err := c.GetStepConfig(nil, paramJSON, ioutil.NopCloser(strings.NewReader(testConf)), nil, true, StepFilters{Parameters: []string{"p0"}}, nil, secrets, nil, "stage1", "step1", []Alias{{}})
assert.NoError(t, err, "Error occurred but no error expected")
assert.Equal(t, "p1_value", stepConfig.Config["p0"])
})
t.Run("Failure case config", func(t *testing.T) {
var c Config
myConfig := ioutil.NopCloser(strings.NewReader("invalid config"))