2022-09-18 16:49:34 +02:00
|
|
|
package schema
|
|
|
|
|
|
|
|
import "gopkg.in/yaml.v3"
|
|
|
|
|
2022-09-18 17:02:47 +02:00
|
|
|
type OctopushSchema struct {
|
2022-09-18 16:49:34 +02:00
|
|
|
ApiVersion string `yaml:"apiVersion"`
|
|
|
|
Name string `yaml:"name"`
|
|
|
|
Select struct {
|
|
|
|
Repositories []string `yaml:"repositories"`
|
|
|
|
Providers []struct {
|
|
|
|
Gitea string `yaml:"gitea"`
|
|
|
|
Organisation string `yaml:"organisation"`
|
|
|
|
} `yaml:"providers"`
|
|
|
|
} `yaml:"select"`
|
|
|
|
Actions []struct {
|
|
|
|
Type string `yaml:"type"`
|
|
|
|
Entry string `yaml:"entry"`
|
|
|
|
} `yaml:"actions"`
|
|
|
|
Queries []struct {
|
|
|
|
Type string `yaml:"type"`
|
|
|
|
Query string `yaml:"query"`
|
|
|
|
} `yaml:"queries"`
|
|
|
|
}
|
|
|
|
|
2022-09-18 17:02:47 +02:00
|
|
|
func Unmarshal(raw string) (*OctopushSchema, error) {
|
|
|
|
k := &OctopushSchema{}
|
2022-09-18 16:49:34 +02:00
|
|
|
err := yaml.Unmarshal([]byte(raw), k)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return k, nil
|
|
|
|
}
|