Remove deprecated options parsing (#2480)

Main change is that backwards compatibility to `platform` was removed.
Part of
https://github.com/woodpecker-ci/woodpecker/discussions/2170#discussioncomment-7047394
This commit is contained in:
qwerty287 2023-09-20 13:48:34 +02:00 committed by GitHub
parent 6d86ec7fe7
commit 842e8a8e50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 68 deletions

View file

@ -15,12 +15,9 @@
package yaml package yaml
import ( import (
"fmt"
"codeberg.org/6543/xyaml" "codeberg.org/6543/xyaml"
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types" "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. // ParseBytes parses the configuration from bytes b.
@ -31,27 +28,6 @@ func ParseBytes(b []byte) (*types.Workflow, error) {
return nil, err 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 return out, nil
} }

View file

@ -18,7 +18,6 @@ import (
"testing" "testing"
"github.com/franela/goblin" "github.com/franela/goblin"
"github.com/stretchr/testify/assert"
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/metadata" "github.com/woodpecker-ci/woodpecker/pipeline/frontend/metadata"
yaml_base_types "github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types/base" yaml_base_types "github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types/base"
@ -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 = ` var sampleYaml = `
image: hello-world image: hello-world
when: when:

View file

@ -36,13 +36,6 @@ type (
Cache base.StringOrSlice `yaml:"cache,omitempty"` Cache base.StringOrSlice `yaml:"cache,omitempty"`
Networks WorkflowNetworks `yaml:"networks,omitempty"` Networks WorkflowNetworks `yaml:"networks,omitempty"`
Volumes WorkflowVolumes `yaml:"volumes,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. // Workspace defines a pipeline workspace.