From dc5d937a3aedc1a05ec6bea7f08becb332912398 Mon Sep 17 00:00:00 2001 From: Jason Hall Date: Fri, 18 Sep 2020 23:52:02 -0400 Subject: [PATCH] Remove unused test builder methods --- internal/builder/v1alpha1/condition.go | 3 +- internal/builder/v1alpha1/pipeline.go | 20 --------- internal/builder/v1alpha1/step.go | 62 -------------------------- internal/builder/v1alpha1/task.go | 53 ---------------------- internal/builder/v1beta1/pipeline.go | 20 --------- internal/builder/v1beta1/pod.go | 28 ------------ internal/builder/v1beta1/step.go | 62 -------------------------- internal/builder/v1beta1/task.go | 43 ------------------ 8 files changed, 1 insertion(+), 290 deletions(-) diff --git a/internal/builder/v1alpha1/condition.go b/internal/builder/v1alpha1/condition.go index ccef5a9bee2..c5d25f6b398 100644 --- a/internal/builder/v1alpha1/condition.go +++ b/internal/builder/v1alpha1/condition.go @@ -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. diff --git a/internal/builder/v1alpha1/pipeline.go b/internal/builder/v1alpha1/pipeline.go index 9c72df3a35d..fbad8813645 100644 --- a/internal/builder/v1alpha1/pipeline.go +++ b/internal/builder/v1alpha1/pipeline.go @@ -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 { diff --git a/internal/builder/v1alpha1/step.go b/internal/builder/v1alpha1/step.go index b489ce71b7f..695f4671b8a 100644 --- a/internal/builder/v1alpha1/step.go +++ b/internal/builder/v1alpha1/step.go @@ -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. @@ -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 - } -} diff --git a/internal/builder/v1alpha1/task.go b/internal/builder/v1alpha1/task.go index 42314b000c6..d45da4cab91 100644 --- a/internal/builder/v1alpha1/task.go +++ b/internal/builder/v1alpha1/task.go @@ -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 { @@ -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) { @@ -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 { diff --git a/internal/builder/v1beta1/pipeline.go b/internal/builder/v1beta1/pipeline.go index 27e869e51ab..edf9df3b235 100644 --- a/internal/builder/v1beta1/pipeline.go +++ b/internal/builder/v1beta1/pipeline.go @@ -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 { diff --git a/internal/builder/v1beta1/pod.go b/internal/builder/v1beta1/pod.go index 508ae3dc138..dd04195cf64 100644 --- a/internal/builder/v1beta1/pod.go +++ b/internal/builder/v1beta1/pod.go @@ -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" @@ -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) - } -} diff --git a/internal/builder/v1beta1/step.go b/internal/builder/v1beta1/step.go index a2f10ddf364..e9c428c8d60 100644 --- a/internal/builder/v1beta1/step.go +++ b/internal/builder/v1beta1/step.go @@ -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. @@ -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 - } -} diff --git a/internal/builder/v1beta1/task.go b/internal/builder/v1beta1/task.go index 59cf340d906..06b5d5156fc 100644 --- a/internal/builder/v1beta1/task.go +++ b/internal/builder/v1beta1/task.go @@ -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) { @@ -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) {