-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Adding support to enable resourceSpec #1324
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: task-to-list-files | ||
spec: | ||
inputs: | ||
resources: | ||
- name: pipeline-git | ||
type: git | ||
outputs: | ||
resources: | ||
- name: pipeline-git | ||
type: git | ||
steps: | ||
- name: list | ||
image: ubuntu | ||
command: | ||
- bash | ||
args: | ||
- -c | ||
- | | ||
ls -al $(inputs.resources.pipeline-git.path) | ||
--- | ||
|
||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Condition | ||
metadata: | ||
name: always-true-sample-condition | ||
spec: | ||
resources: | ||
- name: pipeline-git | ||
type: git | ||
check: | ||
image: ubuntu | ||
command: | ||
- bash | ||
args: | ||
- -c | ||
- | | ||
echo "Hello from Tekton Pipeline!" | ||
--- | ||
|
||
apiVersion: tekton.dev/v1alpha1 | ||
kind: Pipeline | ||
metadata: | ||
name: pipeline-to-list-files | ||
spec: | ||
resources: | ||
- name: pipeline-git | ||
type: git | ||
params: | ||
- name: "path" | ||
default: "README.md" | ||
tasks: | ||
- name: list-files | ||
taskRef: | ||
name: task-to-list-files | ||
resources: | ||
inputs: | ||
- name: pipeline-git | ||
resource: pipeline-git | ||
outputs: | ||
- name: pipeline-git | ||
resource: pipeline-git | ||
- name: conditional-list-files | ||
taskRef: | ||
name: task-to-list-files | ||
conditions: | ||
- conditionRef: always-true-sample-condition | ||
resources: | ||
- name: pipeline-git | ||
resource: pipeline-git | ||
resources: | ||
inputs: | ||
- name: pipeline-git | ||
resource: pipeline-git | ||
outputs: | ||
- name: pipeline-git | ||
resource: pipeline-git | ||
--- | ||
|
||
apiVersion: tekton.dev/v1alpha1 | ||
kind: PipelineRun | ||
metadata: | ||
name: demo-pipelinerun-with-resourcespec | ||
spec: | ||
pipelineRef: | ||
name: pipeline-to-list-files | ||
serviceAccount: 'default' | ||
resources: | ||
- name: pipeline-git | ||
resourceSpec: | ||
type: git | ||
params: | ||
- name: revision | ||
value: master | ||
- name: url | ||
value: https://github.com/tektoncd/pipeline | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,13 +174,22 @@ func (rcc *ResolvedConditionCheck) ToTaskResourceBindings() []v1alpha1.TaskResou | |
var trb []v1alpha1.TaskResourceBinding | ||
|
||
for name, r := range rcc.ResolvedResources { | ||
trb = append(trb, v1alpha1.TaskResourceBinding{ | ||
tr := v1alpha1.TaskResourceBinding{ | ||
Name: name, | ||
ResourceRef: v1alpha1.PipelineResourceRef{ | ||
} | ||
if r.SelfLink != "" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hey @pritidesai, somehow I didn't notice this when I looked before: what's the significance of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Hey @bobcatfish yes |
||
tr.ResourceRef = v1alpha1.PipelineResourceRef{ | ||
Name: r.Name, | ||
APIVersion: r.APIVersion, | ||
}, | ||
}) | ||
} | ||
} else if r.Spec.Type != "" { | ||
tr.ResourceSpec = &v1alpha1.PipelineResourceSpec{ | ||
Type: r.Spec.Type, | ||
Params: r.Spec.Params, | ||
SecretParams: r.Spec.SecretParams, | ||
} | ||
} | ||
trb = append(trb, tr) | ||
} | ||
|
||
return trb | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -290,9 +290,6 @@ func TestResolvedConditionCheck_ToTaskResourceBindings(t *testing.T) { | |
|
||
expected := []v1alpha1.TaskResourceBinding{{ | ||
Name: "git-resource", | ||
ResourceRef: v1alpha1.PipelineResourceRef{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this deleted? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sometimes you want to have a ResourceBinding without a Ref (e.g. if you're using a spec!). So in the tests for embedded TaskRun Resource specs, this was being set even tho it shouldn't be (The other function actually doesn't set this) (Might be worth adding this to the commit message if it isn't there already @pritidesai !) |
||
Name: "some-repo", | ||
}, | ||
}} | ||
|
||
if d := cmp.Diff(expected, rcc.ToTaskResourceBindings()); d != "" { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great example!