Validate dependency param/cred mappings during lint#3641
Draft
kichristensen wants to merge 2 commits into
Draft
Conversation
Add porter-103/104 lint errors when a dependency's parameters or credentials mapping references a name not defined on the dependency bundle. Add porter-105 warning when the dependency bundle can't be resolved to check against. Resolves the dependency bundle.json (cache, else registry) during lint, same as build/install already do at digest-pin and install-prep time. Reuses the existing PullBundle helper instead of duplicating BundleResolver construction. Fixes getporter#2674 Signed-off-by: Kim Christensen <[email protected]>
Ran mage docsGen to pick up --insecure-registry on porter lint and porter bundles lint. Signed-off-by: Kim Christensen <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances porter lint to proactively validate dependency parameter/credential mappings by resolving dependency bundles (cache-first, then registry) and checking that mapped names exist on the dependency’s bundle definition. It also threads --insecure-registry through lint (and the auto-lint run during porter build) to support dependency resolution against insecure registries.
Changes:
- Add new lint checks for dependency mappings: porter-103 (undefined parameter), porter-104 (undefined credential), porter-105 (unable to resolve dependency bundle so mappings can’t be validated).
- Update lint/build plumbing to resolve dependency bundles in
pkg/porterand pass them intopkg/linteras data. - Refactor dependency graph bundle pulling to use the existing
Porter.PullBundlehelper and update docs/CLI flags accordingly.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/porter/publish_test.go | Updates publish test to mock dependency bundle pull needed by lint-time dependency resolution. |
| pkg/porter/lint.go | Resolves dependency bundles during lint and returns porter-105 warnings when resolution fails. |
| pkg/porter/lint_test.go | Adds integration-style test ensuring porter-103/104 errors and porter-105 warning are produced. |
| pkg/porter/dependency_graph_builder.go | Switches dependency bundle pull path to Porter.PullBundle. |
| pkg/porter/build.go | Threads BuildOptions.InsecureRegistry into the pre-lint call. |
| pkg/linter/linter.go | Adds dependency mapping validation logic (porter-103/104) using resolved dependency bundles. |
| pkg/linter/linter_test.go | Adds unit tests for dependency mapping validation and updates existing lint calls for new signature. |
| docs/content/docs/references/linter.md | Documents porter-103/104/105. |
| docs/content/docs/references/cli/lint.md | Documents new --insecure-registry flag for lint. |
| docs/content/docs/references/cli/bundles_lint.md | Documents new --insecure-registry flag for bundles lint. |
| cmd/porter/bundle.go | Adds --insecure-registry flag wiring to the lint command. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+90
to
+94
| for _, dep := range m.Dependencies.Requires { | ||
| pullOpts := BundlePullOptions{ | ||
| Reference: dep.Bundle.Reference, | ||
| InsecureRegistry: opts.InsecureRegistry, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this change
Adds three new
porter lintchecks for bundle dependencies:parametersmapping references a name that isn't actually a parameter defined on the dependency bundle.credentialsmapping.To check porter-103/104, lint now resolves each dependency's bundle.json (checking the local cache first, then pulling from the registry), the same way build/install already do elsewhere in the codebase. Previously this mismatch was only caught at install time.
Example:
What issue does it fix
Closes #2674
Notes for the reviewer
pkg/linterfree of registry/cache I/O:pkg/porter/lint.goresolves the dependency bundles and passes them intolinter.Lint(...)as plain data, so the mapping check itself stays a pure, easily unit-tested function.--insecure-registrytoporter lint(and threadedBuildOptions.InsecureRegistrythrough to the auto-lint thatporter buildruns), since resolving dependencies now needs registry options.GraphBuilder.pullDependencyBundlewas manually constructing aBundleResolverinstead of using the existingPorter.PullBundlehelper; switched it over while touching this area.Checklist