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

set the param type based on the default value #4608

Merged

Conversation

pritidesai
Copy link
Member

Changes

(pp *ParamSpec) SetDefaults sets the param type based on the default type. But, it is possible that the default value is specified without specifying the type. Also, the else block sets the type to string when default is nil not when the type can not be inferred from the default value (like its explained in the comment):

if pp.Default != nil {
// propagate the parsed ArrayOrString's type to the parent ParamSpec's type
pp.Type = pp.Default.Type
} else {
// ParamTypeString is the default value (when no type can be inferred from the default value)
pp.Type = ParamTypeString
}

The unit tests does not catch this since the test uses v1beta1.NewArrayOrString which sets the type explicitly:

func NewArrayOrString(value string, values ...string) *ArrayOrString {
if len(values) > 0 {
return &ArrayOrString{
Type: ParamTypeArray,
ArrayVal: append([]string{value}, values...),
}
}
return &ArrayOrString{
Type: ParamTypeString,
StringVal: value,
}
}

This commit checks if the type is not specified, infer it from the default value and sets the param type based on the default value.

/kind bug

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 or deleted (only if no user facing changes)

Release Notes

For pull requests with a release note:

Set the type of the param based on the default value when the type is not specified or cannot be inferred from the default value.

@tekton-robot tekton-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. labels Feb 22, 2022
@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 22, 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/param_types.go 97.0% 97.3% 0.3

Check if the type is specified or not, if not, infer it from the
default value.

This commit fixes a bug where the param type is set to the default type without
checking if default type is specified or not.
@pritidesai pritidesai force-pushed the pipelinerun-params-default-type branch from b1e9db9 to 94107d8 Compare February 22, 2022 20:51
@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/param_types.go 97.0% 97.3% 0.3

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

thanks @pritidesai 😁

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jerop, 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

@jerop
Copy link
Member

jerop commented Mar 15, 2022

workspace-in-sidecar is a known flake: #4169

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

@tekton-robot tekton-robot merged commit 6738db7 into tektoncd:main Mar 15, 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/bug Categorizes issue or PR as related to a bug. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants