-
Notifications
You must be signed in to change notification settings - Fork 155
Description
This issue is similar to #300
Summary
Kubernetes API machinery allows duration fields to be specified using either:
- Go
time.ParseDurationformat, or - Scala duration format
duration: a duration string like "22 ns" as parsed by Golang time.ParseDuration or compatible with Scala duration format
However, kubeconform only accepts:
- Go
time.ParseDurationformat, and - ISO 8601 duration format
See:
kubeconform/pkg/validator/validator.go
Lines 288 to 292 in e608924
| // validateDuration is a custom validator for the duration format | |
| // as JSONSchema only supports the ISO 8601 format, i.e. `PT1H30M`, | |
| // while Kubernetes API machinery expects the Go duration format, i.e. `1h30m` | |
| // which is commonly used in Kubernetes operators for specifying intervals. | |
| // https://github.com/kubernetes/apiextensions-apiserver/blob/1ecd29f74da0639e2e6e3b8fac0c9bfd217e05eb/pkg/apis/apiextensions/v1/types_jsonschema.go#L71 |
Issue
Because kubeconform does not support Scala duration format, values that are valid in Kubernetes — such as 2w (2 weeks) — are incorrectly treated as invalid by kubeconform.
Examples of valid Kubernetes durations rejected by kubeconform:
2w3d1h30m- Values valid under Scala duration rules but not under Go's
time.ParseDuration
Expected Behavior
kubeconform should accept all duration formats that Kubernetes itself considers valid, including Scala duration format.
Actual Behavior
Duration values valid in Kubernetes but formatted according to Scala duration rules are rejected as invalid during validation.