Skip to content

Commit

Permalink
Merge branch 'master' into ce-preview4
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Nichols committed Mar 20, 2020
2 parents d75412a + 212e3d4 commit dc0a6d7
Show file tree
Hide file tree
Showing 17 changed files with 163 additions and 238 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ a cluster with **Kubernetes version 1.15 or later***.
| [HEAD](DEVELOPMENT.md#install-pipeline) | [Docs @ HEAD](/docs/README.md) | [Examples @ HEAD](/examples) |
| [v0.11.0-rc2](https:/tektoncd/pipeline/releases/tag/v0.11.0-rc2) | [Docs @ v0.11.0-rc2](https:/tektoncd/pipeline/tree/v0.11.0-rc2/docs#tekton-pipelines) | [Examples @ v0.11.0-rc2](https:/tektoncd/pipeline/tree/v0.11.0-rc2/examples#examples) |
| [v0.11.0-rc1](https:/tektoncd/pipeline/releases/tag/v0.11.0-rc1) | [Docs @ v0.11.0-rc1](https:/tektoncd/pipeline/tree/v0.11.0-rc1/docs#tekton-pipelines) | [Examples @ v0.11.0-rc1](https:/tektoncd/pipeline/tree/v0.11.0-rc1/examples#examples) |
| [v0.10.2](https:/tektoncd/pipeline/releases/tag/v0.10.2) | [Docs @ v0.10.2](https:/tektoncd/pipeline/tree/v0.10.2/docs#tekton-pipelines) | [Examples @ v0.10.1](https:/tektoncd/pipeline/tree/v0.10.1/examples#examples) |
| [v0.10.1](https:/tektoncd/pipeline/releases/tag/v0.10.1) | [Docs @ v0.10.1](https:/tektoncd/pipeline/tree/v0.10.1/docs#tekton-pipelines) | [Examples @ v0.10.1](https:/tektoncd/pipeline/tree/v0.10.1/examples#examples) |
| [v0.10.0](https:/tektoncd/pipeline/releases/tag/v0.10.0) | [Docs @ v0.10.0](https:/tektoncd/pipeline/tree/v0.10.0/docs#tekton-pipelines) | [Examples @ v0.10.0](https:/tektoncd/pipeline/tree/v0.10.0/examples#examples) |
| [v0.9.2](https:/tektoncd/pipeline/releases/tag/v0.9.2) | [Docs @ v0.9.2](https:/tektoncd/pipeline/tree/v0.9.2/docs#tekton-pipelines) | [Examples @ v0.9.2](https:/tektoncd/pipeline/tree/v0.9.2/examples#examples) |
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ spec:
value: Dockerfile
- name: pathToContext
value: /workspace/docker-source/examples/microservices/leeroy-web #configure: may change according to your source
resource:
resources:
inputs:
- name: docker-source
resourceRef:
Expand Down Expand Up @@ -425,7 +425,7 @@ First, create a new role called `tutorial-role`:

```bash
kubectl create clusterrole tutorial-role \
--verb=get,list,watch,create,update,patch,delete \
--verb=* \
--resource=deployments,deployments.apps
```

Expand Down
2 changes: 1 addition & 1 deletion docs/workspaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ on [configuring a `VolumeSource`](#volumesources-for-workspaces) in your `Pipeli
#### Example PipelineRun Specs With Workspaces

The examples below show the relevant fields of `PipelineRun` specs when working with
`Workspaces`. For a more complete end-to-end example, see [the Workspaces PipelineRun](../examples/v1beta1/pipelineruns/workspace.yaml)
`Workspaces`. For a more complete end-to-end example, see [the Workspaces PipelineRun](../examples/v1beta1/pipelineruns/workspaces.yaml)
in the examples directory.

Here an existing PersistentVolumeClaim called `mypvc` is used for a Pipeline's `workspace`
Expand Down
4 changes: 2 additions & 2 deletions examples/v1beta1/taskruns/task-result.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ spec:
- name: current-date-unix-timestamp
description: The current date in unix timestamp format
- name: current-date-human-readable
description: The current date in humand readable format
description: The current date in human readable format
steps:
- name: print-date-unix-timestamp
image: bash:latest
script: |
#!/usr/bin/env bash
date +%s | tee /tekton/results/current-date-unix-timestamp
- name: print-date-humman-readable
- name: print-date-human-readable
image: bash:latest
script: |
#!/usr/bin/env bash
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/pipeline/v1alpha1/pipeline_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func (source *PipelineSpec) ConvertTo(ctx context.Context, sink *v1beta1.Pipelin
sink.Resources = source.Resources
sink.Params = source.Params
sink.Workspaces = source.Workspaces
sink.Description = source.Description
if len(source.Tasks) > 0 {
sink.Tasks = make([]v1beta1.PipelineTask, len(source.Tasks))
for i := range source.Tasks {
Expand Down Expand Up @@ -86,6 +87,7 @@ func (sink *PipelineSpec) ConvertFrom(ctx context.Context, source v1beta1.Pipeli
sink.Resources = source.Resources
sink.Params = source.Params
sink.Workspaces = source.Workspaces
sink.Description = source.Description
if len(source.Tasks) > 0 {
sink.Tasks = make([]PipelineTask, len(source.Tasks))
for i := range source.Tasks {
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/pipeline/v1alpha1/pipeline_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func TestPipelineConversion(t *testing.T) {
Generation: 1,
},
Spec: PipelineSpec{
Description: "test",
Resources: []PipelineDeclaredResource{{
Name: "resource1",
Type: resource.PipelineResourceTypeGit,
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/pipeline/v1alpha1/task_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func (source *TaskSpec) ConvertTo(ctx context.Context, sink *v1beta1.TaskSpec) e
sink.Results = source.Results
sink.Resources = source.Resources
sink.Params = source.Params
sink.Description = source.Description
if source.Inputs != nil {
if len(source.Inputs.Params) > 0 && len(source.Params) > 0 {
// This shouldn't happen as it shouldn't pass validation
Expand Down Expand Up @@ -120,5 +121,6 @@ func (sink *TaskSpec) ConvertFrom(ctx context.Context, source *v1beta1.TaskSpec)
sink.Results = source.Results
sink.Params = source.Params
sink.Resources = source.Resources
sink.Description = source.Description
return nil
}
1 change: 1 addition & 0 deletions pkg/apis/pipeline/v1alpha1/task_conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func TestTaskConversion(t *testing.T) {
},
Spec: TaskSpec{
TaskSpec: v1beta1.TaskSpec{
Description: "test",
Steps: []v1beta1.Step{{Container: corev1.Container{
Image: "foo",
}}},
Expand Down
27 changes: 27 additions & 0 deletions test/builder/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ type TaskRunStatusOp func(*v1alpha1.TaskRunStatus)
// TaskRefOp is an operation which modify a TaskRef struct.
type TaskRefOp func(*v1alpha1.TaskRef)

// TaskResultOp is an operation which modifies there
type TaskResultOp func(result *v1beta1.TaskResult)

// TaskRunInputsOp is an operation which modify a TaskRunInputs struct.
type TaskRunInputsOp func(*v1alpha1.TaskRunInputs)

Expand Down Expand Up @@ -247,6 +250,17 @@ func TaskResources(ops ...TaskResourcesOp) TaskSpecOp {
}
}

// TaskResults sets the Results to the TaskSpec
func TaskResults(name, desc string) TaskSpecOp {
return func(spec *v1alpha1.TaskSpec) {
r := &v1beta1.TaskResult{
Name: name,
Description: desc,
}
spec.Results = append(spec.Results, *r)
}
}

// TaskResourcesInput adds a TaskResource as Inputs to the TaskResources
func TaskResourcesInput(name string, resourceType v1alpha1.PipelineResourceType, ops ...TaskResourceOp) TaskResourcesOp {
return func(r *v1beta1.TaskResources) {
Expand Down Expand Up @@ -279,6 +293,19 @@ func TaskResourcesOutput(name string, resourceType v1alpha1.PipelineResourceType
}
}

// TaskResultsOutput adds a TaskResult as Outputs to the TaskResources
func TaskResultsOutput(name, desc string, ops ...TaskResultOp) TaskResultOp {
return func(result *v1beta1.TaskResult) {
r := &v1beta1.TaskResult{
Name: name,
Description: desc,
}
for _, op := range ops {
op(r)
}
}
}

// TaskInputs sets inputs to the TaskSpec.
// Any number of Inputs modifier can be passed to transform it.
func TaskInputs(ops ...InputsOp) TaskSpecOp {
Expand Down
55 changes: 4 additions & 51 deletions test/cancel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ limitations under the License.
package test

import (
"errors"
"fmt"
"sync"
"testing"

"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
tb "github.com/tektoncd/pipeline/test/builder"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/pkg/apis"
knativetest "knative.dev/pkg/test"
)

Expand Down Expand Up @@ -91,17 +87,7 @@ func TestTaskRunPipelineRunCancel(t *testing.T) {
}

t.Logf("Waiting for Pipelinerun %s in namespace %s to be started", "pear", namespace)
if err := WaitForPipelineRunState(c, "pear", pipelineRunTimeout, func(pr *v1alpha1.PipelineRun) (bool, error) {
c := pr.Status.GetCondition(apis.ConditionSucceeded)
if c != nil {
if c.Status == corev1.ConditionTrue || c.Status == corev1.ConditionFalse {
return true, errors.New(`pipelineRun "pear" already finished`)
} else if c.Status == corev1.ConditionUnknown && (c.Reason == "Running" || c.Reason == "Pending") {
return true, nil
}
}
return false, nil
}, "PipelineRunRunning"); err != nil {
if err := WaitForPipelineRunState(c, "pear", pipelineRunTimeout, Running("pear"), "PipelineRunRunning"); err != nil {
t.Fatalf("Error waiting for PipelineRun %s to be running: %s", "pear", err)
}

Expand All @@ -118,16 +104,7 @@ func TestTaskRunPipelineRunCancel(t *testing.T) {
wg.Add(1)
go func(name string) {
defer wg.Done()
err := WaitForTaskRunState(c, name, func(tr *v1alpha1.TaskRun) (bool, error) {
if c := tr.Status.GetCondition(apis.ConditionSucceeded); c != nil {
if c.IsTrue() || c.IsFalse() {
return true, fmt.Errorf("taskRun %q already finished", name)
} else if c.IsUnknown() && (c.Reason == "Running" || c.Reason == "Pending") {
return true, nil
}
}
return false, nil
}, "TaskRunRunning")
err := WaitForTaskRunState(c, name, Running(name), "TaskRunRunning")
if err != nil {
t.Errorf("Error waiting for TaskRun %s to be running: %v", name, err)
}
Expand All @@ -146,19 +123,7 @@ func TestTaskRunPipelineRunCancel(t *testing.T) {
}

t.Logf("Waiting for PipelineRun %s in namespace %s to be cancelled", "pear", namespace)
if err := WaitForPipelineRunState(c, "pear", pipelineRunTimeout, func(pr *v1alpha1.PipelineRun) (bool, error) {
if c := pr.Status.GetCondition(apis.ConditionSucceeded); c != nil {
if c.IsFalse() {
if c.Reason == "PipelineRunCancelled" {
return true, nil
}
return true, fmt.Errorf(`pipelineRun "pear" completed with the wrong reason: %s`, c.Reason)
} else if c.IsTrue() {
return true, errors.New(`pipelineRun "pear" completed successfully, should have been cancelled`)
}
}
return false, nil
}, "PipelineRunCancelled"); err != nil {
if err := WaitForPipelineRunState(c, "pear", pipelineRunTimeout, FailedWithReason("PipelineRunCancelled", "pear"), "PipelineRunCancelled"); err != nil {
t.Errorf("Error waiting for PipelineRun `pear` to finished: %s", err)
}

Expand All @@ -167,19 +132,7 @@ func TestTaskRunPipelineRunCancel(t *testing.T) {
wg.Add(1)
go func(name string) {
defer wg.Done()
err := WaitForTaskRunState(c, name, func(tr *v1alpha1.TaskRun) (bool, error) {
if c := tr.Status.GetCondition(apis.ConditionSucceeded); c != nil {
if c.IsFalse() {
if c.Reason == "TaskRunCancelled" {
return true, nil
}
return true, fmt.Errorf("taskRun %q completed with the wrong reason: %s", name, c.Reason)
} else if c.IsTrue() {
return true, fmt.Errorf("taskRun %q completed successfully, should have been cancelled", name)
}
}
return false, nil
}, "TaskRunCancelled")
err := WaitForTaskRunState(c, name, FailedWithReason("TaskRunCancelled", name), "TaskRunCancelled")
if err != nil {
t.Errorf("Error waiting for TaskRun %s to be finished: %v", name, err)
}
Expand Down
4 changes: 1 addition & 3 deletions test/kaniko_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ func TestKanikoTaskRun(t *testing.T) {

// Verify status of TaskRun (wait for it)

if err := WaitForTaskRunState(c, kanikoTaskRunName, func(tr *v1alpha1.TaskRun) (bool, error) {
return TaskRunSucceed(kanikoTaskRunName)(tr)
}, "TaskRunCompleted"); err != nil {
if err := WaitForTaskRunState(c, kanikoTaskRunName, Succeed(kanikoTaskRunName), "TaskRunCompleted"); err != nil {
t.Errorf("Error waiting for TaskRun %s to finish: %s", kanikoTaskRunName, err)
}

Expand Down
13 changes: 7 additions & 6 deletions test/sidecar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"testing"
"time"

"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
tb "github.com/tektoncd/pipeline/test/builder"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -91,14 +90,16 @@ func TestSidecarTaskSupport(t *testing.T) {
t.Errorf("Failed to create TaskRun %q: %v", sidecarTaskRunName, err)
}

var podName string
if err := WaitForTaskRunState(clients, sidecarTaskRunName, func(tr *v1alpha1.TaskRun) (bool, error) {
podName = tr.Status.PodName
return TaskRunSucceed(sidecarTaskRunName)(tr)
}, "TaskRunSucceed"); err != nil {
if err := WaitForTaskRunState(clients, sidecarTaskRunName, Succeed(sidecarTaskRunName), "TaskRunSucceed"); err != nil {
t.Errorf("Error waiting for TaskRun %q to finish: %v", sidecarTaskRunName, err)
}

tr, err := clients.TaskRunClient.Get(sidecarTaskRunName, metav1.GetOptions{})
if err != nil {
t.Errorf("Error getting Taskrun: %v", err)
}
podName := tr.Status.PodName

if err := WaitForPodState(clients, podName, namespace, func(pod *corev1.Pod) (bool, error) {
terminatedCount := 0
for _, c := range pod.Status.ContainerStatuses {
Expand Down
Loading

0 comments on commit dc0a6d7

Please sign in to comment.