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 {
|
|
|
|
for _, p := range c.Pipeline {
|
|
|
|
if p.Name == clone {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
2016-05-23 21:35:58 +00:00
|
|
|
if plugin == "" {
|
|
|
|
plugin = "git"
|
|
|
|
}
|
2016-05-09 18:28:49 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|