feat: enforce lowercase namespaces and rename two mixed-case namespaces - #1031
feat: enforce lowercase namespaces and rename two mixed-case namespaces#1031matifali wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR strengthens the cmd/readmevalidation repo-structure validator by enforcing lowercase-only namespace directory names under registry/, while explicitly allowing the four legacy mixed-case namespaces to avoid breaking existing module source paths.
Changes:
- Added
validateNamespaceNamewith a lowercase-only namespace regex and a small allowlist for legacy mixed-case namespaces. - Added a table-driven unit test covering valid lowercase, grandfathered mixed-case, and invalid namespaces.
- Documented the lowercase namespace requirement and rationale in
CONTRIBUTING.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| CONTRIBUTING.md | Documents the new lowercase namespace directory requirement and rationale. |
| cmd/readmevalidation/repostructure.go | Implements lowercase namespace validation with legacy allowlist and improved error messaging. |
| cmd/readmevalidation/repostructure_test.go | Adds unit tests for the new namespace validation behavior. |
| for _, tc := range testCases { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| err := validateNamespaceName(tc.name) | ||
| if tc.shouldPass && err != nil { | ||
| t.Errorf("expected %q to be a valid namespace name, got error: %v", tc.name, err) | ||
| } | ||
| if !tc.shouldPass && err == nil { | ||
| t.Errorf("expected %q to be an invalid namespace name, got no error", tc.name) | ||
| } | ||
| }) | ||
| } |
There was a problem hiding this comment.
Not applicable here. go.mod declares go 1.25.0, and loop variables have been per-iteration since Go 1.22, so the closure captures the correct tc. go test -race passes on this test. This also matches the existing pattern in codermodules_test.go.
🤖 This response was generated by Coder Agents.
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
cc: @IamTaoChen @Excellencedev Heads-up: this PR lowercases your registry namespaces for consistency with the rest of the registry, Both of your namespaces contain templates only and have no release tags, so nothing breaks for anyone using them. The one visible change is the registry URL, e.g. Please update the links if you are using them anywhere in your portfolio. |
Problem
Namespace directories under
registry/are inconsistently cased. Four use mixed case (AJ0070,BenraouaneSoufiane,Excellencedev,IamTaoChen) while the other 21 are lowercase. The namespace becomes part of the case-sensitive module source path, so users end up with paths that are easy to mistype:Nothing stops the next contributor from adding another one.
Changes
Lint rule.
validateNamespaceNamevalidates namespace directories against a lowercase-only pattern (^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$). Mixed-case names get an actionable error suggesting the lowercase form. Table test covers lowercase, grandfathered, mixed-case, and otherwise-invalid names.CONTRIBUTING.mddocuments the requirement.Renamed the two namespaces that can move safely.
Excellencedev→excellencedevandIamTaoChen→iamtaochen. Both are templates-only with zero release tags, so no published module source path can break. Puregit mv, no content changes.display_name,github, andsupport_emailfrontmatter keep their original casing.AJ0070andBenraouaneSoufianestay allowlisted. Both have published modules (pgadmin,rustdesk) whose source paths are case-sensitive, and registry-server has no alias mechanism for the old path. Renaming them needs server-side work first.ExcellencedevIamTaoChenAJ0070pgadmin)BenraouaneSoufianerustdesk)No new CI job. The existing
validate-readme-filesjob already runs this binary on every PR.Validation
Validator runs clean on the renamed tree,
go test,go vet, andbun x prettier --checkall pass. Adding a mixed-case namespace fails as expected:Note
The two renamed namespaces change their registry.coder.com URLs, e.g.
/templates/IamTaoChen/ssh-linuxbecomes/templates/iamtaochen/ssh-linux. There's no redirect mechanism, so old links will 404.Closes #683