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

Fix test cases for validatePipelineParameterVariables function #4901

Merged
merged 1 commit into from
Jun 9, 2022

Conversation

chuangw6
Copy link
Member

@chuangw6 chuangw6 commented May 23, 2022

Changes

Prior to this commit, many success tests were meaningless because they
just use the param names in the format of $(baz), $(foo-is-baz).
In validation, without using the format of $(params.<Name>), the
two examples above will be treated as just string literal instead of param
reference, and thus in fact validation agains using correct params
are not executed. That explains why there is no problem even though
declared param is actually called baz, but using $(bazzzz).

In this commit, the usage of param names is corrected to $(params.<Name>)
and type for ArrayOrString is added so that the param reference is really
validated.

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

Prior to this commit, many success tests were meaningless because they
just use the param names in the format of `$(baz)`, `$(foo-is-baz)`.
In validation, without using the format of `$(params.<Name>)`, the
two examples above will be treated as just string literal instead of param
reference, and thus  in fact validation agains using correct params
are not executed. That explains why there is no problem even though
declared param is actually called `baz`, but using `$(bazzzz)`.

In this commit, the usage of param names is corrected to `$(params.<Name>)`
and type for ArrayOrString is added so that the param reference is really
validated.
@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label May 23, 2022
@tekton-robot tekton-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label May 23, 2022
Copy link
Member

@lbernick lbernick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I'm curious if the type: ParamTypeString is needed, since users don't have to declare the param type if it is a string

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 25, 2022
@chuangw6
Copy link
Member Author

Nice catch! I'm curious if the type: ParamTypeString is needed, since users don't have to declare the param type if it is a string

Yes, that's needed here in the test because it's used in validatePipelineParametersVariablesInTaskParameters .

In yaml file, users don't have to specify the param type because the unmarshal operation will infer its type and set it i.e.

the following declaration will have string as the inferred type.

params:
- name: myString
   value: "test value"

the following declaration will have array as the inferred type.

params:
- name: myArray
   value: 
     - a
     - b

the following declaration will have object as the inferred type.

params:
- name: myObject
   value: 
     key1: "val1"
     key2: "val2"

@ywluogg
Copy link
Contributor

ywluogg commented Jun 2, 2022

/assign @ywluogg

@ywluogg
Copy link
Contributor

ywluogg commented Jun 6, 2022

Link this to #4723

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lbernick, ywluogg

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

@abayer
Copy link
Contributor

abayer commented Jun 7, 2022

/lgtm

Merge won't go through until #4944 has merged.

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 7, 2022
@abayer
Copy link
Contributor

abayer commented Jun 7, 2022

/test pull-tekton-pipeline-integration-tests
/test pull-tekton-pipeline-alpha-integration-tests

@abayer
Copy link
Contributor

abayer commented Jun 7, 2022

/test pull-tekton-pipeline-integration-tests

@chuangw6
Copy link
Member Author

chuangw6 commented Jun 7, 2022

/test pull-tekton-pipeline-build-tests

@chuangw6
Copy link
Member Author

chuangw6 commented Jun 8, 2022

/retest

1 similar comment
@abayer
Copy link
Contributor

abayer commented Jun 8, 2022

/retest

@chuangw6
Copy link
Member Author

chuangw6 commented Jun 8, 2022

/test pull-tekton-pipeline-alpha-integration-tests

2 similar comments
@chuangw6
Copy link
Member Author

chuangw6 commented Jun 8, 2022

/test pull-tekton-pipeline-alpha-integration-tests

@chuangw6
Copy link
Member Author

chuangw6 commented Jun 9, 2022

/test pull-tekton-pipeline-alpha-integration-tests

@tekton-robot tekton-robot merged commit 26d7366 into tektoncd:main Jun 9, 2022
@afrittoli
Copy link
Member

/kind misc

@tekton-robot tekton-robot added the kind/misc Categorizes issue or PR as a miscellaneuous one. label Jun 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/misc Categorizes issue or PR as a miscellaneuous one. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants