harness-drone/yaml/transform/clone.go

33 lines
554 B
Go
Raw Normal View History

2016-05-09 18:28:49 +00:00
package transform
import "github.com/drone/drone/yaml"
const clone = "clone"
// Clone transforms the Yaml to include a clone step.
func Clone(c *yaml.Config, plugin string) error {
2016-09-29 21:23:26 +00:00
switch plugin {
case "", "git":
plugin = "plugins/git:latest"
case "hg":
plugin = "plugins/hg:latest"
2016-06-03 18:45:06 +00:00
}
2016-05-09 18:28:49 +00:00
for _, p := range c.Pipeline {
if p.Name == clone {
2016-06-03 18:45:06 +00:00
if p.Image == "" {
p.Image = plugin
}
2016-05-09 18:28:49 +00:00
return nil
}
}
s := &yaml.Container{
Image: plugin,
Name: clone,
}
2016-05-10 05:57:57 +00:00
2016-05-09 18:28:49 +00:00
c.Pipeline = append([]*yaml.Container{s}, c.Pipeline...)
return nil
}