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

feat: add experimental support for Go #686

Merged
merged 46 commits into from
May 26, 2021
Merged

feat: add experimental support for Go #686

merged 46 commits into from
May 26, 2021

Conversation

ansgarm
Copy link
Member

@ansgarm ansgarm commented May 5, 2021

This PR is going to add language support for Go 🎉 (It will resolve #368)

Open Tasks

  • add Go to supported languages for provider generation
  • configure naming for generated provider packages (Current test uses e.g. hashicorprandom/hashicorprandom which feels too verbose)
  • add example for Go
  • update jsii-srcmak to a version which supports Go (waiting on upstream PR feat: support for golang cdklabs/jsii-srcmak#476)
  • publish cdktf library for Go
  • add template for Go projects
  • Fix generating provider bindings for hashicorp/aws@~> 3.39.0 (out of memory error gist)
  • Add package.json to AWS example as soon as OOM error is fixed
  • Add a note to docs about AWS Go provider generation needing lots of memory
  • add getting started guide for Go
  • add integration tests in Go (check cases for Java/CSharp/Python for inspiration)
  • add unit tests for Go related code
  • Adjust example to new import paths
  • Support generating Go bindings for Terraform Modules
  • make cdktf get print instructions on which version of jsii-runtime was used and should be included in the root go.mod on which go command to run to let go generate required jsii-runtime import
  • Add follow-up issue to publish prebuilt providers in Go as well

@ansgarm ansgarm added this to the v0.4 milestone May 5, 2021
@ansgarm ansgarm self-assigned this May 5, 2021
@ansgarm
Copy link
Member Author

ansgarm commented May 21, 2021

Hey @skorfmann @DanielMSchmidt 👋
Could you add a preliminary review of this PR so I could address it in the next days while working on all the tests and documentation?
I'd be happy already with a superficial skim of the changes and some comments on them 😁

And if you want to try this locally:

git checkout support-golang
yarn build && yarn package
cd some/test/dir
# adjust to your env
/Users/ansgar/projects/hashicorp/terraform-cdk/packages/cdktf-cli/bin/cdktf --dist ../../hashicorp/terraform-cdk/dist init --local --template go

I still have to adjust the imports in the examples, but you can use them as a quick reference of how to work with the cdktf constructs in Go: https://github.com/hashicorp/terraform-cdk/blob/support-golang/examples/go/docker/main.go

Copy link
Contributor

@skorfmann skorfmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, left a few comments.

Is this https://github.com/hashicorp/terraform-cdk-go already pushed from this PR? What I'm wondering is, if we could start building a sample prebuilt provider for this. I'd be keen to see how. that works out.

Dockerfile Outdated Show resolved Hide resolved
docs/getting-started/go.md Outdated Show resolved Hide resolved
examples/go/aws/go.mod Outdated Show resolved Hide resolved
examples/go/docker/cdktf.json Show resolved Hide resolved
packages/cdktf-cli/package.json Outdated Show resolved Hide resolved
packages/cdktf-cli/lib/get/constructs-maker.ts Outdated Show resolved Hide resolved
@ansgarm
Copy link
Member Author

ansgarm commented May 21, 2021

@skorfmann

Is this https://github.com/hashicorp/terraform-cdk-go already pushed from this PR?

I pushed it manually based on this PR, yep.

What I'm wondering is, if we could start building a sample prebuilt provider for this. I'd be keen to see how. that works out.

I'm going to create a follow up issue for the prebuilt providers for Go as it is not in scope for this PR. But if you want to, feel free to experiment with that already.

docs/getting-started/go.md Outdated Show resolved Hide resolved
packages/cdktf-cli/lib/get/constructs-maker.ts Outdated Show resolved Hide resolved
@jsteinich jsteinich mentioned this pull request May 21, 2021
Copy link
Contributor

@skorfmann skorfmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good and works as expected. Was able to build and synth the aws example. The cdktf init works flawless as well 👍

Building the AWS provider took roughly 10 minutes and peaked at 6.7 GB of memory consumption. I think we should create an issue in jsii to track this. After merging this, we should also look into adding Go to the pre-built providers.

packages/cdktf-cli/lib/get/constructs-maker.ts Outdated Show resolved Hide resolved
…ady.

Print a warning if the present value does not contain --max-old-space-size
@ansgarm ansgarm marked this pull request as ready for review May 26, 2021 08:14
Copy link
Contributor

@skorfmann skorfmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - great work 🚀

@skorfmann
Copy link
Contributor

Ah, and please adjust the title for a semantic commit

@ansgarm ansgarm changed the title Add support for Golang feat: add experimental support for Go May 26, 2021
@ansgarm ansgarm merged commit 23affc8 into main May 26, 2021
@ansgarm ansgarm deleted the support-golang branch May 26, 2021 08:59
@github-actions
Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Go language support
4 participants