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

add support for reserved default object param #164

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Yongxuanzhang
Copy link
Owner

@Yongxuanzhang Yongxuanzhang commented Dec 12, 2023

Changes

This commit adds support for reserved default object param.Users can reference to default object param values without needing to declaring them in remote Task&Pipeline. Validation err will be returned if referencing to non-existent object key.

This is the PR to run all tests: tektoncd#7484

Signed-off-by: Yongxuan Zhang [email protected]

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

NONE

@Yongxuanzhang Yongxuanzhang force-pushed the param-to-remote-patch branch 4 times, most recently from 1f81f21 to e2e1633 Compare December 12, 2023 20:05
taskSpec = "taskSpec"
pipelineRef = "pipelineRef"
pipelineSpec = "pipelineSpec"
ReservedParamName = "TBD"
Copy link
Owner Author

Choose a reason for hiding this comment

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

will add changes to v1beta1 soon

@@ -132,6 +132,7 @@ func ValidateUsageOfDeclaredParameters(ctx context.Context, steps []Step, params
var errs *apis.FieldError
_, _, objectParams := params.SortByType()
allParameterNames := sets.NewString(params.GetNames()...)
allParameterNames.Insert(ReservedParamName)

Choose a reason for hiding this comment

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

May be here we should check that the ReservedParamName is not already in the set. If it is then a user also declared it and it should throw an error since it is reserved?

Copy link
Owner Author

@Yongxuanzhang Yongxuanzhang Dec 12, 2023

Choose a reason for hiding this comment

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

this check is not done from our side, there will be additional validation out of tekton and we're sure that users cannot declare the param with reserved name. :D

Copy link
Owner Author

Choose a reason for hiding this comment

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

(and we cannot do it from out side for some reason...

@@ -395,6 +396,7 @@ func (ps *PipelineSpec) validatePipelineParameterUsage(ctx context.Context) (err
// validatePipelineTaskParameterUsage validates that parameters referenced in the Pipeline Tasks are declared by the Pipeline
func validatePipelineTaskParameterUsage(tasks []PipelineTask, params ParamSpecs) (errs *apis.FieldError) {
allParamNames := sets.NewString(params.GetNames()...)
allParamNames.Insert(ReservedParamName)

Choose a reason for hiding this comment

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

May be here we should check that the ReservedParamName is not already in the set. If it is then a user also declared it and it should throw an error since it is reserved?

@@ -671,6 +671,20 @@ func (c *Reconciler) reconcile(ctx context.Context, pr *v1.PipelineRun, getPipel
}

if pipelineRunFacts.State.IsBeforeFirstTaskRun() {
// check if the object's key names are referenced correctly i.e. param.objectParam.key1
Copy link
Owner Author

@Yongxuanzhang Yongxuanzhang Dec 12, 2023

Choose a reason for hiding this comment

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

working on adding unit tests for this, same for taskrun. e2e tests have been added to cover this code

@Yongxuanzhang Yongxuanzhang force-pushed the param-to-remote-patch branch 5 times, most recently from 0d050fc to d4fe76d Compare January 16, 2024 15:37
This commit adds support for reserved default object param.Users can
reference to default object param values without needing to declaring
them in remote Task&Pipeline. Validation err will be returned if
referencing to non-existent object key.

Signed-off-by: Yongxuan Zhang [email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants