From 4136df75511e5a0ab7a7fbceddc1ecd97899e295 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 17 May 2022 16:43:05 +0200 Subject: [PATCH] Drop VarArgs in steps in favour of settings (#919) * drop VarArgs in steps in favour of settings * update unit tests --- pipeline/frontend/yaml/container.go | 14 +------------- pipeline/frontend/yaml/container_test.go | 18 +++++++----------- pipeline/schema/.woodpecker/test-step.yml | 4 ++-- 3 files changed, 10 insertions(+), 26 deletions(-) diff --git a/pipeline/frontend/yaml/container.go b/pipeline/frontend/yaml/container.go index 8543e7b42..f7c24f1a7 100644 --- a/pipeline/frontend/yaml/container.go +++ b/pipeline/frontend/yaml/container.go @@ -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 } diff --git a/pipeline/frontend/yaml/container_test.go b/pipeline/frontend/yaml/container_test.go index 52cd0d82c..5b1964adc 100644 --- a/pipeline/frontend/yaml/container_test.go +++ b/pipeline/frontend/yaml/container_test.go @@ -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`, diff --git a/pipeline/schema/.woodpecker/test-step.yml b/pipeline/schema/.woodpecker/test-step.yml index f6d01afec..e3239bc19 100644 --- a/pipeline/schema/.woodpecker/test-step.yml +++ b/pipeline/schema/.woodpecker/test-step.yml @@ -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