From d16cb2c85b31545b8dacc5597e5dccaf33653c4f Mon Sep 17 00:00:00 2001 From: Dibyo Mukherjee Date: Tue, 21 May 2019 12:20:06 -0400 Subject: [PATCH] Review: gofmt + remove outdated comment --- .../v1alpha1/build_gcs_resource_test.go | 2 +- .../pipeline/v1alpha1/gcs_resource_test.go | 2 +- pkg/apis/pipeline/v1alpha1/git_resource.go | 1 - .../v1alpha1/taskrun/resources/apply.go | 2 +- .../v1alpha1/taskrun/resources/apply_test.go | 37 +++++++++---------- .../taskrun/resources/input_resource_test.go | 8 ++-- .../taskrun/resources/input_resources.go | 2 +- .../taskrun/resources/output_resource_test.go | 6 +-- 8 files changed, 29 insertions(+), 31 deletions(-) diff --git a/pkg/apis/pipeline/v1alpha1/build_gcs_resource_test.go b/pkg/apis/pipeline/v1alpha1/build_gcs_resource_test.go index b2c10307488..20cbb558935 100644 --- a/pkg/apis/pipeline/v1alpha1/build_gcs_resource_test.go +++ b/pkg/apis/pipeline/v1alpha1/build_gcs_resource_test.go @@ -201,7 +201,7 @@ func Test_BuildGCSGetReplacements(t *testing.T) { "name": "gcs-resource", "type": "build-gcs", "location": "gs://fake-bucket", - "path": "", + "path": "", } if d := cmp.Diff(r.Replacements(), expectedReplacementMap); d != "" { t.Errorf("BuildGCS Replacement map mismatch: %s", d) diff --git a/pkg/apis/pipeline/v1alpha1/gcs_resource_test.go b/pkg/apis/pipeline/v1alpha1/gcs_resource_test.go index 2d6bbbcba7f..3636065df99 100644 --- a/pkg/apis/pipeline/v1alpha1/gcs_resource_test.go +++ b/pkg/apis/pipeline/v1alpha1/gcs_resource_test.go @@ -170,7 +170,7 @@ func Test_GCSGetReplacements(t *testing.T) { "name": "gcs-resource", "type": "gcs", "location": "gs://fake-bucket", - "path": "", + "path": "", } if d := cmp.Diff(gcsResource.Replacements(), expectedReplacementMap); d != "" { t.Errorf("GCS Replacement map mismatch: %s", d) diff --git a/pkg/apis/pipeline/v1alpha1/git_resource.go b/pkg/apis/pipeline/v1alpha1/git_resource.go index 192f1d59fb5..f1abc6d2b80 100644 --- a/pkg/apis/pipeline/v1alpha1/git_resource.go +++ b/pkg/apis/pipeline/v1alpha1/git_resource.go @@ -91,7 +91,6 @@ func (s GitResource) GetParams() []Param { return []Param{} } // Replacements is used for template replacement on a GitResource inside of a Taskrun. func (s *GitResource) Replacements() map[string]string { - return map[string]string{ "name": s.Name, "type": string(s.Type), diff --git a/pkg/reconciler/v1alpha1/taskrun/resources/apply.go b/pkg/reconciler/v1alpha1/taskrun/resources/apply.go index bf3340d3495..3f784224a26 100644 --- a/pkg/reconciler/v1alpha1/taskrun/resources/apply.go +++ b/pkg/reconciler/v1alpha1/taskrun/resources/apply.go @@ -42,7 +42,7 @@ func ApplyParameters(spec *v1alpha1.TaskSpec, tr *v1alpha1.TaskRun, defaults ... } // ApplyResources applies the templating from values in resources which are referenced in spec as subitems -// of the replacementStr. It retrieves the referenced resources via the getter. +// of the replacementStr. func ApplyResources(spec *v1alpha1.TaskSpec, resolvedResources map[string]v1alpha1.PipelineResourceInterface, replacementStr string) *v1alpha1.TaskSpec { replacements := map[string]string{} for name, r := range resolvedResources { diff --git a/pkg/reconciler/v1alpha1/taskrun/resources/apply_test.go b/pkg/reconciler/v1alpha1/taskrun/resources/apply_test.go index a682ca81fb3..cc4b287f9e4 100644 --- a/pkg/reconciler/v1alpha1/taskrun/resources/apply_test.go +++ b/pkg/reconciler/v1alpha1/taskrun/resources/apply_test.go @@ -30,10 +30,10 @@ var simpleTaskSpec = &v1alpha1.TaskSpec{ Name: "foo", Image: "${inputs.params.myimage}", }, { - Name: "baz", - Image: "bat", + Name: "baz", + Image: "bat", WorkingDir: "${inputs.resources.workspace.path}", - Args: []string{"${inputs.resources.workspace.url}"}, + Args: []string{"${inputs.resources.workspace.url}"}, }, { Name: "qux", Image: "quux", @@ -180,31 +180,30 @@ func TestApplyParameters(t *testing.T) { } } - func TestApplyResources(t *testing.T) { type args struct { - ts *v1alpha1.TaskSpec - r map[string]v1alpha1.PipelineResourceInterface - rStr string + ts *v1alpha1.TaskSpec + r map[string]v1alpha1.PipelineResourceInterface + rStr string } tests := []struct { - name string - args args - want *v1alpha1.TaskSpec + name string + args args + want *v1alpha1.TaskSpec }{{ name: "no replacements specified", args: args{ - ts: simpleTaskSpec, - r: make(map[string]v1alpha1.PipelineResourceInterface), - rStr: "inputs", + ts: simpleTaskSpec, + r: make(map[string]v1alpha1.PipelineResourceInterface), + rStr: "inputs", }, want: simpleTaskSpec, }, { name: "input resource specified", args: args{ - ts: simpleTaskSpec, - r: inputs, - rStr: "inputs", + ts: simpleTaskSpec, + r: inputs, + rStr: "inputs", }, want: applyMutation(simpleTaskSpec, func(spec *v1alpha1.TaskSpec) { spec.Steps[1].WorkingDir = "/workspace/workspace" @@ -213,9 +212,9 @@ func TestApplyResources(t *testing.T) { }, { name: "output resource specified", args: args{ - ts: simpleTaskSpec, - r: outputs, - rStr: "outputs", + ts: simpleTaskSpec, + r: outputs, + rStr: "outputs", }, want: applyMutation(simpleTaskSpec, func(spec *v1alpha1.TaskSpec) { spec.Steps[2].Args = []string{"gcr.io/hans/sandwiches"} diff --git a/pkg/reconciler/v1alpha1/taskrun/resources/input_resource_test.go b/pkg/reconciler/v1alpha1/taskrun/resources/input_resource_test.go index 84fa4243817..7027a751212 100644 --- a/pkg/reconciler/v1alpha1/taskrun/resources/input_resource_test.go +++ b/pkg/reconciler/v1alpha1/taskrun/resources/input_resource_test.go @@ -28,7 +28,7 @@ import ( var ( inputResourceInterfaces map[string]v1alpha1.PipelineResourceInterface - logger *zap.SugaredLogger + logger *zap.SugaredLogger gitInputs = &v1alpha1.Inputs{ Resources: []v1alpha1.TaskResource{{ @@ -189,7 +189,7 @@ func setUp(t *testing.T) { }} inputResourceInterfaces = make(map[string]v1alpha1.PipelineResourceInterface) for _, r := range rs { - ri,_ := v1alpha1.ResourceFromType(r) + ri, _ := v1alpha1.ResourceFromType(r) inputResourceInterfaces[r.Name] = ri } } @@ -1011,7 +1011,7 @@ func mockResolveTaskResources(taskRun *v1alpha1.TaskRun) map[string]v1alpha1.Pip i = inputResourceInterfaces[name] resolved[r.Name] = i } else if r.ResourceSpec != nil { - i, _ =v1alpha1.ResourceFromType(&v1alpha1.PipelineResource{ + i, _ = v1alpha1.ResourceFromType(&v1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: r.Name, }, @@ -1023,4 +1023,4 @@ func mockResolveTaskResources(taskRun *v1alpha1.TaskRun) map[string]v1alpha1.Pip } } return resolved -} \ No newline at end of file +} diff --git a/pkg/reconciler/v1alpha1/taskrun/resources/input_resources.go b/pkg/reconciler/v1alpha1/taskrun/resources/input_resources.go index 9a06d3c7069..fd93b0b5357 100644 --- a/pkg/reconciler/v1alpha1/taskrun/resources/input_resources.go +++ b/pkg/reconciler/v1alpha1/taskrun/resources/input_resources.go @@ -142,7 +142,7 @@ func AddInputResource( return taskSpec, nil } -func addStorageFetchStep(taskSpec *v1alpha1.TaskSpec, storageResource v1alpha1.PipelineStorageResourceInterface,) ([]corev1.Container, []corev1.Volume, error) { +func addStorageFetchStep(taskSpec *v1alpha1.TaskSpec, storageResource v1alpha1.PipelineStorageResourceInterface) ([]corev1.Container, []corev1.Volume, error) { gcsContainers, err := storageResource.GetDownloadContainerSpec() if err != nil { return nil, nil, err diff --git a/pkg/reconciler/v1alpha1/taskrun/resources/output_resource_test.go b/pkg/reconciler/v1alpha1/taskrun/resources/output_resource_test.go index 2019372a35c..bdb24749180 100644 --- a/pkg/reconciler/v1alpha1/taskrun/resources/output_resource_test.go +++ b/pkg/reconciler/v1alpha1/taskrun/resources/output_resource_test.go @@ -93,7 +93,7 @@ func outputResourceSetup(t *testing.T) { outputResources = make(map[string]v1alpha1.PipelineResourceInterface) for _, r := range rs { - ri,_ := v1alpha1.ResourceFromType(r) + ri, _ := v1alpha1.ResourceFromType(r) outputResources[r.Name] = ri } } @@ -1022,7 +1022,7 @@ func resolveOutputResources(taskRun *v1alpha1.TaskRun) map[string]v1alpha1.Pipel i = outputResources[name] resolved[r.Name] = i } else if r.ResourceSpec != nil { - i, _ =v1alpha1.ResourceFromType(&v1alpha1.PipelineResource{ + i, _ = v1alpha1.ResourceFromType(&v1alpha1.PipelineResource{ ObjectMeta: metav1.ObjectMeta{ Name: r.Name, }, @@ -1032,4 +1032,4 @@ func resolveOutputResources(taskRun *v1alpha1.TaskRun) map[string]v1alpha1.Pipel } } return resolved -} \ No newline at end of file +}