Skip to content

Commit

Permalink
Remove unused test builder methods
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh authored and tekton-robot committed Sep 21, 2020
1 parent 06ad7c5 commit dc5d937
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 290 deletions.
3 changes: 1 addition & 2 deletions internal/builder/v1alpha1/condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ limitations under the License.
package builder

import (
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

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

// ConditionOp is an operation which modifies a Condition struct.
Expand Down
20 changes: 0 additions & 20 deletions internal/builder/v1alpha1/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -465,26 +465,6 @@ func PipelineRunNodeSelector(values map[string]string) PipelineRunSpecOp {
}
}

// PipelineRunTolerations sets the Node selector to the PipelineRunSpec.
func PipelineRunTolerations(values []corev1.Toleration) PipelineRunSpecOp {
return func(prs *v1alpha1.PipelineRunSpec) {
if prs.PodTemplate == nil {
prs.PodTemplate = &v1alpha1.PodTemplate{}
}
prs.PodTemplate.Tolerations = values
}
}

// PipelineRunAffinity sets the affinity to the PipelineRunSpec.
func PipelineRunAffinity(affinity *corev1.Affinity) PipelineRunSpecOp {
return func(prs *v1alpha1.PipelineRunSpec) {
if prs.PodTemplate == nil {
prs.PodTemplate = &v1alpha1.PodTemplate{}
}
prs.PodTemplate.Affinity = affinity
}
}

// PipelineRunPipelineSpec adds a PipelineSpec to the PipelineRunSpec.
// Any number of PipelineSpec modifiers can be passed to transform it.
func PipelineRunPipelineSpec(ops ...PipelineSpecOp) PipelineRunSpecOp {
Expand Down
62 changes: 0 additions & 62 deletions internal/builder/v1alpha1/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package builder
import (
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
)

// StepOp is an operation which modifies a Container struct.
Expand Down Expand Up @@ -87,64 +86,3 @@ func StepScript(script string) StepOp {
step.Script = script
}
}

// StepResources adds ResourceRequirements to the Container (step).
func StepResources(ops ...ResourceRequirementsOp) StepOp {
return func(step *v1alpha1.Step) {
rr := &corev1.ResourceRequirements{}
for _, op := range ops {
op(rr)
}
step.Resources = *rr
}
}

// StepLimits adds Limits to the ResourceRequirements.
func StepLimits(ops ...ResourceListOp) ResourceRequirementsOp {
return func(rr *corev1.ResourceRequirements) {
limits := corev1.ResourceList{}
for _, op := range ops {
op(limits)
}
rr.Limits = limits
}
}

// StepRequests adds Requests to the ResourceRequirements.
func StepRequests(ops ...ResourceListOp) ResourceRequirementsOp {
return func(rr *corev1.ResourceRequirements) {
requests := corev1.ResourceList{}
for _, op := range ops {
op(requests)
}
rr.Requests = requests
}
}

// StepCPU sets the CPU resource on the ResourceList.
func StepCPU(val string) ResourceListOp {
return func(r corev1.ResourceList) {
r[corev1.ResourceCPU] = resource.MustParse(val)
}
}

// StepMemory sets the memory resource on the ResourceList.
func StepMemory(val string) ResourceListOp {
return func(r corev1.ResourceList) {
r[corev1.ResourceMemory] = resource.MustParse(val)
}
}

// StepEphemeralStorage sets the ephemeral storage resource on the ResourceList.
func StepEphemeralStorage(val string) ResourceListOp {
return func(r corev1.ResourceList) {
r[corev1.ResourceEphemeralStorage] = resource.MustParse(val)
}
}

// StepTerminationMessagePath sets the source of the termination message.
func StepTerminationMessagePath(terminationMessagePath string) StepOp {
return func(step *v1alpha1.Step) {
step.TerminationMessagePath = terminationMessagePath
}
}
53 changes: 0 additions & 53 deletions internal/builder/v1alpha1/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,19 +313,6 @@ 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 Expand Up @@ -551,36 +538,6 @@ func TaskRunNodeSelector(values map[string]string) TaskRunSpecOp {
}
}

