woodpecker/pipeline/frontend/yaml/secret.go
Jacob Floyd e34daae0cf
Move cncd/pipeline/pipeline/ to pipeline/ (#347)
* Refactor: move cncd/pipeline/ to pipeline/

* Refactor: move pipeline/pipeline/ to pipeline/
2021-09-24 13:18:34 +02:00

34 lines
657 B
Go

package yaml
import "gopkg.in/yaml.v3"
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.
func (s *Secrets) UnmarshalYAML(value *yaml.Node) error {
y, _ := yaml.Marshal(value)
var strslice []string
err := yaml.Unmarshal(y, &strslice)
if err == nil {
for _, str := range strslice {
s.Secrets = append(s.Secrets, &Secret{
Source: str,
Target: str,
})
}
return nil
}
return yaml.Unmarshal(y, &s.Secrets)
}