Documentation ¶
Overview ¶
Package builder holds Builder functions that can be used to create struct in tests with less noise.
One of the most important characteristic of a unit test (and any type of test really) is readability. This means it should be easy to read but most importantly it should clearly show the intent of the test. The setup (and cleanup) of the tests should be as small as possible to avoid the noise. Those builders exists to help with that.
There is two types of functions defined in that package :
- Builders: create and return a struct
- Modifiers: return a function that will operate on a given struct. They can be applied to other Modifiers or Builders.
Most of the Builder (and Modifier) that accepts Modifiers defines a type (`TypeOp`) that can be satisfied by existing function in this package, from other package *or* inline. An example would be the following.
// Definition type TaskOp func(*v1alpha1.Task) func Task(name string, ops ...TaskOp) *v1alpha1.Task { // […] } func TaskNamespace(namespace string) TaskOp { return func(t *v1alpha1.Task) { // […] } } // Usage t := Task("foo", TaskNamespace("bar"), func(t *v1alpha1.Task){ // Do something with the Task struct // […] })
The main reason to define the `Op` type, and using it in the methods signatures is to group Modifier function together. It makes it easier to see what is a Modifier (or Builder) and on what it operates.
By convention, this package is import with the "tb" as alias. The examples make that assumption.
Index ¶
- func BlockOwnerDeletion(o *metav1.OwnerReference)
- func ClusterTask(name string, ops ...ClusterTaskOp) *v1alpha1.ClusterTask
- func Controller(o *metav1.OwnerReference)
- func Pipeline(name, namespace string, ops ...PipelineOp) *v1alpha1.Pipeline
- func PipelineResource(name, namespace string, ops ...PipelineResourceOp) *v1alpha1.PipelineResource
- func PipelineRun(name, namespace string, ops ...PipelineRunOp) *v1alpha1.PipelineRun
- func PipelineRunCancelled(spec *v1alpha1.PipelineRunSpec)
- func PipelineRunNilTimeout(prs *v1alpha1.PipelineRunSpec)
- func Pod(name, namespace string, ops ...PodOp) *corev1.Pod
- func ResolvedTaskResources(ops ...ResolvedTaskResourcesOp) *resources.ResolvedTaskResources
- func Task(name, namespace string, ops ...TaskOp) *v1alpha1.Task
- func TaskRun(name, namespace string, ops ...TaskRunOp) *v1alpha1.TaskRun
- func TaskRunCancelled(spec *v1alpha1.TaskRunSpec)
- func TaskRunNilTimeout(spec *v1alpha1.TaskRunSpec)
- type ClusterTaskOp
- type ContainerOp
- func Args(args ...string) ContainerOp
- func Command(args ...string) ContainerOp
- func EnvVar(name, value string) ContainerOp
- func Resources(ops ...ResourceRequirementsOp) ContainerOp
- func TerminationMessagePath(terminationMessagePath string) ContainerOp
- func TerminationMessagePolicy(terminationMessagePolicy corev1.TerminationMessagePolicy) ContainerOp
- func VolumeMount(name, mountPath string, ops ...VolumeMountOp) ContainerOp
- func WorkingDir(workingDir string) ContainerOp
- type InputsOp
- type OutputsOp
- type OwnerReferenceOp
- type PipelineOp
- type PipelineParamOp
- type PipelineResourceBindingOp
- type PipelineResourceOp
- type PipelineResourceSpecOp
- type PipelineRunOp
- type PipelineRunSpecOp
- func PipelineRunAffinity(affinity *corev1.Affinity) PipelineRunSpecOp
- func PipelineRunNodeSelector(values map[string]string) PipelineRunSpecOp
- func PipelineRunParam(name, value string) PipelineRunSpecOp
- func PipelineRunResourceBinding(name string, ops ...PipelineResourceBindingOp) PipelineRunSpecOp
- func PipelineRunServiceAccount(sa string) PipelineRunSpecOp
- func PipelineRunServiceAccountTask(taskName, sa string) PipelineRunSpecOp
- func PipelineRunTimeout(duration time.Duration) PipelineRunSpecOp
- func PipelineRunTolerations(values []corev1.Toleration) PipelineRunSpecOp
- type PipelineRunStatusOp
- func PipelineRunCompletionTime(t time.Time) PipelineRunStatusOp
- func PipelineRunStartTime(startTime time.Time) PipelineRunStatusOp
- func PipelineRunStatusCondition(condition apis.Condition) PipelineRunStatusOp
- func PipelineRunTaskRunsStatus(taskRuns map[string]*v1alpha1.PipelineRunTaskRunStatus) PipelineRunStatusOp
- type PipelineSpecOp
- type PipelineTaskInputResourceOp
- type PipelineTaskOp
- func PipelineTaskInputResource(name, resource string, ops ...PipelineTaskInputResourceOp) PipelineTaskOp
- func PipelineTaskOutputResource(name, resource string) PipelineTaskOp
- func PipelineTaskParam(name, value string) PipelineTaskOp
- func PipelineTaskRefKind(kind v1alpha1.TaskKind) PipelineTaskOp
- func Retries(retries int) PipelineTaskOp
- func RunAfter(tasks ...string) PipelineTaskOp
- type PodOp
- type PodSpecOp
- func PodContainer(name, image string, ops ...ContainerOp) PodSpecOp
- func PodInitContainer(name, image string, ops ...ContainerOp) PodSpecOp
- func PodRestartPolicy(restartPolicy corev1.RestartPolicy) PodSpecOp
- func PodServiceAccountName(sa string) PodSpecOp
- func PodVolumes(volumes ...corev1.Volume) PodSpecOp
- type ResolvedTaskResourcesOp
- type ResourceListOp
- type ResourceRequirementsOp
- type StepStateOp
- type TaskOp
- type TaskParamOp
- type TaskRefOp
- type TaskResourceBindingOp
- func TaskResourceBindingPaths(paths ...string) TaskResourceBindingOp
- func TaskResourceBindingRef(name string) TaskResourceBindingOp
- func TaskResourceBindingRefAPIVersion(version string) TaskResourceBindingOp
- func TaskResourceBindingResourceSpec(spec *v1alpha1.PipelineResourceSpec) TaskResourceBindingOp
- type TaskResourceOp
- type TaskRunInputsOp
- type TaskRunOp
- type TaskRunOutputsOp
- type TaskRunSpecOp
- func TaskRunAffinity(affinity *corev1.Affinity) TaskRunSpecOp
- func TaskRunInputs(ops ...TaskRunInputsOp) TaskRunSpecOp
- func TaskRunNodeSelector(values map[string]string) TaskRunSpecOp
- func TaskRunOutputs(ops ...TaskRunOutputsOp) TaskRunSpecOp
- func TaskRunServiceAccount(sa string) TaskRunSpecOp
- func TaskRunSpecStatus(status v1alpha1.TaskRunSpecStatus) TaskRunSpecOp
- func TaskRunTaskRef(name string, ops ...TaskRefOp) TaskRunSpecOp
- func TaskRunTaskSpec(ops ...TaskSpecOp) TaskRunSpecOp
- func TaskRunTimeout(d time.Duration) TaskRunSpecOp
- func TaskRunTolerations(values []corev1.Toleration) TaskRunSpecOp
- type TaskRunStatusOp
- type TaskSpecOp
- func Step(name, image string, ops ...ContainerOp) TaskSpecOp
- func TaskContainerTemplate(ops ...ContainerOp) TaskSpecOp
- func TaskInputs(ops ...InputsOp) TaskSpecOp
- func TaskOutputs(ops ...OutputsOp) TaskSpecOp
- func TaskStepTemplate(ops ...ContainerOp) TaskSpecOp
- func TaskVolume(name string, ops ...VolumeOp) TaskSpecOp
- type VolumeMountOp
- type VolumeOp
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlockOwnerDeletion ¶
func BlockOwnerDeletion(o *metav1.OwnerReference)
func ClusterTask ¶
func ClusterTask(name string, ops ...ClusterTaskOp) *v1alpha1.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" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" tb "github.com/tektoncd/pipeline/test/builder" ) // 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("simple-step", "myotherimage", tb.Command("/mycmd")), )) expectedClusterTask := &v1alpha1.Task{ // […] } // […] if d := cmp.Diff(expectedClusterTask, myClusterTask); d != "" { t.Fatalf("ClusterTask diff -want, +got: %v", d) } }
Output:
func Controller ¶
func Controller(o *metav1.OwnerReference)
func Pipeline ¶
func Pipeline(name, namespace string, ops ...PipelineOp) *v1alpha1.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" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" tb "github.com/tektoncd/pipeline/test/builder" ) // This is a "hack" to make the example "look" like tests var t *testing.T func main() { pipeline := tb.Pipeline("tomatoes", "namespace", tb.PipelineSpec(tb.PipelineTask("foo", "banana")), ) expectedPipeline := &v1alpha1.Pipeline{ // […] } // […] if d := cmp.Diff(expectedPipeline, pipeline); d != "" { t.Fatalf("Task diff -want, +got: %v", d) } }
Output:
func PipelineResource ¶
func PipelineResource(name, namespace string, ops ...PipelineResourceOp) *v1alpha1.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" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" tb "github.com/tektoncd/pipeline/test/builder" ) // This is a "hack" to make the example "look" like tests var t *testing.T func main() { gitResource := tb.PipelineResource("git-resource", "namespace", tb.PipelineResourceSpec( v1alpha1.PipelineResourceTypeGit, tb.PipelineResourceSpecParam("URL", "https://foo.git"), )) imageResource := tb.PipelineResource("image-resource", "namespace", tb.PipelineResourceSpec( v1alpha1.PipelineResourceTypeImage, tb.PipelineResourceSpecParam("URL", "gcr.io/kristoff/sven"), )) expectedGitResource := v1alpha1.PipelineResource{ // […] } expectedImageResource := v1alpha1.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, namespace string, ops ...PipelineRunOp) *v1alpha1.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" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" tb "github.com/tektoncd/pipeline/test/builder" ) // This is a "hack" to make the example "look" like tests var t *testing.T func main() { pipelineRun := tb.PipelineRun("pear", "namespace", tb.PipelineRunSpec("tomatoes", tb.PipelineRunServiceAccount("inexistent")), ) expectedPipelineRun := &v1alpha1.PipelineRun{ // […] } // […] if d := cmp.Diff(expectedPipelineRun, pipelineRun); d != "" { t.Fatalf("Task diff -want, +got: %v", d) } }
Output:
func PipelineRunCancelled ¶
func PipelineRunCancelled(spec *v1alpha1.PipelineRunSpec)
PipelineRunCancelled sets the status to cancel to the TaskRunSpec.
func PipelineRunNilTimeout ¶ added in v0.5.2
func PipelineRunNilTimeout(prs *v1alpha1.PipelineRunSpec)
PipelineRunNilTimeout sets the timeout to nil on the PipelineRunSpec
func Pod ¶
Pod creates a Pod with default values. Any number of Pod modifiers can be passed to transform it.
func ResolvedTaskResources ¶
func ResolvedTaskResources(ops ...ResolvedTaskResourcesOp) *resources.ResolvedTaskResources
ResolvedTaskResources creates a ResolvedTaskResources with default values. Any number of ResolvedTaskResources modifier can be passed to transform it.
func 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" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" tb "github.com/tektoncd/pipeline/test/builder" ) // 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("my-step", "myimage") // … and use them in a Task definition myTask := tb.Task("my-task", "namespace", tb.TaskSpec( tb.Step("simple-step", "myotherimage", tb.Command("/mycmd")), myStep, )) // … and another one. myOtherTask := tb.Task("my-other-task", "namespace", tb.TaskSpec(myStep, tb.TaskInputs(tb.InputsResource("workspace", v1alpha1.PipelineResourceTypeGit)), ), ) expectedTask := &v1alpha1.Task{ // […] } expectedOtherTask := &v1alpha1.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 ¶
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" "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1" tb "github.com/tektoncd/pipeline/test/builder" ) // 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", "namespace", tb.TaskRunSpec( tb.TaskRunTaskRef("my-task"), )) // … or a more complex one with inline TaskSpec myTaskRunWithSpec := tb.TaskRun("my-taskrun-with-spec", "namespace", tb.TaskRunSpec( tb.TaskRunInputs( tb.TaskRunInputsParam("myarg", "foo"), tb.TaskRunInputsResource("workspace", tb.TaskResourceBindingRef("git-resource")), ), tb.TaskRunTaskSpec( tb.TaskInputs( tb.InputsResource("workspace", v1alpha1.PipelineResourceTypeGit), tb.InputsParam("myarg", tb.ParamDefault("mydefault")), ), tb.Step("mycontainer", "myimage", tb.Command("/mycmd"), tb.Args("--my-arg=${inputs.params.myarg}"), ), ), )) expectedTaskRun := &v1alpha1.TaskRun{ // […] } expectedTaskRunWithSpec := &v1alpha1.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 *v1alpha1.TaskRunSpec)
TaskRunCancelled sets the status to cancel to the TaskRunSpec.
func TaskRunNilTimeout ¶ added in v0.5.2
func TaskRunNilTimeout(spec *v1alpha1.TaskRunSpec)
TaskRunNilTimeout sets the timeout duration to nil on the TaskRunSpec.
Types ¶
type ClusterTaskOp ¶
type ClusterTaskOp func(*v1alpha1.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 ¶
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 ¶ added in v0.3.0
func Resources(ops ...ResourceRequirementsOp) ContainerOp
Resources adds ResourceRequirements to the Container (step).
func TerminationMessagePath ¶ added in v0.5.0
func TerminationMessagePath(terminationMessagePath string) ContainerOp
TerminationMessagePath sets the source of the termination message.
func TerminationMessagePolicy ¶ added in v0.5.0
func TerminationMessagePolicy(terminationMessagePolicy corev1.TerminationMessagePolicy) ContainerOp
TerminationMessagePolicy sets the policy of the termination message.
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 InputsOp ¶
InputsOp is an operation which modify an Inputs struct.
func InputsParam ¶
func InputsParam(name string, ops ...TaskParamOp) InputsOp
InputsParam adds a param, with specified name, to the Inputs. Any number of ParamSpec modifier can be passed to transform it.
func InputsResource ¶
func InputsResource(name string, resourceType v1alpha1.PipelineResourceType, ops ...TaskResourceOp) InputsOp
InputsResource adds a resource, with specified name and type, to the Inputs. Any number of TaskResource modifier can be passed to transform it.
type OutputsOp ¶
OutputsOp is an operation which modify an Outputs struct.
func OutputsResource ¶
func OutputsResource(name string, resourceType v1alpha1.PipelineResourceType) OutputsOp
OutputsResource adds a resource, with specified name and type, to the Outputs.
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 PipelineOp ¶
PipelineOp is an operation which modify a Pipeline struct.
func PipelineCreationTimestamp ¶ added in v0.4.0
func PipelineCreationTimestamp(t time.Time) PipelineOp
PipelineCreationTimestamp sets the creation time of 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 PipelineParamOp ¶
PipelineParamOp is an operation which modify a ParamSpec struct.
func PipelineParamDefault ¶
func PipelineParamDefault(value string) PipelineParamOp
PipelineParamDefault sets the default value to the ParamSpec.
func PipelineParamDescription ¶
func PipelineParamDescription(desc string) PipelineParamOp
PipelineParamDescription sets the description to the ParamSpec.
type PipelineResourceBindingOp ¶
type PipelineResourceBindingOp func(*v1alpha1.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.
type PipelineResourceOp ¶
type PipelineResourceOp func(*v1alpha1.PipelineResource)
PipelineResourceOp is an operation which modify a PipelineResource struct.
func PipelineResourceSpec ¶
func PipelineResourceSpec(resourceType v1alpha1.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(*v1alpha1.PipelineResourceSpec)
PipelineResourceSpecOp is an operation which modify a PipelineResourceSpec struct.
func PipelineResourceSpecParam ¶
func PipelineResourceSpecParam(name, value string) PipelineResourceSpecOp
PipelineResourceSpecParam adds a Param, 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(*v1alpha1.PipelineRun)
PipelineRunOp is an operation which modify a PipelineRun struct.
func PipelineRunAnnotation ¶ added in v0.4.0
func PipelineRunAnnotation(key, value string) PipelineRunOp
PipelineRunAnnotations adds a annotation to the PipelineRun.
func PipelineRunLabel ¶
func PipelineRunLabel(key, value string) PipelineRunOp
PipelineRunLabels adds a label to the PipelineRun.
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(*v1alpha1.PipelineRunSpec)
PipelineRunSpecOp is an operation which modify a PipelineRunSpec struct.
func PipelineRunAffinity ¶
func PipelineRunAffinity(affinity *corev1.Affinity) PipelineRunSpecOp
PipelineRunAffinity sets the affinity to the PipelineSpec.
func PipelineRunNodeSelector ¶
func PipelineRunNodeSelector(values map[string]string) PipelineRunSpecOp
PipelineRunNodeSelector sets the Node selector to the PipelineSpec.
func PipelineRunParam ¶
func PipelineRunParam(name, value string) PipelineRunSpecOp
PipelineRunParam add a param, with specified name and value, 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 PipelineRunServiceAccount ¶
func PipelineRunServiceAccount(sa string) PipelineRunSpecOp
PipelineRunServiceAccount sets the service account to the PipelineRunSpec.
func PipelineRunServiceAccountTask ¶ added in v0.5.0
func PipelineRunServiceAccountTask(taskName, sa string) PipelineRunSpecOp
PipelineRunServiceAccountTask configures the service account for given Task in PipelineRun.
func PipelineRunTimeout ¶
func PipelineRunTimeout(duration time.Duration) PipelineRunSpecOp
PipelineRunTimeout sets the timeout to the PipelineRunSpec.
func PipelineRunTolerations ¶ added in v0.3.0
func PipelineRunTolerations(values []corev1.Toleration) PipelineRunSpecOp
PipelineRunTolerations sets the Node selector to the PipelineSpec.
type PipelineRunStatusOp ¶
type PipelineRunStatusOp func(*v1alpha1.PipelineRunStatus)
PipelineRunStatusOp is an operation which modify a PipelineRunStatus
func PipelineRunCompletionTime ¶ added in v0.4.0
func PipelineRunCompletionTime(t time.Time) PipelineRunStatusOp
PipelineRunCompletionTime sets the completion time to the PipelineRunStatus.
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 Condition to the TaskRunStatus.
func PipelineRunTaskRunsStatus ¶ added in v0.3.0
func PipelineRunTaskRunsStatus(taskRuns map[string]*v1alpha1.PipelineRunTaskRunStatus) PipelineRunStatusOp
PipelineRunTaskRunsStatus sets the TaskRuns of the PipelineRunStatus.
type PipelineSpecOp ¶
type PipelineSpecOp func(*v1alpha1.PipelineSpec)
PipelineSpecOp is an operation which modify a PipelineSpec struct.
func PipelineDeclaredResource ¶
func PipelineDeclaredResource(name string, t v1alpha1.PipelineResourceType) PipelineSpecOp
PipelineDeclaredResource adds a resource declaration to the Pipeline Spec, with the specified name and type.
func PipelineParam ¶
func PipelineParam(name string, ops ...PipelineParamOp) PipelineSpecOp
ParamSpec adds a param, with specified name, to the Spec. Any number of ParamSpec modifiers can be passed to transform it.
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.
type PipelineTaskInputResourceOp ¶
type PipelineTaskInputResourceOp func(*v1alpha1.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(*v1alpha1.PipelineTask)
PipelineTaskOp is an operation which modify a PipelineTask struct.
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, value string) PipelineTaskOp
PipelineTaskParam adds a Param, with specified name and value, to the PipelineTask.
func PipelineTaskRefKind ¶
func PipelineTaskRefKind(kind v1alpha1.TaskKind) PipelineTaskOp
PipelineTaskRefKind sets the TaskKind to the PipelineTaskRef.
func Retries ¶ added in v0.4.0
func Retries(retries int) PipelineTaskOp
func RunAfter ¶ added in v0.2.0
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.
type PodOp ¶
PodOp is an operation which modifies a Pod struct.
func PodAnnotation ¶
PodLabel adds an annotation to the Pod.
func PodOwnerReference ¶
func PodOwnerReference(kind, name string, ops ...OwnerReferenceOp) PodOp
PodOwnerReference adds an OwnerReference, with specified kind and name, to the Pod.
type PodSpecOp ¶
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 ¶
PodServiceAccountName sets the service account on the PodSpec.
func PodVolumes ¶
PodVolume sets the Volumes on the PodSpec.
type ResolvedTaskResourcesOp ¶
type ResolvedTaskResourcesOp func(*resources.ResolvedTaskResources)
ResolvedTaskResourcesOp is an operation which modify a ResolvedTaskResources struct.
func ResolvedTaskResourcesInputs ¶
func ResolvedTaskResourcesInputs(name string, resource *v1alpha1.PipelineResource) ResolvedTaskResourcesOp
ResolvedTaskResourcesInputs adds an input PipelineResource, with specified name, to the ResolvedTaskResources.
func ResolvedTaskResourcesOutputs ¶
func ResolvedTaskResourcesOutputs(name string, resource *v1alpha1.PipelineResource) ResolvedTaskResourcesOp
ResolvedTaskResourcesOutputs adds an output PipelineResource, with specified name, to the ResolvedTaskResources.
func ResolvedTaskResourcesTaskSpec ¶
func ResolvedTaskResourcesTaskSpec(ops ...TaskSpecOp) ResolvedTaskResourcesOp
ResolvedTaskResourcesTaskSpec sets a TaskSpec to the ResolvedTaskResources. Any number of TaskSpec modifier can be passed to transform it.
type ResourceListOp ¶ added in v0.3.0
type ResourceListOp func(corev1.ResourceList)
ResourceListOp is an operation which modifies a ResourceList struct.
func CPU ¶ added in v0.3.0
func CPU(val string) ResourceListOp
CPU sets the CPU resource on the ResourceList.
func EphemeralStorage ¶ added in v0.3.0
func EphemeralStorage(val string) ResourceListOp
EphemeralStorage sets the ephemeral storage resource on the ResourceList.
func Memory ¶ added in v0.3.0
func Memory(val string) ResourceListOp
Memory sets the memory resource on the ResourceList.
type ResourceRequirementsOp ¶ added in v0.3.0
type ResourceRequirementsOp func(*corev1.ResourceRequirements)
ResourceRequirementsOp is an operation which modifies a ResourceRequirements struct.
func Limits ¶ added in v0.3.0
func Limits(ops ...ResourceListOp) ResourceRequirementsOp
Limits adds Limits to the ResourceRequirements.
func Requests ¶ added in v0.3.0
func Requests(ops ...ResourceListOp) ResourceRequirementsOp
Requests adds Requests to the ResourceRequirements.
type StepStateOp ¶
StepStateOp is an operation which modify a StepStep struct.
func StateTerminated ¶
func StateTerminated(exitcode int) StepStateOp
StateTerminated set Terminated to the StepState.
type TaskOp ¶
TaskOp is an operation which modify a Task struct.
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 TaskParamOp ¶
TaskParamOp is an operation which modify a ParamSpec struct.
func ParamDefault ¶
func ParamDefault(value string) TaskParamOp
ParamDefault sets the default value to the ParamSpec.
func ParamDescription ¶
func ParamDescription(desc string) TaskParamOp
ParamDescripiton sets the description to the ParamSpec.
type TaskRefOp ¶
TaskRefOp is an operation which modify a TaskRef struct.
func TaskRefAPIVersion ¶
TaskRefAPIVersion sets the specified api version to the TaskRef.
func TaskRefKind ¶
TaskRefKind set the specified kind to the TaskRef.
type TaskResourceBindingOp ¶
type TaskResourceBindingOp func(*v1alpha1.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 *v1alpha1.PipelineResourceSpec) TaskResourceBindingOp
TaskResourceBindingResourceSpec set the PipelineResourceResourceSpec to the TaskResourceBinding.
type TaskResourceOp ¶
type TaskResourceOp func(*v1alpha1.TaskResource)
TaskResourceOp is an operation which modify a TaskResource struct.
func ResourceTargetPath ¶
func ResourceTargetPath(path string) TaskResourceOp
type TaskRunInputsOp ¶
type TaskRunInputsOp func(*v1alpha1.TaskRunInputs)
TaskRunInputsOp is an operation which modify a TaskRunInputs struct.
func TaskRunInputsParam ¶
func TaskRunInputsParam(name, value string) TaskRunInputsOp
TaskRunInputsParam add a param, with specified name and value, to the TaskRunInputs.
func TaskRunInputsResource ¶
func TaskRunInputsResource(name string, ops ...TaskResourceBindingOp) TaskRunInputsOp
TaskRunInputsResource adds a resource, with specified name, to the TaskRunInputs. Any number of TaskResourceBinding modifier can be passed to transform it.
type TaskRunOp ¶
TaskRunOp is an operation which modify a TaskRun struct.
func TaskRunAnnotation ¶ added in v0.4.0
func TaskRunLabel ¶
func TaskRunOwnerReference ¶
func TaskRunOwnerReference(kind, name string, ops ...OwnerReferenceOp) TaskRunOp
TaskRunOwnerReference sets the OwnerReference, with specified kind and name, to the TaskRun.
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 TaskRunOutputsOp ¶
type TaskRunOutputsOp func(*v1alpha1.TaskRunOutputs)
TaskRunOutputsOp is an operation which modify a TaskRunOutputs struct.
func TaskRunOutputsResource ¶
func TaskRunOutputsResource(name string, ops ...TaskResourceBindingOp) TaskRunOutputsOp
TaskRunOutputsResource adds a TaskResourceBinding, with specified name, to the TaskRunOutputs. Any number of TaskResourceBinding modifier can be passed to modifiy it.
type TaskRunSpecOp ¶
type TaskRunSpecOp func(*v1alpha1.TaskRunSpec)
TaskRunSpecOp is an operation which modify a TaskRunSpec struct.
func TaskRunAffinity ¶
func TaskRunAffinity(affinity *corev1.Affinity) TaskRunSpecOp
TaskRunAffinity sets the Affinity to the PipelineSpec.
func TaskRunInputs ¶
func TaskRunInputs(ops ...TaskRunInputsOp) TaskRunSpecOp
TaskRunInputs sets inputs to the TaskRunSpec. Any number of TaskRunInputs modifier can be passed to transform it.
func TaskRunNodeSelector ¶
func TaskRunNodeSelector(values map[string]string) TaskRunSpecOp
TaskRunNodeSelector sets the NodeSelector to the PipelineSpec.
func TaskRunOutputs ¶
func TaskRunOutputs(ops ...TaskRunOutputsOp) TaskRunSpecOp
TaskRunOutputs sets inputs to the TaskRunSpec. Any number of TaskRunOutputs modifier can be passed to transform it.
func TaskRunServiceAccount ¶
func TaskRunServiceAccount(sa string) TaskRunSpecOp
TaskRunServiceAccount sets the serviceAccount to the TaskRunSpec.
func TaskRunSpecStatus ¶ added in v0.5.0
func TaskRunSpecStatus(status v1alpha1.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 TaskRunTolerations ¶ added in v0.3.0
func TaskRunTolerations(values []corev1.Toleration) TaskRunSpecOp
TaskRunTolerations sets the Tolerations to the PipelineSpec.
type TaskRunStatusOp ¶
type TaskRunStatusOp func(*v1alpha1.TaskRunStatus)
TaskRunStatusOp is an operation which modify a TaskRunStatus struct.
func Condition ¶
func Condition(condition apis.Condition) TaskRunStatusOp
Condition adds a Condition to the TaskRunStatus.
func PodName ¶
func PodName(name string) TaskRunStatusOp
PodName sets the Pod name to the TaskRunStatus.
func Retry ¶ added in v0.4.0
func Retry(retry v1alpha1.TaskRunStatus) TaskRunStatusOp
func StepState ¶
func StepState(ops ...StepStateOp) TaskRunStatusOp
StepState adds a StepState to the TaskRunStatus.
func TaskRunStartTime ¶
func TaskRunStartTime(startTime time.Time) TaskRunStatusOp
TaskRunStartTime sets the start time to the TaskRunStatus.
type TaskSpecOp ¶
TaskSpeOp is an operation which modify a TaskSpec struct.
func Step ¶
func Step(name, image string, ops ...ContainerOp) 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 TaskContainerTemplate ¶ added in v0.3.0
func TaskContainerTemplate(ops ...ContainerOp) TaskSpecOp
TaskContainerTemplate adds the deprecated (#977) base container for all steps in the task. ContainerTemplate is now StepTemplate.
func TaskInputs ¶
func TaskInputs(ops ...InputsOp) TaskSpecOp
TaskInputs sets inputs to the TaskSpec. Any number of Inputs modifier can be passed to transform it.
func TaskOutputs ¶
func TaskOutputs(ops ...OutputsOp) TaskSpecOp
TaskOutputs sets inputs to the TaskSpec. Any number of Outputs modifier can be passed to transform it.
func TaskStepTemplate ¶ added in v0.5.0
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.
type VolumeMountOp ¶
type VolumeMountOp func(*corev1.VolumeMount)
VolumeMountOp is an operation which modifies a VolumeMount struct.
type VolumeOp ¶
VolumeOp is an operation which modify a Volume struct.
func VolumeSource ¶
func VolumeSource(s corev1.VolumeSource) VolumeOp
VolumeSource sets the VolumeSource to the Volume.