-
Notifications
You must be signed in to change notification settings - Fork 68
Conversation
Signed-off-by: Aditya Sharma <[email protected]>
@@ -30,10 +30,6 @@ GO_SUBDIRS ?= cmd pkg | |||
# Optional. Additional subdirs used for integration or e2e testings | |||
GO_INTEGRATION_TESTS_SUBDIRS ?= | |||
|
|||
# Optional directories (relative to CURDIR) | |||
GO_VENDOR_DIR ?= 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.
We don't vendor if GO111MODULE is on. GO111MODULE
is set to on
automatically if there is a go.mod
file since Go 1.16: https://go.dev/blog/go116-module-changes
DEP_VERSION=v0.5.1 | ||
DEP := $(TOOLS_HOST_DIR)/dep-$(DEP_VERSION) |
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.
DEP was deprecated long ago (Go 1.13 iirc)
@@ -30,10 +30,6 @@ GO_SUBDIRS ?= cmd pkg | |||
# Optional. Additional subdirs used for integration or e2e testings | |||
GO_INTEGRATION_TESTS_SUBDIRS ?= | |||
|
|||
# Optional directories (relative to CURDIR) | |||
GO_VENDOR_DIR ?= vendor | |||
GO_PKG_DIR ?= $(WORK_DIR)/pkg |
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.
Use the default/system global $GOPATH/pkg
directory, this helps go mod cache ($GOPATH/pkg/mod
) reuse between different repos.
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.
Not to mention having $(WORK_DIR)/pkg
messes up with vscode + gopls when it sees several thousand files.
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 think I'm mostly concerned about this part of the changes. I agree with the cache reuse aspect; however I want to dig into why the mod cache was placed in the directories to get that context.
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.
however I want to dig into why the mod cache was placed in the directories to get that context
To tie a bow on this, it looks like this behavior was introduced during the introduction to using Go modules here #74. Most likely this was done for two reasons:
- we were still supporting dep at that time
- it wasn't entirely clear how to work with go modules yet
With that context, I'm comfortable moving forward with this changeset.
# NOTE: the install suffixes are matched with the build container to speed up the | ||
# the build. Please keep them in sync. | ||
|
||
ifneq ($(GO_PKG_DIR),) | ||
GO_PKG_BASE_DIR := $(abspath $(GO_PKG_DIR)/$(PLATFORM)) | ||
GO_PKG_STATIC_FLAGS := -pkgdir $(GO_PKG_BASE_DIR)_static | ||
endif | ||
|
||
GO_COMMON_FLAGS = $(GO_BUILDFLAGS) -tags '$(GO_TAGS)' | ||
GO_STATIC_FLAGS = $(GO_COMMON_FLAGS) $(GO_PKG_STATIC_FLAGS) -installsuffix static -ldflags '$(GO_LDFLAGS)' |
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.
Use default/system global $GOPATH/pkg directory, helps with reuse across multiple repos
|
||
GO_COMMON_FLAGS = $(GO_BUILDFLAGS) -tags '$(GO_TAGS)' | ||
GO_STATIC_FLAGS = $(GO_COMMON_FLAGS) $(GO_PKG_STATIC_FLAGS) -installsuffix static -ldflags '$(GO_LDFLAGS)' | ||
GO_COMMON_FLAGS = $(GO_BUILDFLAGS) -tags '$(GO_TAGS)' -trimpath |
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.
Add -trimpath
to Go invocations:
-trimpath
remove all file system paths from the resulting executable.
Instead of absolute file system paths, the recorded file names
will begin either a module path@version (when using modules),
or a plain import path (when using the standard library, or GOPATH).
Signed-off-by: Aditya Sharma <[email protected]>
@@ -70,7 +70,7 @@ export BUILD_IMAGE_ARCHS=$(subst linux_,,$(filter linux_%,$(BUILD_PLATFORMS))) | |||
export TARGETARCH | |||
|
|||
# Install gomplate | |||
GOMPLATE_VERSION := 3.7.0 | |||
GOMPLATE_VERSION := 3.11.1 |
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.
Missed this in one of the older PRs
Signed-off-by: Aditya Sharma <[email protected]>
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.
Nice clean up @epk! Have a few comments below.
Also, I see that you tested this against managed-control-planes and shimmer. Could you also test this against:
- crossplane/crossplane
- upbound/official-providers
If we merge this and something breaks I'm ok with our repos being broken. However I'd like to be extra cautious about those that impact our external consumers (crossplane/crossplane) as well as the the providers use case with upbound/official-providers.
@@ -18,7 +18,7 @@ | |||
# Optional. The Go Binary to use | |||
GO ?= go | |||
|
|||
# Optional. Minimum Go version. | |||
# Optional. Required Go version. |
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.
Is it really the 'Required' version? What about if someone is using 1.19, etc (once those are released)?
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.
GO_REQUIRED_VERSION=1.19 make ...
:D
I just changed the comment and error message because I was not really checking for GO_VERSION < GO_REQUIRED_VERSION
but rather GO_REQUIRED_VERSION == GO_VERSION
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 just changed the comment and error message because I was not really checking for GO_VERSION < GO_REQUIRED_VERSION but rather GO_REQUIRED_VERSION == GO_VERSION
Gotcha. What're your thoughts on changing the check to this?:
GO_REQUIRED_VERSION <= GO_VERSION
That way we don't have to update the build submodule each time we upgrade our go version.
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.
GO_REQUIRED_VERSION
can be set per project: https://github.com/upbound/distro/blob/main/Makefile#L65
So we can change Go versions without needing to change the submodule.
Signed-off-by: Aditya Sharma <[email protected]>
Signed-off-by: Aditya Sharma <[email protected]>
crossplane/crossplane:
|
Signed-off-by: Aditya Sharma <[email protected]>
Tested |
Signed-off-by: Chuan-Yen Chiang <[email protected]>
Signed-off-by: Chuan-Yen Chiang <[email protected]>
Signed-off-by: Chuan-Yen Chiang <[email protected]>
Signed-off-by: Chuan-Yen Chiang <[email protected]> Signed-off-by: Chuan-Yen Chiang <[email protected]>
Signed-off-by: Aditya Sharma [email protected]
Description of your changes
Cleans up some of the stuff in the Go build module that is no longer relevant. Inline comments follow
I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR, as appropriate.How has this code been tested
Tested all
go
targets withmanaged-control-plane
andshimmer