Guard delete of in-use credential/parameter set - #3642
Merged
kichristensen merged 3 commits intoJul 28, 2026
Conversation
Deleting a credential/parameter set still referenced by an installation broke the next apply/upgrade with no link back to the delete. Block delete when in use; require --force. Global-set delete excludes installations shadowed by a local set of the same name, avoiding false positives. Closes getporter#3640 Signed-off-by: Kim Christensen <kimworking@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds safety checks to prevent porter credentials delete / porter parameters delete from silently deleting sets that are still referenced by one or more installations, requiring an explicit --force override when the set is in use (including correct handling for global sets shadowed by same-named local sets).
Changes:
- Add
--forceoption and pre-delete “in use by installations” guard for credential/parameter set deletion. - Implement namespace-aware usage detection (including global-vs-local shadowing semantics).
- Add unit tests and update CLI reference docs to document the new flag/behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/porter/parameters.go | Adds Force option and usage detection logic before deleting parameter sets (with global shadowing behavior). |
| pkg/porter/parameters_test.go | Adds tests for delete behavior: not in use, blocked without force, forced delete, and shadowed global set. |
| pkg/porter/credentials.go | Adds Force option and usage detection logic before deleting credential sets (with global shadowing behavior). |
| pkg/porter/credentials_test.go | Adds tests for delete behavior when credential sets are referenced and for shadowed global sets. |
| cmd/porter/parameters.go | Wires --force flag into porter parameters delete. |
| cmd/porter/credentials.go | Wires --force flag into porter credentials delete. |
| docs/content/docs/references/cli/parameters_delete.md | Documents the new --force flag for parameters delete. |
| docs/content/docs/references/cli/credentials_delete.md | Documents the new --force flag for credentials delete. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Check existence before in-use guard so deleting a set that doesn't exist no longer errors when its name is still referenced by an installation. Aligned error/debug messages between credentials and parameters. Signed-off-by: Kim Christensen <kimworking@gmail.com>
Signed-off-by: Kim Christensen <kimworking@gmail.com>
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
porter credentials delete/porter parameters deleteremoved the setunconditionally, even if an installation's
credentialSets/parameterSetsstill named it. The nextapply/upgrade then failed toresolve the missing set, with no link back to the delete that caused it.
Both commands now check whether any installation still references the
set before deleting, and require
--forceto proceed if so:Credential/parameter sets resolve with a namespace fallback (local
namespace, then global). Deleting a global set excludes installations
whose own namespace shadows it with a same-named local set, so that
case isn't a false positive.
What issue does it fix
Closes #3640
Notes for the reviewer
Raised by @carolynvs in #1781, split out of #3637 as out-of-scope there.
Only
pkg/portertests were added (backed by a real datastore, same asthe existing
TestCredentialsDelete); notests/integrationtest, sincethe feature is pure storage/query logic with no bundle-execution surface
and there's no existing integration-level precedent for the credentials/
parameters CLI commands.
Checklist