Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Terminated, Running, and Waiting Container States to Test Builder #1591

Merged
merged 1 commit into from
Nov 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion test/builder/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ func TaskRunPodSecurityContext(context *corev1.PodSecurityContext) TaskRunSpecOp
}
}

// StateTerminated set Terminated to the StepState.
// StateTerminated sets Terminated to the StepState.
func StateTerminated(exitcode int) StepStateOp {
return func(s *v1alpha1.StepState) {
s.ContainerState = corev1.ContainerState{
Expand All @@ -409,6 +409,33 @@ func StateTerminated(exitcode int) StepStateOp {
}
}

// SetStepStateTerminated sets Terminated state of a step.
func SetStepStateTerminated(terminated corev1.ContainerStateTerminated) StepStateOp {
return func(s *v1alpha1.StepState) {
s.ContainerState = corev1.ContainerState{
Terminated: &terminated,
}
}
}

// SetStepStateRunning sets Running state of a step.
func SetStepStateRunning(running corev1.ContainerStateRunning) StepStateOp {
return func(s *v1alpha1.StepState) {
s.ContainerState = corev1.ContainerState{
Running: &running,
}
}
}

// SetStepStateWaiting sets Waiting state of a step.
func SetStepStateWaiting(waiting corev1.ContainerStateWaiting) StepStateOp {
return func(s *v1alpha1.StepState) {
s.ContainerState = corev1.ContainerState{
Waiting: &waiting,
}
}
}

// TaskRunOwnerReference sets the OwnerReference, with specified kind and name, to the TaskRun.
func TaskRunOwnerReference(kind, name string, ops ...OwnerReferenceOp) TaskRunOp {
return func(tr *v1alpha1.TaskRun) {
Expand Down