Use k8s Duration instead of string for build timeout#365
Use k8s Duration instead of string for build timeout#365knative-prow-robot merged 4 commits intoknative:masterfrom
Conversation
pkg/webhook/build.go
Outdated
| if timeout.Duration > maxTimeout { | ||
| return validationError("InvalidTimeout", "build timeout exceeded 24h") | ||
| } else if timeout.Duration < 0 { | ||
| return validationError("InvalidTimeFormat", "invalid build timeout %q. Refer https://golang.org/pkg/time/#ParseDuration for time format documentation", timeout) |
There was a problem hiding this comment.
This type should handle parse validation errors now, so this error message should just be "cannot define negative timeout" or something along those lines.
| build: &v1alpha1.Build{ | ||
| Spec: v1alpha1.BuildSpec{ | ||
| Timeout: "garbagetimeout", | ||
| Timeout: metav1.Duration{Duration: -48 * time.Hour}, |
There was a problem hiding this comment.
This test case should be "negative timeout" now
|
/assign @imjasonh |
pkg/webhook/build.go
Outdated
| if timeout.Duration > maxTimeout { | ||
| return validationError("InvalidTimeout", "build timeout exceeded 24h") | ||
| } else if timeout.Duration < 0 { | ||
| return validationError("InvalidTimeFormat", "build timeout should be greater than 0") |
There was a problem hiding this comment.
The reason should be InvalidFormat just like a timeout >24h, otherwise everything LGTM
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ImJasonH, shashwathi The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
The following is the coverage report on pkg/.
|
|
good straight forward change |
* use k8s Duration instead of string for build timeout * Update codegen * update validation error msg * Address comments
* use k8s Duration instead of string for build timeout * Update codegen * update validation error msg * Address comments
Fixes #335
Proposed Changes
cc @tcnghia