mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-13 12:41:21 +00:00
204d05f447
close #1192
52 lines
1.1 KiB
Go
52 lines
1.1 KiB
Go
package yaml
|
|
|
|
import (
|
|
"codeberg.org/6543/xyaml"
|
|
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/constraint"
|
|
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types"
|
|
)
|
|
|
|
type (
|
|
// Config defines a pipeline configuration.
|
|
Config struct {
|
|
When constraint.When `yaml:"when,omitempty"`
|
|
Cache types.StringOrSlice
|
|
Platform string
|
|
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"`
|
|
// Deprecated use When.Branch
|
|
Branches constraint.List
|
|
}
|
|
|
|
// 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 := xyaml.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),
|
|
)
|
|
}
|