Skip to content
This repository has been archived by the owner on Sep 5, 2019. It is now read-only.

Use k8s Duration instead of string for build timeout #365

Merged
merged 4 commits into from
Sep 19, 2018

Conversation

shashwathi
Copy link
Contributor

Fixes #335

Proposed Changes

  • Follow up PR to update type from string to k8s Duration type

cc @tcnghia

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)
Copy link
Member

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.

@@ -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},
Copy link
Member

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

@shashwathi
Copy link
Contributor Author

/assign @imjasonh
/assign @pivotal-nader-ziada

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")
Copy link
Member

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

Copy link
Member

@imjasonh imjasonh left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow-robot
Copy link

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-metrics-robot
Copy link

The following is the coverage report on pkg/.
Say /test pull-knative-build-go-coverage to run the coverage report again

File Old Coverage New Coverage Delta
pkg/webhook/build.go 89.9% 89.6% -0.3

@nader-ziada
Copy link
Member

good straight forward change
/lgtm

@knative-prow-robot knative-prow-robot merged commit 80fa4e8 into knative:master Sep 19, 2018
@shashwathi shashwathi deleted the time-refactor branch September 19, 2018 16:10
vdemeester pushed a commit to vdemeester/knative-build that referenced this pull request Apr 3, 2019
* use k8s Duration instead of string for build timeout

* Update codegen

* update validation error msg

* Address comments
vdemeester pushed a commit to vdemeester/knative-build that referenced this pull request Apr 3, 2019
* use k8s Duration instead of string for build timeout

* Update codegen

* update validation error msg

* Address comments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants