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

fix go redirect #5531

Merged
merged 2 commits into from
Apr 13, 2023
Merged
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
136 changes: 67 additions & 69 deletions golang/_redirects
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

should we delete this one since we're archiving the repo whenever I remember to actually do it?

Copy link
Member Author

Choose a reason for hiding this comment

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

When you archive the repo - we can regenerate this config that will remove it.

Copy link
Member Author

Choose a reason for hiding this comment

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

the tool (tools/redir-gen) ignores archived repos

/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
4 changes: 0 additions & 4 deletions golang/actions-downstream-test.html

This file was deleted.

4 changes: 0 additions & 4 deletions golang/actions-kind.html

This file was deleted.

4 changes: 0 additions & 4 deletions golang/build-spike.html

This file was deleted.

4 changes: 2 additions & 2 deletions golang/func-go.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<html><head>
<meta name="go-import" content="knative.dev/runtime git https://github.com/knative-sandbox/func-go">
<meta name="go-source" content="knative.dev/runtime https://github.com/knative-sandbox/func-go https://github.com/knative-sandbox/func-go/tree/main{/dir} https://github.com/knative-sandbox/func-go/blob/main{/dir}/{file}#L{line}">
<meta name="go-import" content="knative.dev/runtime git https://github.com/knative-sandbox/func-go">
<meta name="go-source" content="knative.dev/runtime https://github.com/knative-sandbox/func-go https://github.com/knative-sandbox/func-go/tree/main{/dir} https://github.com/knative-sandbox/func-go/blob/main{/dir}/{file}#L{line}">
</head></html>
4 changes: 0 additions & 4 deletions golang/integration.html

This file was deleted.

4 changes: 0 additions & 4 deletions golang/kn-plugin-source-pkg.html

This file was deleted.

4 changes: 0 additions & 4 deletions golang/website.html

This file was deleted.

32 changes: 28 additions & 4 deletions tools/redir-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/<repo> in a browser should redirect to
// https://pkg.go.dev/knative.dev/<repo>
redirectingGoRepos = []string{"pkg", "serving", "security-guard"}

repoToModule = map[string]string{
"func-go": "runtime",
}
)

// repoInfo provides a simple holder for GitHub repo information needed to
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -101,11 +125,11 @@ func fetchRepos(orgs []string) ([]repoInfo, error) {

const (
goHTML = `<html><head>
<meta name="go-import" content="knative.dev/{{.Repo}} git https://github.com/{{.Org}}/{{.Repo}}">
<meta name="go-source" content="knative.dev/{{.Repo}} https://github.com/{{.Org}}/{{.Repo}} https://github.com/{{.Org}}/{{.Repo}}/tree/{{.DefaultBranch}}{/dir} https://github.com/{{.Org}}/{{.Repo}}/blob/{{.DefaultBranch}}{/dir}/{file}#L{line}">
<meta name="go-import" content="knative.dev/{{.Module}} git https://github.com/{{.Org}}/{{.Repo}}">
<meta name="go-source" content="knative.dev/{{.Module}} https://github.com/{{.Org}}/{{.Repo}} https://github.com/{{.Org}}/{{.Repo}}/tree/{{.DefaultBranch}}{/dir} https://github.com/{{.Org}}/{{.Repo}}/blob/{{.DefaultBranch}}{/dir}/{file}#L{line}">
</head></html>
`
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
`
Expand Down