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

cannot use ResourceProvider as type ProviderFunc in field value #2077

Closed
nathanielks opened this issue Oct 27, 2017 · 16 comments
Closed

cannot use ResourceProvider as type ProviderFunc in field value #2077

nathanielks opened this issue Oct 27, 2017 · 16 comments
Labels
question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. upstream-terraform Addresses functionality related to the Terraform core binary.

Comments

@nathanielks
Copy link
Contributor

Hey, team!

I'm trying to contribute but unfortunately tests are failing out of the gate. I haven't made any modifications to my fork of the repo at all. I cloned then ran go get github.com/nathanielks/terraform-provider-aws to download it.

Terraform Version

Terraform v0.10.7

Debug Output

https://gist.github.com/nathanielks/8e2ac160c09258c4ece0ccb2f097a1ae

Expected Behavior

Tests should pass as I pulled off of master which should be stable.

Actual Behavior

Tests are failing with error:

terraform-provider-aws/main.go:10: cannot use "github.com/terraform-providers/terraform-provider-aws/aws".Provider (type func() "github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/terraform".ResourceProvider) as type "github.com/nathanielks/terraform-provider-aws/vendor/github.com/hashicorp/terraform/plugin".ProviderFunc in field value

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. go get github.com/nathanielks/terraform

Important Factoids

Are there anything atypical about your accounts that we should know? For example: Running in EC2 Classic? Custom version of OpenStack? Tight ACLs?

References

Are there any other GitHub issues (open or closed) or Pull Requests that should be linked here? For example:

@jwermuth
Copy link

jwermuth commented Nov 14, 2017

Hi @nathanielks . I get the same error trying to build a plugin for terraform. Also on a fresh clone, on a commit that I can see passes travis tests!

./main.go:10:15: cannot use "github.com/f5devcentral/terraform-provider-bigip/bigip".Provider (type func() "github.com/f5devcentral/terraform-provider-bigip/vendor/github.com/hashicorp/terraform/terraform".ResourceProvider) as type "terraform-provider-bigip/vendor/github.com/hashicorp/terraform/plugin".ProviderFunc in field value

@Ninir Ninir added the bug Addresses a defect in current functionality. label Nov 14, 2017
@Ninir
Copy link
Contributor

Ninir commented Nov 14, 2017

Hi folks,

As a quick review:

  • Could you share the Go version you are running?
  • Can you ensure your fork is in-sync with the upstream one?

Thanks!

@Ninir Ninir added the waiting-response Maintainers are waiting on response from community or contributor. label Nov 14, 2017
@jwermuth
Copy link

@Ninir I think I found at least some of the problem. When I got the error reported above I did:
A1 clone github.com/f5devcentral/terraform-provider-bigip into GOPATH/src/terraform-provider-bigip
A2 execute go build
A3 error

Just now I did
B1 go get github.com/f5devcentral/terraform-provider-bigip
B2 cd into GOPATH/src/github.com/f5devcentral/terraform-provider-bigip
B3 execute go build
B4 success

It seems I got the dir structure convention in go wrong (this is my first attempt to build go code). It has to be as in B2, not A1

@nathanielks
Copy link
Contributor Author

I can confirm @jwermuth. I had to rename the directory to $GOPATH/src/github.com/terraform-providers/terraform-provider-aws instead of $GOPATH/src/github.com/nathanielks/terraform-provider-aws.

@nathanielks
Copy link
Contributor Author

@Ninir can confirm my fork is in sync and am currently using Go 1.9.1.

@paddycarver paddycarver removed the waiting-response Maintainers are waiting on response from community or contributor. label Nov 21, 2017
@pawelsocha
Copy link

I had the same problem.
After refresh vendor in terraform-provider-aws/vendor/ I got working make build command.

@thomaswhitcomb
Copy link

@nathanielks I'm stuck on this problem as well. Did you figure out a work-around? @pawelsocha what do you mean by a vendor "refresh"?

@thomaswhitcomb
Copy link

I forked 'terraform-providers/terraform-provider-aws' under my $GOPATH/src/github.com. It builds and allows me to do my provider development.

Maybe the README section: "Developing the Provider" meant to include that one should fork in the same directory location as specified under "Building the Provider"....

@pawelsocha
Copy link

@thomaswhitcomb I'm trying to reproduce the problem on a new computer.

@pawelsocha
Copy link

Okey, I create full path in GOPATH
and now everything works o_O

> echo $GOPATH
/Users/psocha/go/
> pwd
/Users/psocha/go/src/github.com/terraform-providers/terraform-provider-aws
> make
==> Checking that code complies with gofmt requirements...
go install
> echo $?
0

@nathanielks
Copy link
Contributor Author

@thomaswhitcomb I just renamed the parent directory from $GOPATH/src/github.com/nathanielks/terraform-provider-aws to $GOPATH/src/github.com/terraform-providers/terraform-provider-aws ¯_(ツ)_/¯

@radeksimko radeksimko added question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. upstream-terraform Addresses functionality related to the Terraform core binary. and removed bug Addresses a defect in current functionality. labels Jan 28, 2018
@iancward
Copy link
Contributor

I have a similar issue. I forked this repo, cloned it into $GOPATH/src/github.com/iancward/terraform-provider-aws and run make test and get the same error as the OP.
If I move this forked repo to $GOPATH/src/github.com/terraform-providers/terraform-provider-aws the command works from there. But that seems dirty.

$ go version
go version go1.9.2 linux/amd64

Maybe the issue is that terraform has vendored terraform-provider-aws and terraform-provider-aws has a dependency on terraform (and also has it vendored)?

@pawelsocha
Copy link

I change makefile on the forked repo to build provider everywhere ;P
https://github.com/NikkeiFTLearning/terraform-provider-aws-nftl/blob/master/GNUmakefile#L14-L18

@iancward golang building process is strictly connected with GOPATH and sometimes it defaults to resolve dependencies from import block.

@pawelsocha
Copy link

pawelsocha commented Jun 21, 2018

The solution is to built terraform provider in $GOPATH/src/github.com/terraform-providers/terraform-provider-aws

@bflad
Copy link
Contributor

bflad commented Jun 21, 2018

The repository README does indeed list the solution mentioned above: https://github.com/terraform-providers/terraform-provider-aws/#building-the-provider

Clone repository to: $GOPATH/src/github.com/terraform-providers/terraform-provider-aws

If there are indeed errors with the README instructions for building/testing, please do let us know!

@bflad bflad closed this as completed Jun 21, 2018
@ghost
Copy link

ghost commented Apr 3, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question A question about existing functionality; most questions are re-routed to discuss.hashicorp.com. upstream-terraform Addresses functionality related to the Terraform core binary.
Projects
None yet
Development

No branches or pull requests

9 participants