-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstep_unknown.go
48 lines (39 loc) · 1.1 KB
/
step_unknown.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package pipeline
import (
"encoding/json"
"github.com/buildkite/go-pipeline/ordered"
)
// Compile-time check that *UnknownStep satisfies necessary interfaces
var _ interface {
Step
ordered.Unmarshaler
} = (*UnknownStep)(nil)
// UnknownStep models any step we don't know how to represent in this version.
// When future step types are added, they should be parsed with more specific
// types. UnknownStep is present to allow older parsers to preserve newer
// pipelines.
type UnknownStep struct {
Contents any
}
// MarshalJSON marshals the contents of the step.
func (u *UnknownStep) MarshalJSON() ([]byte, error) {
return json.Marshal(u.Contents)
}
// MarshalYAML returns the contents of the step.
func (u *UnknownStep) MarshalYAML() (any, error) {
return u.Contents, nil
}
// UnmarshalOrdered unmarshals an unknown step.
func (u *UnknownStep) UnmarshalOrdered(src any) error {
u.Contents = src
return nil
}
func (u *UnknownStep) interpolate(tf stringTransformer) error {
c, err := interpolateAny(tf, u.Contents)
if err != nil {
return err
}
u.Contents = c
return nil
}
func (UnknownStep) stepTag() {}