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

Adds Basic Support for Star Array Notation #2085

Merged
merged 2 commits into from
Mar 2, 2020
Merged

Adds Basic Support for Star Array Notation #2085

merged 2 commits into from
Mar 2, 2020

Conversation

skaegi
Copy link
Contributor

@skaegi skaegi commented Feb 21, 2020

Changes

When referring to an array reference that we want to expand inside an existing array we should use star syntax.
For example: ["a", "b", "$(params.myArray[*])", "d"] to avoid confusion when in the future we want to add the array itself as an array element.

Basic support changes are in substitution.go
All other changes are for unit tests

Fixes #2041

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

@googlebot googlebot added the cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit label Feb 21, 2020
@tekton-robot tekton-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 21, 2020
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/substitution/substitution.go 57.8% 58.8% 1.0

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

Seems ok to me.

Can we have a e2e tests on this as yaml examples ? (and some docs update 😛)

/area api
/kind feature

@tekton-robot tekton-robot added area/api Indicates an issue or PR that deals with the API. kind/feature Categorizes issue or PR as related to a new feature. labels Feb 25, 2020
@skaegi
Copy link
Contributor Author

skaegi commented Feb 27, 2020

Whoops -- didn't see this til right now. Yep you bet.

when referring to an array reference that we want to expand inside an existing array we should use star syntax.
For example: ["a", "b", "$(params.myArray[*])", "d"] to avoid confusion when in the future we want to add the array itself as an array element.

Basic support changes are in substitution.go
All other changes are for unit tests
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/substitution/substitution.go 57.8% 58.8% 1.0

Updating the docs however for now we are not breaking existing use of arrays without star-expansion, and are not mentioning the old approach.
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/substitution/substitution.go 57.8% 58.8% 1.0

@skaegi
Copy link
Contributor Author

skaegi commented Feb 28, 2020

/retest

@@ -576,7 +576,7 @@ Param values from resources can also be accessed using [variable substitution](.

##### Variable Substitution with Parameters of Type `Array`

Referenced parameters of type `array` will expand to insert the array elements in the reference string's spot.
Referenced parameters of type `array` can be expanded using 'star-expansion' by adding `[*]` to the named parameter to insert the array elements in the reference string's spot.
Copy link
Member

@dibyom dibyom Feb 28, 2020

Choose a reason for hiding this comment

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

What happens if I don't use the * with an array param? Is that an error or will it simply not expand the values out?

Reading the issue, it seems like both the old style and the * expansion should work!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes with caveats. Right now the behaviour is identical as the star expansion is effectively an alias, but longer term when we add proper type support if you just reference the array directly then the array itself will be added. Whether or not that is an error is going to depend on the type we unmarshal into (see #1530 for where we're heading).

Copy link
Contributor Author

@skaegi skaegi Feb 28, 2020

Choose a reason for hiding this comment

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

As it turn out right now you can't assign an array parameter to an actual array field, so afaik in all cases we currently have, we should just use star-expansion. Talking to @afrittoli earlier, I'll also update the catalog tasks, but that is not desperately urgent for now other than to illustrate good practices.

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 28, 2020
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 2, 2020
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dibyom, vdemeester

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 merged commit 43b11da into tektoncd:master Mar 2, 2020
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. area/api Indicates an issue or PR that deals with the API. cla: yes Trying to make the CLA bot happy with ppl from different companies work on one commit kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. 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.

Provide short term solution for array "star" substitution
5 participants