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

go get explicit versions to avoid ambiguous imports #305

Merged
merged 1 commit into from
Jan 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions artifacts/scripts/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ update-deps-in-gomod() {
[ -s go.sum ] && rm go.sum

GO111MODULE=on GOPRIVATE="${dep_packages}" GOPROXY=https://proxy.golang.org go mod download
fixAmbiguousImports
GOPROXY="file://${GOPATH}/pkg/mod/cache/download,https://proxy.golang.org" GO111MODULE=on GOPRIVATE="${dep_packages}" go mod tidy

git add go.mod go.sum
Expand All @@ -853,6 +854,13 @@ update-deps-in-gomod() {
ensure-clean-working-dir
}

function fixAmbiguousImports() {
# ref: https://github.com/kubernetes/publishing-bot/issues/304
# TODO(nikhita): remove this when k/k drops or bumps
# cloud.google.com/go to a version > v0.105.0
go get cloud.google.com/[email protected]
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I'm not sure we should do this… doesn't this change the versions the module is requiring?

Copy link
Member Author

Choose a reason for hiding this comment

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

doesn't this change the versions the module is requiring

Yes, but it ends up being a no-op for repos (e.g kube-aggregator) that don't need to require cloud.google.com/go because go mod tidy will remove it from go.mod.

For repos that already require it (e.g. apiserver), they are already at v0.97.0 so it ends up being a no-op again.

Copy link
Member

Choose a reason for hiding this comment

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

This still seems like something that shouldn't happen at this level, and will get stale or force the wrong version eventually on some branch

Copy link
Member

@skitt skitt Jan 5, 2023

Choose a reason for hiding this comment

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

At least it could check that the current go.mod pulls in cloud.google.com/go, in a version older than v0.105.0 (if any); something like

if [ "$((go list -m -json cloud.google.com/go | jq -r '.Version'; echo v0.105.0) | sort -V | head -n 1)" != v0.105.0 ]; then

Or just re-get the currently-required version:

if [ -n "$(go list -m cloud.google.com/go)" ]; then go get "cloud.google.com/go@$(go list -m -json cloud.google.com/go | jq -r '.Version')"; fi

}

gomod-pseudo-version() {
TZ=GMT git show -q --pretty='format:v0.0.0-%cd-%h' --date='format-local:%Y%m%d%H%M%S' --abbrev=12
}
Expand Down