You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add kubeconform template for Kubernetes schema validation
This commit introduces a new kubeconform template that validates
Kubernetes resources against their schemas using the kubeconform library.
Features:
- Validates Kubernetes resources against official schemas
- Supports custom schema locations and Kubernetes versions
- Configurable strict mode for catching extra properties
- Can ignore missing schemas for CRDs
- Skip/reject specific resource kinds
- Schema caching support
Changes:
- Added kubeconform template with comprehensive parameter support
- Fixed godoc comments following Go conventions
- Added unit tests for template functionality
- Added e2e tests with sample valid and invalid resources
- Integrated template into kube-linter's template registry
- Updated documentation with template parameters
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/generated/templates.md
+58Lines changed: 58 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -445,6 +445,64 @@ KubeLinter supports the following templates:
445
445
**Supported Objects**: JobLike
446
446
447
447
448
+
## kubeconform
449
+
450
+
**Key**: `kubeconform`
451
+
452
+
**Description**: Flag objects that does not match schema using https://github.com/yannh/kubeconform
453
+
454
+
**Supported Objects**: Any
455
+
456
+
457
+
**Parameters**:
458
+
459
+
```yaml
460
+
- arrayElemType: string
461
+
description: 'SchemaLocations contains locations of schemas to use. See: https://github.com/yannh/kubeconform/tree/master?tab=readme-ov-file#overriding-schemas-location'
462
+
name: schemaLocations
463
+
negationAllowed: true
464
+
regexAllowed: false
465
+
required: false
466
+
type: array
467
+
- description: Cache specifies the folder to cache schemas downloaded via HTTP.
468
+
name: cache
469
+
negationAllowed: true
470
+
regexAllowed: false
471
+
required: false
472
+
type: string
473
+
- arrayElemType: string
474
+
description: SkipKinds lists resource kinds to ignore during validation.
475
+
name: skipKinds
476
+
negationAllowed: true
477
+
regexAllowed: false
478
+
required: false
479
+
type: array
480
+
- arrayElemType: string
481
+
description: RejectKinds lists resource kinds to reject during validation.
482
+
name: rejectKinds
483
+
negationAllowed: true
484
+
regexAllowed: false
485
+
required: false
486
+
type: array
487
+
- description: KubernetesVersion specifies the Kubernetes version - must match one
488
+
in https://github.com/instrumenta/kubernetes-json-schema
489
+
name: kubernetesVersion
490
+
negationAllowed: true
491
+
regexAllowed: false
492
+
required: false
493
+
type: string
494
+
- description: Strict enables strict validation that will error if resources contain
495
+
undocumented fields.
496
+
name: strict
497
+
required: false
498
+
type: boolean
499
+
- description: IgnoreMissingSchemas will skip validation for resources if no schema
// Params defines the configuration parameters for this template.
4
+
typeParamsstruct {
5
+
// SchemaLocations contains locations of schemas to use. See: https://github.com/yannh/kubeconform/tree/master?tab=readme-ov-file#overriding-schemas-location
6
+
// +noregex
7
+
SchemaLocations []string
8
+
// Cache specifies the folder to cache schemas downloaded via HTTP.
9
+
// +noregex
10
+
Cachestring
11
+
// SkipKinds lists resource kinds to ignore during validation.
12
+
// +noregex
13
+
SkipKinds []string
14
+
// RejectKinds lists resource kinds to reject during validation.
15
+
// +noregex
16
+
RejectKinds []string
17
+
// KubernetesVersion specifies the Kubernetes version - must match one in https://github.com/instrumenta/kubernetes-json-schema
18
+
// +noregex
19
+
KubernetesVersionstring
20
+
// Strict enables strict validation that will error if resources contain undocumented fields.
21
+
Strictbool
22
+
// IgnoreMissingSchemas will skip validation for resources if no schema can be found.
0 commit comments