mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-13 03:56:39 +00:00
29 lines
488 B
Go
29 lines
488 B
Go
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
|
|
}
|