Add -Environment and make -ProjectName optional for catlet name lookups - #125
Merged
Conversation
Catlets are unique per project + environment, so name lookups can no longer assume project uniqueness. Add an optional -Environment filter to the catlet query and action commands (empty = all environments), mirroring Get-VNetwork and Get-CatletDisk, and route every catlet listing through a shared ListCatlets helper. Rework ResolveActionTargets so an exact name is resolved across all accessible projects and -ProjectName only narrows the search; a name matching several projects/environments is reported as ambiguous with a hint to narrow with -ProjectName / -Environment. A wildcard still requires -ProjectName so a mutation cannot fan out across projects. Update and extend the name-lookup Pester tests for the new -Environment surface and the relaxed project resolution.
There was a problem hiding this comment.
Pull request overview
This PR updates catlet name-based resolution to account for catlets being unique per project + environment, by adding an -Environment narrowing filter across catlet cmdlets and relaxing -ProjectName requirements for exact-name mutations (while retaining safety guards against accidental fan-out).
Changes:
- Adds
-Environmentfiltering to catlet list/name lookup paths (client-side filtering via a shared helper). - Updates mutating cmdlet resolution to allow exact-name lookups across accessible projects, with ambiguity/empty-target safeguards and better disambiguation hints.
- Extends/updates Pester coverage for parameter surfaces and the updated name-resolution semantics.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/pester/ResourceNameLookup.Tests.ps1 | Extends Pester coverage for new -Environment surface and updated name-resolution behavior. |
| src/Eryph.ComputeClient.Commands/ComputeCmdLet.cs | Updates ResolveActionTargets semantics (cross-project exact-name resolution, wildcard scoping, empty-target guard, ambiguity hinting). |
| src/Eryph.ComputeClient.Commands/Catlets/UpdateCatletCommand.cs | Adds -Environment narrowing filter and uses shared catlet listing helper for resolution. |
| src/Eryph.ComputeClient.Commands/Catlets/StopCatletCommand.cs | Adds -Environment narrowing filter and routes listing through shared helper. |
| src/Eryph.ComputeClient.Commands/Catlets/StartCatletCommand.cs | Adds -Environment narrowing filter and routes listing through shared helper. |
| src/Eryph.ComputeClient.Commands/Catlets/SetCatletGuestServiceConfigCommand.cs | Adds -Environment narrowing filter and routes listing through shared helper. |
| src/Eryph.ComputeClient.Commands/Catlets/RemoveCatletGuestServiceAccessKeyCommand.cs | Adds -Environment narrowing filter and routes listing through shared helper. |
| src/Eryph.ComputeClient.Commands/Catlets/RemoveCatletCommand.cs | Adds -Environment narrowing filter and routes listing through shared helper. |
| src/Eryph.ComputeClient.Commands/Catlets/GetCatletProvisioningStatusCommand.cs | Adds -Environment list filter and uses shared helper + consistent resource-kind messaging. |
| src/Eryph.ComputeClient.Commands/Catlets/GetCatletProvisioningLogCommand.cs | Adds -Environment list filter, uses shared helper, and avoids Environment name collision with System.Environment. |
| src/Eryph.ComputeClient.Commands/Catlets/GetCatletIpCommand.cs | Adds -Environment list filter and uses shared helper + consistent resource-kind messaging. |
| src/Eryph.ComputeClient.Commands/Catlets/GetCatletCommand.cs | Adds -Environment list filter and uses shared helper + consistent resource-kind messaging. |
| src/Eryph.ComputeClient.Commands/Catlets/CatletGuestServiceGetCmdlet.cs | Adds -Environment list filter and uses shared helper + consistent resource-kind messaging. |
| src/Eryph.ComputeClient.Commands/Catlets/CatletCmdLet.cs | Introduces shared ListCatlets(projectId, environment) helper and ambiguity-hint constants. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (hasProject && !TryGetProjectId(projectName, out projectId)) | ||
| yield break; | ||
|
|
||
| var matches = FilterByName(listInProject(projectId), nameOrId, nameSelector, resourceKind).ToList(); |
Comment on lines
44
to
+45
| foreach (var catlet in ResolveActionTargets(nameOrId, ProjectName, GetSingleCatlet, | ||
| projectId => client.List(projectId: projectId), c => c.Name, "catlet")) | ||
| projectId => ListCatlets(projectId, Environment), c => c.Name, CatletResourceKind, EnvironmentHintIfUnset(Environment))) |
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.
Catlets are unique per project + environment, so name-based lookups can no longer assume a name is unique within a project.
-Environmentfilter added to the 11 catlet name-lookup cmdlets — query (Get-Catlet,Get-CatletIp,Get-CatletGuestServiceStatus/Config,Get-CatletProvisioningStatus/Log) and action (Start/Stop/Remove/Update-Catlet,Set-CatletGuestServiceConfig,Remove-CatletGuestServiceAccessKey). Empty = all environments; specified = client-side filter. MirrorsGet-VNetwork/Get-CatletDisk.-ProjectNameno longer required for name lookups:ResolveActionTargetsnow resolves an exact name across all accessible projects, with-ProjectName/-Environmentas narrowing filters. A name matching several projects/environments errors as ambiguous with a hint naming the filters not yet applied. A wildcard still requires-ProjectNameso a mutation can't fan out across projects. A GUID id bypasses everything.ListCatlets(projectId, environment)helper +CatletResourceKind/EnvironmentHintIfUnsetonCatletCmdLet.