Skip to content

Commit

Permalink
Merge pull request #731 from fluxcd/api-validate-duration
Browse files Browse the repository at this point in the history
api: add custom validation for v1.Duration types
  • Loading branch information
stefanprodan authored Sep 20, 2022
2 parents 095c63d + 21d0228 commit 503686e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/v1beta2/kustomization_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ type KustomizationSpec struct {
Decryption *Decryption `json:"decryption,omitempty"`

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

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

Expand Down Expand Up @@ -130,6 +134,8 @@ type KustomizationSpec struct {

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ spec:
type: array
interval:
description: The interval at which to reconcile the Kustomization.
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$
type: string
kubeConfig:
description: The KubeConfig for reconciling the Kustomization on a
Expand Down Expand Up @@ -928,6 +929,7 @@ spec:
description: The interval at which to retry a previously failed reconciliation.
When not specified, the controller uses the KustomizationSpec.Interval
value to retry failures.
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$
type: string
serviceAccountName:
description: The name of the Kubernetes service account to impersonate
Expand Down Expand Up @@ -972,6 +974,7 @@ spec:
timeout:
description: Timeout for validation, apply and health checking operations.
Defaults to 'Interval' duration.
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$
type: string
validation:
description: 'Deprecated: Not used in v1beta2.'
Expand Down

0 comments on commit 503686e

Please sign in to comment.