-
Notifications
You must be signed in to change notification settings - Fork 420
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
Drop escaping of strings in the JSON. #823
Conversation
/test pull-tekton-triggers-integration-tests |
/retest |
390d2e6
to
d6fab86
Compare
/test pull-tekton-triggers-integration-tests |
|
3e8c705
to
2ddda3d
Compare
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.
Overall looks good, just some small tweaks.
/lgtm
pkg/template/event.go
Outdated
triggersv1 "github.com/tektoncd/triggers/pkg/apis/triggers/v1alpha1" | ||
) | ||
|
||
const ( | ||
OldEscapeAnnotation = "tekton.dev/old-escape-quotes" |
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.
Add a comment explaining what this controls, when it can be removed, etc.
docs/triggertemplates.md
Outdated
@@ -120,3 +120,28 @@ As of Tekton Pipelines version | |||
embed resource specs. It is a best practice to embed each resource specs in the | |||
PipelineRun or TaskRun that uses the resource spec. Embedding the resource spec | |||
avoids a race condition between creating and using resources. | |||
|
|||
|
|||
## Quote-Escaping |
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 primarily focuses on what the old behavior was, but doesn't really explain what the current behavior is. Let's add some more details 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'm not sure what to put here, the strings are no longer escaped at all, which means that it's up to you to put the correct quoting around params if you expect the values to be quoted or not.
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.
One thing that could be useful is an example of what a templated JSON body would look like now and with the annotation. something like- previously or with the annotation {\"foo\": \"bar\"}
and while now it will be {"foo": "bar"}
2ddda3d
to
b2339ed
Compare
7be544b
to
edd3154
Compare
Looks good. One question -- if I am using a TriggerTemplate that is embedded inside a Trigger resource, can I still use the annotation on the Trigger resource itself or does this only apply TriggerTemplates used via reference? |
Add support for the old escaping mechanism through an annotation on the TriggerTemplate. This removes the old replacement of " with \" in parameters, which was yielding invalid JSON when the strings were already quoted.
edd3154
to
8b5988b
Compare
The following is the coverage report on the affected files.
|
It doesn't work for embedded trigger templates yet but at the WG we decided this would be fine to start off with. We can add the annotation support for embedded templates if users ask for it. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dibyom 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 |
Changes
Add support for the old escaping mechanism through an annotation on the
TriggerTemplate.
This removes the old replacement of
"
with\"
in parameters, which was yieldinginvalid JSON when the strings were already quoted.
Fixes: #777
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Release Notes