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:
parent
5dbb7be6b6
commit
61a669778a
@ -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)
|
||||
}
|
||||
|
@ -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"))
|
||||
|
Loading…
Reference in New Issue
Block a user