mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-11 19:16:32 +00:00
43 lines
762 B
Go
43 lines
762 B
Go
|
package parse
|
||
|
|
||
|
// BuildNode represents Docker image build instructions.
|
||
|
type BuildNode struct {
|
||
|
NodeType
|
||
|
|
||
|
Context string
|
||
|
Dockerfile string
|
||
|
Args map[string]string
|
||
|
|
||
|
root *RootNode
|
||
|
}
|
||
|
|
||
|
// Root returns the root node.
|
||
|
func (n *BuildNode) Root() *RootNode { return n.root }
|
||
|
|
||
|
//
|
||
|
// intermediate types for yaml decoding.
|
||
|
//
|
||
|
|
||
|
type build struct {
|
||
|
Context string
|
||
|
Dockerfile string
|
||
|
Args map[string]string
|
||
|
}
|
||
|
|
||
|
func (b *build) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
||
|
err := unmarshal(&b.Context)
|
||
|
if err == nil {
|
||
|
return nil
|
||
|
}
|
||
|
out := struct {
|
||
|
Context string
|
||
|
Dockerfile string
|
||
|
Args map[string]string
|
||
|
}{}
|
||
|
err = unmarshal(&out)
|
||
|
b.Context = out.Context
|
||
|
b.Args = out.Args
|
||
|
b.Dockerfile = out.Dockerfile
|
||
|
return err
|
||
|
}
|