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 variable interpolation on StepTemplate #4803

Merged
merged 1 commit into from May 3, 2022

Conversation

vdemeester
Copy link
Member

@vdemeester vdemeester commented Apr 27, 2022

Changes

This changes the way we interpolate variables by using StepTemplate
directly instead of modifying a de-referenced version of it.

Dereferencing means that changes happening to it (in
ApplyStepReplacements) are not reflected to the original object.
Before this change, using variable interpolation on StepTemplate
would only work on part of the fields they were supposed to be.
For example, it works on env because, it is an array and the
de-referenced version of StepTemplate would share the same pointer
to it, making any changes on the array reflect to the initial object.

This is now fixed.

Signed-off-by: Vincent Demeester vdemeest@redhat.com

/kind bug
/cc @imjasonh @abayer @jerop

Fixes #4801

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

Variable are now correctly interpolated on `stepTemplate` field for `Task`

@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 27, 2022
@tekton-robot tekton-robot requested a review from jerop April 27, 2022 15:54
@tekton-robot tekton-robot added kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 27, 2022
@tekton-robot tekton-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 27, 2022
@abayer
Copy link
Contributor

abayer commented Apr 27, 2022

/lgtm

I was actually playing around with an alternative fix, but this one's better. =)

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 27, 2022
@tekton-robot tekton-robot removed the lgtm Indicates that a PR is ready to be merged. label Apr 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/step_replacements.go 100.0% 66.7% -33.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/step_replacements.go 100.0% 66.7% -33.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/step_replacements.go 100.0% 66.7% -33.3

@abayer
Copy link
Contributor

abayer commented Apr 27, 2022

/lgtm

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

abayer commented Apr 27, 2022

/retest

4 similar comments
@abayer
Copy link
Contributor

abayer commented Apr 27, 2022

/retest

@abayer
Copy link
Contributor

abayer commented Apr 27, 2022

/retest

@abayer
Copy link
Contributor

abayer commented Apr 28, 2022

/retest

@vdemeester
Copy link
Member Author

/retest

@afrittoli
Copy link
Member

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

Copy link
Member

@afrittoli afrittoli left a comment

Choose a reason for hiding this comment

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

Thanks for this, nice catch!
/approve

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: afrittoli

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 Apr 29, 2022
@afrittoli
Copy link
Member

/test pull-tekton-pipeline-unit-tests

1 similar comment
@lbernick
Copy link
Member

/test pull-tekton-pipeline-unit-tests

@vdemeester vdemeester force-pushed the 4801-steptemplate-variables branch from 665abc1 to 9cda7e9 Compare May 3, 2022 05:30
@tekton-robot tekton-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 3, 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/step_replacements.go 100.0% 66.7% -33.3

This changes the way we interpolate variables by using `StepTemplate`
directly instead of modifying a de-referenced version of it.

Dereferencing means that changes happening to it (in
`ApplyStepReplacements`) are not reflected to the original object.
Before this change, using variable interpolation on `StepTemplate`
would only work on part of the fields they were supposed to be.
For example, it works on `env` because, it is an array and the
de-referenced version of `StepTemplate` would share the same pointer
to it, making any changes on the array reflect to the initial object.

This is now fixed.

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
@vdemeester vdemeester force-pushed the 4801-steptemplate-variables branch from 9cda7e9 to 179f349 Compare May 3, 2022 07:17
@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/container_types.go 100.0% 68.2% -31.8
pkg/apis/pipeline/v1beta1/step_replacements.go 100.0% 40.0% -60.0
pkg/reconciler/taskrun/resources/apply.go 99.2% 99.2% -0.0

@vdemeester
Copy link
Member Author

/test tekton-pipeline-unit-tests

@vdemeester
Copy link
Member Author

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

@abayer
Copy link
Contributor

abayer commented May 3, 2022

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label May 3, 2022
@tekton-robot tekton-robot merged commit 2a8169f into tektoncd:main May 3, 2022
@vdemeester vdemeester deleted the 4801-steptemplate-variables branch May 3, 2022 13:58
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/bug Categorizes issue or PR as related to a bug. 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/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.

Variable interpolation doesn't work in stepTemplate
5 participants