mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 18:31:00 +00:00
27 lines
545 B
Go
27 lines
545 B
Go
|
package yaml
|
||
|
|
||
|
import (
|
||
|
"gopkg.in/yaml.v2"
|
||
|
|
||
|
"github.com/drone/drone/yaml/types"
|
||
|
)
|
||
|
|
||
|
// ParseLabel parses the labels section of the Yaml document.
|
||
|
func ParseLabel(in []byte) map[string]string {
|
||
|
out := struct {
|
||
|
Labels types.MapEqualSlice `yaml:"labels"`
|
||
|
}{}
|
||
|
|
||
|
yaml.Unmarshal(in, &out)
|
||
|
labels := out.Labels.Map()
|
||
|
if labels == nil {
|
||
|
labels = make(map[string]string)
|
||
|
}
|
||
|
return labels
|
||
|
}
|
||
|
|
||
|
// ParseLabelString parses the labels section of the Yaml document.
|
||
|
func ParseLabelString(in string) map[string]string {
|
||
|
return ParseLabel([]byte(in))
|
||
|
}
|