-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Updated regex pattern to allow all three valid bracket notations. #4811
Conversation
Add unit test with large result for setTaskRunStatusBasedOnStepStatus.
Prior to this, when supplied parameter name was not the same as that called in the step, webhook raised an error when using the dot notation as expected. However, it did not when using the bracket notation. Updated the unit tests to also check for valid bracket notations.
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @chitrangpatel. Thanks for your PR. I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
} else { | ||
// if expected variables but cannot be extracted from the string. | ||
if len(vars) > 0 { | ||
return &apis.FieldError{ | ||
Message: fmt.Sprintf("Expected to find variables but none found in %q", value), | ||
// Empty path is required to make the `ViaField`, … work | ||
Paths: []string{""}, | ||
} | ||
} |
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.
Adding this else
will not work because different values can be passed to ValidateVariableP
function other than just param names i.e. image name, step name.
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
generateName: validation-
spec:
taskSpec:
params:
- name: foo
default: "bar1"
results:
- name: echo-output
description: "successful echo"
steps:
- name: echo-params
image: bash
script: |
set -e
echo $(params.foo) | tee $(results.echo-output.path)
Try this example, when you apply, you'll see
Error from server (BadRequest): error when creating "validation.yaml": admission webhook "validation.webhook.pipeline.tekton.dev" denied the request: validation failed: Expected to find variables but none found in "": spec.taskSpec.steps[0].workingDir
Expected to find variables but none found in "bash": spec.taskSpec.steps[0].image
Expected to find variables but none found in "echo-params": spec.taskSpec.steps[0].name
Expected to find variables but none found in "set -e\necho $(params.foo) | tee $(results.echo-output.path)\n": spec.taskSpec.steps[0].script
Changes
Updated regex pattern to allow all three valid bracket notations.
Prior to this, when supplied parameter name was not the same as that
called in the step, webhook raised an error when using the dot notation
as expected. However, it did not when using the bracket notation.
Updated the unit tests to also check for valid bracket notations.
This PR addresses issue #4787 and #4792
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
(if there are no user facing changes, use release note "NONE")
Release Notes
NONE