1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2025-03-29 20:39:54 +02:00

51 lines
1008 B
Go
Raw Normal View History

2017-03-05 18:56:08 +11:00
package yaml
import (
2019-11-14 20:16:03 +01:00
"gopkg.in/yaml.v3"
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types"
2017-03-05 18:56:08 +11:00
)
type (
// Config defines a pipeline configuration.
Config struct {
Cache types.Stringorslice
2017-03-05 18:56:08 +11:00
Platform string
Branches Constraint
Workspace Workspace
Clone Containers
Pipeline Containers
Services Containers
Networks Networks
Volumes Volumes
Labels types.SliceorMap
2019-06-12 11:03:59 +02:00
DependsOn []string `yaml:"depends_on,omitempty"`
RunsOn []string `yaml:"runs_on,omitempty"`
2019-06-24 11:19:12 +02:00
SkipClone bool `yaml:"skip_clone"`
2017-03-05 18:56:08 +11:00
}
// Workspace defines a pipeline workspace.
Workspace struct {
Base string
Path string
}
)
// ParseBytes parses the configuration from bytes b.
func ParseBytes(b []byte) (*Config, error) {
out := new(Config)
err := yaml.Unmarshal(b, out)
if err != nil {
return nil, err
}
return out, nil
}
// ParseString parses the configuration from string s.
func ParseString(s string) (*Config, error) {
return ParseBytes(
[]byte(s),
)
}