Skip to content

Commit 8cdf1e6

Browse files
committed
Redirect common Go package URLs to pkg.go.dev
Signed-off-by: Jason Hall <jasonhall@redhat.com>
1 parent 931f2c7 commit 8cdf1e6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

apps/k8s-io/configmap-nginx.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ data:
5454
';
5555
}
5656
57+
# Redirect go import paths to Go package documentation.
58+
if ($repo ~ "api|apimachinery|client-go|kubernetes") {
59+
return 301 https://pkg.go.dev/k8s.io/$repo/$subpath;
60+
}
61+
5762
# Default to redirecting to the "real" site.
5863
return 301 https://kubernetes.io$request_uri;
5964
}

apps/k8s-io/test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@ def test_protocol_upgrade(self):
149149
'http://' + url + path,
150150
'https://' + url + path, 301)
151151

152+
def test_godoc_redirect(self):
153+
self.assert_scheme_redirect(
154+
'http://k8s.io/kubernetes',
155+
'https://k8s.io/kubernetes', 301)
156+
for repo in ('api', 'apimachinery', 'client-go', 'kubernetes'):
157+
self.assert_scheme_redirect(
158+
'https://k8s.io/%s' % repo,
159+
'https://pkg.go.dev/k8s.io/%s' % repo, 301)
160+
# Sub-paths also work.
161+
self.assert_scheme_redirect(
162+
'https://k8s.io/api/core/v1',
163+
'https://pkg.go.dev/k8s.io/api/core/v1', 301)
164+
152165
def test_go_get(self):
153166
self.assert_scheme_redirect(
154167
'http://k8s.io/kubernetes?go-get=1',

0 commit comments

Comments
 (0)