mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-18 22:46:33 +00:00
Weakly decode backend options (#4577)
This commit is contained in:
parent
b3c61fa47b
commit
1ec785c7e9
3 changed files with 19 additions and 2 deletions
|
@ -16,6 +16,6 @@ func parseBackendOptions(step *backend.Step) (BackendOptions, error) {
|
||||||
if step == nil || step.BackendOptions == nil {
|
if step == nil || step.BackendOptions == nil {
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
err := mapstructure.Decode(step.BackendOptions[EngineName], &result)
|
err := mapstructure.WeakDecode(step.BackendOptions[EngineName], &result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,6 @@ func parseBackendOptions(step *backend.Step) (BackendOptions, error) {
|
||||||
if step == nil || step.BackendOptions == nil {
|
if step == nil || step.BackendOptions == nil {
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
err := mapstructure.Decode(step.BackendOptions[EngineName], &result)
|
err := mapstructure.WeakDecode(step.BackendOptions[EngineName], &result)
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 {
|
for _, tt := range tests {
|
||||||
|
|
Loading…
Reference in a new issue