1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-12 08:23:48 +02:00
woodpecker/pipeline/frontend/yaml/secret.go

35 lines
657 B
Go
Raw Normal View History

2017-04-10 12:39:50 +02:00
package yaml
2019-11-14 21:16:03 +02:00
import "gopkg.in/yaml.v3"
2017-04-10 12:39:50 +02:00
type (
// Secrets defines a collection of secrets.
Secrets struct {
Secrets []*Secret
}
// Secret defines a container secret.
Secret struct {
Source string `yaml:"source"`
Target string `yaml:"target"`
}
)
// UnmarshalYAML implements the Unmarshaller interface.
2019-11-14 21:16:03 +02:00
func (s *Secrets) UnmarshalYAML(value *yaml.Node) error {
y, _ := yaml.Marshal(value)
2017-04-10 12:39:50 +02:00
var strslice []string
2019-11-14 21:16:03 +02:00
err := yaml.Unmarshal(y, &strslice)
2017-04-10 12:39:50 +02:00
if err == nil {
for _, str := range strslice {
s.Secrets = append(s.Secrets, &Secret{
Source: str,
Target: str,
})
}
return nil
}
2019-11-14 21:16:03 +02:00
return yaml.Unmarshal(y, &s.Secrets)
2017-04-10 12:39:50 +02:00
}