2017-03-05 07:56:08 +00:00
|
|
|
package yaml
|
|
|
|
|
|
|
|
import (
|
2023-04-29 12:49:41 +00:00
|
|
|
"codeberg.org/6543/xyaml"
|
2022-01-17 13:43:30 +00:00
|
|
|
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/constraint"
|
2021-10-30 15:52:02 +00:00
|
|
|
"github.com/woodpecker-ci/woodpecker/pipeline/frontend/yaml/types"
|
2017-03-05 07:56:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
// Config defines a pipeline configuration.
|
|
|
|
Config struct {
|
2022-09-26 07:27:20 +00:00
|
|
|
When constraint.When `yaml:"when,omitempty"`
|
2023-02-01 23:08:02 +00:00
|
|
|
Cache types.StringOrSlice
|
2017-03-05 07:56:08 +00:00
|
|
|
Platform string
|
|
|
|
Workspace Workspace
|
|
|
|
Clone Containers
|
|
|
|
Pipeline Containers
|
|
|
|
Services Containers
|
|
|
|
Networks Networks
|
|
|
|
Volumes Volumes
|
2021-10-30 15:52:02 +00:00
|
|
|
Labels types.SliceorMap
|
2019-06-12 09:03:59 +00:00
|
|
|
DependsOn []string `yaml:"depends_on,omitempty"`
|
2019-06-17 07:06:36 +00:00
|
|
|
RunsOn []string `yaml:"runs_on,omitempty"`
|
2019-06-24 09:19:12 +00:00
|
|
|
SkipClone bool `yaml:"skip_clone"`
|
2022-09-26 07:27:20 +00:00
|
|
|
// Deprecated use When.Branch
|
|
|
|
Branches constraint.List
|
2017-03-05 07:56:08 +00: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)
|
2023-04-29 12:49:41 +00:00
|
|
|
err := xyaml.Unmarshal(b, out)
|
2017-03-05 07:56:08 +00:00
|
|
|
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),
|
|
|
|
)
|
|
|
|
}
|