From 48ed3a4214df8c46c664ee0e39e35b4f2049a31c Mon Sep 17 00:00:00 2001 From: Dave Protasowski Date: Thu, 13 Apr 2023 15:09:51 -0400 Subject: [PATCH] fix go redirect (#5531) * fix redirect * clean up and ignore some repos --- golang/_redirects | 136 ++++++++++++++-------------- golang/actions-downstream-test.html | 4 - golang/actions-kind.html | 4 - golang/build-spike.html | 4 - golang/func-go.html | 4 +- golang/integration.html | 4 - golang/kn-plugin-source-pkg.html | 4 - golang/website.html | 4 - tools/redir-gen/main.go | 32 ++++++- 9 files changed, 97 insertions(+), 99 deletions(-) delete mode 100644 golang/actions-downstream-test.html delete mode 100644 golang/actions-kind.html delete mode 100644 golang/build-spike.html delete mode 100644 golang/integration.html delete mode 100644 golang/kn-plugin-source-pkg.html delete mode 100644 golang/website.html diff --git a/golang/_redirects b/golang/_redirects index e1e3f10e8..9c5c860a3 100755 --- a/golang/_redirects +++ b/golang/_redirects @@ -5,75 +5,73 @@ # # To regenerate, run: # go run ./tools/redir-gen/ -/actions/* go-get=1 /golang/actions.html 200 -/async-component/* go-get=1 /golang/async-component.html 200 -/caching/* go-get=1 /golang/caching.html 200 -/client/* go-get=1 /golang/client.html 200 -/client-pkg/* go-get=1 /golang/client-pkg.html 200 -/community/* go-get=1 /golang/community.html 200 -/container-freezer/* go-get=1 /golang/container-freezer.html 200 -/scaling-group/* go-get=1 /golang/scaling-group.html 200 -/control-protocol/* go-get=1 /golang/control-protocol.html 200 -/discovery/* go-get=1 /golang/discovery.html 200 -/docs/* go-get=1 /golang/docs.html 200 -/eventing/* go-get=1 /golang/eventing.html 200 -/eventing-autoscaler-keda/* go-get=1 /golang/eventing-autoscaler-keda.html 200 -/eventing-awssqs/* go-get=1 /golang/eventing-awssqs.html 200 -/eventing-ceph/* go-get=1 /golang/eventing-ceph.html 200 -/eventing-contrib/* go-get=1 /golang/eventing-contrib.html 200 -/eventing-couchdb/* go-get=1 /golang/eventing-couchdb.html 200 -/eventing-istio/* go-get=1 /golang/eventing-istio.html 200 -/eventing-github/* go-get=1 /golang/eventing-github.html 200 -/eventing-gitlab/* go-get=1 /golang/eventing-gitlab.html 200 -/eventing-kafka/* go-get=1 /golang/eventing-kafka.html 200 -/eventing-kafka-broker/* go-get=1 /golang/eventing-kafka-broker.html 200 -/eventing-kogito/* go-get=1 /golang/eventing-kogito.html 200 -/eventing-natss/* go-get=1 /golang/eventing-natss.html 200 -/eventing-prometheus/* go-get=1 /golang/eventing-prometheus.html 200 -/eventing-rabbitmq/* go-get=1 /golang/eventing-rabbitmq.html 200 -/eventing-redis/* go-get=1 /golang/eventing-redis.html 200 -/func/* go-get=1 /golang/func.html 200 -/func-tastic/* go-get=1 /golang/func-tastic.html 200 -/hack/* go-get=1 /golang/hack.html 200 -/homebrew-client/* go-get=1 /golang/homebrew-client.html 200 -/homebrew-kn-plugins/* go-get=1 /golang/homebrew-kn-plugins.html 200 -/infra/* go-get=1 /golang/infra.html 200 -/kn-plugin-admin/* go-get=1 /golang/kn-plugin-admin.html 200 -/kn-plugin-diag/* go-get=1 /golang/kn-plugin-diag.html 200 -/kn-plugin-event/* go-get=1 /golang/kn-plugin-event.html 200 -/kn-plugin-func/* go-get=1 /golang/kn-plugin-func.html 200 -/kn-plugin-migration/* go-get=1 /golang/kn-plugin-migration.html 200 -/kn-plugin-operator/* go-get=1 /golang/kn-plugin-operator.html 200 -/kn-plugin-quickstart/* go-get=1 /golang/kn-plugin-quickstart.html 200 -/kn-plugin-sample/* go-get=1 /golang/kn-plugin-sample.html 200 -/kn-plugin-service-log/* go-get=1 /golang/kn-plugin-service-log.html 200 -/kn-plugin-source-kafka/* go-get=1 /golang/kn-plugin-source-kafka.html 200 -/kn-plugin-source-kamelet/* go-get=1 /golang/kn-plugin-source-kamelet.html 200 -/kn-plugin-source-pkg/* go-get=1 /golang/kn-plugin-source-pkg.html 200 -/knobots/* go-get=1 /golang/knobots.html 200 -/kperf/* go-get=1 /golang/kperf.html 200 -/monitoring/* go-get=1 /golang/monitoring.html 200 -/net-certmanager/* go-get=1 /golang/net-certmanager.html 200 -/net-contour/* go-get=1 /golang/net-contour.html 200 -/net-gateway-api/* go-get=1 /golang/net-gateway-api.html 200 -/net-http01/* go-get=1 /golang/net-http01.html 200 -/net-istio/* go-get=1 /golang/net-istio.html 200 -/net-kourier/* go-get=1 /golang/net-kourier.html 200 -/networking/* go-get=1 /golang/networking.html 200 -/operator/* go-get=1 /golang/operator.html 200 -/pkg/* go-get=1 /golang/pkg.html 200 +/actions/* go-get=:go-get /golang/actions.html 200 +/async-component/* go-get=:go-get /golang/async-component.html 200 +/caching/* go-get=:go-get /golang/caching.html 200 +/client/* go-get=:go-get /golang/client.html 200 +/client-pkg/* go-get=:go-get /golang/client-pkg.html 200 +/community/* go-get=:go-get /golang/community.html 200 +/container-freezer/* go-get=:go-get /golang/container-freezer.html 200 +/control-protocol/* go-get=:go-get /golang/control-protocol.html 200 +/discovery/* go-get=:go-get /golang/discovery.html 200 +/docs/* go-get=:go-get /golang/docs.html 200 +/eventing/* go-get=:go-get /golang/eventing.html 200 +/eventing-autoscaler-keda/* go-get=:go-get /golang/eventing-autoscaler-keda.html 200 +/eventing-awssqs/* go-get=:go-get /golang/eventing-awssqs.html 200 +/eventing-ceph/* go-get=:go-get /golang/eventing-ceph.html 200 +/eventing-contrib/* go-get=:go-get /golang/eventing-contrib.html 200 +/eventing-couchdb/* go-get=:go-get /golang/eventing-couchdb.html 200 +/eventing-github/* go-get=:go-get /golang/eventing-github.html 200 +/eventing-gitlab/* go-get=:go-get /golang/eventing-gitlab.html 200 +/eventing-istio/* go-get=:go-get /golang/eventing-istio.html 200 +/eventing-kafka/* go-get=:go-get /golang/eventing-kafka.html 200 +/eventing-kafka-broker/* go-get=:go-get /golang/eventing-kafka-broker.html 200 +/eventing-kogito/* go-get=:go-get /golang/eventing-kogito.html 200 +/eventing-natss/* go-get=:go-get /golang/eventing-natss.html 200 +/eventing-prometheus/* go-get=:go-get /golang/eventing-prometheus.html 200 +/eventing-rabbitmq/* go-get=:go-get /golang/eventing-rabbitmq.html 200 +/eventing-redis/* go-get=:go-get /golang/eventing-redis.html 200 +/func/* go-get=:go-get /golang/func.html 200 +/func-go/* go-get=:go-get /golang/func-go.html 200 +/func-tastic/* go-get=:go-get /golang/func-tastic.html 200 +/hack/* go-get=:go-get /golang/hack.html 200 +/homebrew-client/* go-get=:go-get /golang/homebrew-client.html 200 +/homebrew-kn-plugins/* go-get=:go-get /golang/homebrew-kn-plugins.html 200 +/infra/* go-get=:go-get /golang/infra.html 200 +/kn-plugin-admin/* go-get=:go-get /golang/kn-plugin-admin.html 200 +/kn-plugin-diag/* go-get=:go-get /golang/kn-plugin-diag.html 200 +/kn-plugin-event/* go-get=:go-get /golang/kn-plugin-event.html 200 +/kn-plugin-migration/* go-get=:go-get /golang/kn-plugin-migration.html 200 +/kn-plugin-operator/* go-get=:go-get /golang/kn-plugin-operator.html 200 +/kn-plugin-quickstart/* go-get=:go-get /golang/kn-plugin-quickstart.html 200 +/kn-plugin-sample/* go-get=:go-get /golang/kn-plugin-sample.html 200 +/kn-plugin-service-log/* go-get=:go-get /golang/kn-plugin-service-log.html 200 +/kn-plugin-source-kafka/* go-get=:go-get /golang/kn-plugin-source-kafka.html 200 +/kn-plugin-source-kamelet/* go-get=:go-get /golang/kn-plugin-source-kamelet.html 200 +/knobots/* go-get=:go-get /golang/knobots.html 200 +/kperf/* go-get=:go-get /golang/kperf.html 200 +/monitoring/* go-get=:go-get /golang/monitoring.html 200 +/net-certmanager/* go-get=:go-get /golang/net-certmanager.html 200 +/net-contour/* go-get=:go-get /golang/net-contour.html 200 +/net-gateway-api/* go-get=:go-get /golang/net-gateway-api.html 200 +/net-http01/* go-get=:go-get /golang/net-http01.html 200 +/net-istio/* go-get=:go-get /golang/net-istio.html 200 +/net-kourier/* go-get=:go-get /golang/net-kourier.html 200 +/networking/* go-get=:go-get /golang/networking.html 200 +/operator/* go-get=:go-get /golang/operator.html 200 +/pkg/* go-get=:go-get /golang/pkg.html 200 /pkg/* https://pkg.go.dev/knative.dev/pkg/:splat -/reconciler-test/* go-get=1 /golang/reconciler-test.html 200 -/release/* go-get=1 /golang/release.html 200 -/runtime/* go-get=1 /golang/func-go.html 200 -/sample-controller/* go-get=1 /golang/sample-controller.html 200 -/sample-source/* go-get=1 /golang/sample-source.html 200 -/security-guard/* go-get=1 /golang/security-guard.html 200 +/reconciler-test/* go-get=:go-get /golang/reconciler-test.html 200 +/release/* go-get=:go-get /golang/release.html 200 +/sample-controller/* go-get=:go-get /golang/sample-controller.html 200 +/sample-source/* go-get=:go-get /golang/sample-source.html 200 +/scaling-group/* go-get=:go-get /golang/scaling-group.html 200 +/security-guard/* go-get=:go-get /golang/security-guard.html 200 /security-guard/* https://pkg.go.dev/knative.dev/security-guard/:splat -/serving/* go-get=1 /golang/serving.html 200 +/serving/* go-get=:go-get /golang/serving.html 200 /serving/* https://pkg.go.dev/knative.dev/serving/:splat -/specs/* go-get=1 /golang/specs.html 200 -/test-infra/* go-get=1 /golang/test-infra.html 200 -/toolbox/* go-get=1 /golang/toolbox.html 200 -/ux/* go-get=1 /golang/ux.html 200 -/wg-repository/* go-get=1 /golang/wg-repository.html 200 +/specs/* go-get=:go-get /golang/specs.html 200 +/test-infra/* go-get=:go-get /golang/test-infra.html 200 +/toolbox/* go-get=:go-get /golang/toolbox.html 200 +/ux/* go-get=:go-get /golang/ux.html 200 +/wg-repository/* go-get=:go-get /golang/wg-repository.html 200 diff --git a/golang/actions-downstream-test.html b/golang/actions-downstream-test.html deleted file mode 100644 index 967e1a0e7..000000000 --- a/golang/actions-downstream-test.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/golang/actions-kind.html b/golang/actions-kind.html deleted file mode 100644 index af9f2fa49..000000000 --- a/golang/actions-kind.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/golang/build-spike.html b/golang/build-spike.html deleted file mode 100644 index 5a12e71dd..000000000 --- a/golang/build-spike.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/golang/func-go.html b/golang/func-go.html index 851444011..34d2bd44f 100644 --- a/golang/func-go.html +++ b/golang/func-go.html @@ -1,4 +1,4 @@ - - + + diff --git a/golang/integration.html b/golang/integration.html deleted file mode 100644 index 06cedf4b8..000000000 --- a/golang/integration.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/golang/kn-plugin-source-pkg.html b/golang/kn-plugin-source-pkg.html deleted file mode 100644 index dbb50c02c..000000000 --- a/golang/kn-plugin-source-pkg.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/golang/website.html b/golang/website.html deleted file mode 100644 index e09ba44df..000000000 --- a/golang/website.html +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/tools/redir-gen/main.go b/tools/redir-gen/main.go index 324cc615d..87956dc16 100644 --- a/tools/redir-gen/main.go +++ b/tools/redir-gen/main.go @@ -29,11 +29,23 @@ var ( knativeOrgs = []string{"knative", "knative-sandbox"} allowedRepoRe = regexp.MustCompile("^[a-z][-a-z0-9]+$") archivedExceptions = []string{"eventing-contrib"} + ignoreRepos = []string{ + "actions", + "community", + "docs", + "knobots", + "monitoring", + "release", + } // Repos known to contain Go libraries, so that requesting // https://knative.dev/ in a browser should redirect to // https://pkg.go.dev/knative.dev/ redirectingGoRepos = []string{"pkg", "serving", "security-guard"} + + repoToModule = map[string]string{ + "func-go": "runtime", + } ) // repoInfo provides a simple holder for GitHub repo information needed to @@ -44,6 +56,11 @@ type repoInfo struct { // Repo is the name of the github repo within the organizatiøon (e.g. // "serving", NOT "knative/serving") Repo string + + // Module is the name of the github repo within the organizatiøon (e.g. + // "serving", NOT "knative/serving") + Module string + // DefaultBranch is the name of the default branch. This will be changing // from "master" to "main" over time. DefaultBranch string @@ -88,7 +105,14 @@ func fetchRepos(orgs []string) ([]repoInfo, error) { log.Print("Ignoring archived repo: ", *r.Name) continue } - allRepos = append(allRepos, repoInfo{org, *r.Name, *r.DefaultBranch}) + repo := repoInfo{Org: org, Repo: *r.Name, DefaultBranch: *r.DefaultBranch} + + if override, ok := repoToModule[repo.Repo]; ok { + repo.Module = override + } else { + repo.Module = repo.Repo + } + allRepos = append(allRepos, repo) } if resp.NextPage == 0 { break @@ -101,11 +125,11 @@ func fetchRepos(orgs []string) ([]repoInfo, error) { const ( goHTML = ` - - + + ` - redirText = `/{{.Repo}}/* go-get=1 /golang/{{.Repo}}.html 200 + redirText = `/{{.Repo}}/* go-get=:go-get /golang/{{.Repo}}.html 200 ` godocRedirText = `/{{.Repo}}/* https://pkg.go.dev/knative.dev/{{.Repo}}/:splat `