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

[TEP-0075] Validate against using the whole object in task steps #4861

Merged
merged 1 commit into from
Jun 13, 2022

Conversation

chuangw6
Copy link
Member

@chuangw6 chuangw6 commented May 11, 2022

Changes

According to TEP-0075:
When providing values for strings, Task and Pipeline authors can
access individual attributes of an object param; but they cannot access
the object as whole.

This PR makes sure that the object param cannot be used as whole when providing values for strings in task steps.

Also modified extractVariablesFromString function a bit to recognize
params.foo.bar reference that was treated as invalid previously.

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

Added validation against using the whole object in fields of a task step.
For example, the following reference to the whole object param is not allowed.
steps:
  - name: my-step
     image: $(params.myObjectParam[*])


This is part of TEP-0075. In order to have the changes in this PR to be applied, 
users have to enable the `alpha` feature flag.

@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 11, 2022
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 11, 2022
@chuangw6 chuangw6 force-pushed the validate-using-object-as-whole branch from dce66fe to 07a8117 Compare May 11, 2022 23:50
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/substitution/substitution.go 54.5% 43.3% -11.2

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/task_validation.go 97.6% 97.4% -0.2
pkg/substitution/substitution.go 54.5% 43.3% -11.2

@chuangw6 chuangw6 force-pushed the validate-using-object-as-whole branch from 07a8117 to 103bc3f Compare May 12, 2022 00:24
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 12, 2022
@chuangw6 chuangw6 force-pushed the validate-using-object-as-whole branch from 103bc3f to 86720cd Compare May 12, 2022 00:27
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/task_validation.go 97.6% 97.4% -0.2
pkg/substitution/substitution.go 54.5% 62.9% 8.3

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/task_validation.go 97.6% 97.4% -0.2
pkg/substitution/substitution.go 54.5% 62.9% 8.3

@chuangw6 chuangw6 changed the title Add validation against the usage of the entire object [TEP-0075] Add validation against the usage of the entire object May 12, 2022
@ywluogg
Copy link
Contributor

ywluogg commented May 16, 2022

/assign ywluogg

@chuangw6 chuangw6 force-pushed the validate-using-object-as-whole branch from 86720cd to 4f10980 Compare May 17, 2022 03:29
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/task_validation.go 97.7% 97.4% -0.2
pkg/substitution/substitution.go 54.5% 62.9% 8.3

@chuangw6
Copy link
Member Author

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

@ywluogg
Copy link
Contributor

ywluogg commented May 18, 2022

Just wanted to confirm that this PR will still be focused on substituted field is a string, and the substituting param is an object, is it?

@chuangw6
Copy link
Member Author

chuangw6 commented May 18, 2022

Just wanted to confirm that this PR will still be focused on substituted field is a string, and the substituting param is an object, is it?

This PR makes sure object param cannot be used as whole in any part of a task step.
As tep75 proposed, the whole object can only be used when providing value for other objects. That validation will be part of pipeline validation (not in this pr).

@ywluogg
Copy link
Contributor

ywluogg commented May 18, 2022

This PR makes sure object param cannot be used as whole in any part of a task step.
As tep75 proposed, the whole object can only be used when providing value for other objects. That validation will be part of pipeline validation (not in this pr).

Oh I think I meant to ask - if this PR would be focused on validations of whole object substitutions, when the substituted field is a string?

You can close this thread, as I found where you add the validations of substituted param is an array and substituting param is an object. I updated a comment in test cases to help reviewers quickly identify what validations you added more easily.

@chuangw6 chuangw6 changed the title [TEP-0075] Add validation against the usage of the entire object [TEP-0075] Add validation against the usage of the entire object in task steps May 19, 2022
@chuangw6 chuangw6 changed the title [TEP-0075] Add validation against the usage of the entire object in task steps [TEP-0075] Validate against the usage of the entire object in task steps May 19, 2022
@chuangw6 chuangw6 changed the title [TEP-0075] Validate against the usage of the entire object in task steps [TEP-0075] Validate against using the whole object in task steps May 19, 2022
@chuangw6 chuangw6 force-pushed the validate-using-object-as-whole branch from 4f10980 to 73681ce Compare May 20, 2022 02:38
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 27, 2022
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/task_validation.go 97.7% 97.5% -0.2
pkg/substitution/substitution.go 57.9% 63.6% 5.7

@chuangw6
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

@ywluogg
Copy link
Contributor

ywluogg commented May 31, 2022

/assign @lbernick

pkg/substitution/substitution.go Outdated Show resolved Hide resolved
@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

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 1, 2022
@chuangw6 chuangw6 force-pushed the validate-using-object-as-whole branch 2 times, most recently from 484a061 to d521656 Compare June 1, 2022 19:47
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/task_validation.go 97.7% 97.5% -0.2
pkg/substitution/substitution.go 57.9% 64.9% 7.0

@chuangw6 chuangw6 force-pushed the validate-using-object-as-whole branch from d521656 to 0070ba8 Compare June 1, 2022 19:50
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/task_validation.go 97.7% 97.5% -0.2
pkg/substitution/substitution.go 57.9% 64.9% 7.0

According to TEP-0075:
When providing values for strings, Task and Pipeline authors can
access individual attributes of an object param; but they cannot access
the object as whole.

Also modified `extractVariablesFromString` function a bit to recognize
`params.foo.bar` reference that was treated as invalid previously.
@chuangw6 chuangw6 force-pushed the validate-using-object-as-whole branch from 0070ba8 to f576c18 Compare June 1, 2022 21:13
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/pipeline/v1beta1/task_validation.go 97.7% 97.5% -0.2
pkg/substitution/substitution.go 57.9% 64.9% 7.0

@ywluogg
Copy link
Contributor

ywluogg commented Jun 2, 2022

Link this to #4723

@chuangw6 chuangw6 requested a review from lbernick June 2, 2022 18:29
@abayer
Copy link
Contributor

abayer commented Jun 7, 2022

This needs a release note.

@tekton-robot tekton-robot added release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Jun 13, 2022
@abayer
Copy link
Contributor

abayer commented Jun 13, 2022

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 13, 2022
@chuangw6
Copy link
Member Author

/test pull-tekton-pipeline-integration-tests

@tekton-robot tekton-robot merged commit c13edc2 into tektoncd:main Jun 13, 2022
@afrittoli
Copy link
Member

/kind feature

@tekton-robot tekton-robot added the kind/feature Categorizes issue or PR as related to a new feature. 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/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants