-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI: fix prefix matching across multiple commands #23502
Merged
Merged
Conversation
This file contains 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
This was referenced Jul 3, 2024
tgross
added
backport/ent/1.6.x+ent
Changes are backported to 1.6.x+ent
backport/ent/1.7.x+ent
Changes are backported to 1.7.x+ent
backport/1.8.x
backport to 1.8.x release line
theme/cli
labels
Jul 3, 2024
tgross
force-pushed
the
cli-prefix-match-fixes
branch
from
July 3, 2024 20:16
7889a91
to
2297a4d
Compare
tgross
force-pushed
the
cli-prefix-match-fixes
branch
from
July 8, 2024 17:58
2297a4d
to
5f29d78
Compare
tgross
force-pushed
the
cli-prefix-match-fixes
branch
from
July 8, 2024 18:16
5f29d78
to
ab993de
Compare
Several commands that inspect objects where the names are user-controlled share a bug where the user cannot inspect the object if it has a name that is an exact prefix of the name of another object (in the same namespace, where applicable). For example, the object "test" can't be inspected if there's an object with the name "testing". Copy existing logic we have for jobs, node pools, etc. to the impacted commands: * `plugin status` * `quota inspect` * `quota status` * `scaling policy info` * `service info` * `volume deregister` * `volume detach` * `volume status` If we get multiple objects for the prefix query, we check if any of them are an exact match and use that object instead of returning an error. Where possible because the prefix query signatures are the same, use a generic function that can be shared across multiple commands. Fixes: #13920 Fixes: #17132 Fixes: #23236 Ref: https://hashicorp.atlassian.net/browse/NET-10054 Ref: https://hashicorp.atlassian.net/browse/NET-10055
tgross
force-pushed
the
cli-prefix-match-fixes
branch
from
July 8, 2024 18:36
ab993de
to
dfe259b
Compare
pkazmierczak
approved these changes
Jul 10, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backport/ent/1.6.x+ent
Changes are backported to 1.6.x+ent
backport/ent/1.7.x+ent
Changes are backported to 1.7.x+ent
backport/1.8.x
backport to 1.8.x release line
theme/cli
type/bug
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.
Several commands that inspect objects where the names are user-controlled share a bug where the user cannot inspect the object if it has a name that is an exact prefix of the name of another object (in the same namespace, where applicable). For example, the object "test" can't be inspected if there's an object with the name "testing".
Copy existing logic we have for jobs, node pools, etc. to the impacted commands:
plugin status
quota inspect
quota status
scaling policy info
service info
volume deregister
volume detach
volume status
If we get multiple objects for the prefix query, we check if any of them are an exact match and use that object instead of returning an error. Where possible because the prefix query signatures are the same, use a generic function that can be shared across multiple commands.
Fixes: #13920
Fixes: #17132
Fixes: #23236
Ref: https://hashicorp.atlassian.net/browse/NET-10054
Ref: https://hashicorp.atlassian.net/browse/NET-10055