@@ -40,17 +40,28 @@ type TCPService struct {
40
40
}
41
41
42
42
type SectionFrontend struct {
43
- models.Frontend `json:",inline"`
44
- Binds []* models.Bind `json:"binds"`
43
+ models.Frontend `json:",inline"`
44
+ Acls models.Acls `json:"acl_list,omitempty"`
45
+ Binds []* models.Bind `json:"binds"`
46
+ BackendSwitchingRules models.BackendSwitchingRules `json:"backend_switching_rule_list,omitempty"`
47
+ Captures models.Captures `json:"capture_list,omitempty"`
48
+ Filters models.Filters `json:"filter_list,omitempty"`
49
+ LogTargets models.LogTargets `json:"log_target_list,omitempty"`
50
+ TCPRequestRules models.TCPRequestRules `json:"tcp_request_rule_list,omitempty"`
45
51
}
46
52
47
53
type TCPModel struct {
48
54
// +kubebuilder:validation:Required
49
55
Name string `json:"name"`
50
56
Frontend SectionFrontend `json:"frontend"`
51
- Service TCPService `json:"service"`
57
+ // Service defines the name of the default service (default_backend)
58
+ Service TCPService `json:"service"`
59
+ // Services defines additional services for additional backends
60
+ Services TCPServices `json:"services,omitempty"`
52
61
}
53
62
63
+ type TCPServices []* TCPService
64
+
54
65
// TCPSpec defines the desired state of a TCPService
55
66
type TCPSpec []TCPModel
56
67
@@ -60,6 +71,10 @@ func (a *TCPModel) DeepCopyInto(out *TCPModel) {
60
71
a .Frontend .DeepCopyInto (& out .Frontend )
61
72
s , _ := a .Service .MarshalBinary ()
62
73
_ = out .Service .UnmarshalBinary (s )
74
+
75
+ if a .Services != nil {
76
+ a .Services .DeepCopyInto (& out .Services )
77
+ }
63
78
}
64
79
65
80
func (a * SectionFrontend ) DeepCopyInto (out * SectionFrontend ) {
@@ -75,6 +90,60 @@ func (a *SectionFrontend) DeepCopyInto(out *SectionFrontend) {
75
90
_ = out .Binds [i ].UnmarshalBinary (b )
76
91
}
77
92
}
93
+
94
+ if a .Acls != nil {
95
+ out .Acls = make (models.Acls , len (a .Acls ))
96
+ for i , v := range a .Acls {
97
+ b , _ := v .MarshalBinary ()
98
+ out .Acls [i ] = & models.ACL {}
99
+ _ = out .Acls [i ].UnmarshalBinary (b )
100
+ }
101
+ }
102
+
103
+ if len (a .BackendSwitchingRules ) > 0 {
104
+ out .BackendSwitchingRules = make ([]* models.BackendSwitchingRule , len (a .BackendSwitchingRules ))
105
+ for i , v := range a .BackendSwitchingRules {
106
+ b , _ := v .MarshalBinary ()
107
+ out .BackendSwitchingRules [i ] = & models.BackendSwitchingRule {}
108
+ _ = out .BackendSwitchingRules [i ].UnmarshalBinary (b )
109
+ }
110
+ }
111
+
112
+ if len (a .Captures ) > 0 {
113
+ out .Captures = make ([]* models.Capture , len (a .Captures ))
114
+ for i , v := range a .Captures {
115
+ b , _ := v .MarshalBinary ()
116
+ out .Captures [i ] = & models.Capture {}
117
+ _ = out .Captures [i ].UnmarshalBinary (b )
118
+ }
119
+ }
120
+
121
+ if len (a .Filters ) > 0 {
122
+ out .Filters = make ([]* models.Filter , len (a .Filters ))
123
+ for i , v := range a .Filters {
124
+ b , _ := v .MarshalBinary ()
125
+ out .Filters [i ] = & models.Filter {}
126
+ _ = out .Filters [i ].UnmarshalBinary (b )
127
+ }
128
+ }
129
+
130
+ if len (a .LogTargets ) > 0 {
131
+ out .LogTargets = make ([]* models.LogTarget , len (a .LogTargets ))
132
+ for i , v := range a .LogTargets {
133
+ b , _ := v .MarshalBinary ()
134
+ out .LogTargets [i ] = & models.LogTarget {}
135
+ _ = out .LogTargets [i ].UnmarshalBinary (b )
136
+ }
137
+ }
138
+
139
+ if len (a .TCPRequestRules ) > 0 {
140
+ out .TCPRequestRules = make ([]* models.TCPRequestRule , len (a .TCPRequestRules ))
141
+ for i , v := range a .TCPRequestRules {
142
+ b , _ := v .MarshalBinary ()
143
+ out .TCPRequestRules [i ] = & models.TCPRequestRule {}
144
+ _ = out .TCPRequestRules [i ].UnmarshalBinary (b )
145
+ }
146
+ }
78
147
}
79
148
80
149
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
@@ -120,15 +189,76 @@ func (a TCPModel) Equal(b TCPModel, opt ...models.Options) bool {
120
189
return false
121
190
}
122
191
for i , value := range a .Frontend .Binds {
123
- if ! value .Equal (* b .Frontend .Binds [i ], opt ... ) {
192
+ if (value == nil && b .Frontend .Binds [i ] != nil ) || (value != nil && b .Frontend .Binds [i ] == nil ) {
193
+ return false
194
+ }
195
+ if value != nil &&
196
+ b .Frontend .Binds [i ] != nil &&
197
+ ! value .Equal (* b .Frontend .Binds [i ], opt ... ) {
124
198
return false
125
199
}
126
200
}
127
201
}
128
202
203
+ if ! a .Frontend .Acls .Equal (b .Frontend .Acls , models.Options {
204
+ NilSameAsEmpty : true ,
205
+ }) {
206
+ return false
207
+ }
208
+
209
+ if ! a .Frontend .BackendSwitchingRules .Equal (b .Frontend .BackendSwitchingRules , models.Options {
210
+ NilSameAsEmpty : true ,
211
+ }) {
212
+ return false
213
+ }
214
+
215
+ if ! a .Frontend .Captures .Equal (b .Frontend .Captures , models.Options {
216
+ NilSameAsEmpty : true ,
217
+ }) {
218
+ return false
219
+ }
220
+
221
+ if ! a .Frontend .Filters .Equal (b .Frontend .Filters , models.Options {
222
+ NilSameAsEmpty : true ,
223
+ }) {
224
+ return false
225
+ }
226
+
227
+ if ! a .Frontend .LogTargets .Equal (b .Frontend .LogTargets , models.Options {
228
+ NilSameAsEmpty : true ,
229
+ }) {
230
+ return false
231
+ }
232
+
233
+ if ! a .Frontend .TCPRequestRules .Equal (b .Frontend .TCPRequestRules , models.Options {
234
+ NilSameAsEmpty : true ,
235
+ }) {
236
+ return false
237
+ }
238
+
129
239
if ! a .Service .Equal (b .Service , opt ... ) {
130
240
return false
131
241
}
242
+
243
+ if (a .Services == nil && b .Services != nil ) || (a .Services != nil && b .Services == nil ) {
244
+ return false
245
+ }
246
+ if a .Services != nil && b .Services != nil {
247
+ if len (a .Services ) != len (b .Services ) {
248
+ return false
249
+ }
250
+ for i , value := range a .Services {
251
+ if (value == nil && b .Services [i ] != nil ) || (value != nil && b .Services [i ] == nil ) {
252
+ return false
253
+ }
254
+ if value != nil &&
255
+ b .Services [i ] != nil &&
256
+ ! value .Equal (* b .Services [i ], opt ... ) {
257
+ return false
258
+ }
259
+ }
260
+ }
261
+
132
262
return true
133
263
}
134
264
0 commit comments