// TaskRunTolerations sets the Tolerations to the TaskRunSpec.
func TaskRunTolerations(values []corev1.Toleration) TaskRunSpecOp {
return func(spec *v1alpha1.TaskRunSpec) {
if spec.PodTemplate == nil {
spec.PodTemplate = &v1alpha1.PodTemplate{}
}
spec.PodTemplate.Tolerations = values
}
}

// TaskRunAffinity sets the Affinity to the TaskRunSpec.
func TaskRunAffinity(affinity *corev1.Affinity) TaskRunSpecOp {
return func(spec *v1alpha1.TaskRunSpec) {
if spec.PodTemplate == nil {
spec.PodTemplate = &v1alpha1.PodTemplate{}
}
spec.PodTemplate.Affinity = affinity
}
}

// TaskRunPodSecurityContext sets the SecurityContext to the TaskRunSpec (through PodTemplate).
func TaskRunPodSecurityContext(context *corev1.PodSecurityContext) TaskRunSpecOp {
return func(spec *v1alpha1.TaskRunSpec) {
if spec.PodTemplate == nil {
spec.PodTemplate = &v1alpha1.PodTemplate{}
}
spec.PodTemplate.SecurityContext = context
}
}

// StateTerminated sets Terminated to the StepState.
func StateTerminated(exitcode int) StepStateOp {
return func(s *v1alpha1.StepState) {
Expand Down Expand Up @@ -819,16 +776,6 @@ func TaskRunInputs(ops ...TaskRunInputsOp) TaskRunSpecOp {
}
}

// TaskRunInputsParam add a param, with specified name and value, to the TaskRunInputs.
func TaskRunInputsParam(name, value string, additionalValues ...string) TaskRunInputsOp {
return func(i *v1alpha1.TaskRunInputs) {
i.Params = append(i.Params, v1alpha1.Param{
Name: name,
Value: *v1beta1.NewArrayOrString(value, additionalValues...),
})
}
}

// TaskRunInputsResource adds a resource, with specified name, to the TaskRunInputs.
// Any number of TaskResourceBinding modifier can be passed to transform it.
func TaskRunInputsResource(name string, ops ...TaskResourceBindingOp) TaskRunInputsOp {
Expand Down
20 changes: 0 additions & 20 deletions internal/builder/v1beta1/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,26 +518,6 @@ func PipelineRunNodeSelector(values map[string]string) PipelineRunSpecOp {
}
}

// PipelineRunTolerations sets the Node selector to the PipelineRunSpec.
func PipelineRunTolerations(values []corev1.Toleration) PipelineRunSpecOp {
return func(prs *v1beta1.PipelineRunSpec) {
if prs.PodTemplate == nil {
prs.PodTemplate = &v1beta1.PodTemplate{}
}
prs.PodTemplate.Tolerations = values
}
}

// PipelineRunAffinity sets the affinity to the PipelineRunSpec.
func PipelineRunAffinity(affinity *corev1.Affinity) PipelineRunSpecOp {
return func(prs *v1beta1.PipelineRunSpec) {
if prs.PodTemplate == nil {
prs.PodTemplate = &v1beta1.PodTemplate{}
}
prs.PodTemplate.Affinity = affinity
}
}

// PipelineRunPipelineSpec adds a PipelineSpec to the PipelineRunSpec.
// Any number of PipelineSpec modifiers can be passed to transform it.
func PipelineRunPipelineSpec(ops ...PipelineSpecOp) PipelineRunSpecOp {
Expand Down
28 changes: 0 additions & 28 deletions internal/builder/v1beta1/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ limitations under the License.
package builder

import (
"time"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -164,29 +162,3 @@ func PodVolumes(volumes ...corev1.Volume) PodSpecOp {
spec.Volumes = volumes
}
}

// PodCreationTimestamp sets the creation time of the pod
func PodCreationTimestamp(t time.Time) PodOp {
return func(p *corev1.Pod) {
p.CreationTimestamp = metav1.Time{Time: t}
}
}

// PodStatus creates a PodStatus with default values.
// Any number of PodStatus modifiers can be passed to transform it.
func PodStatus(ops ...PodStatusOp) PodOp {
return func(pod *corev1.Pod) {
podStatus := &pod.Status
for _, op := range ops {
op(podStatus)
}
pod.Status = *podStatus
}
}

// PodStatusConditions adds a Conditions (set) to the Pod status.
func PodStatusConditions(cond corev1.PodCondition) PodStatusOp {
return func(status *corev1.PodStatus) {
status.Conditions = append(status.Conditions, cond)
}
}
62 changes: 0 additions & 62 deletions internal/builder/v1beta1/step.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package builder
import (
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
)

// StepOp is an operation which modifies a Container struct.
Expand Down Expand Up @@ -87,64 +86,3 @@ func StepScript(script string) StepOp {
step.Script = script
}
}

// StepResources adds ResourceRequirements to the Container (step).
func StepResources(ops ...ResourceRequirementsOp) StepOp {
return func(step *v1beta1.Step) {
rr := &corev1.ResourceRequirements{}
for _, op := range ops {
op(rr)
}
step.Resources = *rr
}
}

// StepLimits adds Limits to the ResourceRequirements.
func StepLimits(ops ...ResourceListOp) ResourceRequirementsOp {
return func(rr *corev1.ResourceRequirements) {
limits := corev1.ResourceList{}
for _, op := range ops {
op(limits)
}
rr.Limits = limits
}
}

// StepRequests adds Requests to the ResourceRequirements.
func StepRequests(ops ...ResourceListOp) ResourceRequirementsOp {
return func(rr *corev1.ResourceRequirements) {
requests := corev1.ResourceList{}
for _, op := range ops {
op(requests)
}
rr.Requests = requests
}
}

// StepCPU sets the CPU resource on the ResourceList.
func StepCPU(val string) ResourceListOp {
return func(r corev1.ResourceList) {
r[corev1.ResourceCPU] = resource.MustParse(val)
}
}

// StepMemory sets the memory resource on the ResourceList.
func StepMemory(val string) ResourceListOp {
return func(r corev1.ResourceList) {
r[corev1.ResourceMemory] = resource.MustParse(val)
}
}

// StepEphemeralStorage sets the ephemeral storage resource on the ResourceList.
func StepEphemeralStorage(val string) ResourceListOp {
return func(r corev1.ResourceList) {
r[corev1.ResourceEphemeralStorage] = resource.MustParse(val)
}
}

// StepTerminationMessagePath sets the source of the termination message.
func StepTerminationMessagePath(terminationMessagePath string) StepOp {
return func(step *v1beta1.Step) {
step.TerminationMessagePath = terminationMessagePath
}
}
43 changes: 0 additions & 43 deletions internal/builder/v1beta1/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,19 +305,6 @@ func TaskResourcesOutput(name string, resourceType resource.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)
}
}
}

