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

Don't require pointer to binding #2834

Merged
merged 3 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ type GetTaskRun func(name string) (*v1beta1.TaskRun, error)
func GetResourcesFromBindings(pr *v1beta1.PipelineRun, getResource resources.GetResource) (map[string]*resourcev1alpha1.PipelineResource, error) {
rs := map[string]*resourcev1alpha1.PipelineResource{}
for _, resource := range pr.Spec.Resources {
r, err := resources.GetResourceFromBinding(&resource, getResource)
r, err := resources.GetResourceFromBinding(resource, getResource)
if err != nil {
return rs, fmt.Errorf("error following resource reference for %s: %w", resource.Name, err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/taskrun/resources/image_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func AddOutputImageDigestExporter(
return fmt.Errorf("failed to get bound resource: %w while adding output image digest exporter", err)
}

resource, err := GetResourceFromBinding(&boundResource.PipelineResourceBinding, gr)
resource, err := GetResourceFromBinding(boundResource.PipelineResourceBinding, gr)
if err != nil {
return fmt.Errorf("failed to get output pipeline Resource for taskRun %q resource %v; error: %w while adding output image digest exporter", tr.Name, boundResource, err)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/reconciler/taskrun/resources/taskresourceresolution.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func ResolveTaskResources(ts *v1beta1.TaskSpec, taskName string, kind v1beta1.Ta
}

for _, r := range inputs {
rr, err := GetResourceFromBinding(&r.PipelineResourceBinding, gr)
rr, err := GetResourceFromBinding(r.PipelineResourceBinding, gr)
if err != nil {
return nil, fmt.Errorf("couldn't retrieve referenced input PipelineResource: %w", err)
}
Expand All @@ -64,7 +64,7 @@ func ResolveTaskResources(ts *v1beta1.TaskSpec, taskName string, kind v1beta1.Ta
}

for _, r := range outputs {
rr, err := GetResourceFromBinding(&r.PipelineResourceBinding, gr)
rr, err := GetResourceFromBinding(r.PipelineResourceBinding, gr)

if err != nil {
return nil, fmt.Errorf("couldn't retrieve referenced output PipelineResource: %w", err)
Expand All @@ -77,7 +77,7 @@ func ResolveTaskResources(ts *v1beta1.TaskSpec, taskName string, kind v1beta1.Ta

// GetResourceFromBinding will return an instance of a PipelineResource to use for r, either by getting it with getter or by
// instantiating it from the embedded spec.
func GetResourceFromBinding(r *v1beta1.PipelineResourceBinding, getter GetResource) (*resourcev1alpha1.PipelineResource, error) {
func GetResourceFromBinding(r v1beta1.PipelineResourceBinding, getter GetResource) (*resourcev1alpha1.PipelineResource, error) {
if (r.ResourceRef != nil && r.ResourceRef.Name != "") && r.ResourceSpec != nil {
return nil, errors.New("Both ResourseRef and ResourceSpec are defined. Expected only one")
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/reconciler/taskrun/resources/taskresourceresolution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func TestGetResourceFromBinding_Ref(t *testing.T) {
Name: "git-repo",
},
}
binding := &v1beta1.PipelineResourceBinding{
binding := v1beta1.PipelineResourceBinding{
ResourceRef: &v1beta1.PipelineResourceRef{
Name: "foo-resource",
},
Expand All @@ -292,7 +292,7 @@ func TestGetResourceFromBinding_Ref(t *testing.T) {
}

func TestGetResourceFromBinding_Spec(t *testing.T) {
binding := &v1beta1.PipelineResourceBinding{
binding := v1beta1.PipelineResourceBinding{
ResourceSpec: &resourcev1alpha1.PipelineResourceSpec{
Type: resourcev1alpha1.PipelineResourceTypeGit,
Params: []resourcev1alpha1.ResourceParam{{
Expand All @@ -318,7 +318,7 @@ func TestGetResourceFromBinding_Spec(t *testing.T) {
}

func TestGetResourceFromBinding_NoNameOrSpec(t *testing.T) {
binding := &v1beta1.PipelineResourceBinding{}
binding := v1beta1.PipelineResourceBinding{}
gr := func(n string) (*resourcev1alpha1.PipelineResource, error) {
return nil, nil
}
Expand All @@ -330,7 +330,7 @@ func TestGetResourceFromBinding_NoNameOrSpec(t *testing.T) {
}

func TestGetResourceFromBinding_NameAndSpec(t *testing.T) {
binding := &v1beta1.PipelineResourceBinding{
binding := v1beta1.PipelineResourceBinding{
ResourceSpec: &resourcev1alpha1.PipelineResourceSpec{
Type: resourcev1alpha1.PipelineResourceTypeGit,
Params: []resourcev1alpha1.ResourceParam{{
Expand All @@ -353,7 +353,7 @@ func TestGetResourceFromBinding_NameAndSpec(t *testing.T) {
}

func TestGetResourceFromBinding_ErrorGettingResource(t *testing.T) {
binding := &v1beta1.PipelineResourceBinding{
binding := v1beta1.PipelineResourceBinding{
ResourceRef: &v1beta1.PipelineResourceRef{
Name: "foo-resource",
},
Expand Down