drone-yaml/yaml/compiler/transform/labels.go

24 lines
557 B
Go
Raw Normal View History

2019-01-22 23:44:17 +00:00
package transform
import "github.com/drone/drone-runtime/engine"
// WithLables is a transform function that adds a set
// of labels to each resource.
func WithLables(labels map[string]string) func(*engine.Spec) {
return func(spec *engine.Spec) {
for k, v := range labels {
spec.Metadata.Labels[k] = v
}
for _, resource := range spec.Docker.Volumes {
for k, v := range labels {
resource.Metadata.Labels[k] = v
}
}
for _, resource := range spec.Steps {
for k, v := range labels {
resource.Metadata.Labels[k] = v
}
}
}
}