Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

api: add custom validation for v1.Duration types #903

Merged
merged 1 commit into from
Sep 20, 2022

Conversation

hiddeco
Copy link
Member

@hiddeco hiddeco commented Sep 20, 2022

To solve discrepancies between parsing versus validation.

xref: kubernetes/apimachinery#131

To solve discrepancies between parsing versus validation.

xref: kubernetes/apimachinery#131

Signed-off-by: Hidde Beydals <hello@hidde.co>
// +required
Interval metav1.Duration `json:"interval"`

// Timeout for fetch operations, defaults to 60s.
// +kubebuilder:default="60s"
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ms|s|m))+$"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not include h for timeouts (nor did I include ns, us, µs) to stimulate the user to keep their bounds realistic.

Copy link
Contributor

@darkowlzz darkowlzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hiddeco hiddeco added the bug Something isn't working label Sep 20, 2022
@hiddeco hiddeco merged commit 54d706a into main Sep 20, 2022
@hiddeco hiddeco deleted the api-validate-duration branch September 20, 2022 09:46
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants