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-0144] Validate PipelineRun for Param Enum #7338

Merged

Conversation

QuanZhang-William
Copy link
Member

@QuanZhang-William QuanZhang-William commented Nov 7, 2023

Changes

Part of #7270. In TEP-0144 we proposed a new enum field to support built-in param input validation.

This commit adds validation logic for PipelineRun against Param Enum

/kind feature

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

Implement Param Enum validation for PipelineRuns. Param Enum is supported per TEP-0144

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Nov 7, 2023
@tekton-robot
Copy link
Collaborator

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@tekton-robot tekton-robot added 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 Nov 7, 2023
@QuanZhang-William
Copy link
Member Author

/test all

@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/pipelinerun.go 92.5% 92.6% 0.1

@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/pipelinerun.go 92.5% 92.6% 0.1

@QuanZhang-William
Copy link
Member Author

/retest

@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/pipelinerun.go 92.5% 92.6% 0.1

@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/pipelinerun.go 92.5% 92.6% 0.1

@QuanZhang-William QuanZhang-William marked this pull request as ready for review November 7, 2023 16:58
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 7, 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/pipelinerun.go 92.5% 92.6% 0.1

@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/pipelinerun.go 92.5% 92.6% 0.1

@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/pipelinerun.go 92.5% 92.6% 0.1

@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/pipelinerun.go 92.5% 92.6% 0.1

docs/pipelineruns.md Outdated Show resolved Hide resolved
pkg/reconciler/pipelinerun/pipelinerun.go Outdated Show resolved Hide resolved
@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/pipelinerun.go 92.5% 92.6% 0.1

@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/pipelinerun.go 92.5% 92.6% 0.1

@QuanZhang-William
Copy link
Member Author

/retest

@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/pipelinerun.go 92.5% 92.6% 0.1

@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/pipelinerun.go 92.5% 92.6% 0.1

@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 Nov 9, 2023
@QuanZhang-William
Copy link
Member Author

@tektoncd/core-collaborators @tektoncd/core-maintainers. Please take a look if you are interested 😃

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.

I have a concern about the intersection approach when enum is specified in both tasks and pipelines, I think we should require that the enum in pipeline is a subset of the enum in task

Also, what happens currently when the param in pipeline is passed to multiple tasks with enums? do you take the intersection of the enums in all the tasks the param is passed to and the pipeline? in the example below, what is the valid value for "message" param in a pipelinerun?

apiVersion: tekton.dev/v1
kind: Task
metadata:
  name: param-enum-demo-1
spec:
  params:
  - name: message
    type: string
    enum: ["v1", "v2", "v3"]
  steps:
  - name: build
    image: bash:latest
    script: |
      echo "$(params.message)"
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
  name: param-enum-demo-2
spec:
  params:
  - name: message
    type: string
    enum: ["v3", "v4"]
  steps:
  - name: build
    image: bash:latest
    script: |
      echo "$(params.message)"
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: pipeline-param-enum
spec:
  params:
  - name: message
    enum: ["v1", "v3", "v4", "v5"]
  tasks:
  - name: task-1
    params:
      - name: message
        value: $(params.message)
    taskRef:
      name: param-enum-demo-1
  - name: task-2 
    params:
      - name: message
        value: $(params.message)
    taskRef:
      name: param-enum-demo-2

docs/pipelineruns.md Outdated Show resolved Hide resolved
docs/pipelineruns.md Outdated Show resolved Hide resolved
docs/pipelineruns.md Outdated Show resolved Hide resolved
docs/pipelines.md Outdated Show resolved Hide resolved
docs/pipelines.md Outdated Show resolved Hide resolved
@jerop
Copy link
Member

jerop commented Nov 13, 2023

/hold

wait on tektoncd/community#1106 to be 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 Nov 13, 2023
@tekton-robot tekton-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Nov 15, 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/pipelinerun.go 92.5% 92.3% -0.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.4% -0.3

@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/pipelinerun.go 92.5% 92.3% -0.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.4% -0.3

@QuanZhang-William
Copy link
Member Author

I have a concern about the intersection approach when enum is specified in both tasks and pipelines, I think we should require that the enum in pipeline is a subset of the enum in task

Also, what happens currently when the param in pipeline is passed to multiple tasks with enums? do you take the intersection of the enums in all the tasks the param is passed to and the pipeline? in the example below, what is the valid value for "message" param in a pipelinerun?

apiVersion: tekton.dev/v1
kind: Task
metadata:
  name: param-enum-demo-1
spec:
  params:
  - name: message
    type: string
    enum: ["v1", "v2", "v3"]
  steps:
  - name: build
    image: bash:latest
    script: |
      echo "$(params.message)"
---
apiVersion: tekton.dev/v1
kind: Task
metadata:
  name: param-enum-demo-2
spec:
  params:
  - name: message
    type: string
    enum: ["v3", "v4"]
  steps:
  - name: build
    image: bash:latest
    script: |
      echo "$(params.message)"
---
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: pipeline-param-enum
spec:
  params:
  - name: message
    enum: ["v1", "v3", "v4", "v5"]
  tasks:
  - name: task-1
    params:
      - name: message
        value: $(params.message)
    taskRef:
      name: param-enum-demo-1
  - name: task-2 
    params:
      - name: message
        value: $(params.message)
    taskRef:
      name: param-enum-demo-2

Hi Jerop. You are right about the behaviour in the previous intersection design, it essentially takes the intersection of all related enum sets. I have changed to subset design, which also essentially validates the pipeline-level is a subset of all referenced Tasks

@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/pipelinerun.go 92.5% 92.3% -0.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.4% -0.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/reconciler/pipelinerun/pipelinerun.go 92.5% 92.3% -0.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.4% -0.3

Part of [tektoncd#7270][tektoncd#7270]. In [TEP-0144][tep-0144] we proposed a new `enum` field to support built-in param input validation.

This commit adds validation logic for PipelineRun against Param Enum

/kind feature

[tektoncd#7270]: tektoncd#7270
[tep-0144]: https://github.com/tektoncd/community/blob/main/teps/0144-param-enum.md
@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/pipelinerun.go 92.5% 92.3% -0.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.4% -0.3

@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/pipelinerun.go 92.5% 92.3% -0.2
pkg/reconciler/pipelinerun/resources/pipelinerunresolution.go 96.7% 96.4% -0.3

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.

Thank you @QuanZhang-William!

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 22, 2023
@tekton-robot tekton-robot merged commit 8a8c0c3 into tektoncd:main Nov 22, 2023
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. 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.

None yet

4 participants