gravitational/teleport-plugins

Add a `go.mod` for the terraform provider

jaxxstorm opened this issue · 4 comments

I would like to bridge the terraform provider into a pulumi provider, but that's not currently possible without a go.mod

Would you folks be able to add a go.mod so I can reference it :)

We do have a go.mod in the project's root
Do you need it to be within the terraform folder?

The go.mod currently isn't usable for a few reasons:

  • you're on v10 of the plugins but not updating the go.mod for a major version:
go get github.com/gravitational/teleport-plugins@v10.1.4
go: github.com/gravitational/teleport-plugins@v10.1.4: invalid version: module contains a go.mod file, so module path must match major version ("github.com/gravitational/teleport-plugins/v10")

Trying to pull the version by commit throws an error due to the java apps in the repo:

go get github.com/gravitational/teleport-plugins@5c50e63fa42233f4e2abe5b168c339cccc6a0ba5
go: downloading github.com/gravitational/teleport-plugins v0.0.0-20220812065221-5c50e63fa422
go: github.com/gravitational/teleport-plugins@5c50e63fa42233f4e2abe5b168c339cccc6a0ba5: create zip: apps/example-tomcat-jwt/eclipseproject/sampleaap/WebContent/img/genericperson.png:Zone.Identifier:$DATA: malformed file path "apps/example-tomcat-jwt/eclipseproject/sampleaap/WebContent/img/genericperson.png:Zone.Identifier:$DATA": invalid char ':

Hi @jaxxstorm, we've merged plugins into the main Teleport repo, and this file is now available here.

Unfortunately this does not solve the issue. I did some testing and it looks like we cannot fix this without a large restructuring due to the following Go issues:

  • golang/go#35732 - prevents go get github.com/gravitational/teleport/integrations/terraform@<version> from working
  • golang/go#30354 - prevents go get github.com/gravitational/teleport/integrations/terraform@<commit> from working

My best recommendation is that you clone the Teleport repo (as this codebase has been merged there), then use a replace directive in your go.mod to point to the Terraform module. We do something similar for building the plugin binaries as shown here.

This isn't ideal, but I don't see another way around it without a Golang fix, or a major change to how we build and version plugins.

You don't need to clone the whole teleport repo, just create equivalent replace to the ones we have in the terraform module. For the replace teleport ../ and teleport/api ../api you can refer to the git object instead of the local files.

I will close this issue as we now have a go module for the Terraform provider. Including it is not as simple as doing a go get, but this is feasible now.