I am trying to build a provider for opsgenie using...
# general
g
I am trying to build a provider for opsgenie using the https://github.com/pulumi/pulumi-tf-provider-boilerplate, but I keep getting this error
Copy code
make
scripts/get-py-version.go:7:2: cannot find module providing package <http://github.com/pulumi/pulumi/sdk/v2/go/common/util/buildutil|github.com/pulumi/pulumi/sdk/v2/go/common/util/buildutil>: working directory is not part of a module
================
opsgenie Package
================
BUILD:
cd provider && go install -ldflags "-X <http://github.com/pulumi/pulumi-opsgenie/provider/pkg/version.Version=v0.0.1-alpha.1588074230+gca4ea26.dirty|github.com/pulumi/pulumi-opsgenie/provider/pkg/version.Version=v0.0.1-alpha.1588074230+gca4ea26.dirty>" <http://github.com/pulumi/pulumi-opsgenie/provider/cmd/pulumi-tfgen-opsgenie|github.com/pulumi/pulumi-opsgenie/provider/cmd/pulumi-tfgen-opsgenie>
pulumi-tfgen-opsgenie schema --out ./provider/cmd/pulumi-resource-opsgenie
/bin/bash: pulumi-tfgen-opsgenie: command not found
make: *** [generate_schema] Error 127
Any idea on what I might be doing wrong?
l
do you have a
go.mod
file in the
provider
directory?
g
I am following the directions in the pulumi-tf-provider-boilerplate readme. I did notice this package does not exist in the
provider/vendor
folder`github.com/pulumi/pulumi/sdk/v2/go/common/util/buildutil`. So that explains why when I run
make
it complains about not being able to find it.. but not sure why its not there. I've only dabbled in go, so i'm no expert on what might be happening there
This is what I see in the vendor folder for pulumi. I should see a
buildutil
folder in the
util
folder
b
@billowy-army-68599 can you help @gray-yak-9058 here?
b
sure! @gray-yak-9058 do you have this checked in anywhere I can have a look?
also, which version go are you using?
ah, I see the option, you need to add
$GOBIN
to your
GOPATH
b
I think that the opsgenie TF provider may not be upgraded to the sdk @billowy-army-68599
b
that's possible too, but currently this is failing to execute
pulumi-tfgen-opsgenie schema --out ./provider/cmd/pulumi-resource-opsgenie
it's doing a
go install
but can't resolve
@gray-yak-9058 can you double check by running
which pulumi-tfgen-opsgenie
g
I don't have this checked in anywhere. I have version 1.14.1 of go installed. I am getting
pulumi-tfgen-opsgenie not found
when running that command
b
so the
Makefile
is doing two things, first it's installing your tfgen command like so
Copy code
cd provider && go install -ldflags "-X <http://github.com/pulumi/pulumi-opsgenie/provider/pkg/version.Version=v0.0.1-alpha.1588074230+gca4ea26.dirty|github.com/pulumi/pulumi-opsgenie/provider/pkg/version.Version=v0.0.1-alpha.1588074230+gca4ea26.dirty>" <http://github.com/pulumi/pulumi-opsgenie/provider/cmd/pulumi-tfgen-opsgenie|github.com/pulumi/pulumi-opsgenie/provider/cmd/pulumi-tfgen-opsgenie>
this install the tfgen binary to
$GOPATH/bin
so you'll need to add this to
$PATH
, try doing
PATH=$PATH:$GOPATH/bin make
I'm on a call at the moment, but if you like I can get on a zoom with you in about an hour to help you through this
g
I think it worked, though it did blow up on the dotnet SDK as I have dotnet core 3.1 installed, but that's ok for now
I actually have a meeting I need to get ready for soon as well. I think my last question would be, what do I need to do on this step in the readme https://github.com/pulumi/pulumi-tf-provider-boilerplate#build-the-provider. It looks like the provider was built, but not seeing any opsgenie resources
I guess the question is, what do I need to do in
provider/resources.go
?
I think I see after reading through that file. I updated the
Resources
property to
Copy code
Resources: map[string]*tfbridge.ResourceInfo{
			"opsgenie_user": {Tok: makeResource(mainMod, "User")},
		},
and after running
make
again it looks like I have a
User
resource now
b
g
Awesome. Thanks for that. And thanks again for the help with getting the sdk's built @billowy-army-68599 @broad-dog-22463
b
we are looking to make this easier, so thanks for the feedback!
b
@gray-yak-9058 let us know if you need any more information or help!!
l
@billowy-army-68599 I think the template may be out of sync with the world after modules if the instructions include vendoring.
b
the instructions shouldn't, I do have a work item to get the docs up to speed
g
Hey @billowy-army-68599 @broad-dog-22463 sorry to revive an old thread, but I have another issue related to this now. I built the pulumi-opsgenie SDKs and pushed it up into my github repo (https://github.com/jacobscunn07/pulumi-opsgenie), but now when I attempt to use this provider I get an error
Copy code
➜ pulumi preview
Previewing update (dev):
     Type                          Name            Plan       Info
 +   pulumi:pulumi:Stack           my-project-dev  create
     └─ pulumi:providers:opsgenie  opsgenie                   1 error

Diagnostics:
  pulumi:providers:opsgenie (opsgenie):
    error: no resource plugin 'opsgenie' found in the workspace or on your $PATH
Doing a quick google and I came across this github issue, would this be the fix for me? If so, I guess I need to version my opsgenie provider 🤔 https://github.com/pulumi/pulumi/issues/2571
b
if you build this locally, it will go on your GOPATH
then Pulumi should find it if GOPATH is part of PATH
otherwise you will need to publish a version of the plugin and have pulumi install it
g
Ideally, I wouldn't be building the provider and running pulumi up together during CICD.. so it sounds like I need to version it
this is in my go.mod
Copy code
module my-project

go 1.13

require (
	<http://github.com/jacobscunn07/pulumi-opsgenie/sdk|github.com/jacobscunn07/pulumi-opsgenie/sdk> v0.0.0-20200505144548-ecdf0538b17f
	<http://github.com/pulumi/pulumi/sdk/v2|github.com/pulumi/pulumi/sdk/v2> v2.0.0
)
not sure how that version was found/named, but this isn't enough to get it going if there are no tags in github currently?
hmm I needed to run it like this
PATH=$PATH:$GOPATH/bin pulumi preview
and the preview completed without error. I'm still fairly new to golang, so not quite sure why
$GOPATH/bin
needs to be in
$PATH
b
yeah sorry this isn't a bit more documented - I promise we are looking at this atm 😕
g
Thanks for taking the time to respond so quickly and help me with this. Yeah, updating docs would definitely help! I was able to create an opsgenie user. It was the only resource I included to be converted as a quick test. I think I should be good to go now on including the other opsgenie resources and versioning the provider
b
We are also going to write docs on how to use Github Releases to host your plugin 🙂
and the required GitHub Actions to do it