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
Go Modules #4109
Go Modules #4109
Conversation
Not sure why this is only appearing now, but I was seeing failures related to how we parse python versions. Ther version on my local machine was showing up as
I've updated our versioning to include a PEP440 is pretty loose with requirements, and it looks like this falls within them: https://www.python.org/dev/peps/pep-0440/ |
so in the last two commits I did two things:
|
Un update on #4109 (comment) (python versioning) I noticed that other repos distinguish between It looks like this change never made it into pulumi/pulumi. I've reverted the change to the python versioning code, and updated the makefile to use VERSION and PYPI_VERSION appropriately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit and a question. Happy to address these in followup, though.
@@ -62,9 +62,13 @@ build_script: | |||
- cmd: >- | |||
set GO111MODULE=on | |||
|
|||
go mod tidy | |||
pushd . && cd sdk && go mod tidy && go mod vendor && popd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pushd . && cd sdk && go mod tidy && go mod vendor && popd | |
pushd sdk && go mod tidy && go mod vendor && popd |
Same below, and in .github/workflows/windows-build.yml
.
$(call STEP_MESSAGE) | ||
ifeq ($(NOPROXY), true) | ||
@echo "cd sdk && GO111MODULE=on go mod tidy"; cd sdk && GO111MODULE=on go mod tidy | ||
@echo "cd sdk && GO111MODULE=on go mod vendor"; cd sdk && GO111MODULE=on go mod vendor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we were switching to go mod download
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this with go mod download
and got errors. I'll give this another try and open up a follow up PR.
This PR enables four go modules at
/pkg
/sdk
/tests
and/examples
. The end goal is to enable users to use go modules when developing pulumi programs with the go sdk.The general strategy is as follows:
/cmd
->/pkg/cmd
/pkg
and/sdk
into/sdk/go/common
/pkg
/sdk
/tests
and/examples
./sdk/proto
where it was, and keeping the language hosts where they are (more on that below).Based on feedback from my first attempt at #4089, I tried to move the language hosts (pulumi-language-*) out of the SDKs, but noticed that they only brought a single dependency with them (github.com/Microsoft/go-winio v0.4.14`), so I wound up reverting that change and leaving them as is to reduce the churn on our make/build system.
The biggest delta between this set, and this one from @jen20 #4049, is that this change doesn't duplicate code from pkg. The best example to illustrate this is probably the shared marshalling code. In this changeset,
pkg/resource/plugin
is moved intocommon
and in the one from James it is copied wholesale:copied version of
pkg/resource/plugin
: https://github.com/pulumi/pulumi/blob/a1ccbb17eac288be5f07d52f8c76f60d47b3ea8f/sdk/go/pulumi/resource/marshal.goused here via
resource.Marshal
rather thanplugin.Marshal
: https://github.com/pulumi/pulumi/blob/a1ccbb17eac288be5f07d52f8c76f60d47b3ea8f/sdk/go/pulumi/context.goI did end up accidently bringing in some unnecessary code under the common package during my first attempt, and was able to eliminate it during this pass (
deploy
). The new set of dependencies isn't much smaller in the SDK go.mod (33 prev vs 31 for this iteration):If we'd like to reduce this set, we'll have to duplicate some of the shared code to trim the set of dependencies. Given that we've removed the biggest culprits (cloud sdks, terraform deps) I'm inclined to ship this as is and resort to further duplication if we see that this dependency set is untenable based on user feedback.
Notable Changes:
There were a couple of things with our build and engineering system that required rework due to moving towards modules:
glog -> klog
: glog usesfunc init()
to parse flags. This causes a panic if the module is imported twice. Now that we have four different modules, we vendor into four folders and have the potential for this init to be called multiple times. To avoid this we moved to klog which is actively maintained by the kubernetes community and has worked around some of these issues. klog requires explicitly calling an explicit init function to parse command line args. I have updated our logging implementation to do this and verified that it works, but it currently has the restriction that theInitLogging
function can only be called once. This wasn't previously the case, but nowhere in the code other than tests do we exercise this path. I added this issue to keep track of this: Reenable multiple calls to InitLogging #4121 4e44854 31d8f79 a2b3688 163444bVERSION
that is semver compatible to mint the plugin and aPYPI_VERSION
that is used for releasing the python SDK. Go Modules #4109 (comment) 5e1f597version
package in both/sdk
and/pkg
. This is trivial code, so it shouldn't be a burden or cause future problems. I'm not sure why, but when I shared the package, the versions wouldn't get linked in properly, even though the makefile had been appropriately updated. I have a feeling that this has to do with that code being vendored causing some issue with the linking. 1fec569