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

feat: support for variable interpolation in workspace.* (in PipelineRun and TaskRun) #7671

Conversation

l-qing
Copy link
Contributor

@l-qing l-qing commented Feb 15, 2024

fix #7667

Support for variable interpolation in:

  • spec.workspaces[].configMap.items[].*
  • spec.workspaces[].secret.items[].*
  • spec.workspaces[].projected.sources[].configMap.items[].*
  • spec.workspaces[].projected.sources[].secret.items[].*

Changes

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs if any changes are user facing, including updates to minimum requirements e.g. Kubernetes version bumps
  • Has Tests included if any functionality added or changed
  • pre-commit Passed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings). See some examples of good release notes.
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

feat: support for variable interpolation in workspace.* (in PipelineRun and TaskRun)

/kind feature

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 15, 2024
@tekton-robot
Copy link
Collaborator

Hi @l-qing. 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 the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 15, 2024
| `Task` | `spec.steps[].volumemounts.name` |
| `Task` | `spec.steps[].volumemounts.mountpath` |
| `Task` | `spec.steps[].volumemounts.subpath` |
| `Task` | `spec.steps[].env.valueFrom.secretKeyRef.name` |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should actually be camel case notation.

Copy link
Member

Choose a reason for hiding this comment

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

This will go away once this is rebased on top of the related PR, right?

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, that's why I set up the do-not-merge/hold.

@@ -4891,18 +4891,18 @@ spec:
steps:
- name: s1
image: alpine
script: |
script: |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove trailing whitespace.

}
}
}
pr.Spec.Workspaces = workspace.ReplaceWorkspaceBindingsVars(pr.Spec.Workspaces, stringReplacements)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactor this section of the code so that it can be reused in taskrun and pipelinerun.


