Drop VarArgs in steps in favour of settings (#919)

* drop VarArgs in steps in favour of settings
* update unit tests
This commit is contained in:
6543 2022-05-17 16:43:05 +02:00 committed by GitHub
parent eb2118e451
commit 4136df7551
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 26 deletions

View file

@ -60,8 +60,6 @@ type (
Sysctls types.SliceorMap `yaml:"sysctls,omitempty"`
Constraints constraint.Constraints `yaml:"when,omitempty"`
Settings map[string]interface{} `yaml:"settings"`
// Deprecated
Vargs map[string]interface{} `yaml:",inline"` // TODO: remove deprecated with v0.16.0
}
)
@ -84,20 +82,10 @@ func (c *Containers) UnmarshalYAML(value *yaml.Node) error {
if container.Name == "" {
container.Name = fmt.Sprintf("%v", value.Content[i-1].Value)
}
c.Containers = append(c.Containers, &container)
}
}
// TODO drop Vargs in favor of Settings in v0.16.0 release
for _, cc := range c.Containers {
if cc.Settings == nil && cc.Vargs != nil {
cc.Settings = make(map[string]interface{})
}
for k, v := range cc.Vargs {
cc.Settings[k] = v
}
cc.Vargs = nil
}
return nil
}

View file

@ -62,7 +62,6 @@ when:
settings:
foo: bar
baz: false
deprecated_setting: fallback
`)
func TestUnmarshalContainer(t *testing.T) {
@ -119,9 +118,6 @@ func TestUnmarshalContainer(t *testing.T) {
"foo": "bar",
"baz": false,
},
Vargs: map[string]interface{}{
"deprecated_setting": "fallback",
},
}
got := Container{}
err := yaml.Unmarshal(containerYaml, &got)
@ -147,14 +143,13 @@ func TestUnmarshalContainers(t *testing.T) {
},
},
{
from: "test: { name: unit_test, image: node, deprecated_setting: fallback, settings: { normal_setting: true } }",
from: "test: { name: unit_test, image: node, settings: { normal_setting: true } }",
want: []*Container{
{
Name: "unit_test",
Image: "node",
Settings: map[string]interface{}{
"deprecated_setting": "fallback",
"normal_setting": true,
"normal_setting": true,
},
},
},
@ -163,11 +158,12 @@ func TestUnmarshalContainers(t *testing.T) {
from: `publish-agent:
group: bundle
image: print/env
repo: woodpeckerci/woodpecker-agent
dockerfile: docker/Dockerfile.agent
settings:
repo: woodpeckerci/woodpecker-agent
dry_run: true
dockerfile: docker/Dockerfile.agent
tag: [next, latest]
secrets: [docker_username, docker_password]
tag: [next, latest]
dry_run: true
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
event: push`,

View file

@ -41,8 +41,8 @@ pipeline:
secrets:
image: docker
commands:
- echo $DOCKER_USERNAME
- echo $DOCKER_PASSWORD
- echo $DOCKER_USERNAME
- echo $DOCKER_PASSWORD
secrets:
- docker_username
- source: docker_prod_password