Skip to content

Commit

Permalink
Review: gofmt + remove outdated comment
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyom authored and tekton-robot committed May 29, 2019
1 parent cd8a172 commit d16cb2c
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 31 deletions.
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1alpha1/build_gcs_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1alpha1/gcs_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/v1alpha1/git_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/v1alpha1/taskrun/resources/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
37 changes: 18 additions & 19 deletions pkg/reconciler/v1alpha1/taskrun/resources/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand All @@ -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"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

var (
inputResourceInterfaces map[string]v1alpha1.PipelineResourceInterface
logger *zap.SugaredLogger
logger *zap.SugaredLogger

gitInputs = &v1alpha1.Inputs{
Resources: []v1alpha1.TaskResource{{
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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,
},
Expand All @@ -1023,4 +1023,4 @@ func mockResolveTaskResources(taskRun *v1alpha1.TaskRun) map[string]v1alpha1.Pip
}
}
return resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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,
},
Expand All @@ -1032,4 +1032,4 @@ func resolveOutputResources(taskRun *v1alpha1.TaskRun) map[string]v1alpha1.Pipel
}
}
return resolved
}
}

0 comments on commit d16cb2c

Please sign in to comment.