harness-drone/engine/compiler/builtin/alias.go

30 lines
488 B
Go
Raw Normal View History

2016-04-16 07:51:05 +00:00
package builtin
import (
"fmt"
"github.com/drone/drone/engine/compiler/parse"
)
type aliasOp struct {
visitor
index map[string]string
prefix string
suffix int
}
func NewAliasOp(prefix string) Visitor {
return &aliasOp{
index: map[string]string{},
prefix: prefix,
}
}
func (v *aliasOp) VisitContainer(node *parse.ContainerNode) error {
v.suffix++
node.Container.Alias = node.Container.Name
node.Container.Name = fmt.Sprintf("%s_%d", v.prefix, v.suffix)
return nil
}