This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
/
branch.go
108 lines (87 loc) · 2.51 KB
/
branch.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package v1alpha1
import (
"bytes"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"
"github.com/golang/protobuf/jsonpb"
)
type Error struct {
*core.Error
}
func (in Error) UnmarshalJSON(b []byte) error {
in.Error = &core.Error{}
return jsonpb.Unmarshal(bytes.NewReader(b), in.Error)
}
func (in Error) MarshalJSON() ([]byte, error) {
if in.Error == nil {
return nilJSON, nil
}
var buf bytes.Buffer
if err := marshaler.Marshal(&buf, in.Error); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Error) DeepCopyInto(out *Error) {
*out = *in
// We do not manipulate the object, so its ok
// Once we figure out the autogenerate story we can replace this
}
type BooleanExpression struct {
*core.BooleanExpression
}
func (in BooleanExpression) MarshalJSON() ([]byte, error) {
if in.BooleanExpression == nil {
return nilJSON, nil
}
var buf bytes.Buffer
if err := marshaler.Marshal(&buf, in.BooleanExpression); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func (in *BooleanExpression) UnmarshalJSON(b []byte) error {
in.BooleanExpression = &core.BooleanExpression{}
return jsonpb.Unmarshal(bytes.NewReader(b), in.BooleanExpression)
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *BooleanExpression) DeepCopyInto(out *BooleanExpression) {
*out = *in
// We do not manipulate the object, so its ok
// Once we figure out the autogenerate story we can replace this
}
type IfBlock struct {
Condition BooleanExpression `json:"condition"`
ThenNode *NodeID `json:"then"`
}
func (in IfBlock) GetCondition() *core.BooleanExpression {
return in.Condition.BooleanExpression
}
func (in *IfBlock) GetThenNode() *NodeID {
return in.ThenNode
}
type BranchNodeSpec struct {
If IfBlock `json:"if"`
ElseIf []*IfBlock `json:"elseIf,omitempty"`
Else *NodeID `json:"else,omitempty"`
ElseFail *Error `json:"elseFail,omitempty"`
}
func (in *BranchNodeSpec) GetIf() ExecutableIfBlock {
return &in.If
}
func (in *BranchNodeSpec) GetElse() *NodeID {
return in.Else
}
func (in *BranchNodeSpec) GetElseIf() []ExecutableIfBlock {
elifs := make([]ExecutableIfBlock, 0, len(in.ElseIf))
for _, b := range in.ElseIf {
elifs = append(elifs, b)
}
return elifs
}
func (in *BranchNodeSpec) GetElseFail() *core.Error {
if in.ElseFail != nil {
return in.ElseFail.Error
}
return nil
}