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

parameterize pipelineTask displayName #7273

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

pritidesai
Copy link
Member

@pritidesai pritidesai commented Oct 25, 2023

Changes

Allow specifying parameters, task results, or context variables in a displayName.

spec:
params:
  - name: git-repo
  tasks:
    - name: scan
      displayName: "Code Scan for $(params.git-repo)"
      taskRef:
        name: sonar-scan

Specifying task results in a displayName does not introduce a resource dependency. Pipeline authors have to specify resource dependency using runAfter or task params.

/kind feature

Fixes #7200

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
  • 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

displayName can now accept params, task result references, or context variables.

@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/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 25, 2023
@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.4% 98.4% 0.0

@pritidesai pritidesai changed the title parameterize displayName parameterize pipelineTask displayName Oct 25, 2023
Copy link
Member

@jerop jerop left a comment

Choose a reason for hiding this comment

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

this is only applying the replacements on the pipeline task display name, do we want to do the same for pipeline display name? this can be done in future work, just want to understand if it's intentional to not do it for pipelines

please update the docs for displayname in pipelinetasks:

- [`displayName`](#specifying-a-display-name) - a user-facing name of this `Task` within the context of this `Pipeline`.

@@ -42,7 +42,7 @@ spec:
default: "1"
tasks:
- name: sum-two-numbers
displayName: Calculate the first two numbers
displayName: "Calculate the first two numbers $(params.a)"
Copy link
Member

Choose a reason for hiding this comment

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

why just passing params a here? Can we have:

displayName: "Calculate the first two numbers $(params.a) + $(params.b)"

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, we can but the resulting string is not normalized/evaluated and will be displayed as:

"Calculate the first two numbers 1 + 2"

@@ -52,7 +52,7 @@ spec:
- name: b
value: "$(params.b)"
- name: sum-with-third-number
displayName: Sum with the third number
displayName: Sum with the third number - $(tasks.sum-two-numbers.results.sum)
Copy link
Member

Choose a reason for hiding this comment

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

how about

Sum $(tasks.sum-two-numbers.results.sum) with the third number $(params.c)

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Yongxuanzhang

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 Oct 25, 2023
@pritidesai pritidesai force-pushed the parameterize-displayname branch from d883472 to 708345c Compare October 26, 2023 01:00
@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.4% 98.4% 0.0

@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.4% 98.4% 0.0

@pritidesai
Copy link
Member Author

this is only applying the replacements on the pipeline task display name, do we want to do the same for pipeline display name?

Yes, this PR is only replacing displayName for tasks[].displayName or finally[].displayName.

We could definitely extend this support to pipeline and task names if there is a use case.

please update the docs for displayname in pipelinetasks:

- [`displayName`](#specifying-a-display-name) - a user-facing name of this `Task` within the context of this `Pipeline`.

I have updated the documentation, PTAL 🙏

Allow specifying parameters or task results in a displayName.

Specifying task results in a displayName does not introduce a resource
dependency. Pipeline authors have to specify resource dependency using
runAfter or task params.

Signed-off-by: Priti Desai <[email protected]>
@pritidesai pritidesai force-pushed the parameterize-displayname branch from 708345c to 51a86a4 Compare October 26, 2023 01:16
@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.4% 98.4% 0.0

@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.4% 98.4% 0.0

@pritidesai
Copy link
Member Author

/retest

@chmouel
Copy link
Member

chmouel commented Oct 26, 2023

/lgtm

@tekton-robot
Copy link
Collaborator

@chmouel: changing LGTM is restricted to collaborators

In response to this:

/lgtm

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.

Copy link
Member

@jerop jerop 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 Oct 26, 2023
@tekton-robot tekton-robot merged commit f78bcff into tektoncd:main Oct 26, 2023
2 checks passed
@pritidesai pritidesai deleted the parameterize-displayname branch October 26, 2023 15:03
@AverageMarcus
Copy link
Contributor

Does this also work within Matrixes? If so can we close off #7082 ?

@pritidesai
Copy link
Member Author

Does this also work within Matrixes? If so can we close off #7082 ?

This works with matrix but not as expected by #7082.

The way we have matrix designed and implemented by creating a list of taskRuns as part of a single pipelineTask, doesn't help to identify different instances of matrix using pipelineTask.displayName. pipelineTask.displayName stays common across all instances of matrix. I have been playing around and trying to figure out the best way to handle matrix use case without introducing a new API specifications.

For example:

  pipelineSpec:
    tasks:
      - name: platforms-and-browsers
        displayName: "Execution of a task with $(params.platform) and $(params.browser)"
        matrix:
          params:
            - name: platform
              value:
                - linux
                - mac
                - windows
            - name: browser
              value:
                - chrome
                - safari
                - firefox
        taskRef:
          name: platform-browsers

The platforms-and-browsers pipelineTask is a single task with 9 different taskRuns. All 9 taskRuns rely on a common displayName instead of having its own displayName for #7082 to work.

I think we might have to go with your proposed design of having displayName under matrix and have the dashboard read in displayName from the matrix section. @AlanGreene thoughts?

@AlanGreene
Copy link
Member

Having displayName under matrix seems like the best option right now. We'd need to clearly document that pipelineTask.matrix.displayName takes precedence if pipelineTask.displayName is also set, and maybe produce a warning in this case?

As discussed on Slack, ideally the resolved displayName with param / results references replaced would be made available somewhere for all consuming clients (Dashboard, tkn, OpenShift console, etc.) so they don't have to duplicate the effort of resolving it themselves. This could potentially be in pipelineRun.status.childReferences or similar.

@pritidesai
Copy link
Member Author

I will take this discussion to the issue #7082 so that we can track the history.

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 Denotes a PR that will be considered when it comes time to generate release notes. 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.

introduce an option to parameterize displayName
7 participants