Repository navigation
refactor: export the config linter and image registry for reuse - #251
Conversation
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>
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>
- 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>
|
📋 PR Summary Moves the config linter from Changes
|
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>
There was a problem hiding this comment.
Warning
Changes suggested — 🟡 1 warning
🔁 Incremental · 8 files reviewed
Verification
checkDirgives the same detection order as before for first-party builds: Flex when.upsunhas YAML files, else Fixed through the.platform/dir or a root-level.platform.app.yaml, else an error.addStrayWarningsstill warns about nested.upsunand.platformdirectories, the same pair of names the first-party vendor candidates used to produce.- No code in the repo uses the removed
registry.Docs,Web,HooksorLocationtypes or theImage.Descriptionfield, and no code still callslint.VendororvendorFromConfig. - The "flex wins over fixed" case added to
TestDetectStylereplaces what the deletedTestCheckDir_Vendorscovered 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 5 of 10 for this pull request · View the full run
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>
Makes the config linter importable by other Go modules:
internal/lint→pkg/lintinternal/lint/registry→pkg/registry(image registry, also used outside linting)internal/lint/schema→internal/schema(only used bypkg/lint)Test data and the
gen.gogenerators move with their packages. Imports, theupdate-registry/update-schemaMakefile targets and CLAUDE.md are updated.The public API is kept small:
pkg/lint:CheckContent,CheckDir,Result,IssueandErrEmptyContent. The individual checks and the config model are unexported; external tests reach them throughexport_test.go.Resultexposes itsErrors/Warningsfields,HasErrors,HasWarningsandString, and no longer implementserror.FindProjectRootmoves to thelintcommand.pkg/registry:Load(wasParsed),Parse,Registry,Image,VersionInfoandChannelStable. UnusedDocstypes are removed.Behavior change:
CheckDirno 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 anotherproject_config_diris no longer supported bylint.The public packages note that other projects import them and that they are not covered by semantic versioning: the module has no
/v5path, so importers use pseudo-versions.🤖 Generated with Claude Code