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 template variable expansion for Resources. #153

Merged
merged 2 commits into from
Oct 17, 2018

Conversation

dlorenc
Copy link
Contributor

@dlorenc dlorenc commented Oct 15, 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.

Ref #64

@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 15, 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 15, 2018
pkg/apis/pipeline/v1alpha1/resource_types.go Outdated Show resolved Hide resolved
pkg/apis/pipeline/v1alpha1/resource_types.go Outdated Show resolved Hide resolved
pkg/reconciler/v1alpha1/taskrun/taskrun.go Outdated Show resolved Hide resolved
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 dlorenc force-pushed the resources branch 4 times, most recently from 5b45385 to 886af16 Compare October 16, 2018 15:32
b = b.DeepCopy()
f(b)
return b
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

whoa 😎

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.

I had one totally minor comment about error messages but otherwise I think it's looking good!

/lgtm

Remove if you want to merge as-is:
/hold

@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 16, 2018
@nader-ziada
Copy link
Member

also one more comment from me, the taskrun controller as it stands now in this PR:

  • makes a call to addInputResource which loops on all the input resources to add them to the build
  • makes a call to applyReplacements which also loops on all the input resources to update them

was wondering if we can combine these two operations in one loop?

we can also make this optimization in a later PR if you want to merge this in.

- Move logic to a new file in resources pkg.
- Switch to using a Getter from a Lister
- Add separate tests for params and resources
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 17, 2018
@dlorenc
Copy link
Contributor Author

dlorenc commented Oct 17, 2018

we can also make this optimization in a later PR if you want to merge this in.

Ah I thought I addressed this somewhere else. I prefer keeping the two loops separate (for readability and testability), but we could fetch the list of resources once and use that in the loops rather than going through the Lister each time.

I'm not sure how big of a speedup that would be though, given that the Lister is cached.

WDYT?

@dlorenc
Copy link
Contributor Author

dlorenc commented Oct 17, 2018

I had one totally minor comment about error messages but otherwise I think it's looking good!

Fixed it!

case PipelineResourceTypeImage:
return NewImageResource(r)
}
return nil, fmt.Errorf("%s is an invalid or unimplemented PipelineResource", r.Spec.Type)
Copy link
Collaborator

Choose a reason for hiding this comment

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

lol okay

}
}

type rg struct {
Copy link
Collaborator

Choose a reason for hiding this comment

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

what's the g in rg?

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.

IT IS A BEAUTIFUL THING

/lgtm
/meow space

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 17, 2018
@knative-prow-robot
Copy link

@bobcatfish: cat image

In response to this:

IT IS A BEAUTIFUL THING

/lgtm
/meow space

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.

@bobcatfish
Copy link
Collaborator

im just gonna remove the hold for you cuz i assume that is what you want 😇

/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 17, 2018
@knative-prow-robot knative-prow-robot merged commit 3b03577 into tektoncd:master Oct 17, 2018
vdemeester referenced this pull request in vdemeester/tektoncd-pipeline Oct 7, 2019
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/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.

4 participants