forked from servicemeshinterface/smi-controller-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathv1Alpha_specs.go
More file actions
207 lines (174 loc) · 4.93 KB
/
v1Alpha_specs.go
File metadata and controls
207 lines (174 loc) · 4.93 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
package sdk
import (
"context"
"github.com/go-logr/logr"
specsv1alpha4 "github.com/servicemeshinterface/smi-controller-sdk/apis/specs/v1alpha4"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
)
// V1AlphaSpec defines an interface containing callback methods for the v1alpha4 API
// traffic access objects
type v1AlphaSpecs interface {
UpsertHTTPRouteGroup
DeleteHTTPRouteGroup
UpsertTCPRoute
DeleteTCPRoute
UpsertUDPRoute
DeleteUDPRoute
}
// UpsertHTTPRouteGroup defines a callback function for updating or
// inserting a new HTTPRouteGroup
type UpsertHTTPRouteGroup interface {
UpsertHTTPRouteGroup(
ctx context.Context,
r client.Client,
l logr.Logger,
rg *specsv1alpha4.HTTPRouteGroup) (ctrl.Result, error)
}
// DeleteHTTPRouteGroup defines a callback function for deleting
// a new HTTPRouteGroup
type DeleteHTTPRouteGroup interface {
DeleteHTTPRouteGroup(
ctx context.Context,
r client.Client,
l logr.Logger,
tr *specsv1alpha4.HTTPRouteGroup) (ctrl.Result, error)
}
// UpsertTCPRoute defines a callback function for updating or
// inserting a new TCPRoute
type UpsertTCPRoute interface {
UpsertTCPRoute(
ctx context.Context,
r client.Client,
l logr.Logger,
tr *specsv1alpha4.TCPRoute) (ctrl.Result, error)
}
// DeleteTCPRoute defines a callback function for deleting
// a new TCPRoute
type DeleteTCPRoute interface {
DeleteTCPRoute(
ctx context.Context,
r client.Client,
l logr.Logger,
rg *specsv1alpha4.TCPRoute) (ctrl.Result, error)
}
// UpsertUDPRoute defines a callback function for updating or
// inserting a new UDPRoute
type UpsertUDPRoute interface {
UpsertUDPRoute(
ctx context.Context,
r client.Client,
l logr.Logger,
tr *specsv1alpha4.UDPRoute) (ctrl.Result, error)
}
// DeleteTCPRoute defines a callback function for deleting
// a new TCPRoute
type DeleteUDPRoute interface {
DeleteUDPRoute(
ctx context.Context,
r client.Client,
l logr.Logger,
rg *specsv1alpha4.UDPRoute) (ctrl.Result, error)
}
// UpsertHTTPRouteGroup will call the user defined UpsertHTTPRouteGroup callback
// when defined
func (a *v1AlphaImpl) UpsertHTTPRouteGroup(
ctx context.Context,
r client.Client,
l logr.Logger,
rg *specsv1alpha4.HTTPRouteGroup,
) (ctrl.Result, error) {
// does the user api have this callback?
v, ok := a.userV1alpha.(UpsertHTTPRouteGroup)
if !ok {
l.Info("Client code does not implement UpsertHTTPRouteGroup")
return ctrl.Result{}, nil
}
// call the interface method
return v.UpsertHTTPRouteGroup(ctx, r, l, rg)
}
// DeleteHTTPRouteGroup will call the user defined DeleteHTTPRouteGroup callback
// when defined
func (a *v1AlphaImpl) DeleteHTTPRouteGroup(
ctx context.Context,
r client.Client,
l logr.Logger,
rg *specsv1alpha4.HTTPRouteGroup,
) (ctrl.Result, error) {
// does the user api have this callback?
v, ok := a.userV1alpha.(DeleteHTTPRouteGroup)
if !ok {
l.Info("Client code does not implement DeleteTrafficTarget")
return ctrl.Result{}, nil
}
// call the interface method
return v.DeleteHTTPRouteGroup(ctx, r, l, rg)
}
// UpsertTCPRoute will call the user defined UpsertTCPRoute callback
// when defined
func (a *v1AlphaImpl) UpsertTCPRoute(
ctx context.Context,
r client.Client,
l logr.Logger,
tr *specsv1alpha4.TCPRoute,
) (ctrl.Result, error) {
// does the user api have this callback?
v, ok := a.userV1alpha.(UpsertTCPRoute)
if !ok {
l.Info("Client code does not implement UpsertTCPRoute")
return ctrl.Result{}, nil
}
// call the interface method
return v.UpsertTCPRoute(ctx, r, l, tr)
}
// DeleteTCPRoute will call the user defined DeleteTCPRoute callback
// when defined
func (a *v1AlphaImpl) DeleteTCPRoute(
ctx context.Context,
r client.Client,
l logr.Logger,
tr *specsv1alpha4.TCPRoute,
) (ctrl.Result, error) {
// does the user api have this callback?
v, ok := a.userV1alpha.(DeleteTCPRoute)
if !ok {
l.Info("Client code does not implement DeleteTCPRoute")
return ctrl.Result{}, nil
}
// call the interface method
return v.DeleteTCPRoute(ctx, r, l, tr)
}
// UpsertTCPRoute will call the user defined UpsertTCPRoute callback
// when defined
func (a *v1AlphaImpl) UpsertUDPRoute(
ctx context.Context,
r client.Client,
l logr.Logger,
ur *specsv1alpha4.UDPRoute,
) (ctrl.Result, error) {
// does the user api have this callback?
v, ok := a.userV1alpha.(UpsertUDPRoute)
if !ok {
l.Info("Client code does not implement UpsertUDPRoute")
return ctrl.Result{}, nil
}
// call the interface method
return v.UpsertUDPRoute(ctx, r, l, ur)
}
// DeleteUDPRoute will call the user defined DeleteUDPRoute callback
// when defined
func (a *v1AlphaImpl) DeleteUDPRoute(
ctx context.Context,
r client.Client,
l logr.Logger,
ur *specsv1alpha4.UDPRoute,
) (ctrl.Result, error) {
// does the user api have this callback?
v, ok := a.userV1alpha.(DeleteUDPRoute)
if !ok {
l.Info("Client code does not implement DeleteUDPRoute")
return ctrl.Result{}, nil
}
// call the interface method
return v.DeleteUDPRoute(ctx, r, l, ur)
}