Skip to content

Commit 21d0228

Browse files
committed
api: add custom validation for v1.Duration types
Signed-off-by: Stefan Prodan <[email protected]>
1 parent 095c63d commit 21d0228

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

api/v1beta2/kustomization_types.go

+6
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,16 @@ type KustomizationSpec struct {
4747
Decryption *Decryption `json:"decryption,omitempty"`
4848

4949
// The interval at which to reconcile the Kustomization.
50+
// +kubebuilder:validation:Type=string
51+
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m|h))+$"
5052
// +required
5153
Interval metav1.Duration `json:"interval"`
5254

5355
// The interval at which to retry a previously failed reconciliation.
5456
// When not specified, the controller uses the KustomizationSpec.Interval
5557
// value to retry failures.
58+
// +kubebuilder:validation:Type=string
59+
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m|h))+$"
5660
// +optional
5761
RetryInterval *metav1.Duration `json:"retryInterval,omitempty"`
5862

@@ -130,6 +134,8 @@ type KustomizationSpec struct {
130134

131135
// Timeout for validation, apply and health checking operations.
132136
// Defaults to 'Interval' duration.
137+
// +kubebuilder:validation:Type=string
138+
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m))+$"
133139
// +optional
134140
Timeout *metav1.Duration `json:"timeout,omitempty"`
135141

config/crd/bases/kustomize.toolkit.fluxcd.io_kustomizations.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,7 @@ spec:
689689
type: array
690690
interval:
691691
description: The interval at which to reconcile the Kustomization.
692+
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$
692693
type: string
693694
kubeConfig:
694695
description: The KubeConfig for reconciling the Kustomization on a
@@ -928,6 +929,7 @@ spec:
928929
description: The interval at which to retry a previously failed reconciliation.
929930
When not specified, the controller uses the KustomizationSpec.Interval
930931
value to retry failures.
932+
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$
931933
type: string
932934
serviceAccountName:
933935
description: The name of the Kubernetes service account to impersonate
@@ -972,6 +974,7 @@ spec:
972974
timeout:
973975
description: Timeout for validation, apply and health checking operations.
974976
Defaults to 'Interval' duration.
977+
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$
975978
type: string
976979
validation:
977980
description: 'Deprecated: Not used in v1beta2.'

0 commit comments

Comments
 (0)