Skip to content

Validate dependency param/cred mappings during lint#3641

Draft
kichristensen wants to merge 2 commits into
getporter:mainfrom
kichristensen:issue2674
Draft

Validate dependency param/cred mappings during lint#3641
kichristensen wants to merge 2 commits into
getporter:mainfrom
kichristensen:issue2674

Conversation

@kichristensen

@kichristensen kichristensen commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What does this change

Adds three new porter lint checks for bundle dependencies:

  • porter-103 (error): a dependency's parameters mapping references a name that isn't actually a parameter defined on the dependency bundle.
  • porter-104 (error): same as porter-103, but for the credentials mapping.
  • porter-105 (warning): the dependency's bundle reference couldn't be resolved (cache miss + pull failure), so its mappings couldn't be checked.

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:

porter lint
error(porter-103) - Dependency error
dependencies.mysql.parameters.NOT_A_PARAM is not defined as a parameter on the dependency bundle
See https://porter.sh/reference/linter/#porter-103 for more information

What issue does it fix

Closes #2674

Notes for the reviewer

  • Kept pkg/linter free of registry/cache I/O: pkg/porter/lint.go resolves the dependency bundles and passes them into linter.Lint(...) as plain data, so the mapping check itself stays a pure, easily unit-tested function.
  • Added --insecure-registry to porter lint (and threaded BuildOptions.InsecureRegistry through to the auto-lint that porter build runs), since resolving dependencies now needs registry options.
  • Also removed a small pre-existing duplication: GraphBuilder.pullDependencyBundle was manually constructing a BundleResolver instead of using the existing Porter.PullBundle helper; switched it over while touching this area.

Checklist

  • Did you write tests?
  • Did you write documentation?
  • Did you change porter.yaml or a storage document record? Update the corresponding schema file.
  • If this is your first pull request, please add your name to the bottom of our Contributors list. Thank you for making Porter better! 🙇‍♀️

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]>

Copilot AI 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.

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/porter and pass them into pkg/linter as data.
  • Refactor dependency graph bundle pulling to use the existing Porter.PullBundle helper 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 thread pkg/porter/lint.go
Comment on lines +90 to +94
for _, dep := range m.Dependencies.Requires {
pullOpts := BundlePullOptions{
Reference: dep.Bundle.Reference,
InsecureRegistry: opts.InsecureRegistry,
}
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.

Validate dependency value mappings during lint

2 participants