// ReplaceWorkspaceBindingsVars returns a new slice of WorkspaceBinding with references to parameters replaced,
// based on the mapping provided in replacements.
func ReplaceWorkspaceBindingsVars(wbs []v1.WorkspaceBinding, replacements map[string]string) []v1.WorkspaceBinding {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an extracted public method for reuse in both taskrun and pipelinerun.

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/apply.go 98.7% 98.5% -0.2
pkg/reconciler/taskrun/resources/apply.go 99.5% 99.5% -0.0
pkg/workspace/apply.go 97.4% 98.1% 0.7

@l-qing l-qing force-pushed the feat/populate-params-and-results-to-workspace-bindings branch from 21e1b05 to b6478cf Compare February 17, 2024 00:38
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/apply.go 98.7% 98.5% -0.2
pkg/reconciler/taskrun/resources/apply.go 99.5% 99.5% -0.0
pkg/workspace/apply.go 97.4% 98.1% 0.7

@l-qing l-qing force-pushed the feat/populate-params-and-results-to-workspace-bindings branch 2 times, most recently from 7a8abcd to ca41dc9 Compare February 17, 2024 01:07
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/apply.go 98.7% 98.5% -0.2
pkg/reconciler/taskrun/resources/apply.go 99.5% 99.5% -0.0
pkg/workspace/apply.go 97.4% 98.1% 0.7

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/apply.go 98.7% 98.5% -0.2
pkg/reconciler/taskrun/resources/apply.go 99.5% 99.5% -0.0
pkg/workspace/apply.go 97.4% 98.1% 0.7

@l-qing l-qing force-pushed the feat/populate-params-and-results-to-workspace-bindings branch from ca41dc9 to c7e512f Compare February 21, 2024 14:19
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/apply.go 98.7% 98.5% -0.2
pkg/reconciler/taskrun/resources/apply.go 99.5% 99.5% -0.0
pkg/workspace/apply.go 97.4% 98.1% 0.7

@l-qing l-qing force-pushed the feat/populate-params-and-results-to-workspace-bindings branch from c7e512f to c61546f Compare February 22, 2024 10:33
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/apply.go 98.7% 98.5% -0.2
pkg/reconciler/taskrun/resources/apply.go 99.5% 99.5% -0.0
pkg/workspace/apply.go 97.4% 98.1% 0.7

@l-qing
Copy link
Contributor Author

l-qing commented Feb 22, 2024

/cc @JeromeJu

@JeromeJu
Copy link
Member

/ok-to-test

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 22, 2024
Copy link
Member

@JeromeJu JeromeJu left a comment

Choose a reason for hiding this comment

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

Thanks @l-qing for this!
Would you mind splitting up the PR from refactoring and changing the variable camel cases according to https://github.com/tektoncd/community/blob/main/standards.md#small-pull-requests?

@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/reconciler/pipelinerun/resources/apply.go 98.7% 98.5% -0.2
pkg/reconciler/taskrun/resources/apply.go 99.5% 99.5% -0.0
pkg/workspace/apply.go 97.4% 98.1% 0.7

@l-qing l-qing force-pushed the feat/populate-params-and-results-to-workspace-bindings branch from c61546f to 325e973 Compare February 22, 2024 16:05
@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/reconciler/pipelinerun/resources/apply.go 98.7% 98.5% -0.2
pkg/reconciler/taskrun/resources/apply.go 99.5% 99.5% -0.0
pkg/workspace/apply.go 97.4% 98.1% 0.7

@l-qing
Copy link
Contributor Author

l-qing commented Feb 22, 2024

/hold

Hold this PR until the #7701 is merged.

@tekton-robot tekton-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 22, 2024
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/apply.go 98.7% 98.5% -0.2
pkg/reconciler/taskrun/resources/apply.go 99.5% 99.5% -0.0
pkg/workspace/apply.go 97.4% 98.1% 0.7

@l-qing
Copy link
Contributor Author

l-qing commented Feb 22, 2024

Thanks @l-qing for this! Would you mind splitting up the PR from refactoring and changing the variable camel cases according to https://github.com/tektoncd/community/blob/main/standards.md#small-pull-requests?

Thank you for your suggestion.
I've split the document modification PR #7701; please review it when you have time.

@l-qing l-qing force-pushed the feat/populate-params-and-results-to-workspace-bindings branch from 325e973 to 273bc7e Compare February 26, 2024 13:46
@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/apply.go 98.7% 98.5% -0.2
pkg/reconciler/taskrun/resources/apply.go 99.5% 99.5% -0.0
pkg/workspace/apply.go 97.4% 98.1% 0.7

name: "projected.sources.secret.items success",
prs: []*v1.PipelineRun{parse.MustParseV1PipelineRun(t, `
metadata:
name: test-pipeline-run-different-service-accs
Copy link
Member

Choose a reason for hiding this comment

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

NIT: maybe the PR name should be more specific to the aspect we are testing here (variable substitution)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I found that the latter part of the unit tests fixed the name of the PR, so any modifications would have to be changed consistently.

_, clients := prt.reconcileRun("foo", "test-pipeline-run-different-service-accs", []string{}, false)
// Check that the expected TaskRun was created
actual, err := clients.Pipeline.TektonV1().TaskRuns("foo").List(prt.TestAssets.Ctx, metav1.ListOptions{
LabelSelector: "tekton.dev/pipelineTask=b-task,tekton.dev/pipelineRun=test-pipeline-run-different-service-accs",
Limit: 1,
})

I've uniformly renamed test-pipeline-run-different-service-accs to test-pipeline-run-variable-substitution to better reflect the purpose of this case.

@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/reconciler/pipelinerun/resources/apply.go 98.7% 98.5% -0.2
pkg/reconciler/taskrun/resources/apply.go 99.5% 99.5% -0.0
pkg/workspace/apply.go 97.4% 98.1% 0.7

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!
/approve

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 26, 2024
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 Feb 26, 2024
@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: afrittoli, 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:
  • OWNERS [afrittoli,vdemeester]

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 needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 26, 2024
…un and TaskRun)

fix tektoncd#7667

Support for variable interpolation in:

* spec.workspaces[].configMap.items[].*
* spec.workspaces[].secret.items[].*
* spec.workspaces[].projected.sources[].configMap.items[].*
* spec.workspaces[].projected.sources[].secret.items[].*
@l-qing l-qing force-pushed the feat/populate-params-and-results-to-workspace-bindings branch from 273bc7e to 42637e1 Compare February 26, 2024 16:12
@tekton-robot tekton-robot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 26, 2024
@l-qing
Copy link
Contributor Author

l-qing commented Feb 26, 2024

/unhold

@tekton-robot tekton-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 26, 2024
@vdemeester
Copy link
Member

/lgtm

@l-qing
Copy link
Contributor Author

l-qing commented Feb 26, 2024

/lgtm

Thank you very much, I was just about to at you for comment. 😆

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 26, 2024
@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/reconciler/pipelinerun/resources/apply.go 98.7% 98.5% -0.2
pkg/reconciler/taskrun/resources/apply.go 99.5% 99.5% -0.0
pkg/workspace/apply.go 97.4% 98.1% 0.7

@tekton-robot
Copy link
Collaborator

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

File Old Coverage New Coverage Delta
pkg/reconciler/pipelinerun/resources/apply.go 98.7% 98.5% -0.2
pkg/reconciler/taskrun/resources/apply.go 99.5% 99.5% -0.0
pkg/workspace/apply.go 97.4% 98.1% 0.7

@tekton-robot tekton-robot merged commit 33365cf into tektoncd:main Feb 26, 2024
13 checks passed
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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for variable interpolation in workspace.configmap.items * (in PipelineRun and TaskRun)
5 participants