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

*: Bump module version to v2 #10608

Merged
merged 3 commits into from
Feb 11, 2025
Merged

Conversation

timflannagan
Copy link
Member

Description

Bump the go.mod module version to /v2 now that we agreed on a v2.x tagging convention. Unfortunately, Go is very strict about this scenario (despite an entirely new module name) when I tested this out locally:

$ mkdir kgateway-import-test && cd kgateway-import-test
$ cat > main.go << 'EOF'
package main

import (
    "fmt"
    _ "github.com/kgateway-dev/kgateway"
)

func main() {
    fmt.Println("Testing kgateway import")
}
EOF

$ go mod init example.com/kgateway-import-test
go: creating new go.mod: module example.com/kgateway-import-test
go: to add module requirements and sums:
	go mod tidy

$ # Attempt to get the module directly (this fails)
$ go get github.com/kgateway-dev/kgateway@v2.0.0-main
go: github.com/kgateway-dev/kgateway@v2.0.0-main: invalid version: module contains a go.mod file, so module path must match major version ("github.com/kgateway-dev/kgateway/v2")

# Attempt to tidy the module (this also fails)
$ go mod tidy
go: finding module for package github.com/kgateway-dev/kgateway
go: toolchain upgrade needed to resolve github.com/kgateway-dev/kgateway
go: github.com/kgateway-dev/kgateway@v1.17.16 requires go >= 1.22.7; switching to go1.22.12
go: finding module for package github.com/kgateway-dev/kgateway
go: found github.com/kgateway-dev/kgateway in github.com/kgateway-dev/kgateway v1.17.16
go: example.com/kgateway-import-test imports
	github.com/kgateway-dev/kgateway: github.com/kgateway-dev/kgateway@v1.17.16: parsing go.mod:
	module declares its path as: github.com/solo-io/gloo
	        but was required as: github.com/kgateway-dev/kgateway

Testing this using the following script:

cat scratch/update-imports.sh           
#!/bin/bash

set -e

# Find all .go files and update the import paths
find . -type f -name "*.go" -exec sed -i.bak 's|"github.com/kgateway-dev/kgateway/|"github.com/kgateway-dev/kgateway/v2/|g' {} \;
find . -name "*.bak" -type f -delete

# Update go.mod (already done, but just to be safe)
sed -i.bak 's|module github.com/kgateway-dev/kgateway$|module github.com/kgateway-dev/kgateway/v2|g' go.mod
rm -f go.mod.bak

# Run go mod tidy to clean up dependencies
go mod tidy%                                                                                                                                                

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Signed-off-by: timflannagan <timflannagan@gmail.com>
Signed-off-by: timflannagan <timflannagan@gmail.com>
Signed-off-by: timflannagan <timflannagan@gmail.com>
@jenshu jenshu added this pull request to the merge queue Feb 11, 2025
@timflannagan
Copy link
Member Author

Related to #10607. I'll close that issue out once I re-test locally.

Merged via the queue into kgateway-dev:main with commit ee7fa7b Feb 11, 2025
9 checks passed
@timflannagan timflannagan deleted the v2-modules branch February 11, 2025 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants