builder

package
v0.28.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package builder holds Builder functions that can be used to create struct in tests with less noise.

By convention, this package is import with the "tb" as alias. The examples make that assumption.

Deprecated: This package is deprecated. See https://github.com/tektoncd/pipeline/issues/3178 for more information.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlockOwnerDeletion

func BlockOwnerDeletion(o *metav1.OwnerReference)

BlockOwnerDeletion sets the BlockOwnerDeletion to the OwnerReference.

func ClusterTask

func ClusterTask(name string, ops ...ClusterTaskOp) *v1beta1.ClusterTask

ClusterTask creates a ClusterTask with default values. Any number of ClusterTask modifier can be passed to transform it.

Example
package main

import (
	"testing"

	"github.com/google/go-cmp/cmp"
	tb "github.com/tektoncd/pipeline/internal/builder/v1beta1"
	"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
)

// This is a "hack" to make the example "look" like tests
var t *testing.T

func main() {
	myClusterTask := tb.ClusterTask("my-task", tb.ClusterTaskSpec(
		tb.Step("myotherimage", tb.StepCommand("/mycmd")),
	))
	expectedClusterTask := &v1beta1.Task{
		// […]
	}
	// […]
	if d := cmp.Diff(expectedClusterTask, myClusterTask); d != "" {
		t.Fatalf("ClusterTask diff -want, +got: %v", d)
	}
}
Output:

func ClusterTaskType

func ClusterTaskType(t *v1beta1.ClusterTask)

ClusterTaskType sets the TypeMeta on the ClusterTask which is useful for making it serializable/deserializable.

func Controller

func Controller(o *metav1.OwnerReference)

Controller sets the Controller to the OwnerReference.y

func Pipeline

func Pipeline(name string, ops ...PipelineOp) *v1beta1.Pipeline

Pipeline creates a Pipeline with default values. Any number of Pipeline modifier can be passed to transform it.

Example
package main

import (
	"testing"

	"github.com/google/go-cmp/cmp"
	tb "github.com/tektoncd/pipeline/internal/builder/v1beta1"
	"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
)

// This is a "hack" to make the example "look" like tests
var t *testing.T

func main() {
	pipeline := tb.Pipeline("tomatoes",
		tb.PipelineSpec(tb.PipelineTask("foo", "banana")),
	)
	expectedPipeline := &v1beta1.Pipeline{
		// […]
	}
	// […]
	if d := cmp.Diff(expectedPipeline, pipeline); d != "" {
		t.Fatalf("Task diff -want, +got: %v", d)
	}
}
Output:

func PipelineResource

func PipelineResource(name string, ops ...PipelineResourceOp) *resource.PipelineResource

PipelineResource creates a PipelineResource with default values. Any number of PipelineResource modifier can be passed to transform it.

Example
package main

import (
	"testing"

	"github.com/google/go-cmp/cmp"
	tb "github.com/tektoncd/pipeline/internal/builder/v1beta1"
	"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"

	resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1"
)

// This is a "hack" to make the example "look" like tests
var t *testing.T

func main() {
	gitResource := tb.PipelineResource("git-resource", tb.PipelineResourceSpec(
		v1beta1.PipelineResourceTypeGit, tb.PipelineResourceSpecParam("URL", "https://foo.git"),
	))
	imageResource := tb.PipelineResource("image-resource", tb.PipelineResourceSpec(
		v1beta1.PipelineResourceTypeImage, tb.PipelineResourceSpecParam("URL", "gcr.io/kristoff/sven"),
	))
	expectedGitResource := resource.PipelineResource{
		// […]
	}
	expectedImageResource := resource.PipelineResource{
		// […]
	}
	// […]
	if d := cmp.Diff(expectedGitResource, gitResource); d != "" {
		t.Fatalf("Task diff -want, +got: %v", d)
	}
	if d := cmp.Diff(expectedImageResource, imageResource); d != "" {
		t.Fatalf("Task diff -want, +got: %v", d)
	}
}
Output:

func PipelineRun

func PipelineRun(name string, ops ...PipelineRunOp) *v1beta1.PipelineRun

PipelineRun creates a PipelineRun with default values. Any number of PipelineRun modifier can be passed to transform it.

Example
package main

import (
	"testing"

	"github.com/google/go-cmp/cmp"
	tb "github.com/tektoncd/pipeline/internal/builder/v1beta1"
	"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
)

// This is a "hack" to make the example "look" like tests
var t *testing.T

func main() {
	pipelineRun := tb.PipelineRun("pear",
		tb.PipelineRunSpec("tomatoes", tb.PipelineRunServiceAccountName("inexistent")),
	)
	expectedPipelineRun := &v1beta1.PipelineRun{
		// […]
	}
	// […]
	if d := cmp.Diff(expectedPipelineRun, pipelineRun); d != "" {
		t.Fatalf("Task diff -want, +got: %v", d)
	}
}
Output:

func PipelineRunCancelled

func PipelineRunCancelled(spec *v1beta1.PipelineRunSpec)

PipelineRunCancelled sets the status to Cancelled in the PipelineRunSpec.

func PipelineRunCancelledDeprecated added in v0.25.0

func PipelineRunCancelledDeprecated(spec *v1beta1.PipelineRunSpec)

PipelineRunCancelledDeprecated sets the status to PipelineRunCancelled in the PipelineRunSpec.

func PipelineRunCancelledRunFinally added in v0.25.0

func PipelineRunCancelledRunFinally(spec *v1beta1.PipelineRunSpec)

PipelineRunCancelledRunFinally sets the status to cancel and run finally in the PipelineRunSpec.

func PipelineRunNilTimeout

func PipelineRunNilTimeout(prs *v1beta1.PipelineRunSpec)

PipelineRunNilTimeout sets the timeout to nil on the PipelineRunSpec

func PipelineRunPending added in v0.21.0

func PipelineRunPending(spec *v1beta1.PipelineRunSpec)

PipelineRunPending sets the status to pending in the PipelineRunSpec.

func PipelineRunStoppedRunFinally added in v0.25.0

func PipelineRunStoppedRunFinally(spec *v1beta1.PipelineRunSpec)

PipelineRunStoppedRunFinally sets the status to stop and run finally in the PipelineRunSpec.

func PipelineType added in v0.18.0

func PipelineType(t *v1beta1.Pipeline)

PipelineType will add a TypeMeta to the pipeline's definition.

func Pod

func Pod(name string, ops ...PodOp) *corev1.Pod

Pod creates a Pod with default values. Any number of Pod modifiers can be passed to transform it.

func Task

func Task(name string, ops ...TaskOp) *v1beta1.Task

Task creates a Task with default values. Any number of Task modifier can be passed to transform it.

Example
package main

import (
	"testing"

	"github.com/google/go-cmp/cmp"
	tb "github.com/tektoncd/pipeline/internal/builder/v1beta1"
	"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"

	resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1"
)

// This is a "hack" to make the example "look" like tests
var t *testing.T

func main() {
	// You can declare re-usable modifiers
	myStep := tb.Step("myimage")
	// … and use them in a Task definition
	myTask := tb.Task("my-task", tb.TaskSpec(
		tb.Step("myotherimage", tb.StepCommand("/mycmd")),
		myStep,
	))
	// … and another one.
	myOtherTask := tb.Task("my-other-task",
		tb.TaskSpec(myStep,
			tb.TaskResources(tb.TaskResourcesInput("workspace", resource.PipelineResourceTypeGit)),
		),
	)
	expectedTask := &v1beta1.Task{
		// […]
	}
	expectedOtherTask := &v1beta1.Task{
		// […]
	}
	// […]
	if d := cmp.Diff(expectedTask, myTask); d != "" {
		t.Fatalf("Task diff -want, +got: %v", d)
	}
	if d := cmp.Diff(expectedOtherTask, myOtherTask); d != "" {
		t.Fatalf("Task diff -want, +got: %v", d)
	}
}
Output:

func TaskRun

func TaskRun(name string, ops ...TaskRunOp) *v1beta1.TaskRun

TaskRun creates a TaskRun with default values. Any number of TaskRun modifier can be passed to transform it.

Example
package main

import (
	"testing"

	"github.com/google/go-cmp/cmp"
	tb "github.com/tektoncd/pipeline/internal/builder/v1beta1"
	"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"

	resource "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1"
)

// This is a "hack" to make the example "look" like tests
var t *testing.T

func main() {
	// A simple definition, with a Task reference
	myTaskRun := tb.TaskRun("my-taskrun", tb.TaskRunSpec(
		tb.TaskRunTaskRef("my-task"),
	))
	// … or a more complex one with inline TaskSpec
	myTaskRunWithSpec := tb.TaskRun("my-taskrun-with-spec", tb.TaskRunSpec(
		tb.TaskRunParam("myarg", "foo"),
		tb.TaskRunResources(
			tb.TaskRunResourcesInput("workspace", tb.TaskResourceBindingRef("git-resource")),
		),
		tb.TaskRunTaskSpec(
			tb.TaskResources(tb.TaskResourcesInput("workspace", resource.PipelineResourceTypeGit)),
			tb.TaskParam("myarg", v1beta1.ParamTypeString, tb.ParamSpecDefault("mydefault")),
			tb.Step("myimage", tb.StepCommand("/mycmd"),
				tb.StepArgs("--my-arg=$(inputs.params.myarg)"),
			),
		),
	))
	expectedTaskRun := &v1beta1.TaskRun{
		// […]
	}
	expectedTaskRunWithSpec := &v1beta1.TaskRun{
		// […]
	}
	// […]
	if d := cmp.Diff(expectedTaskRun, myTaskRun); d != "" {
		t.Fatalf("Task diff -want, +got: %v", d)
	}
	if d := cmp.Diff(expectedTaskRunWithSpec, myTaskRunWithSpec); d != "" {
		t.Fatalf("Task diff -want, +got: %v", d)
	}
}
Output:

func TaskRunCancelled

func TaskRunCancelled(spec *v1beta1.TaskRunSpec)

TaskRunCancelled sets the status to cancel to the TaskRunSpec.

func TaskRunNilTimeout

func TaskRunNilTimeout(spec *v1beta1.TaskRunSpec)

TaskRunNilTimeout sets the timeout duration to nil on the TaskRunSpec.

func TaskType

func TaskType(t *v1beta1.Task)

TaskType sets the TypeMeta on the Task which is useful for making it serializable/deserializable.

Types

type ClusterTaskOp

type ClusterTaskOp func(*v1beta1.ClusterTask)

ClusterTaskOp is an operation which modify a ClusterTask struct.

func ClusterTaskSpec

func ClusterTaskSpec(ops ...TaskSpecOp) ClusterTaskOp

ClusterTaskSpec sets the specified spec of the cluster task. Any number of TaskSpec modifier can be passed to create it.

type ContainerOp

type ContainerOp func(*corev1.Container)

ContainerOp is an operation which modifies a Container struct.

func Args

func Args(args ...string) ContainerOp

Args sets the command arguments to the Container (step in this case).

func Command

func Command(args ...string) ContainerOp

Command sets the command to the Container (step in this case).

func EnvVar

func EnvVar(name, value string) ContainerOp

EnvVar add an environment variable, with specified name and value, to the Container (step).

func Resources

func Resources(ops ...ResourceRequirementsOp) ContainerOp

Resources adds ResourceRequirements to the Container (step).

func TerminationMessagePath

func TerminationMessagePath(terminationMessagePath string) ContainerOp

TerminationMessagePath sets the termination message path.

func VolumeMount

func VolumeMount(name, mountPath string, ops ...VolumeMountOp) ContainerOp

VolumeMount add a VolumeMount to the Container (step).

func WorkingDir

func WorkingDir(workingDir string) ContainerOp

WorkingDir sets the WorkingDir on the Container.

type OwnerReferenceOp

type OwnerReferenceOp func(*metav1.OwnerReference)

OwnerReferenceOp is an operation which modifies an OwnerReference struct.

func OwnerReferenceAPIVersion

func OwnerReferenceAPIVersion(version string) OwnerReferenceOp

OwnerReferenceAPIVersion sets the APIVersion to the OwnerReference.

type ParamSpecOp

type ParamSpecOp func(*v1beta1.ParamSpec)

ParamSpecOp is an operation which modify a ParamSpec struct.

func ParamSpecDefault

func ParamSpecDefault(value string, additionalValues ...string) ParamSpecOp

ParamSpecDefault sets the default value of a ParamSpec.

func ParamSpecDescription

func ParamSpecDescription(desc string) ParamSpecOp

ParamSpecDescription sets the description of a ParamSpec.

type PipelineOp

type PipelineOp func(*v1beta1.Pipeline)

PipelineOp is an operation which modify a Pipeline struct.

func PipelineCreationTimestamp

func PipelineCreationTimestamp(t time.Time) PipelineOp

PipelineCreationTimestamp sets the creation time of the pipeline

func PipelineNamespace

func PipelineNamespace(namespace string) PipelineOp

PipelineNamespace sets the namespace on the Pipeline

func PipelineSpec

func PipelineSpec(ops ...PipelineSpecOp) PipelineOp

PipelineSpec sets the PipelineSpec to the Pipeline. Any number of PipelineSpec modifier can be passed to transform it.

type PipelineResourceBindingOp

type PipelineResourceBindingOp func(*v1beta1.PipelineResourceBinding)

PipelineResourceBindingOp is an operation which modify a PipelineResourceBinding struct.

func PipelineResourceBindingRef

func PipelineResourceBindingRef(name string) PipelineResourceBindingOp

PipelineResourceBindingRef set the ResourceRef name to the Resource called Name.

func PipelineResourceBindingResourceSpec

func PipelineResourceBindingResourceSpec(spec *resource.PipelineResourceSpec) PipelineResourceBindingOp

PipelineResourceBindingResourceSpec set the PipelineResourceResourceSpec to the PipelineResourceBinding.

type PipelineResourceOp

type PipelineResourceOp func(*resource.PipelineResource)

PipelineResourceOp is an operation which modify a PipelineResource struct.

func PipelineResourceNamespace

func PipelineResourceNamespace(namespace string) PipelineResourceOp

PipelineResourceNamespace sets the namespace on a PipelineResource.

func PipelineResourceSpec

func PipelineResourceSpec(resourceType resource.PipelineResourceType, ops ...PipelineResourceSpecOp) PipelineResourceOp

PipelineResourceSpec set the PipelineResourceSpec, with specified type, to the PipelineResource. Any number of PipelineResourceSpec modifier can be passed to transform it.

type PipelineResourceSpecOp

type PipelineResourceSpecOp func(*resource.PipelineResourceSpec)

PipelineResourceSpecOp is an operation which modify a PipelineResourceSpec struct.

func PipelineResourceDescription

func PipelineResourceDescription(desc string) PipelineResourceSpecOp

PipelineResourceDescription sets the description of the pipeline resource

func PipelineResourceSpecParam

func PipelineResourceSpecParam(name, value string) PipelineResourceSpecOp

PipelineResourceSpecParam adds a ResourceParam, with specified name and value, to the PipelineResourceSpec.

func PipelineResourceSpecSecretParam

func PipelineResourceSpecSecretParam(fieldname, secretName, secretKey string) PipelineResourceSpecOp

PipelineResourceSpecSecretParam adds a SecretParam, with specified fieldname, secretKey and secretName, to the PipelineResourceSpec.

type PipelineRunOp

type PipelineRunOp func(*v1beta1.PipelineRun)

PipelineRunOp is an operation which modify a PipelineRun struct.

func PipelineRunAnnotation

func PipelineRunAnnotation(key, value string) PipelineRunOp

PipelineRunAnnotation adds a annotation to the PipelineRun.

func PipelineRunLabel

func PipelineRunLabel(key, value string) PipelineRunOp

PipelineRunLabel adds a label to the PipelineRun.

func PipelineRunNamespace

func PipelineRunNamespace(namespace string) PipelineRunOp

PipelineRunNamespace sets the namespace on a PipelineRun

func PipelineRunSelfLink(selflink string) PipelineRunOp

PipelineRunSelfLink adds a SelfLink

func PipelineRunSpec

func PipelineRunSpec(name string, ops ...PipelineRunSpecOp) PipelineRunOp

PipelineRunSpec sets the PipelineRunSpec, references Pipeline with specified name, to the PipelineRun. Any number of PipelineRunSpec modifier can be passed to transform it.

func PipelineRunStatus

func PipelineRunStatus(ops ...PipelineRunStatusOp) PipelineRunOp

PipelineRunStatus sets the PipelineRunStatus to the PipelineRun. Any number of PipelineRunStatus modifier can be passed to transform it.

type PipelineRunSpecOp

type PipelineRunSpecOp func(*v1beta1.PipelineRunSpec)

PipelineRunSpecOp is an operation which modify a PipelineRunSpec struct.

func PipelineRunFinallyTimeout added in v0.25.0

func PipelineRunFinallyTimeout(duration time.Duration) PipelineRunSpecOp

PipelineRunFinallyTimeout sets the timeout to the PipelineRunSpec.

func PipelineRunNodeSelector

func PipelineRunNodeSelector(values map[string]string) PipelineRunSpecOp

PipelineRunNodeSelector sets the Node selector to the PipelineRunSpec.

func PipelineRunParam

func PipelineRunParam(name string, value string, additionalValues ...string) PipelineRunSpecOp

PipelineRunParam add a param, with specified name and value, to the PipelineRunSpec.

func PipelineRunPipelineRefBundle added in v0.18.0

func PipelineRunPipelineRefBundle(url string) PipelineRunSpecOp

PipelineRunPipelineRefBundle will specify the given URL as the bundle url in the pipeline ref.

func PipelineRunPipelineSpec

func PipelineRunPipelineSpec(ops ...PipelineSpecOp) PipelineRunSpecOp

PipelineRunPipelineSpec adds a PipelineSpec to the PipelineRunSpec. Any number of PipelineSpec modifiers can be passed to transform it.

func PipelineRunPipelineTimeout added in v0.25.0

func PipelineRunPipelineTimeout(duration time.Duration) PipelineRunSpecOp

PipelineRunPipelineTimeout sets the timeout to the PipelineRunSpec.

func PipelineRunResourceBinding

func PipelineRunResourceBinding(name string, ops ...PipelineResourceBindingOp) PipelineRunSpecOp

PipelineRunResourceBinding adds bindings from actual instances to a Pipeline's declared resources.

func PipelineRunServiceAccountName

func PipelineRunServiceAccountName(sa string) PipelineRunSpecOp

PipelineRunServiceAccountName sets the service account to the PipelineRunSpec.

func PipelineRunServiceAccountNameTask

func PipelineRunServiceAccountNameTask(taskName, sa string) PipelineRunSpecOp

PipelineRunServiceAccountNameTask configures the service account for given Task in PipelineRun.

func PipelineRunTasksTimeout added in v0.25.0

func PipelineRunTasksTimeout(duration time.Duration) PipelineRunSpecOp

PipelineRunTasksTimeout sets the timeout to the PipelineRunSpec.

func PipelineRunTimeout

func PipelineRunTimeout(duration time.Duration) PipelineRunSpecOp

PipelineRunTimeout sets the timeout to the PipelineRunSpec.

func PipelineRunWorkspaceBindingEmptyDir

func PipelineRunWorkspaceBindingEmptyDir(name string) PipelineRunSpecOp

PipelineRunWorkspaceBindingEmptyDir adds an EmptyDir Workspace to the workspaces of a pipelinerun spec.

func PipelineRunWorkspaceBindingVolumeClaimTemplate

func PipelineRunWorkspaceBindingVolumeClaimTemplate(name string, claimName string, subPath string) PipelineRunSpecOp

PipelineRunWorkspaceBindingVolumeClaimTemplate adds an VolumeClaimTemplate Workspace to the workspaces of a pipelineRun spec.

func PipelineTaskRunSpecs

func PipelineTaskRunSpecs(taskRunSpecs []v1beta1.PipelineTaskRunSpec) PipelineRunSpecOp

PipelineTaskRunSpec adds customs TaskRunSpecs

type PipelineRunStatusOp

type PipelineRunStatusOp func(*v1beta1.PipelineRunStatus)

PipelineRunStatusOp is an operation which modifies a PipelineRunStatus

func PipelineRunCompletionTime

func PipelineRunCompletionTime(t time.Time) PipelineRunStatusOp

PipelineRunCompletionTime sets the completion time to the PipelineRunStatus.

func PipelineRunResult

func PipelineRunResult(name, value string) PipelineRunStatusOp

PipelineRunResult adds a PipelineResultStatus, with specified name, value and description, to the PipelineRunStatusSpec.

func PipelineRunStartTime

func PipelineRunStartTime(startTime time.Time) PipelineRunStatusOp

PipelineRunStartTime sets the start time to the PipelineRunStatus.

func PipelineRunStatusCondition

func PipelineRunStatusCondition(condition apis.Condition) PipelineRunStatusOp

PipelineRunStatusCondition adds a StatusCondition to the TaskRunStatus.

func PipelineRunTaskRunsStatus

func PipelineRunTaskRunsStatus(taskRunName string, status *v1beta1.PipelineRunTaskRunStatus) PipelineRunStatusOp

PipelineRunTaskRunsStatus sets the status of TaskRun to the PipelineRunStatus.

type PipelineSpecOp

type PipelineSpecOp func(*v1beta1.PipelineSpec)

PipelineSpecOp is an operation which modify a PipelineSpec struct.

func FinalPipelineTask added in v0.14.0

func FinalPipelineTask(name, taskName string, ops ...PipelineTaskOp) PipelineSpecOp

FinalTask adds a final PipelineTask, with specified name and task name, to the PipelineSpec. Any number of PipelineTask modifier can be passed to transform it.

func PipelineDeclaredResource

func PipelineDeclaredResource(name string, t v1beta1.PipelineResourceType) PipelineSpecOp

PipelineDeclaredResource adds a resource declaration to the Pipeline Spec, with the specified name and type.

func PipelineDescription

func PipelineDescription(desc string) PipelineSpecOp

PipelineDescription sets the description of the pipeline

func PipelineParamSpec

func PipelineParamSpec(name string, pt v1beta1.ParamType, ops ...ParamSpecOp) PipelineSpecOp

PipelineParamSpec adds a param, with specified name and type, to the PipelineSpec. Any number of PipelineParamSpec modifiers can be passed to transform it.

func PipelineResult

func PipelineResult(name, value, description string, ops ...PipelineOp) PipelineSpecOp

PipelineResult adds a PipelineResult, with specified name, value and description, to the PipelineSpec.

func PipelineTask

func PipelineTask(name, taskName string, ops ...PipelineTaskOp) PipelineSpecOp

PipelineTask adds a PipelineTask, with specified name and task name, to the PipelineSpec. Any number of PipelineTask modifier can be passed to transform it.

func PipelineWorkspaceDeclaration

func PipelineWorkspaceDeclaration(names ...string) PipelineSpecOp

PipelineWorkspaceDeclaration adds a Workspace to the workspaces listed in the pipeline spec.

type PipelineTaskConditionOp

type PipelineTaskConditionOp func(condition *v1beta1.PipelineTaskCondition)

PipelineTaskConditionOp is an operation which modifies a PipelineTaskCondition

func PipelineTaskConditionParam

func PipelineTaskConditionParam(name, val string) PipelineTaskConditionOp

PipelineTaskConditionParam adds a parameter to a PipelineTaskCondition

func PipelineTaskConditionResource

func PipelineTaskConditionResource(name, resource string, from ...string) PipelineTaskConditionOp

PipelineTaskConditionResource adds a resource to a PipelineTaskCondition

type PipelineTaskInputResourceOp

type PipelineTaskInputResourceOp func(*v1beta1.PipelineTaskInputResource)

PipelineTaskInputResourceOp is an operation which modifies a PipelineTaskInputResource.

func From

func From(tasks ...string) PipelineTaskInputResourceOp

From will update the provided PipelineTaskInputResource to indicate that it should come from tasks.

type PipelineTaskOp

type PipelineTaskOp func(*v1beta1.PipelineTask)

PipelineTaskOp is an operation which modify a PipelineTask struct.

func PipelineTaskCondition

func PipelineTaskCondition(conditionRef string, ops ...PipelineTaskConditionOp) PipelineTaskOp

PipelineTaskCondition adds a condition to the PipelineTask with the specified conditionRef. Any number of PipelineTaskCondition modifiers can be passed to transform it

func PipelineTaskInputResource

func PipelineTaskInputResource(name, resource string, ops ...PipelineTaskInputResourceOp) PipelineTaskOp

PipelineTaskInputResource adds an input resource to the PipelineTask with the specified name, pointing at the declared resource. Any number of PipelineTaskInputResource modifies can be passed to transform it.

func PipelineTaskOutputResource

func PipelineTaskOutputResource(name, resource string) PipelineTaskOp

PipelineTaskOutputResource adds an output resource to the PipelineTask with the specified name, pointing at the declared resource.

func PipelineTaskParam

func PipelineTaskParam(name string, value string, additionalValues ...string) PipelineTaskOp

PipelineTaskParam adds a ResourceParam, with specified name and value, to the PipelineTask.

func PipelineTaskRefBundle added in v0.18.0

func PipelineTaskRefBundle(url string) PipelineTaskOp

PipelineTaskRefBundle will add the specified URL as a bundle url on the task ref.

func PipelineTaskRefKind

func PipelineTaskRefKind(kind v1beta1.TaskKind) PipelineTaskOp

PipelineTaskRefKind sets the TaskKind to the PipelineTaskRef.

func PipelineTaskSpec

func PipelineTaskSpec(spec v1beta1.TaskSpec) PipelineTaskOp

PipelineTaskSpec sets the TaskSpec on a PipelineTask.

func PipelineTaskTimeout

func PipelineTaskTimeout(duration time.Duration) PipelineTaskOp

PipelineTaskTimeout sets the timeout for the PipelineTask.

func PipelineTaskWhenExpression added in v0.16.0

func PipelineTaskWhenExpression(input string, operator selection.Operator, values []string) PipelineTaskOp

PipelineTaskWhenExpression adds a WhenExpression with the specified input, operator and values which are used to determine whether the PipelineTask should be executed or skipped.

func PipelineTaskWorkspaceBinding

func PipelineTaskWorkspaceBinding(name, workspace, subPath string) PipelineTaskOp

PipelineTaskWorkspaceBinding adds a workspace with the specified name, workspace and subpath on a PipelineTask.

func Retries

func Retries(retries int) PipelineTaskOp

Retries sets the number of retries on a PipelineTask.

func RunAfter

func RunAfter(tasks ...string) PipelineTaskOp

RunAfter will update the provided Pipeline Task to indicate that it should be run after the provided list of Pipeline Task names.

func TaskSpecMetadata added in v0.16.0

func TaskSpecMetadata(metadata v1beta1.PipelineTaskMetadata) PipelineTaskOp

TaskSpecMetadata sets the Metadata on a TaskSpec within PipelineTask.

type PodOp

type PodOp func(*corev1.Pod)

PodOp is an operation which modifies a Pod struct.

func PodAnnotation

func PodAnnotation(key, value string) PodOp

PodAnnotation adds an annotation to the Pod.

func PodLabel

func PodLabel(key, value string) PodOp

PodLabel adds a label to the Pod.

func PodNamespace

func PodNamespace(namespace string) PodOp

PodNamespace sets the namespace on the Pod.

func PodOwnerReference

func PodOwnerReference(kind, name string, ops ...OwnerReferenceOp) PodOp

PodOwnerReference adds an OwnerReference, with specified kind and name, to the Pod.

func PodSpec

func PodSpec(ops ...PodSpecOp) PodOp

PodSpec creates a PodSpec with default values. Any number of PodSpec modifiers can be passed to transform it.

type PodSpecOp

type PodSpecOp func(*corev1.PodSpec)

PodSpecOp is an operation which modifies a PodSpec struct.

func PodContainer

func PodContainer(name, image string, ops ...ContainerOp) PodSpecOp

PodContainer adds a Container, with the specified name and image, to the PodSpec. Any number of Container modifiers can be passed to transform it.

func PodInitContainer

func PodInitContainer(name, image string, ops ...ContainerOp) PodSpecOp

PodInitContainer adds an InitContainer, with the specified name and image, to the PodSpec. Any number of Container modifiers can be passed to transform it.

func PodRestartPolicy

func PodRestartPolicy(restartPolicy corev1.RestartPolicy) PodSpecOp

PodRestartPolicy sets the restart policy on the PodSpec.

func PodServiceAccountName

func PodServiceAccountName(sa string) PodSpecOp

PodServiceAccountName sets the service account on the PodSpec.

func PodVolumes

func PodVolumes(volumes ...corev1.Volume) PodSpecOp

PodVolumes sets the Volumes on the PodSpec.

type PodStatusOp

type PodStatusOp func(status *corev1.PodStatus)

PodStatusOp is an operation which modifies a PodStatus struct.

type ResourceListOp

type ResourceListOp func(corev1.ResourceList)

ResourceListOp is an operation which modifies a ResourceList struct.

func CPU

func CPU(val string) ResourceListOp

CPU sets the CPU resource on the ResourceList.

func EphemeralStorage

func EphemeralStorage(val string) ResourceListOp

EphemeralStorage sets the ephemeral storage resource on the ResourceList.

func Memory

func Memory(val string) ResourceListOp

Memory sets the memory resource on the ResourceList.

type ResourceRequirementsOp

type ResourceRequirementsOp func(*corev1.ResourceRequirements)

ResourceRequirementsOp is an operation which modifies a ResourceRequirements struct.

func Limits

Limits adds Limits to the ResourceRequirements.

func Requests

func Requests(ops ...ResourceListOp) ResourceRequirementsOp

Requests adds Requests to the ResourceRequirements.

type SidecarStateOp

type SidecarStateOp func(*v1beta1.SidecarState)

SidecarStateOp is an operation which modifies a SidecarState struct.

func SetSidecarStateRunning

func SetSidecarStateRunning(running corev1.ContainerStateRunning) SidecarStateOp

SetSidecarStateRunning sets Running state of a Sidecar.

func SetSidecarStateTerminated

func SetSidecarStateTerminated(terminated corev1.ContainerStateTerminated) SidecarStateOp

SetSidecarStateTerminated sets Terminated state of a Sidecar.

func SetSidecarStateWaiting

func SetSidecarStateWaiting(waiting corev1.ContainerStateWaiting) SidecarStateOp

SetSidecarStateWaiting sets Waiting state of a Sidecar.

func SidecarStateContainerName

func SidecarStateContainerName(containerName string) SidecarStateOp

SidecarStateContainerName sets ContainerName of Sidecar for SidecarState.

func SidecarStateImageID

func SidecarStateImageID(imageID string) SidecarStateOp

SidecarStateImageID sets ImageID of Sidecar for SidecarState.

func SidecarStateName

func SidecarStateName(name string) SidecarStateOp

SidecarStateName sets the name of the Sidecar for the SidecarState.

type StepOp

type StepOp func(*v1beta1.Step)

StepOp is an operation which modifies a Container struct.

func StepArgs

func StepArgs(args ...string) StepOp

StepArgs sets the command arguments to the Container (step in this case).

func StepCommand

func StepCommand(args ...string) StepOp

StepCommand sets the command to the Container (step in this case).

func StepEnvVar

func StepEnvVar(name, value string) StepOp

StepEnvVar add an environment variable, with specified name and value, to the Container (step).

func StepName

func StepName(name string) StepOp

StepName sets the name of the step.

func StepOnError added in v0.27.0

func StepOnError(e string) StepOp

StepOnError sets the onError of a step

func StepScript

func StepScript(script string) StepOp

StepScript sets the script to the Step.

func StepSecurityContext

func StepSecurityContext(context *corev1.SecurityContext) StepOp

StepSecurityContext sets the SecurityContext to the Step.

func StepVolumeMount

func StepVolumeMount(name, mountPath string, ops ...VolumeMountOp) StepOp

StepVolumeMount add a VolumeMount to the Container (step).

func StepWorkingDir

func StepWorkingDir(workingDir string) StepOp

StepWorkingDir sets the WorkingDir on the Container.

type StepStateOp

type StepStateOp func(*v1beta1.StepState)

StepStateOp is an operation which modifies a StepState struct.

func SetStepStateRunning

func SetStepStateRunning(running corev1.ContainerStateRunning) StepStateOp

SetStepStateRunning sets Running state of a step.

func SetStepStateTerminated

func SetStepStateTerminated(terminated corev1.ContainerStateTerminated) StepStateOp

SetStepStateTerminated sets Terminated state of a step.

func SetStepStateWaiting

func SetStepStateWaiting(waiting corev1.ContainerStateWaiting) StepStateOp

SetStepStateWaiting sets Waiting state of a step.

func StateTerminated

func StateTerminated(exitcode int) StepStateOp

StateTerminated sets Terminated to the StepState.

type TaskOp

type TaskOp func(*v1beta1.Task)

TaskOp is an operation which modify a Task struct.

func TaskNamespace

func TaskNamespace(namespace string) TaskOp

TaskNamespace sets the namespace to the Task.

func TaskSpec

func TaskSpec(ops ...TaskSpecOp) TaskOp

TaskSpec sets the specified spec of the task. Any number of TaskSpec modifier can be passed to create/modify it.

type TaskRefOp

type TaskRefOp func(*v1beta1.TaskRef)

TaskRefOp is an operation which modify a TaskRef struct.

func TaskRefAPIVersion

func TaskRefAPIVersion(version string) TaskRefOp

TaskRefAPIVersion sets the specified api version to the TaskRef.

func TaskRefBundle added in v0.18.0

func TaskRefBundle(url string) TaskRefOp

TaskRefBundle sets the specified ref to the TaskRef's bundle.

func TaskRefKind

func TaskRefKind(kind v1beta1.TaskKind) TaskRefOp

TaskRefKind set the specified kind to the TaskRef.

type TaskResourceBindingOp

type TaskResourceBindingOp func(*v1beta1.TaskResourceBinding)

TaskResourceBindingOp is an operation which modify a TaskResourceBinding struct.

func TaskResourceBindingPaths

func TaskResourceBindingPaths(paths ...string) TaskResourceBindingOp

TaskResourceBindingPaths add any number of path to the TaskResourceBinding.

func TaskResourceBindingRef

func TaskResourceBindingRef(name string) TaskResourceBindingOp

TaskResourceBindingRef set the PipelineResourceRef name to the TaskResourceBinding.

func TaskResourceBindingRefAPIVersion

func TaskResourceBindingRefAPIVersion(version string) TaskResourceBindingOp

TaskResourceBindingRefAPIVersion set the PipelineResourceRef APIVersion to the TaskResourceBinding.

func TaskResourceBindingResourceSpec

func TaskResourceBindingResourceSpec(spec *resource.PipelineResourceSpec) TaskResourceBindingOp

TaskResourceBindingResourceSpec set the PipelineResourceResourceSpec to the TaskResourceBinding.

type TaskResourceOp

type TaskResourceOp func(*v1beta1.TaskResource)

TaskResourceOp is an operation which modify a TaskResource struct.

func ResourceOptional

func ResourceOptional(optional bool) TaskResourceOp

ResourceOptional marks a TaskResource as optional.

func ResourceTargetPath

func ResourceTargetPath(path string) TaskResourceOp

ResourceTargetPath sets the target path to a TaskResource.

type TaskResourcesOp

type TaskResourcesOp func(*v1beta1.TaskResources)

TaskResourcesOp is an operation which modify a TaskResources struct.

func TaskResourcesInput

func TaskResourcesInput(name string, resourceType resource.PipelineResourceType, ops ...TaskResourceOp) TaskResourcesOp

TaskResourcesInput adds a TaskResource as Inputs to the TaskResources

func TaskResourcesOutput

func TaskResourcesOutput(name string, resourceType resource.PipelineResourceType, ops ...TaskResourceOp) TaskResourcesOp

TaskResourcesOutput adds a TaskResource as Outputs to the TaskResources

type TaskResultOp

type TaskResultOp func(result *v1beta1.TaskResult)

TaskResultOp is an operation which modifies there

type TaskRunOp

type TaskRunOp func(*v1beta1.TaskRun)

TaskRunOp is an operation which modify a TaskRun struct.

func TaskRunAnnotation

func TaskRunAnnotation(key, value string) TaskRunOp

TaskRunAnnotation adds an annotation with the specified key and value to the TaskRun.

func TaskRunAnnotations

func TaskRunAnnotations(annotations map[string]string) TaskRunOp

TaskRunAnnotations adds the specified annotations to the TaskRun.

func TaskRunLabel

func TaskRunLabel(key, value string) TaskRunOp

TaskRunLabel adds a label with the specified key and value to the TaskRun.

func TaskRunLabels

func TaskRunLabels(labels map[string]string) TaskRunOp

TaskRunLabels add the specified labels to the TaskRun.

func TaskRunNamespace

func TaskRunNamespace(namespace string) TaskRunOp

TaskRunNamespace sets the namespace for the TaskRun.

func TaskRunOwnerReference

func TaskRunOwnerReference(kind, name string, ops ...OwnerReferenceOp) TaskRunOp

TaskRunOwnerReference sets the OwnerReference, with specified kind and name, to the TaskRun.

func TaskRunSelfLink(selflink string) TaskRunOp

TaskRunSelfLink adds a SelfLink

func TaskRunSpec

func TaskRunSpec(ops ...TaskRunSpecOp) TaskRunOp

TaskRunSpec sets the specified spec of the TaskRun. Any number of TaskRunSpec modifier can be passed to transform it.

func TaskRunStatus

func TaskRunStatus(ops ...TaskRunStatusOp) TaskRunOp

TaskRunStatus sets the TaskRunStatus to tshe TaskRun

type TaskRunResourcesOp

type TaskRunResourcesOp func(*v1beta1.TaskRunResources)

TaskRunResourcesOp is an operation which modify a TaskRunResources struct.

func TaskRunResourcesInput

func TaskRunResourcesInput(name string, ops ...TaskResourceBindingOp) TaskRunResourcesOp

TaskRunResourcesInput adds a TaskRunResource as Inputs to the TaskRunResources

func TaskRunResourcesOutput

func TaskRunResourcesOutput(name string, ops ...TaskResourceBindingOp) TaskRunResourcesOp

TaskRunResourcesOutput adds a TaskRunResource as Outputs to the TaskRunResources

type TaskRunSpecOp

type TaskRunSpecOp func(*v1beta1.TaskRunSpec)

TaskRunSpecOp is an operation which modify a TaskRunSpec struct.

func TaskRunNodeSelector

func TaskRunNodeSelector(values map[string]string) TaskRunSpecOp

TaskRunNodeSelector sets the NodeSelector to the TaskRunSpec.

func TaskRunParam

func TaskRunParam(name, value string, additionalValues ...string) TaskRunSpecOp

TaskRunParam sets the Params to the TaskSpec

func TaskRunPodTemplate

func TaskRunPodTemplate(podTemplate *pod.Template) TaskRunSpecOp

TaskRunPodTemplate add a custom PodTemplate to the TaskRun

func TaskRunResources

