forked from tektoncd/pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Implementation details Pipelinerun creates pvc for the lifetime for object and uses that pvc as scratch space to transfer git resources between them. This information is passed to taskrun via resource paths. Paths are array of strings and incase of inouts these paths will be considered as new source of pipeline resource. In the case of outputs paths will be considered as new destination directory. Partially fixes tektoncd#148
- Loading branch information
Shash Reddy
committed
Nov 28, 2018
1 parent
57367eb
commit 7381dab
Showing
29 changed files
with
1,616 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: pipeline.knative.dev/v1alpha1 | ||
kind: PipelineRun | ||
metadata: | ||
name: kritis-pipeline-pvc | ||
namespace: default | ||
spec: | ||
pipelineRef: | ||
name: kritis-pipeline-pvc | ||
triggerRef: | ||
type: manual | ||
resources: | ||
- name: create-file-kritis | ||
inputs: | ||
- name: workspace | ||
resourceRef: | ||
name: kritis-resources-git | ||
outputs: | ||
- name: workspace | ||
resourceRef: | ||
name: kritis-resources-git | ||
- name: check-kritis | ||
inputs: | ||
- name: workspace | ||
resourceRef: | ||
name: kritis-resources-git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
apiVersion: pipeline.knative.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: create-file | ||
namespace: default | ||
spec: | ||
inputs: | ||
resources: | ||
- name: workspace | ||
type: git | ||
targetPath: /damnworkspace | ||
outputs: | ||
resources: | ||
- name: workspace | ||
type: git | ||
steps: | ||
- name: read-docs-old | ||
image: ubuntu | ||
command: ["/bin/bash"] | ||
args: ['-c', 'ls -la /workspace/damnworkspace/docs/install.md'] # tests that targetpath works | ||
- name: write-new-stuff | ||
image: ubuntu | ||
command: ['bash'] | ||
args: ['-c', 'echo some stuff > /workspace/damnworkspace/stuff'] | ||
|
||
--- | ||
apiVersion: pipeline.knative.dev/v1alpha1 | ||
kind: Task | ||
metadata: | ||
name: check-stuff-file-exists | ||
namespace: default | ||
spec: | ||
inputs: | ||
resources: | ||
- name: workspace | ||
type: git | ||
targetPath: /newworkspace | ||
steps: | ||
- name: read | ||
image: ubuntu | ||
command: ["/bin/bash"] | ||
args: ['-c', 'cat /workspace/newworkspace/stuff'] # tests that new targetpath and previous task output is dumped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: pipeline.knative.dev/v1alpha1 | ||
kind: Pipeline | ||
metadata: | ||
name: kritis-pipeline-pvc | ||
namespace: default | ||
spec: | ||
tasks: | ||
- name: create-file-kritis # 1. create file | ||
taskRef: | ||
name: create-file | ||
- name: check-kritis # 2. check file exists | ||
taskRef: | ||
name: check-stuff-file-exists | ||
resources: | ||
- name: workspace | ||
providedBy: [create-file-kritis] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,4 @@ spec: | |
- name: token | ||
value: eyJhbGciOiJ..... | ||
- name: username | ||
value: admin | ||
value: admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
Copyright 2018 The Knative Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package v1alpha1 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
corev1 "k8s.io/api/core/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func TestTaskRun_GetBuildRef(t *testing.T) { | ||
tr := TaskRun{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "taskrunname", | ||
Namespace: "testns", | ||
}, | ||
} | ||
expectedBuildRef := corev1.ObjectReference{ | ||
APIVersion: "build.knative.dev/v1alpha1", | ||
Kind: "Build", | ||
Namespace: "testns", | ||
Name: "taskrunname", | ||
} | ||
if d := cmp.Diff(tr.GetBuildRef(), expectedBuildRef); d != "" { | ||
t.Fatalf("taskrun build ref mismatch: %s", d) | ||
} | ||
} | ||
|
||
func TestTasRun_Valid_GetPipelineRunPVCName(t *testing.T) { | ||
tr := TaskRun{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "taskrunname", | ||
Namespace: "testns", | ||
OwnerReferences: []metav1.OwnerReference{{ | ||
Kind: "PipelineRun", | ||
Name: "testpr", | ||
}}, | ||
}, | ||
} | ||
expectedPVCName := "testpr-pvc" | ||
if tr.GetPipelineRunPVCName() != expectedPVCName { | ||
t.Fatalf("taskrun pipeline run mismatch: got %s ; expected %s", tr.GetPipelineRunPVCName(), expectedPVCName) | ||
} | ||
} | ||
|
||
func TestTasRun_InvalidOwner_GetPipelineRunPVCName(t *testing.T) { | ||
tr := TaskRun{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "taskrunname", | ||
Namespace: "testns", | ||
OwnerReferences: []metav1.OwnerReference{{ | ||
Kind: "SomeOtherOwner", | ||
Name: "testpr", | ||
}}, | ||
}, | ||
} | ||
expectedPVCName := "" | ||
if tr.GetPipelineRunPVCName() != expectedPVCName { | ||
t.Fatalf("taskrun pipeline run pvc name mismatch: got %s ; expected %s", tr.GetPipelineRunPVCName(), expectedPVCName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.