// ResourceOptional marks a TaskResource as optional.
func ResourceOptional(optional bool) TaskResourceOp {
return func(r *v1beta1.TaskResource) {
Expand Down Expand Up @@ -474,36 +461,6 @@ func TaskRunNodeSelector(values map[string]string) TaskRunSpecOp {
}
}

// TaskRunTolerations sets the Tolerations to the TaskRunSpec.
func TaskRunTolerations(values []corev1.Toleration) TaskRunSpecOp {
return func(spec *v1beta1.TaskRunSpec) {
if spec.PodTemplate == nil {
spec.PodTemplate = &v1beta1.PodTemplate{}
}
spec.PodTemplate.Tolerations = values
}
}

// TaskRunAffinity sets the Affinity to the TaskRunSpec.
func TaskRunAffinity(affinity *corev1.Affinity) TaskRunSpecOp {
return func(spec *v1beta1.TaskRunSpec) {
if spec.PodTemplate == nil {
spec.PodTemplate = &v1beta1.PodTemplate{}
}
spec.PodTemplate.Affinity = affinity
}
}

// TaskRunPodSecurityContext sets the SecurityContext to the TaskRunSpec (through PodTemplate).
func TaskRunPodSecurityContext(context *corev1.PodSecurityContext) TaskRunSpecOp {
return func(spec *v1beta1.TaskRunSpec) {
if spec.PodTemplate == nil {
spec.PodTemplate = &v1beta1.PodTemplate{}
}
spec.PodTemplate.SecurityContext = context
}
}

// StateTerminated sets Terminated to the StepState.
func StateTerminated(exitcode int) StepStateOp {
return func(s *v1beta1.StepState) {
Expand Down

0 comments on commit dc5d937

Please sign in to comment.