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-0075: Validate object name and key name have no dots #5090

Merged

Conversation

chuangw6
Copy link
Member

@chuangw6 chuangw6 commented Jul 6, 2022

Changes

Prior to this commit, dots are allowed to be used in param names to
support domain-scoped names. However, object params have already
supported domain-scoped names since it has a list of keys. In addition,
using dots in object param names and key names have conflicts.
See more details in tektoncd/community#711.

In this change, we validate against those object names and key names
that contain dots.

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

Dots are not allowed in object param names and key names.

@tekton-robot tekton-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 6, 2022
@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jul 6, 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/task_validation.go 97.5% 97.6% 0.1

@imjasonh
Copy link
Member

imjasonh commented Jul 6, 2022

Is $(params['com.example.foo']) still considered a valid way of referencing a param name that contains dots? That's been the case that's caused us breakages in the past.

@chuangw6
Copy link
Member Author

chuangw6 commented Jul 6, 2022

Is $(params['com.example.foo']) still considered a valid way of referencing a param name that contains dots? That's been the case that's caused us breakages in the past.

Yes! string/array param name can still use dots. And using bracket notation is the way to reference them like the example you commented.

This PR is to make sure only object param name and its key names do not contain dots.

cc @mattmoor

@imjasonh
Copy link
Member

imjasonh commented Jul 6, 2022

This PR is to make sure only object param name and its key names do not contain dots.

cc @mattmoor

Thanks for clarifying! 👍

@tekton-robot tekton-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Jul 6, 2022
@chuangw6
Copy link
Member Author

chuangw6 commented Jul 6, 2022

/kind misc

@tekton-robot tekton-robot added the kind/misc Categorizes issue or PR as a miscellaneuous one. label Jul 6, 2022
@chuangw6 chuangw6 closed this Jul 6, 2022
@chuangw6 chuangw6 reopened this Jul 6, 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/task_validation.go 97.5% 97.6% 0.1

@chuangw6
Copy link
Member Author

chuangw6 commented Jul 6, 2022

/test tekton-pipeline-unit-tests

@chuangw6
Copy link
Member Author

chuangw6 commented Jul 6, 2022

/retest

@chuangw6 chuangw6 closed this Jul 6, 2022
@chuangw6 chuangw6 reopened this Jul 6, 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/task_validation.go 97.5% 97.6% 0.1

@chuangw6
Copy link
Member Author

chuangw6 commented Jul 7, 2022

/retest

@dibyom
Copy link
Member

dibyom commented Jul 7, 2022

@chuangw6 Can we mention this naming limitation for object params in the docs?

@dibyom
Copy link
Member

dibyom commented Jul 7, 2022

/kind misc

@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 8, 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/task_validation.go 97.5% 97.6% 0.1

@chuangw6
Copy link
Member Author

chuangw6 commented Jul 8, 2022

@chuangw6 Can we mention this naming limitation for object params in the docs?

Added! Also restructure the section Specifying Parameters a bit to make it more readable. Please let me know what you think. @dibyom

@chuangw6 chuangw6 closed this Jul 8, 2022
@chuangw6 chuangw6 reopened this Jul 8, 2022
@tekton-robot
Copy link
Collaborator

@abayer: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test pull-tekton-pipeline-alpha-integration-tests
  • /test pull-tekton-pipeline-build-tests
  • /test pull-tekton-pipeline-integration-tests
  • /test tekton-pipeline-unit-tests

The following commands are available to trigger optional jobs:

  • /test pull-tekton-pipeline-go-coverage
  • /test pull-tekton-pipeline-kind-alpha-integration-tests
  • /test pull-tekton-pipeline-kind-alpha-yaml-tests
  • /test pull-tekton-pipeline-kind-integration-tests
  • /test pull-tekton-pipeline-kind-yaml-tests

Use /test all to run the following jobs that were automatically triggered:

  • pull-tekton-pipeline-alpha-integration-tests
  • pull-tekton-pipeline-build-tests
  • pull-tekton-pipeline-go-coverage
  • pull-tekton-pipeline-integration-tests
  • pull-tekton-pipeline-unit-tests

In response to this:

/test check-pr-has-kind-label

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
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/task_validation.go 97.5% 97.6% 0.1

@abayer
Copy link
Contributor

abayer commented Jul 8, 2022

/test check-pr-has-kind-label

@tekton-robot
Copy link
Collaborator

@abayer: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test pull-tekton-pipeline-alpha-integration-tests
  • /test pull-tekton-pipeline-build-tests
  • /test pull-tekton-pipeline-integration-tests
  • /test tekton-pipeline-unit-tests

The following commands are available to trigger optional jobs:

  • /test pull-tekton-pipeline-go-coverage
  • /test pull-tekton-pipeline-kind-alpha-integration-tests
  • /test pull-tekton-pipeline-kind-alpha-yaml-tests
  • /test pull-tekton-pipeline-kind-integration-tests
  • /test pull-tekton-pipeline-kind-yaml-tests

