Add pipeline labels
This commit is contained in:
parent
6f96daaa6c
commit
ea96eed417
|
@ -16,6 +16,7 @@ Currently supports converting only from Drone CI pipeline format with limited fu
|
|||
* `os`
|
||||
* `arch`
|
||||
* `version` - not supported by Woodpecker CI
|
||||
* `node`
|
||||
* `steps`
|
||||
* `name`
|
||||
* `image`
|
||||
|
|
|
@ -181,6 +181,7 @@ func (d DronePipeline) Convert(pipeline *Pipeline) (*transform.Pipeline, error)
|
|||
p := &transform.Pipeline{
|
||||
Name: pipeline.Name,
|
||||
Steps: make(transform.Steps, 0, len(pipeline.Steps)),
|
||||
Labels: pipeline.Node,
|
||||
DependsOn: pipeline.DependsOn,
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ func TestTransformSimple(t *testing.T) {
|
|||
require.NotNil(t, pipeline, "build pipeline not found")
|
||||
|
||||
assert.Equal(t, "linux/amd64", pipeline.Platform)
|
||||
assert.Equal(t, map[string]string{"location": "europe"}, pipeline.Labels)
|
||||
|
||||
require.Len(t, pipeline.Steps, 3)
|
||||
assert.Equal(t, "test", pipeline.Steps[0].Name)
|
||||
|
|
|
@ -41,10 +41,11 @@ type Step struct {
|
|||
}
|
||||
|
||||
type Pipeline struct {
|
||||
Kind string `yaml:"kind"`
|
||||
Type string `yaml:"type"`
|
||||
Name string `yaml:"name"`
|
||||
Platform *Platform `yaml:"platform"`
|
||||
Steps []*Step `yaml:"steps"`
|
||||
DependsOn []string `yaml:"depends_on"`
|
||||
Kind string `yaml:"kind"`
|
||||
Type string `yaml:"type"`
|
||||
Name string `yaml:"name"`
|
||||
Platform *Platform `yaml:"platform"`
|
||||
Node map[string]string `yaml:"node"`
|
||||
Steps []*Step `yaml:"steps"`
|
||||
DependsOn []string `yaml:"depends_on"`
|
||||
}
|
||||
|
|
|
@ -7,6 +7,9 @@ platform:
|
|||
os: linux
|
||||
arch: amd64
|
||||
|
||||
node:
|
||||
location: europe
|
||||
|
||||
steps:
|
||||
- name: test
|
||||
image: golang:1.18
|
||||
|
|
|
@ -20,6 +20,9 @@ func FormatWoodpeckerYAML(data []byte) ([]byte, error) {
|
|||
line := scanner.Text()
|
||||
if line == "pipeline:" {
|
||||
isPipeline = true
|
||||
if i > 0 {
|
||||
out.WriteByte('\n')
|
||||
}
|
||||
i = 0
|
||||
} else if isPipeline && len(line) > 0 && line[0] != ' ' && line[0] != '\t' {
|
||||
isPipeline = false
|
||||
|
|
11
pipeline.go
11
pipeline.go
|
@ -72,9 +72,10 @@ type Workspace struct {
|
|||
}
|
||||
|
||||
type Pipeline struct {
|
||||
Name string `yaml:"-"`
|
||||
Workspace *Workspace `yaml:"workspace,omitempty"`
|
||||
Platform string `yaml:"platform,omitempty"`
|
||||
Steps Steps `yaml:"pipeline"`
|
||||
DependsOn []string `yaml:"depends_on,omitempty"`
|
||||
Name string `yaml:"-"`
|
||||
Workspace *Workspace `yaml:"workspace,omitempty"`
|
||||
Platform string `yaml:"platform,omitempty"`
|
||||
Labels map[string]string `yaml:"labels,omitempty"`
|
||||
Steps Steps `yaml:"pipeline"`
|
||||
DependsOn []string `yaml:"depends_on,omitempty"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue