Weakly decode backend options (#4577)

This commit is contained in:
qwerty287 2024-12-16 19:37:38 +02:00 committed by GitHub
parent b3c61fa47b
commit 1ec785c7e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 2 deletions

View file

@ -16,6 +16,6 @@ func parseBackendOptions(step *backend.Step) (BackendOptions, error) {
if step == nil || step.BackendOptions == nil {
return result, nil
}
err := mapstructure.Decode(step.BackendOptions[EngineName], &result)
err := mapstructure.WeakDecode(step.BackendOptions[EngineName], &result)
return result, err
}

View file

@ -89,6 +89,6 @@ func parseBackendOptions(step *backend.Step) (BackendOptions, error) {
if step == nil || step.BackendOptions == nil {
return result, nil
}
err := mapstructure.Decode(step.BackendOptions[EngineName], &result)
err := mapstructure.WeakDecode(step.BackendOptions[EngineName], &result)
return result, err
}

View file

@ -114,6 +114,23 @@ func Test_parseBackendOptions(t *testing.T) {
},
},
},
{
name: "number options",
step: &backend.Step{BackendOptions: map[string]any{
"kubernetes": map[string]any{
"resources": map[string]any{
"requests": map[string]int{"memory": 128, "cpu": 1000},
"limits": map[string]int{"memory": 256, "cpu": 2},
},
},
}},
want: BackendOptions{
Resources: Resources{
Requests: map[string]string{"memory": "128", "cpu": "1000"},
Limits: map[string]string{"memory": "256", "cpu": "2"},
},
},
},
}
for _, tt := range tests {