1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-12 08:23:48 +02:00
woodpecker/yaml/transform/workspace.go
2016-05-09 11:28:49 -07:00

33 lines
572 B
Go

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
}