func TaskRunResources(ops ...TaskRunResourcesOp) TaskRunSpecOp

TaskRunResources sets the TaskRunResources to the TaskRunSpec

func TaskRunServiceAccountName

func TaskRunServiceAccountName(sa string) TaskRunSpecOp

TaskRunServiceAccountName sets the serviceAccount to the TaskRunSpec.

func TaskRunSpecStatus

func TaskRunSpecStatus(status v1beta1.TaskRunSpecStatus) TaskRunSpecOp

TaskRunSpecStatus sets the Status in the Spec, used for operations such as cancelling executing TaskRuns.

func TaskRunTaskRef

func TaskRunTaskRef(name string, ops ...TaskRefOp) TaskRunSpecOp

TaskRunTaskRef sets the specified Task reference to the TaskRunSpec. Any number of TaskRef modifier can be passed to transform it.

func TaskRunTaskSpec

func TaskRunTaskSpec(ops ...TaskSpecOp) TaskRunSpecOp

TaskRunTaskSpec sets the specified TaskRunSpec reference to the TaskRunSpec. Any number of TaskRunSpec modifier can be passed to transform it.

func TaskRunTimeout

func TaskRunTimeout(d time.Duration) TaskRunSpecOp

TaskRunTimeout sets the timeout duration to the TaskRunSpec.

func TaskRunWorkspaceEmptyDir

func TaskRunWorkspaceEmptyDir(name, subPath string) TaskRunSpecOp

TaskRunWorkspaceEmptyDir adds a workspace binding to an empty dir volume source.

func TaskRunWorkspacePVC

func TaskRunWorkspacePVC(name, subPath, claimName string) TaskRunSpecOp

TaskRunWorkspacePVC adds a workspace binding to a PVC volume source.

func TaskRunWorkspaceVolumeClaimTemplate

func TaskRunWorkspaceVolumeClaimTemplate(name, subPath string, volumeClaimTemplate *corev1.PersistentVolumeClaim) TaskRunSpecOp

TaskRunWorkspaceVolumeClaimTemplate adds a workspace binding with a VolumeClaimTemplate volume source.

type TaskRunStatusOp

type TaskRunStatusOp func(*v1beta1.TaskRunStatus)

TaskRunStatusOp is an operation which modify a TaskRunStatus struct.

func PodName

func PodName(name string) TaskRunStatusOp

PodName sets the Pod name to the TaskRunStatus.

func Retry

Retry adds a RetriesStatus (TaskRunStatus) to the TaskRunStatus.

func SidecarState

func SidecarState(ops ...SidecarStateOp) TaskRunStatusOp

SidecarState adds a SidecarState to the TaskRunStatus.

func StatusCondition

func StatusCondition(condition apis.Condition) TaskRunStatusOp

StatusCondition adds a StatusCondition to the TaskRunStatus.

func StepState

func StepState(ops ...StepStateOp) TaskRunStatusOp

StepState adds a StepState to the TaskRunStatus.

func TaskRunCloudEvent

func TaskRunCloudEvent(target, error string, retryCount int32, condition v1beta1.CloudEventCondition) TaskRunStatusOp

TaskRunCloudEvent adds an event to the TaskRunStatus.

func TaskRunCompletionTime

func TaskRunCompletionTime(completionTime time.Time) TaskRunStatusOp

TaskRunCompletionTime sets the start time to the TaskRunStatus.

func TaskRunResult

func TaskRunResult(name, value string) TaskRunStatusOp

TaskRunResult adds a result with the specified name and value to the TaskRunStatus.

func TaskRunStartTime

func TaskRunStartTime(startTime time.Time) TaskRunStatusOp

TaskRunStartTime sets the start time to the TaskRunStatus.

type TaskSpecOp

type TaskSpecOp func(*v1beta1.TaskSpec)

TaskSpecOp is an operation which modify a TaskSpec struct.

func Sidecar

func Sidecar(name, image string, ops ...ContainerOp) TaskSpecOp

Sidecar adds a sidecar container with the specified name and image to the TaskSpec. Any number of Container modifier can be passed to transform it.

func Step

func Step(image string, ops ...StepOp) TaskSpecOp

Step adds a step with the specified name and image to the TaskSpec. Any number of Container modifier can be passed to transform it.

func TaskDescription

func TaskDescription(desc string) TaskSpecOp

TaskDescription sets the description of the task

func TaskParam

func TaskParam(name string, pt v1beta1.ParamType, ops ...ParamSpecOp) TaskSpecOp

TaskParam sets the Params to the TaskSpec

func TaskResources

func TaskResources(ops ...TaskResourcesOp) TaskSpecOp

TaskResources sets the Resources to the TaskSpec

func TaskResults

func TaskResults(name, desc string) TaskSpecOp

TaskResults sets the Results to the TaskSpec

func TaskStepTemplate

func TaskStepTemplate(ops ...ContainerOp) TaskSpecOp

TaskStepTemplate adds a base container for all steps in the task.

func TaskVolume

func TaskVolume(name string, ops ...VolumeOp) TaskSpecOp

TaskVolume adds a volume with specified name to the TaskSpec. Any number of Volume modifier can be passed to transform it.

func TaskWorkspace

func TaskWorkspace(name, desc, mountPath string, readOnly bool) TaskSpecOp

TaskWorkspace adds a workspace declaration.

type VolumeMountOp

type VolumeMountOp func(*corev1.VolumeMount)

VolumeMountOp is an operation which modifies a VolumeMount struct.

type VolumeOp

type VolumeOp func(*corev1.Volume)

VolumeOp is an operation which modify a Volume struct.

func VolumeSource

func VolumeSource(s corev1.VolumeSource) VolumeOp

VolumeSource sets the VolumeSource to the Volume.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL