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

Implement Task/TaskRun Input Params #149

Merged
merged 1 commit into from
Oct 15, 2018

Conversation

dlorenc
Copy link
Contributor

@dlorenc dlorenc commented Oct 12, 2018

This adds support for Task/TaskRun Input Parameters using the 'ApplyReplacements' function from knative/build.
Reusing this function ensures consistency in variable replacement between the projects.

This change assumes that the supplied TaskRun.Spec.Inputs.Params have been valided against the Task.Inputs.Params elsewhere.
We may want to revisit this and perform additional validation.

This change does not introduce support for Resources or PipelineParams yet.

Vendor changes have been separated into another commit for easier reviewing.
Ref #64

@knative-prow-robot knative-prow-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Oct 12, 2018
@knative-prow-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dlorenc

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

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 12, 2018
@tejal29
Copy link
Contributor

tejal29 commented Oct 12, 2018

one more thing, did you run ./hack/update-deps.sh to update vendor code?
It cleanups a bunch of files, which i think your previous commit ended up adding back.

@dlorenc
Copy link
Contributor Author

dlorenc commented Oct 12, 2018

It cleanups a bunch of files, which i think your previous commit ended up adding back.

Thanks, redid it with that command.

Copy link
Contributor

@tejal29 tejal29 left a comment

Choose a reason for hiding this comment

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

/lgtm
/hold

Remove hold when you are ready to merge.

@knative-prow-robot knative-prow-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Oct 12, 2018
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Oct 12, 2018
@dlorenc
Copy link
Contributor Author

dlorenc commented Oct 12, 2018

Remove hold when you are ready to merge.

actually i screwed something up in vendor/... fixing it

@dlorenc
Copy link
Contributor Author

dlorenc commented Oct 12, 2018

actually i screwed something up in vendor/... fixing it

My git-fu wasn't good enough to go back and edit the initial dep commit. I squashed them for now since it's way fewer files than it was at first.

pkg/reconciler/v1alpha1/taskrun/taskrun.go Outdated Show resolved Hide resolved
pkg/reconciler/v1alpha1/taskrun/taskrun.go Show resolved Hide resolved
pkg/reconciler/v1alpha1/taskrun/taskrun.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@bobcatfish bobcatfish left a comment

Choose a reason for hiding this comment

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

wooooot - pretty cool that we can re-use the functionality in knative/build

@dlorenc how do you feel about getting some docs started in our docs dir about how to use this? (i.e. user facing docs)

@@ -107,8 +170,8 @@ func TestReconcile(t *testing.T) {
t.Errorf("Expected actions to be logged in the buildclient, got none")
}
build := client.Actions()[0].(ktesting.CreateAction).GetObject().(*buildv1alpha1.Build)
if d := cmp.Diff(build.Spec, buildSpec); d != "" {
t.Errorf("Expected created resource to be %v, but was %v", build.Spec, buildSpec)
if d := cmp.Diff(build.Spec, tc.wantedBuildSpec); d != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

im curious on your thoughts here @dlorenc - i feel like the set of situations this one particular test is supposed to handle are growing over time, what about creating a separate function specifically for testing the case where we have replacements in a task?

Copy link
Member

Choose a reason for hiding this comment

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

+1 for moving this to a specific test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, cleaned up the test a bit. I actually ended up leaving this one in the same test, but reorganized the tests around it.

This test actually only had one other tc before this, but it was complicated enough to make that hard to see.

Now there's one test for times a build should have been created (with and without templating), and one for error cases.

@dlorenc dlorenc force-pushed the params branch 2 times, most recently from ed03a7a to dd0138b Compare October 13, 2018 16:18
@knative-prow-robot knative-prow-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. labels Oct 13, 2018
@dlorenc
Copy link
Contributor Author

dlorenc commented Oct 13, 2018

@dlorenc how do you feel about getting some docs started in our docs dir about how to use this? (i.e. user facing docs)

Done.

@dlorenc
Copy link
Contributor Author

dlorenc commented Oct 14, 2018

/hold remove

This adds support for Task/TaskRun Input Parameters using the 'ApplyReplacements' function from knative/build.
Reusing this function ensures consistency in variable replacement between the projects.

This change assumes that the supplied TaskRun.Spec.Inputs.Params have been valided against the Task.Inputs.Params elsewhere.
We may want to revisit this and perform additional validation.

This change does not introduce support for Resources or PipelineParams yet.
@dlorenc
Copy link
Contributor Author

dlorenc commented Oct 15, 2018

/hold cancel

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 15, 2018
@nader-ziada
Copy link
Member

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 15, 2018
@knative-prow-robot knative-prow-robot merged commit 2789caa into tektoncd:master Oct 15, 2018
@@ -0,0 +1,49 @@
## Task Parameters
Copy link
Collaborator

Choose a reason for hiding this comment

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

amaaaaazing

next time we touch this we should add a link from the main README to here, otherwise this would be hard to find

dlorenc added a commit to dlorenc/build-pipeline that referenced this pull request Oct 15, 2018
This commit builds upon tektoncd#149 and makes resource keys available for expansion
inside a TaskRun.

Resources are available under the namespace 'inputs.resources', and each
resource is namespaced under it's own name.

This commit adds to the PipelineResourceInterface, requiring types to support a
Replacements method. This supplies keys to be replaced.
dlorenc added a commit to dlorenc/build-pipeline that referenced this pull request Oct 15, 2018
This commit builds upon tektoncd#149 and makes resource keys available for expansion
inside a TaskRun.

Resources are available under the namespace 'inputs.resources', and each
resource is namespaced under it's own name.

This commit adds to the PipelineResourceInterface, requiring types to support a
Replacements method. This supplies keys to be replaced.
dlorenc added a commit to dlorenc/build-pipeline that referenced this pull request Oct 16, 2018
This commit builds upon tektoncd#149 and makes resource keys available for expansion
inside a TaskRun.

Resources are available under the namespace 'inputs.resources', and each
resource is namespaced under it's own name.

This commit adds to the PipelineResourceInterface, requiring types to support a
Replacements method. This supplies keys to be replaced.
knative-prow-robot pushed a commit that referenced this pull request Oct 17, 2018
This commit builds upon #149 and makes resource keys available for expansion
inside a TaskRun.

Resources are available under the namespace 'inputs.resources', and each
resource is namespaced under it's own name.

This commit adds to the PipelineResourceInterface, requiring types to support a
Replacements method. This supplies keys to be replaced.
pradeepitm12 pushed a commit to pradeepitm12/pipeline that referenced this pull request Jan 28, 2021
Fixes tektoncd#149

Adds $(header) and $(header.X) as interpolation variables that will be
substituted for header values from the event. So, header values can be
used within TriggerBindings.

Changes the "event" interpolation variable to "body" which nicely
separates the "header" and "body" interpolation variables.

Escapes double quotes in JSON strings that are substituted using
variable interpolation. This fixes a bug where Triggers failed to create
resources when a JSON object was passed as a parameter. The e2e test has
been updated to cover this hole.
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. lgtm Indicates that a PR is ready to be merged. 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.

5 participants