Skip to content

Commit 54aee36

Browse files
committed
api: add custom validation for v1.Duration types
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
1 parent 8805f90 commit 54aee36

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

api/v2beta1/helmrelease_types.go

+16
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ type HelmReleaseSpec struct {
7070
Chart HelmChartTemplate `json:"chart"`
7171

7272
// Interval at which to reconcile the Helm release.
73+
// +kubebuilder:validation:Type=string
74+
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m|h))+$"
7375
// +required
7476
Interval metav1.Duration `json:"interval"`
7577

@@ -120,6 +122,8 @@ type HelmReleaseSpec struct {
120122

121123
// Timeout is the time to wait for any individual Kubernetes operation (like Jobs
122124
// for hooks) during the performance of a Helm action. Defaults to '5m0s'.
125+
// +kubebuilder:validation:Type=string
126+
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m))+$"
123127
// +optional
124128
Timeout *metav1.Duration `json:"timeout,omitempty"`
125129

@@ -254,6 +258,8 @@ type HelmChartTemplateSpec struct {
254258

255259
// Interval at which to check the v1beta2.Source for updates. Defaults to
256260
// 'HelmReleaseSpec.Interval'.
261+
// +kubebuilder:validation:Type=string
262+
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m|h))+$"
257263
// +optional
258264
Interval *metav1.Duration `json:"interval,omitempty"`
259265

@@ -326,6 +332,8 @@ type Install struct {
326332
// Timeout is the time to wait for any individual Kubernetes operation (like
327333
// Jobs for hooks) during the performance of a Helm install action. Defaults to
328334
// 'HelmReleaseSpec.Timeout'.
335+
// +kubebuilder:validation:Type=string
336+
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m))+$"
329337
// +optional
330338
Timeout *metav1.Duration `json:"timeout,omitempty"`
331339

@@ -502,6 +510,8 @@ type Upgrade struct {
502510
// Timeout is the time to wait for any individual Kubernetes operation (like
503511
// Jobs for hooks) during the performance of a Helm upgrade action. Defaults to
504512
// 'HelmReleaseSpec.Timeout'.
513+
// +kubebuilder:validation:Type=string
514+
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m))+$"
505515
// +optional
506516
Timeout *metav1.Duration `json:"timeout,omitempty"`
507517

@@ -683,6 +693,8 @@ type Test struct {
683693

684694
// Timeout is the time to wait for any individual Kubernetes operation during
685695
// the performance of a Helm test action. Defaults to 'HelmReleaseSpec.Timeout'.
696+
// +kubebuilder:validation:Type=string
697+
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m))+$"
686698
// +optional
687699
Timeout *metav1.Duration `json:"timeout,omitempty"`
688700

@@ -708,6 +720,8 @@ type Rollback struct {
708720
// Timeout is the time to wait for any individual Kubernetes operation (like
709721
// Jobs for hooks) during the performance of a Helm rollback action. Defaults to
710722
// 'HelmReleaseSpec.Timeout'.
723+
// +kubebuilder:validation:Type=string
724+
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m))+$"
711725
// +optional
712726
Timeout *metav1.Duration `json:"timeout,omitempty"`
713727

@@ -754,6 +768,8 @@ type Uninstall struct {
754768
// Timeout is the time to wait for any individual Kubernetes operation (like
755769
// Jobs for hooks) during the performance of a Helm uninstall action. Defaults
756770
// to 'HelmReleaseSpec.Timeout'.
771+
// +kubebuilder:validation:Type=string
772+
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m))+$"
757773
// +optional
758774
Timeout *metav1.Duration `json:"timeout,omitempty"`
759775

config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ spec:
6363
interval:
6464
description: Interval at which to check the v1beta2.Source
6565
for updates. Defaults to 'HelmReleaseSpec.Interval'.
66+
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$
6667
type: string
6768
reconcileStrategy:
6869
default: ChartVersion
@@ -230,10 +231,12 @@ spec:
230231
description: Timeout is the time to wait for any individual Kubernetes
231232
operation (like Jobs for hooks) during the performance of a
232233
Helm install action. Defaults to 'HelmReleaseSpec.Timeout'.
234+
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$
233235
type: string
234236
type: object
235237
interval:
236238
description: Interval at which to reconcile the Helm release.
239+
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$
237240
type: string
238241
kubeConfig:
239242
description: KubeConfig for reconciling the HelmRelease on a remote
@@ -505,6 +508,7 @@ spec:
505508
description: Timeout is the time to wait for any individual Kubernetes
506509
operation (like Jobs for hooks) during the performance of a
507510
Helm rollback action. Defaults to 'HelmReleaseSpec.Timeout'.
511+
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$
508512
type: string
509513
type: object
510514
serviceAccountName:
@@ -546,12 +550,14 @@ spec:
546550
description: Timeout is the time to wait for any individual Kubernetes
547551
operation during the performance of a Helm test action. Defaults
548552
to 'HelmReleaseSpec.Timeout'.
553+
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$
549554
type: string
550555
type: object
551556
timeout:
552557
description: Timeout is the time to wait for any individual Kubernetes
553558
operation (like Jobs for hooks) during the performance of a Helm
554559
action. Defaults to '5m0s'.
560+
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$
555561
type: string
556562
uninstall:
557563
description: Uninstall holds the configuration for Helm uninstall
@@ -573,6 +579,7 @@ spec:
573579
description: Timeout is the time to wait for any individual Kubernetes
574580
operation (like Jobs for hooks) during the performance of a
575581
Helm uninstall action. Defaults to 'HelmReleaseSpec.Timeout'.
582+
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$
576583
type: string
577584
type: object
578585
upgrade:
@@ -659,6 +666,7 @@ spec:
659666
description: Timeout is the time to wait for any individual Kubernetes
660667
operation (like Jobs for hooks) during the performance of a
661668
Helm upgrade action. Defaults to 'HelmReleaseSpec.Timeout'.
669+
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$
662670
type: string
663671
type: object
664672
values:

0 commit comments

Comments
 (0)