-
Notifications
You must be signed in to change notification settings - Fork 74
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
Allow users/integrators to pass arbitrary keys/values through Result and RecordSummary annotations #426
Allow users/integrators to pass arbitrary keys/values through Result and RecordSummary annotations #426
Conversation
/kind feature |
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
db319d5
to
9ca4778
Compare
/assign @khrm |
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.
@alan-ghelardi can you please add markdown documentation for this feature?
In general looks good, I just have one question on the implementation.
if annotations, err := parseAnnotations(annotation.ResultAnnotations, value); err != nil { | ||
return nil, err | ||
} else { | ||
res.Annotations = annotations |
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.
Are there other annotations that we add to the Result record? Should we merge annotations instead of overwrite?
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 are just copying these annotations from PR for LIST API. So no merge requires. If these annotation changes, then we require a new one. I think it's the responsibility of integrators to ensure that we always merge not overwrite these.
pkg/watcher/results/results.go
Outdated
if annotations, err := parseAnnotations(annotation.RecordSummaryAnnotations, value); err != nil { | ||
return nil, err | ||
} else if res.Summary != nil { | ||
res.Summary.Annotations = annotations |
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.
Likewise - merge instead of overwrite?
/approve This feature can be useful for operators and integrators. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: adambkaplan 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 |
I have the same question as Adam around merging vs overwriting values but otherwise looks good. Thanks @alan-ghelardi |
9ca4778
to
02150f5
Compare
02150f5
to
f8d7707
Compare
pkg/watcher/results/results.go
Outdated
if res.Annotations == nil { | ||
res.Annotations = make(map[string]string, len(annotations)) | ||
} | ||
copyKeys(annotations, res.Annotations) |
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.
Isn't res.Annotations
always empty? You should use curr.Annotations
and copy it to res.Annotations
if we want to merge.
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.
If we don't want to employ merge, was there any issue with the previous approach of just copying?
We can just delegate the responsibility of ensuring that the merge happens to integrators. And we always do upsert.
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.
Merging values made the code trickier, but ultimately, it seems a good idea thinking about future extensibility.
pkg/watcher/results/results.go
Outdated
if annotations, err := parseAnnotations(annotation.RecordSummaryAnnotations, value); err != nil { | ||
return nil, err | ||
} else if res.Summary != nil { | ||
if res.Summary.Annotations == nil { |
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.
Same issue here. We should first copy curr.Summary.Annotations
to res.Summary.Annotations
.
f8d7707
to
7fde7d9
Compare
RecordSummary annotations.
7fde7d9
to
65a2e33
Compare
@adambkaplan and @dibyom in practice nowadays there aren't other entrypoints to set those annotations, but I like the idea of merging the values to support extensibility. @tektoncd/results-maintainers could you have a second review here, please? |
I updated the docs with the new feature, by thee way. |
/lgtm |
Changes
Resolves #343.
Users can pass arbitrary keys/values to the Result.Annotations and
Result.Summary.Annotations fields by adding certain annotations to their
PipelineRuns and TaskRuns.
/feature
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you review them:
/kind <type>
. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes