@@ -17,7 +17,6 @@ limitations under the License.
17
17
package v1alpha1
18
18
19
19
import (
20
- "fmt"
21
20
"reflect"
22
21
23
22
"github.com/go-logr/logr"
@@ -145,17 +144,6 @@ type LimitadorList struct {
145
144
// +kubebuilder:validation:Enum=NONE;DRAFT_VERSION_03
146
145
type RateLimitHeadersType string
147
146
148
- // StorageType defines the valid options for storage
149
- // +kubebuilder:validation:Enum=memory;redis;redis_cached;disk
150
- type StorageType string
151
-
152
- const (
153
- StorageTypeInMemory StorageType = "memory"
154
- StorageTypeRedis StorageType = "redis"
155
- StorageTypeRedisCached StorageType = "redis_cached"
156
- StorageTypeDisk StorageType = "disk"
157
- )
158
-
159
147
// Storage contains the options for Limitador counters database or in-memory data storage
160
148
type Storage struct {
161
149
// +optional
@@ -168,47 +156,6 @@ type Storage struct {
168
156
Disk * DiskSpec `json:"disk,omitempty"`
169
157
}
170
158
171
- func (s * Storage ) Validate () bool {
172
- return s .Redis != nil && s .Redis .ConfigSecretRef != nil ||
173
- s .RedisCached != nil && s .RedisCached .ConfigSecretRef != nil
174
- }
175
-
176
- func (s * Storage ) SecretRef () * corev1.ObjectReference {
177
- if s .Redis != nil {
178
- return s .Redis .ConfigSecretRef
179
- }
180
- return s .RedisCached .ConfigSecretRef
181
- }
182
-
183
- func (s * Storage ) Config (url string ) []string {
184
- if s .Redis != nil {
185
- return []string {string (StorageTypeRedis ), url }
186
- }
187
-
188
- if s .RedisCached != nil {
189
- params := []string {string (StorageTypeRedisCached ), url }
190
-
191
- if s .RedisCached .Options != nil {
192
- options := reflect .ValueOf (* s .RedisCached .Options )
193
- typesOf := options .Type ()
194
- for i := 0 ; i < options .NumField (); i ++ {
195
- if ! options .Field (i ).IsNil () {
196
- var value interface {} = options .Field (i ).Elem ()
197
- params = append (
198
- params ,
199
- fmt .Sprintf (
200
- "--%s %d" ,
201
- helpers .ToKebabCase (typesOf .Field (i ).Name ),
202
- value ))
203
- }
204
- }
205
- }
206
- return params
207
- }
208
-
209
- return []string {string (StorageTypeInMemory )}
210
- }
211
-
212
159
type Redis struct {
213
160
// +ConfigSecretRef refers to the secret holding the URL for Redis.
214
161
// +optional
@@ -331,6 +278,21 @@ type Ports struct {
331
278
GRPC int32 `json:"grpc,omitempty"`
332
279
}
333
280
281
+ type PodDisruptionBudgetType struct {
282
+ // An eviction is allowed if at most "maxUnavailable" limitador pods
283
+ // are unavailable after the eviction, i.e. even in absence of
284
+ // the evicted pod. For example, one can prevent all voluntary evictions
285
+ // by specifying 0. This is a mutually exclusive setting with "minAvailable".
286
+ // +optional
287
+ MaxUnavailable * intstr.IntOrString `json:"maxUnavailable,omitempty"`
288
+ // An eviction is allowed if at least "minAvailable" limitador pods will
289
+ // still be available after the eviction, i.e. even in the absence of
290
+ // the evicted pod. So for example you can prevent all voluntary
291
+ // evictions by specifying "100%".
292
+ // +optional
293
+ MinAvailable * intstr.IntOrString `json:"minAvailable,omitempty"`
294
+ }
295
+
334
296
func (s * LimitadorStatus ) Equals (other * LimitadorStatus , logger logr.Logger ) bool {
335
297
if s .ObservedGeneration != other .ObservedGeneration {
336
298
diff := cmp .Diff (s .ObservedGeneration , other .ObservedGeneration )
@@ -359,18 +321,3 @@ func (s *LimitadorStatus) Equals(other *LimitadorStatus, logger logr.Logger) boo
359
321
func init () {
360
322
SchemeBuilder .Register (& Limitador {}, & LimitadorList {})
361
323
}
362
-
363
- type PodDisruptionBudgetType struct {
364
- // An eviction is allowed if at most "maxUnavailable" limitador pods
365
- // are unavailable after the eviction, i.e. even in absence of
366
- // the evicted pod. For example, one can prevent all voluntary evictions
367
- // by specifying 0. This is a mutually exclusive setting with "minAvailable".
368
- // +optional
369
- MaxUnavailable * intstr.IntOrString `json:"maxUnavailable,omitempty"`
370
- // An eviction is allowed if at least "minAvailable" limitador pods will
371
- // still be available after the eviction, i.e. even in the absence of
372
- // the evicted pod. So for example you can prevent all voluntary
373
- // evictions by specifying "100%".
374
- // +optional
375
- MinAvailable * intstr.IntOrString `json:"minAvailable,omitempty"`
376
- }
0 commit comments