woodpecker/pipeline/frontend/yaml/config.go
6543 dec0eeeed7
Use global branch filter only on events containing branch info (#659)
- close #581
- delete unused code
- simplify code
- add check to procBuilder to fail on invalid config
2022-01-05 17:54:44 +01:00

51 lines
1,008 B
Go

package yaml
import (
"gopkg.in/yaml.v3"
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types"
)
type (
// Config defines a pipeline configuration.
Config struct {
Cache types.Stringorslice
Platform string
Branches Constraint
Workspace Workspace
Clone Containers
Pipeline Containers
Services Containers
Networks Networks
Volumes Volumes
Labels types.SliceorMap
DependsOn []string `yaml:"depends_on,omitempty"`
RunsOn []string `yaml:"runs_on,omitempty"`
SkipClone bool `yaml:"skip_clone"`
}
// 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),
)
}