Skip to content

k8s.io: Redirect common Go package URLs to pkg.go.dev #3130

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions apps/k8s-io/configmap-nginx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ data:
';
}

# Redirect go import paths to Go package documentation.
if ($repo ~ "api|apimachinery|client-go") {
return 302 https://pkg.go.dev/k8s.io/$repo/$subpath;
}

# Default to redirecting to the "real" site.
return 301 https://kubernetes.io$request_uri;
}
Expand Down
13 changes: 13 additions & 0 deletions apps/k8s-io/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,19 @@ def test_protocol_upgrade(self):
'http://' + url + path,
'https://' + url + path, 301)

def test_godoc_redirect(self):
self.assert_scheme_redirect(
'http://k8s.io/kubernetes',
'https://k8s.io/kubernetes', 301)
for repo in ('api', 'apimachinery', 'client-go'):
self.assert_scheme_redirect(
'https://k8s.io/%s' % repo,
'https://pkg.go.dev/k8s.io/%s' % repo, 301)
# Sub-paths also work.
self.assert_scheme_redirect(
'https://k8s.io/api/core/v1',
'https://pkg.go.dev/k8s.io/api/core/v1', 301)

def test_go_get(self):
self.assert_scheme_redirect(
'http://k8s.io/kubernetes?go-get=1',
Expand Down