From 456b48a9094f7f3f8690d2444a858faf0b824f7a Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Tue, 20 Sep 2022 12:08:08 +0300 Subject: [PATCH] api: add custom validation for v1.Duration types Signed-off-by: Stefan Prodan --- api/v1beta1/imageupdateautomation_types.go | 2 ++ .../bases/image.toolkit.fluxcd.io_imageupdateautomations.yaml | 1 + 2 files changed, 3 insertions(+) diff --git a/api/v1beta1/imageupdateautomation_types.go b/api/v1beta1/imageupdateautomation_types.go index 3c1c67a..d926aa9 100644 --- a/api/v1beta1/imageupdateautomation_types.go +++ b/api/v1beta1/imageupdateautomation_types.go @@ -44,6 +44,8 @@ type ImageUpdateAutomationSpec struct { // Interval gives an lower bound for how often the automation // run should be attempted. + // +kubebuilder:validation:Type=string + // +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m|h))+$" // +required Interval metav1.Duration `json:"interval"` diff --git a/config/crd/bases/image.toolkit.fluxcd.io_imageupdateautomations.yaml b/config/crd/bases/image.toolkit.fluxcd.io_imageupdateautomations.yaml index bfac7df..34f0aa4 100644 --- a/config/crd/bases/image.toolkit.fluxcd.io_imageupdateautomations.yaml +++ b/config/crd/bases/image.toolkit.fluxcd.io_imageupdateautomations.yaml @@ -648,6 +648,7 @@ spec: interval: description: Interval gives an lower bound for how often the automation run should be attempted. + pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$ type: string sourceRef: description: SourceRef refers to the resource giving access details