Skip to content

Commit

Permalink
Remove deprecated options parsing (woodpecker-ci#2480)
Browse files Browse the repository at this point in the history
Main change is that backwards compatibility to `platform` was removed.
Part of
woodpecker-ci#2170 (comment)
  • Loading branch information
qwerty287 authored Sep 20, 2023
1 parent 6d86ec7 commit 842e8a8
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 68 deletions.
24 changes: 0 additions & 24 deletions pipeline/frontend/yaml/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
package yaml

import (
"fmt"

"codeberg.org/6543/xyaml"

"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types"
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types/base"
)

// ParseBytes parses the configuration from bytes b.
Expand All @@ -31,27 +28,6 @@ func ParseBytes(b []byte) (*types.Workflow, error) {
return nil, err
}

// fail hard on deprecated branch filter
if out.BranchesDontUseIt != nil {
return nil, fmt.Errorf("\"branches:\" filter got removed, use \"branch\" in global when filter instead")
}

// fail hard on deprecated pipeline keyword
if len(out.PipelineDontUseIt.ContainerList) != 0 {
return nil, fmt.Errorf("\"pipeline:\" got removed, use \"steps:\" instead")
}

// support deprecated platform filter
if out.PlatformDontUseIt != "" {
if out.Labels == nil {
out.Labels = make(base.SliceOrMap)
}
if _, set := out.Labels["platform"]; !set {
out.Labels["platform"] = out.PlatformDontUseIt
}
out.PlatformDontUseIt = ""
}

return out, nil
}

Expand Down
37 changes: 0 additions & 37 deletions pipeline/frontend/yaml/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"testing"

"github.com/franela/goblin"
"github.com/stretchr/testify/assert"

"github.com/woodpecker-ci/woodpecker/pipeline/frontend/metadata"
yaml_base_types "github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types/base"
Expand Down Expand Up @@ -138,42 +137,6 @@ func TestParse(t *testing.T) {
})
}

func TestParseLegacy(t *testing.T) {
sampleYamlPipelineLegacy := `
platform: linux/amd64
steps:
say hello:
image: bash
commands: echo hello
`

sampleYamlPipelineLegacyIgnore := `
platform: windows/amd64
labels:
platform: linux/amd64
steps:
say hello:
image: bash
commands: echo hello
`

workflow1, err := ParseString(sampleYamlPipelineLegacy)
if !assert.NoError(t, err) {
t.Fail()
}

workflow2, err := ParseString(sampleYamlPipelineLegacyIgnore)
if !assert.NoError(t, err) {
t.Fail()
}

assert.EqualValues(t, workflow1, workflow2)
assert.Len(t, workflow1.Steps.ContainerList, 1)
assert.EqualValues(t, "say hello", workflow1.Steps.ContainerList[0].Name)
}

var sampleYaml = `
image: hello-world
when:
Expand Down
7 changes: 0 additions & 7 deletions pipeline/frontend/yaml/types/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ type (
Cache base.StringOrSlice `yaml:"cache,omitempty"`
Networks WorkflowNetworks `yaml:"networks,omitempty"`
Volumes WorkflowVolumes `yaml:"volumes,omitempty"`

// Deprecated
PlatformDontUseIt string `yaml:"platform,omitempty"` // TODO: remove after v1.2.x version
// Deprecated
BranchesDontUseIt *constraint.List `yaml:"branches,omitempty"` // TODO: remove after v1.1.x version
// Deprecated
PipelineDontUseIt ContainerList `yaml:"pipeline,omitempty"` // TODO: remove after v1.1.x version
}

// Workspace defines a pipeline workspace.
Expand Down

0 comments on commit 842e8a8

Please sign in to comment.