-
Notifications
You must be signed in to change notification settings - Fork 157
Use k8s Duration instead of string for build timeout #365
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This type should handle parse validation errors now, so this error message should just be "cannot define negative timeout" or something along those lines.
pkg/webhook/webhook_test.go
Outdated
@@ -210,18 +211,18 @@ func TestValidateBuild(t *testing.T) { | |||
reason: "invalid build timeout", | |||
build: &v1alpha1.Build{ | |||
Spec: v1alpha1.BuildSpec{ | |||
Timeout: "garbagetimeout", | |||
Timeout: metav1.Duration{Duration: -48 * time.Hour}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason should be InvalidFormat
just like a timeout >24h, otherwise everything LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
[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
Needs 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