Skip to content

Commit

Permalink
Merge pull request #314 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 21, 2022
2 parents 51caa7f + af69da1 commit f485eb1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/v1beta1/imagerepository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ type ImageRepositorySpec struct {
Image string `json:"image,omitempty"`
// Interval is the length of time to wait between
// scans of the image repository.
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m|h))+$"
// +required
Interval metav1.Duration `json:"interval,omitempty"`

// Timeout for image scanning.
// 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 All @@ -54,6 +58,7 @@ type ImageRepositorySpec struct {

// ServiceAccountName is the name of the Kubernetes ServiceAccount used to authenticate
// the image pull if the service account has attached pull secrets.
// +kubebuilder:validation:MaxLength=253
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ spec:
interval:
description: Interval is the length of time to wait between scans
of the image repository.
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$
type: string
secretRef:
description: SecretRef can be given the name of a secret containing
Expand All @@ -463,6 +464,7 @@ spec:
description: ServiceAccountName is the name of the Kubernetes ServiceAccount
used to authenticate the image pull if the service account has attached
pull secrets.
maxLength: 253
type: string
suspend:
description: This flag tells the controller to suspend subsequent
Expand All @@ -471,6 +473,7 @@ spec:
type: boolean
timeout:
description: Timeout for image scanning. Defaults to 'Interval' duration.
pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m))+$
type: string
type: object
status:
Expand Down

0 comments on commit f485eb1

Please sign in to comment.