-
Notifications
You must be signed in to change notification settings - Fork 250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding nil Checks to TaskRun and PipelineRun Describe Commands #418
Adding nil Checks to TaskRun and PipelineRun Describe Commands #418
Conversation
The following is the coverage report on pkg/.
|
I think this is the case with Taskref in taskrun, Pipelineref in pipelinerun, resourcespec in both taskrun and pipelinerun. We need to handle all and also in some way like in case of resourceref, if we can show the details that will be good |
I can certainly cover the other cases with I can repurpose this issue for all |
pkg/cmd/taskrun/describe.go
Outdated
@@ -32,7 +32,7 @@ import ( | |||
|
|||
const templ = `Name: {{ .TaskRun.Name }} | |||
Namespace: {{ .TaskRun.Namespace }} | |||
Task Ref: {{ .TaskRun.Spec.TaskRef.Name }} | |||
Task Ref: {{ taskRefExists .TaskRun.Spec }} |
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.
would it be better to just skip showing Task Ref:
label if the task ref is not present (instead of showing that it isnt
) ?
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.
Yeah, agreed. We can just test if the result of taskRefExists
is an empty string and show nothing if it's blank.
The following is the coverage report on pkg/.
|
The following is the coverage report on pkg/.
|
The following is the coverage report on pkg/.
|
The following is the coverage report on pkg/.
|
The following is the coverage report on pkg/.
|
Following up here, I do not believe it is necessary to add nil checks for |
The following is the coverage report on pkg/.
|
You are right but I think this is an oversight of |
@vdemeester Yes, agreed on the oversight. It might be worthwhile to report this to pipelines. The current approach here does not display
And there's a test case that's been added to cover this (i.e. |
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
@vdemeester Thanks! I'll create an issue for updating this when we update the version of pipelines. |
func TaskRefExists(spec v1alpha1.TaskRunSpec) string { | ||
|
||
if spec.TaskRef == nil { | ||
return fieldNotPresent |
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.
we can just return "" here
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.
I would personally prefer to keep it to communicate what an empty string represents. It can be used for PipelineRef
, ResourceRef
, TaskResourceBinding
, and PipelineResourceBinding
as well when nil checks can be added for those with next pipelines version update.
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
/lgtm Thanks 🙇🏽♂️😻 |
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: chmouel, piyush-garg 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 |
Closes #380
This pull request adds nil checks to
tkn pr desc
andtkn tr desc
to prevent describe commands from not working when fields aren't present on specs.For TaskRef, a nil check function has been added to
validate.go
. ForPipelineRef
, an empty string check was added that will determine whether to show thePipelineRef
. ForResourceRef
, nothing has been implemented as an empty string is returned when not present.This will need to be updated for the release of pipelines with the prs mentioned below that will change
PipelineRef
andResourceRef
to nil when not present.Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
make docs
andmake man
if needed.make check
See the contribution guide
for more details.
Release Notes