1
0
Fork 0

Add pipeline labels

This commit is contained in:
Lauris BH 2022-07-30 01:06:51 +03:00
parent 6f96daaa6c
commit ea96eed417
No known key found for this signature in database
GPG Key ID: DFDE60A0093EB926
7 changed files with 22 additions and 11 deletions

View File

@ -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`

View File

@ -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,
}

View File

@ -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)

View File

@ -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"`
}

View File

@ -7,6 +7,9 @@ platform:
os: linux
arch: amd64
node:
location: europe
steps:
- name: test
image: golang:1.18

View File

@ -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

View File

@ -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"`
}