harness-drone/yaml/transform/workspace.go

33 lines
572 B
Go
Raw Normal View History

2016-05-09 18:28:49 +00:00
package transform
import (
"path/filepath"
"github.com/drone/drone/yaml"
)
// WorkspaceTransform transforms ...
func WorkspaceTransform(c *yaml.Config, base, path string) error {
if c.Workspace == nil {
c.Workspace = &yaml.Workspace{}
}
if c.Workspace.Base == "" {
c.Workspace.Base = base
}
if c.Workspace.Path == "" {
c.Workspace.Path = path
}
if !filepath.IsAbs(c.Workspace.Path) {
c.Workspace.Path = filepath.Join(
c.Workspace.Base,
c.Workspace.Path,
)
}
for _, p := range c.Pipeline {
p.WorkingDir = c.Workspace.Path
}
return nil
}