1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-30 08:06:52 +02:00
woodpecker/yaml/transform/identifier.go
2016-05-09 11:28:49 -07:00

31 lines
603 B
Go

package transform
import (
"encoding/base64"
"fmt"
"github.com/drone/drone/yaml"
"github.com/gorilla/securecookie"
)
// Identifier transforms the container steps in the Yaml and assigns a unique
// container identifier.
func Identifier(c *yaml.Config) error {
// creates a random prefix for the build
rand := base64.RawURLEncoding.EncodeToString(
securecookie.GenerateRandomKey(8),
)
for i, step := range c.Services {
step.ID = fmt.Sprintf("drone_%s_%d", rand, i)
}
for i, step := range c.Pipeline {
step.ID = fmt.Sprintf("drone_%s_%d", rand, i+len(c.Services))
}
return nil
}