Skip to content

refactor: export the config linter and image registry for reuse - #251

Merged
pjcdawkins merged 7 commits into
mainfrom
refactor/pkg-lint
Oct 18, 2026
Merged

pjcdawkins merged 7 commits into
mainfrom
refactor/pkg-lint

Conversation

@pjcdawkins

@pjcdawkins pjcdawkins commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Makes the config linter importable by other Go modules:

  • internal/lint → pkg/lint
  • internal/lint/registry → pkg/registry (image registry, also used outside linting)
  • internal/lint/schema → internal/schema (only used by pkg/lint)

Test data and the gen.go generators move with their packages. Imports, the update-registry/update-schema Makefile targets and CLAUDE.md are updated.

The public API is kept small:

  • pkg/lint: CheckContent, CheckDir, Result, Issue and ErrEmptyContent. The individual checks and the config model are unexported; external tests reach them through export_test.go. Result exposes its Errors/Warnings fields, HasErrors, HasWarnings and String, and no longer implements error. FindProjectRoot moves to the lint command.
  • pkg/registry: Load (was Parsed), Parse, Registry, Image, VersionInfo and ChannelStable. Unused Docs types are removed.

Behavior change: CheckDir no longer takes vendor conventions. It looks for .upsun/*.yaml (Flex), else .platform/ or .platform.app.yaml (Fixed), as both first-party CLIs already did. A CLI configured with another project_config_dir is no longer supported by lint.

The public packages note that other projects import them and that they are not covered by semantic versioning: the module has no /v5 path, so importers use pseudo-versions.

🤖 Generated with Claude Code

pjcdawkins and others added 2 commits October 18, 2026 10:34
Move internal/lint, with its registry and schema subpackages, test data
and generators, to pkg/lint so that other Go modules can import the
config linter. Update imports, Makefile targets and CLAUDE.md.

Add a package doc comment stating that the API has no stability
guarantee. No behavior changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move pkg/lint/registry to pkg/registry and pkg/lint/schema to
pkg/schema, since other projects use the image registry outside of
linting.

Add package docs to both, and reword the versioning note: the module has
no /v5 path, so importers use pseudo-versions and the API is not
covered by semantic versioning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pjcdawkins pjcdawkins changed the title refactor(lint): move lint package to pkg/lint for reuse refactor: move lint, registry and schema packages to pkg/ for reuse Oct 18, 2026
Unexport the individual checks, Combine, CheckSchemaAt, Config,
DecodeConfig and the config field types. Callers use CheckContent or
CheckDir, and Result to add their own issues. The external tests reach
the checks through export_test.go.

Move the schema package to internal/schema, since only pkg/lint uses it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pjcdawkins pjcdawkins changed the title refactor: move lint, registry and schema packages to pkg/ for reuse refactor: export the config linter and image registry for reuse Oct 18, 2026
- Remove Result.Error, so a Result is not mistaken for an error; tests
  use String.
- Return only the result and error from CheckDir, and unexport the
  configuration style.
- Move FindProjectRoot to the lint command, its only caller.
- Rename registry.Parsed to Load and unexport the embedded data.
- Document ErrEmptyContent, CheckContent, Parse, Load, Registry and
  AllTypes, and reword other doc comments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@upsun-dispatch

upsun-dispatch Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

📋 PR Summary

Moves the config linter from internal/lint to pkg/lint and the image registry to pkg/registry so other Go modules can import them. The schema package moves to internal/schema. Both public APIs are kept small. Result's mutators (addError, addWarning, merge) are now unexported, and ErrorLines/WarningLines are removed. CheckDir now detects Flex vs Fixed configuration from fixed directory names (.upsun/, .platform/ or .platform.app.yaml) and no longer takes vendor conventions, so a CLI configured with a different project_config_dir can no longer use lint.

Changes
Layer / File(s) Summary
Public lint API
pkg/lint/result.go Unexports AddError, AddWarning and Merge and removes ErrorLines/WarningLines.
pkg/lint/linter.go New entry point that exposes CheckContent and CheckDir.
pkg/lint/normalize.go Detects Flex vs Fixed directories without vendor conventions and switches to the unexported result helpers.
Lint checks
pkg/lint/types.go Switches to the unexported addError/addWarning helpers. The other check files (dependencies, fixed, names, relationships, routes, scripts, tasks, web, yaml) change the same way.
pkg/lint/export_test.go Gives external tests access to the unexported checks.
Registry
pkg/registry/registry.go Moved from internal/lint/registry. Parsed is renamed to Load.
pkg/registry/model.go Registry model with the unused Docs types removed.
Schema
internal/schema/gen.go Moved from internal/lint/schema, with its generator path updated.
CLI
commands/lint.go Now uses pkg/lint and contains FindProjectRoot, moved here from the lint package.
commands/lint_test.go Tests build lint.Result values directly, since the add methods are no longer public.
Build and docs
Makefile Points the update-registry and update-schema targets at the new paths.

CheckDir now takes only a directory and looks for the first-party
layouts: .upsun/*.yaml (Flex), else .platform/ or .platform.app.yaml
(Fixed). Both first-party CLIs already recognized both layouts. A CLI
configured with another project_config_dir is no longer supported by
lint.

Remove the registry's Docs types and the Image Description,
Configuration and Docs fields. The embedded registry.json does not
contain them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@upsun-dispatch upsun-dispatch Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning

Changes suggested — 🟡 1 warning

🔁 Incremental · 8 files reviewed

Verification
  • checkDir gives the same detection order as before for first-party builds: Flex when .upsun has YAML files, else Fixed through the .platform/ dir or a root-level .platform.app.yaml, else an error.
  • addStrayWarnings still warns about nested .upsun and .platform directories, the same pair of names the first-party vendor candidates used to produce.
  • No code in the repo uses the removed registry.Docs, Web, Hooks or Location types or the Image.Description field, and no code still calls lint.Vendor or vendorFromConfig.
  • The "flex wins over fixed" case added to TestDetectStyle replaces what the deleted TestCheckDir_Vendors covered for the first-party Platform.sh scenario.

The existing pkg/lint tests were updated to call checkDir(dir), and TestDetectStyle gained a test for Flex winning over Fixed. These and commands/lint_test.go run in the make test-go and golangci-lint steps of .github/workflows/ci.yml. The vendor-specific detection tests were deleted, and no test covers how lint behaves under a non-first-party project_config_dir.

Review details

Review 5 of 10 for this pull request · View the full run

Comment thread commands/lint.go
pjcdawkins and others added 2 commits October 18, 2026 11:21
lint looks only for .upsun and .platform/.platform.app.yaml, so a CLI
configured with other names would offer a command that cannot find its
projects' configuration. Register the command only when the configured
names match.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove ErrorLines and WarningLines, which had no callers, and unexport
AddError, AddWarning and Merge. Callers outside the package can append
to the exported Errors and Warnings fields. HasErrors, HasWarnings and
String stay exported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@pjcdawkins
pjcdawkins merged commit c08abc0 into main Oct 18, 2026
7 checks passed
@pjcdawkins
pjcdawkins deleted the refactor/pkg-lint branch October 18, 2026 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant