Add exec pipeline support
This commit is contained in:
parent
60d4f9e2fd
commit
0ba7c597ee
|
@ -10,7 +10,7 @@ Currently supports converting only from Drone CI pipeline format with limited fu
|
|||
## Drone pipeline supported features
|
||||
|
||||
* `kind` - must be `pipeline`
|
||||
* `type` - only `docker` supported
|
||||
* `type` - only `docker` and `exec` are supported
|
||||
* `name`
|
||||
* `platform`
|
||||
* `os`
|
||||
|
|
|
@ -193,7 +193,7 @@ func (d DronePipeline) Convert(pipeline *Pipeline) (*transform.Pipeline, error)
|
|||
if pipeline.Kind != "pipeline" {
|
||||
return nil, transform.UnsupportedError
|
||||
}
|
||||
if pipeline.Type != "docker" {
|
||||
if pipeline.Type != "docker" && pipeline.Type != "exec" {
|
||||
return nil, transform.UnsupportedError
|
||||
}
|
||||
if pipeline.Platform != nil && len(pipeline.Platform.Version) > 0 {
|
||||
|
@ -338,9 +338,15 @@ func (d DronePipeline) Convert(pipeline *Pipeline) (*transform.Pipeline, error)
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var image string
|
||||
if pipeline.Type == "docker" {
|
||||
image = d.ConvertImage(step.Image)
|
||||
} else if pipeline.Type == "exec" {
|
||||
image = "bash"
|
||||
}
|
||||
p.Steps = append(p.Steps, &transform.Step{
|
||||
Name: step.Name,
|
||||
Image: d.ConvertImage(step.Image),
|
||||
Image: image,
|
||||
Pull: step.Pull == "always",
|
||||
Environment: env,
|
||||
Secrets: secrets,
|
||||
|
|
|
@ -37,7 +37,7 @@ func TestTransformSimple(t *testing.T) {
|
|||
})
|
||||
|
||||
require.NoError(t, err)
|
||||
require.Len(t, pipelines, 2)
|
||||
require.Len(t, pipelines, 3)
|
||||
|
||||
pipeline := getPipelineByName(pipelines, "build")
|
||||
require.NotNil(t, pipeline, "build pipeline not found")
|
||||
|
@ -120,4 +120,16 @@ func TestTransformSimple(t *testing.T) {
|
|||
assert.Equal(t, "staging", pipeline.Steps[0].When.Environment)
|
||||
|
||||
assert.ElementsMatch(t, []string{"build"}, pipeline.DependsOn)
|
||||
|
||||
pipeline = getPipelineByName(pipelines, "update-nlb")
|
||||
require.NotNil(t, pipeline, "update-nlb pipeline not found")
|
||||
|
||||
assert.True(t, pipeline.SkipClone)
|
||||
|
||||
require.Len(t, pipeline.Steps, 1)
|
||||
assert.Equal(t, "update", pipeline.Steps[0].Name)
|
||||
assert.Equal(t, "bash", pipeline.Steps[0].Image)
|
||||
assert.Len(t, pipeline.Steps[0].Commands, 1)
|
||||
|
||||
assert.ElementsMatch(t, []string{"deploy"}, pipeline.DependsOn)
|
||||
}
|
||||
|
|
|
@ -103,3 +103,22 @@ steps:
|
|||
refs:
|
||||
- refs/tags/v*
|
||||
- refs/tags/RELEASE-*
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: exec
|
||||
name: update-nlb
|
||||
|
||||
depends_on:
|
||||
- deploy
|
||||
|
||||
clone:
|
||||
disable: true
|
||||
|
||||
node:
|
||||
server: nlb
|
||||
|
||||
steps:
|
||||
- name: update
|
||||
commands:
|
||||
- systemctl reload haproxy
|
||||
|
|
|
@ -14,7 +14,7 @@ var UnsupportedError = errors.New("unsupported pipeline")
|
|||
|
||||
type Step struct {
|
||||
Name string `yaml:"-"`
|
||||
Image string `yaml:"image"`
|
||||
Image string `yaml:"image,omitempty"`
|
||||
Pull bool `yaml:"pull,omitempty"`
|
||||
Environment []string `yaml:"environment,omitempty"`
|
||||
Secrets Secrets `yaml:"secrets,omitempty"`
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
|
||||
package transform
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Secret struct {
|
||||
Source string `yaml:"source"`
|
||||
|
|
Loading…
Reference in New Issue