mirror of
https://github.com/thegeeklab/drone-yaml.git
synced 2024-11-16 23:20:41 +00:00
24 lines
557 B
Go
24 lines
557 B
Go
|
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
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|