-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstep_wait.go
41 lines (34 loc) · 977 Bytes
/
step_wait.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
package pipeline
import "encoding/json"
// See the comment in step_scalar.go.
// WaitStep models a wait step.
//
// Standard caveats apply - see the package comment.
type WaitStep struct {
Scalar string `yaml:"-"`
Contents map[string]any `yaml:",inline"`
}
// MarshalJSON marshals a wait step as "wait" if the step is empty, or as the
// s.Scalar if it is not empty, or as s.Contents.
func (s *WaitStep) MarshalJSON() ([]byte, error) {
o, err := s.MarshalYAML()
if err != nil {
return nil, err
}
return json.Marshal(o)
}
// MarshalYAML returns a wait step as "wait" if the step is empty, or as the
// s.Scalar if it is not empty, or as s.Contents.
func (s *WaitStep) MarshalYAML() (any, error) {
if s.Scalar != "" {
return s.Scalar, nil
}
if len(s.Contents) == 0 {
return "wait", nil
}
return s.Contents, nil
}
func (s *WaitStep) interpolate(tf stringTransformer) error {
return interpolateMap(tf, s.Contents)
}
func (*WaitStep) stepTag() {}