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

Changes to support Go SDK #519

Merged
merged 11 commits into from
Jan 27, 2021
Merged

Changes to support Go SDK #519

merged 11 commits into from
Jan 27, 2021

Conversation

viveklak
Copy link
Contributor

@viveklak viveklak commented Jan 26, 2021

These changes are based on @justinvp's branch here: #457.

I have split things up to separate commits to ease review: https://github.com/pulumi/pulumi-eks/pull/519/commits

provider/cmd/pulumi-gen-eks/main.go Show resolved Hide resolved
examples/cluster-go/go.mod Outdated Show resolved Hide resolved
provider/cmd/pulumi-gen-eks/main.go Outdated Show resolved Hide resolved
Copy link
Member

@justinvp justinvp left a comment

Choose a reason for hiding this comment

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

LGTM otherwise

package main

import (
"github.com/pulumi/pulumi-eks/go/eks"
Copy link
Member

Choose a reason for hiding this comment

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

So, one thing I've been wondering...

All our other providers put the SDK files under <repo>/sdk, e.g.:

  • pulumi/pulumi-aws/sdk/dotnet
  • pulumi/pulumi-aws/sdk/go
  • pulumi/pulumi-aws/sdk/nodejs
  • pulumi/pulumi-aws/sdk/python

However, since this repo (eks) was originally only Node.js, it didn't have an sdk dir -- all the Node.js files were in a nodejs dir in the root fo the repo (pulumi/pulumi-eks/nodejs).

When I went to add Python and .NET, I contemplated moving the existing Node.js files under a new sdk dir, but ended up holding off and instead creating python and dotnet dirs in the root of the repo (with the idea that I'd eventually go back and clean this up). In hindsight, I probably should have just gone ahead and created the sdk dir and moved all the sdk files under it.

The structure of the repo doesn't matter much for using these language SDKs, but with Go, you're importing paths in the repo, and all our other repos put the go files under sdk.

I'm wondering if we should just go ahead and do that for the Go SDK now, before anyone has taken a dependency on the import path.

I think this means reworking the existing go.mod/sum in the root of the repo, something like:

  • Add sdk dir
  • Generate Go files under sdk/go.
  • Remove go.mod/sum in repo root.
  • Add go.mod/sum in sdk dir (with just dependencies needed for the SDK)
  • Add go.mod/sum under examples (with just dependencies needed to run the tests)
  • Move utils/utils.go to examples/utils/utils.go
  • Add go.mod/sum under provider (with just dependencies necessary for the provider and code generator program)

Ideally, we'd then also move the nodejs, python, and dotnet dirs under sdk, but we can do that later, as a separate change (will need to ensure all the paths are fixed up across the tests, GHA, etc.).

Copy link
Member

Choose a reason for hiding this comment

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

I agree that we should move Go at least to live in the sdk directory since codegen has that assumption baked in several places (e.g., the PkgVersion function regex).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. Will try this out and update the PR shortly.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated things as you recommended @justinvp. I haven't quite run the tests yet after the reorg but things build. Will look to add a simple starting go test integration test wrapper as well.

CHANGELOG.md Outdated Show resolved Hide resolved
provider/cmd/pulumi-gen-eks/main.go Outdated Show resolved Hide resolved
@justinvp justinvp mentioned this pull request Jan 26, 2021
2 tasks
@justinvp
Copy link
Member

RE: utils/testvpc/index.ts → examples/utils/testvpc/index.ts

Note the tests depend on the path to the testvpc. This will need to be updated:

// Test build of testvpc plugin.
testPluginDir := filepath.Join("..", "utils", "testvpc")
absTestPluginDir, err := filepath.Abs(testPluginDir)
if err != nil {
return "", err
}

And the Makefile:

pulumi-eks/Makefile

Lines 87 to 88 in a1031f9

test_build::
cd utils/testvpc && yarn install && yarn run tsc

Vivek Lakshmanan and others added 2 commits January 26, 2021 16:53
Co-authored-by: Justin Van Patten <jvp@justinvp.com>
Copy link
Contributor

@stack72 stack72 left a comment

Choose a reason for hiding this comment

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

Left some feedback about unnecessary package renames as well as the go tests not working in CI

@@ -13,7 +13,7 @@
// limitations under the License.
// +build dotnet all

package examples
Copy link
Contributor

Choose a reason for hiding this comment

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

This should stay as examples

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something I failed to revert after running into some go mod issues. Fixed now across the examples.

// limitations under the License.
// +build go all

package main
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be package examples

@@ -13,7 +13,7 @@
// limitations under the License.
// +build nodejs all

package examples
package main
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this changing?

@@ -13,7 +13,7 @@
// limitations under the License.
// +build python all

package examples
package main
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question as above

github.com/pulumi/pulumi/sdk/v2 v2.18.2
)

replace github.com/pulumi/pulumi-eks/sdk => ../../sdk
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm pretty sure this won't run in CI as it creates a temp GOPATH and it won't be able to traverse the ../../ notation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm pretty sure this won't run in CI as it creates a temp GOPATH and it won't be able to traverse the ../../ notation

The reason for this to exist currently is because we don't actually have github.com/pulumi/pulumi-eks/sdk - this change adds it. I added a TODO. I could also exclude the example and add it in a separate PR. Let me know if you have a strong preference either way.

Copy link
Member

Choose a reason for hiding this comment

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

TODO works for me. 👍

"aws:region": region,
},
Dependencies: []string{
"Pulumi.Eks",
Copy link
Contributor

Choose a reason for hiding this comment

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

This is specific to DotnEt

Copy link
Member

Choose a reason for hiding this comment

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

We'll need to fix this up, but we can do that when we hook up the test to CI, separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made the change but I expect to need to fiddle here as part of CI work.

Copy link
Member

@justinvp justinvp left a comment

Choose a reason for hiding this comment

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

LGTM

@viveklak viveklak merged commit 2129c31 into master Jan 27, 2021
@pulumi-bot pulumi-bot deleted the vl/SquashedMultilangGo branch January 27, 2021 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants