Skip to content
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

chitrangpatel
Copy link
Contributor

@chitrangpatel chitrangpatel commented Apr 29, 2022

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:

  • Docs included if any changes are user facing
  • Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Release notes block below has been filled in
    (if there are no user facing changes, use release note "NONE")

Release Notes

NONE

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.
@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Apr 29, 2022
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign dibyom
You can assign the PR to them by writing /assign @dibyom in a comment when ready.

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

@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 29, 2022
@tekton-robot
Copy link
Collaborator

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@tekton-robot tekton-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 29, 2022
Comment on lines +70 to +78
} 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{""},
}
}
Copy link
Member

@chuangw6 chuangw6 Apr 29, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants