Commit d33b34f
Add comprehensive webhook validations for CRD configuration (#1762)
* Add validation webhook for appRepo fields
- Add appsRepoPollInterval validation:
- Default: 0 (disabled)
- Minimum: 0, Maximum: 86400 (1 day)
- Values between 1-59 are rejected (must be 0 or >= 60)
- Add appSources uniqueness validation:
- Location + Scope combination must be unique across appSources
- Uses defaults.scope when scope is not specified in appSource
- volumeName is NOT part of uniqueness check
- Add unit tests for all new validations
* Add premiumAppsProps validation for appSources
- Validate that premiumAppsProps.type is required when scope is 'premiumApps'
- Check both source-level and defaults-level premiumAppsProps.type
- Add unit tests for premiumAppsProps validation scenarios
* Add extraEnv uniqueness validation
- Validate that environment variable names in spec.extraEnv are unique
- Report duplicate names with reference to the first occurrence
- Add unit tests for extraEnv uniqueness validation
* Add imagePullSecrets uniqueness validation
- Validate that secret names in spec.imagePullSecrets are unique
- Report duplicate names with reference to the first occurrence
- Add unit tests for imagePullSecrets uniqueness validation
* Add probe fields validation
- Validate livenessProbe, readinessProbe, and startupProbe configurations
- initialDelaySeconds: minimum 0
- timeoutSeconds: minimum 1
- periodSeconds: minimum 1
- failureThreshold: minimum 1
- Add unit tests for probe validation scenarios
* Add resource requirements validation
- Validate that memory request does not exceed memory limit
- Validate that cpu request does not exceed cpu limit
- Add unit tests for resource requirements validation
* Add SmartStore validation for volumes and indexes
- Validate that indexes require at least one volume to be configured
- Validate that index volumeName references an existing volume in volumes list
- Validate that index has volumeName or defaults.volumeName provided
- Update and add unit tests for SmartStore validation
* Add StorageClassSpec ephemeralStorage mutual exclusivity validation
- Validate that ephemeralStorage is mutually exclusive with storageClassName
- Validate that ephemeralStorage is mutually exclusive with storageCapacity
- Add unit tests for ephemeralStorage mutual exclusivity scenarios
* feat(validation): add imagePullSecrets existence validation
- Add ValidationContext to carry Kubernetes client for resource lookups
- Extend Validator interface with context-aware validation methods
- Implement ValidateImagePullSecretsExistence to verify secrets exist
- Update all CRD validators with context-aware validation functions
- Pass manager client to webhook server for API access
- Update ValidationWebhook.md documentation with new validation rules
- Add unit tests for imagePullSecrets existence validation
This enables the webhook to reject CRs that reference non-existent
secrets in spec.imagePullSecrets, providing early feedback to users.
---------
Co-authored-by: Patryk Wasielewski <pwasiele@splunk.com>1 parent 80bafa5 commit d33b34f
15 files changed
Lines changed: 1341 additions & 44 deletions
File tree
- cmd
- docs
- pkg/splunk/enterprise/validation
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
| 306 | + | |
306 | 307 | | |
307 | 308 | | |
308 | 309 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
86 | 96 | | |
87 | 97 | | |
88 | 98 | | |
| |||
111 | 121 | | |
112 | 122 | | |
113 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
114 | 127 | | |
115 | 128 | | |
116 | 129 | | |
| |||
167 | 180 | | |
168 | 181 | | |
169 | 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 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
170 | 219 | | |
171 | 220 | | |
172 | 221 | | |
| |||
264 | 313 | | |
265 | 314 | | |
266 | 315 | | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
267 | 431 | | |
268 | 432 | | |
269 | 433 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
45 | 55 | | |
46 | 56 | | |
47 | 57 | | |
48 | 58 | | |
49 | 59 | | |
50 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
51 | 66 | | |
52 | 67 | | |
53 | 68 | | |
| |||
0 commit comments