Use /test all to run the following jobs that were automatically triggered:

  • pull-tekton-pipeline-alpha-integration-tests
  • pull-tekton-pipeline-build-tests
  • pull-tekton-pipeline-go-coverage
  • pull-tekton-pipeline-integration-tests
  • pull-tekton-pipeline-unit-tests

In response to this:

/test check-pr-has-kind-label

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.

@ywluogg
Copy link
Contributor

ywluogg commented Jul 8, 2022

/assign @ywluogg

@chuangw6
Copy link
Member Author

chuangw6 commented Jul 8, 2022

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

@chuangw6 chuangw6 force-pushed the object-name-key-format-validation branch from d067674 to 9a9c70a Compare July 8, 2022 22:09
@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/task_validation.go 97.5% 97.6% 0.1

@ywluogg
Copy link
Contributor

ywluogg commented Jul 10, 2022

Re: check-pr-has-kind-label: 2 valid "kind/*" labels found({'kind/cleanup', 'kind/misc'}), expecting exactly one.

// - Must only contain alphanumeric characters, hyphens (-), underscores (_), and dots (.)
// - Must begin with a letter or an underscore (_)
// - Exception: Object param name and key names cannot contain dots (.)
func validateNameFormat(allParamNames sets.String, objectParams []ParamSpec) (errs *apis.FieldError) {
Copy link
Contributor

@ywluogg ywluogg Jul 10, 2022

Choose a reason for hiding this comment

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

I'm a bit confused why this is not called in validateStepVariables after this regex match has been removed from validateVariables?

Copy link
Member Author

Choose a reason for hiding this comment

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

Name format validation should happen before validating its usage. The logic was in that order too before the change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mean the naming of the step variables happen before validating its usage? Can you point me to where it is?

Copy link
Member Author

@chuangw6 chuangw6 Jul 11, 2022

Choose a reason for hiding this comment

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

name of parameter names, which is this function you are commenting on.

Copy link
Member Author

Choose a reason for hiding this comment

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

Talked to @ywluogg offline. We decided to make the function arguments more explicit i.e. the first argument is only for string&array type since the format requirements for those two types are the same; and the second argument is for object type since it requires not containing dots specifically.

@chuangw6 chuangw6 force-pushed the object-name-key-format-validation branch from 9a9c70a to c7464bf Compare July 11, 2022 14:38
@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/task_validation.go 97.5% 97.6% 0.1

@ywluogg
Copy link
Contributor

ywluogg commented Jul 11, 2022

/remove-kind misc

@tekton-robot tekton-robot removed the kind/misc Categorizes issue or PR as a miscellaneuous one. label Jul 11, 2022
@ywluogg
Copy link
Contributor

ywluogg commented Jul 11, 2022

/test check-pr-has-kind-label

@tekton-robot
Copy link
Collaborator

@ywluogg: The specified target(s) for /test were not found.
The following commands are available to trigger required jobs:

  • /test pull-tekton-pipeline-alpha-integration-tests
  • /test pull-tekton-pipeline-build-tests
  • /test pull-tekton-pipeline-integration-tests
  • /test tekton-pipeline-unit-tests

The following commands are available to trigger optional jobs:

  • /test pull-tekton-pipeline-go-coverage
  • /test pull-tekton-pipeline-kind-alpha-integration-tests
  • /test pull-tekton-pipeline-kind-alpha-yaml-tests
  • /test pull-tekton-pipeline-kind-integration-tests
  • /test pull-tekton-pipeline-kind-yaml-tests

Use /test all to run the following jobs that were automatically triggered:

  • pull-tekton-pipeline-alpha-integration-tests
  • pull-tekton-pipeline-build-tests
  • pull-tekton-pipeline-go-coverage
  • pull-tekton-pipeline-integration-tests
  • pull-tekton-pipeline-unit-tests

In response to this:

/test check-pr-has-kind-label

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.

@chuangw6 chuangw6 force-pushed the object-name-key-format-validation branch from c7464bf to ba212d3 Compare July 11, 2022 16:03
Prior to this commit, dots are allowed to be used in param names to
support domain-scoped names. However, object params have already
supported domain-scoped names since it has a list of keys. In addition,
using dots in object param names and key names have conflicts.
See more details in tektoncd/community#711.

In this change, we validate against those object names and key names
that contain dots.
@chuangw6 chuangw6 force-pushed the object-name-key-format-validation branch from ba212d3 to 8122b24 Compare July 11, 2022 16:09
@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/task_validation.go 97.5% 97.6% 0.1

@chuangw6
Copy link
Member Author

/retest

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dibyom

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 Jul 11, 2022
@ywluogg
Copy link
Contributor

ywluogg commented Jul 11, 2022

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 11, 2022
@tekton-robot tekton-robot merged commit 9dacb49 into tektoncd:main Jul 11, 2022
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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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.

6 participants