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
/
gate.go
106 lines (84 loc) · 2.35 KB
/
gate.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
package v1alpha1
import (
"bytes"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/core"
"github.com/golang/protobuf/jsonpb"
)
type ConditionKind string
func (n ConditionKind) String() string {
return string(n)
}
const (
ConditionKindApprove ConditionKind = "approve"
ConditionKindSignal ConditionKind = "signal"
ConditionKindSleep ConditionKind = "sleep"
)
type ApproveCondition struct {
*core.ApproveCondition
}
func (in ApproveCondition) MarshalJSON() ([]byte, error) {
if in.ApproveCondition == nil {
return nilJSON, nil
}
var buf bytes.Buffer
if err := marshaler.Marshal(&buf, in.ApproveCondition); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func (in *ApproveCondition) UnmarshalJSON(b []byte) error {
in.ApproveCondition = &core.ApproveCondition{}
return jsonpb.Unmarshal(bytes.NewReader(b), in.ApproveCondition)
}
type SignalCondition struct {
*core.SignalCondition
}
func (in SignalCondition) MarshalJSON() ([]byte, error) {
if in.SignalCondition == nil {
return nilJSON, nil
}
var buf bytes.Buffer
if err := marshaler.Marshal(&buf, in.SignalCondition); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func (in *SignalCondition) UnmarshalJSON(b []byte) error {
in.SignalCondition = &core.SignalCondition{}
return jsonpb.Unmarshal(bytes.NewReader(b), in.SignalCondition)
}
type SleepCondition struct {
*core.SleepCondition
}
func (in SleepCondition) MarshalJSON() ([]byte, error) {
if in.SleepCondition == nil {
return nilJSON, nil
}
var buf bytes.Buffer
if err := marshaler.Marshal(&buf, in.SleepCondition); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func (in *SleepCondition) UnmarshalJSON(b []byte) error {
in.SleepCondition = &core.SleepCondition{}
return jsonpb.Unmarshal(bytes.NewReader(b), in.SleepCondition)
}
type GateNodeSpec struct {
Kind ConditionKind `json:"kind"`
Approve *ApproveCondition `json:"approve,omitempty"`
Signal *SignalCondition `json:"signal,omitempty"`
Sleep *SleepCondition `json:"sleep,omitempty"`
}
func (g *GateNodeSpec) GetKind() ConditionKind {
return g.Kind
}
func (g *GateNodeSpec) GetApprove() *core.ApproveCondition {
return g.Approve.ApproveCondition
}
func (g *GateNodeSpec) GetSignal() *core.SignalCondition {
return g.Signal.SignalCondition
}
func (g *GateNodeSpec) GetSleep() *core.SleepCondition {
return g.Sleep.SleepCondition
}