Add --preview support to rad resource list for Radius.Core environments and applications types - #12728
Conversation
Signed-off-by: lakshmimsft <ljavadekar@microsoft.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12728 +/- ##
==========================================
+ Coverage 54.36% 54.38% +0.02%
==========================================
Files 770 770
Lines 51299 51363 +64
==========================================
+ Hits 27887 27934 +47
- Misses 20796 20806 +10
- Partials 2616 2623 +7 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds preview-mode support to rad resource list so listing scoped by environment/application works correctly for Radius.Core/environments and Radius.Core/applications, while preserving legacy behavior when preview is off.
Changes:
- Wires
rad resource listthrough the shared preview routing mechanism (--preview/RADIUS_PREVIEW=true) and adds a preview runner path. - In preview mode, resolves environment/application inputs to fully-qualified
Radius.Coreresource IDs and validates applications using theRadius.Coreapplications client. - Expands unit tests to cover preview ID resolution, legacy-ID rejection, and preview-mode run behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/rad/cmd/root.go | Routes rad resource list through preview wiring to enable --preview behavior. |
| cmd/rad/cmd/root_test.go | Asserts rad resource list exposes the --preview flag on the assembled command tree. |
| pkg/cli/cmd/resource/list/list.go | Adds preview-aware command construction and runner logic for resolving/validating Radius.Core environment/app identifiers. |
| pkg/cli/cmd/resource/list/list_test.go | Adds preview-focused validation/run tests and updates existing tests for renamed fields. |
| pkg/cli/clients/clients.go | Documents that bare names target Applications.Core, and other types require full IDs. |
| pkg/cli/clients/management.go | Adds matching clarifying comments to list methods (no behavior change). |
| pkg/cli/clients/management_test.go | Adds a test ensuring fullyQualifyID preserves a full Radius.Core ID verbatim. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: lakshmimsft <ljavadekar@microsoft.com>
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
… environment (radius-project#12822) ## Summary `rad env delete --preview` now deletes everything that lives in the environment instead of only the environment resource itself, matching the behavior of `Applications.Core/environments`. When deleting a `Radius.Core` environment, the CLI now: 1. Looks up the environment, and treats a missing environment as a successful no-op so the command is idempotent. 2. Enumerates the applications whose `properties.environment` references the environment, plus the resources reported both by the environment and by each of those applications. 3. Shows a confirmation prompt that states how many applications and resources will be deleted, instead of the previous hardcoded "environment is empty" message. 4. Deletes the resources concurrently, then the applications, then the environment. A `--force` flag is also added to the preview command so resources stuck in a non-terminal state can be deleted, mirroring `rad app delete --force`. The cascade logic is shared with `rad app delete --preview`. That command previously carried its own private copy of the resource-enumeration logic; it now uses the same helpers, which removes the duplication. ## Reason for change The `Radius.Core/environments` env when used in `rad env delete --preview` deleted only the environment resource and silently orphaned every application and resource deployed into it. The confirmation prompt made this worse by always claiming the environment was empty, so users consented to a deletion that did not describe what actually happened. The work is unblocked by radius-project#12728, which made `fullyQualifyID` pass fully qualified resource IDs through unchanged. Fully qualified `Radius.Core` IDs can now be handed to `ListResourcesInApplication` and `ListResourcesInEnvironment` and reach their filters intact, so the preview commands no longer need their own enumeration code. Fixes radius-project#12486 ## How to test Manual, against a cluster with Radius installed: 1. Create a preview environment and deploy an application into it. 2. Confirm the cascade prompt reports the real contents, rather than claiming the environment is empty: ```bash rad env delete my-env --preview ``` 3. Confirm the applications and their resources are gone, not just the environment: ```bash rad app list --preview rad resource list --preview ``` 4. Confirm the command is idempotent — a second delete reports that the environment was not found and exits successfully: ```bash rad env delete my-env --preview ``` 5. Confirm the flag wiring: ```bash rad env delete --help # lists both --preview and --force rad env delete my-env --force # rejected: "--force requires preview mode" rad env delete my-env --preview --force ``` 6. Confirm the legacy path is unchanged: ```bash rad env delete my-env ``` ## File change summary | File | Summary of change | | ---- | ----------------- | | `pkg/cli/cmd/previewdelete.go` | New. Shared preview delete helpers: `PreviewResourceID`/`PreviewApplicationID`/`PreviewEnvironmentID` ID builders, `ListPreviewApplicationsInEnvironment`, `MergeResourcesByID`, and `DeleteResourcesInParallel`. | | `pkg/cli/cmd/previewdelete_test.go` | New. Unit tests for the ID builders, merge/dedupe behavior, and parallel deletion including 404 tolerance, skipping of malformed entries, error surfacing, and `force` passthrough. | | `pkg/cli/cmd/env/delete/preview/delete.go` | Cascade implementation: enumerate applications and resources, delete resources then applications then the environment, accurate three-way confirmation prompt, no-op on a missing environment, new `--force` flag, and updated help text. | | `pkg/cli/cmd/env/delete/preview/cascade_test.go` | New. Behavioral coverage of the cascade: missing environment, empty environment, full cascade with deletion ordering, cross-environment isolation, deduplication, all three prompt messages, declining the prompt, `--force`, and resource, application, and enumeration failures. | | `pkg/cli/cmd/env/delete/preview/delete_test.go` | Removed the `Test_Run` case superseded by `cascade_test.go`, along with its now-unused imports. | | `pkg/cli/cmd/app/delete/preview/delete.go` | Replaced the private `listResourcesOwnedByApplication`/`isResourceOwnedByApplication` duplicates with `ListResourcesInApplication` plus the shared `DeleteResourcesInParallel`. | | `pkg/cli/cmd/app/delete/preview/delete_test.go` | Retargeted mocks from `ListAllResourceTypesNames`/`ListResourcesOfType` onto `ListResourcesInApplication`, and asserted the fully qualified application ID contract. | | `cmd/rad/cmd/root.go` | Wired env delete through `wirePreviewSubcommandPreviewBase` so the preview command is the executed base. This is what makes `--force` visible at parse time in preview mode and rejected outside of it. | | `cmd/rad/cmd/root_test.go` | Regression guards on the assembled command tree covering `--preview`/`--force` exposure and the rejection of `--force` without preview. | | `pkg/cli/clients/management_test.go` | Added table-driven tests for `isResourceInApplication` and `isResourceInEnvironment`, including case-insensitive matching, preserving the coverage previously provided by the removed helpers in `app/delete/preview`. | --------- Signed-off-by: lakshmimsft <ljavadekar@microsoft.com>
….1 (#12831) Patch release `v0.60.1` for channel `0.60`. ## Backported PRs Listed in cherry-pick (topological) order. **Gap filler** = not requested for the patch, but included because it touched the same region of a shared file between `release/0.60` and a requested commit. Without it the cherry-pick has no common merge base and conflicts. | # | Commit | PR | Role | | --- | --- | --- | --- | | 1 | `6882b5fdf` | #12640 | Requested | | 2 | `af0443809` | #12721 | Requested | | 3 | `7c6de043d` | #12733 | **Gap filler** — `.github/workflows/codeql.yml` | | 4 | `ca7b5a3e7` | #12728 | Requested | | 5 | `2eac7c1f1` | #12702 | Requested | | 6 | `b4ebe2f28` | #12751 | Requested | | 7 | `e30a2594d` | #12727 | Requested | | 8 | `3c7dfecd6` | #12769 | **Gap filler** — `.github/workflows/codeql.yml` | | 9 | `787b6ca1a` | #12765 | **Gap filler** — `build/test.mk` | | 10 | `f84184955` | #12775 | Requested | | 11 | `415d5b9c2` | #12779 | Requested | | 12 | `a1d976013` | #12782 | Requested | | 13 | `14a21bd0d` | #12786 | **Gap filler** — `build/test.mk` | | 14 | `a87146c77` | #12764 | **Gap filler** — `build/test.mk` | | 15 | `073ca3cfa` | #12758 | Requested | | 16 | `5e1f94c13` | #12785 | **Gap filler** — `pkg/cli/cmd/install/kubernetes/kubernetes.go` | | 17 | `1fd650af5` | #12742 | Requested | | 18 | `19376c3f3` | #12829 | Requested | Five of the six gap fillers are CI/test-only. #12785 is not: it adds a Helm `control-plane-readiness` Job, a `pre-upgrade wait-for-control-plane` command, UCP readiness probes, and a NetworkPolicy change. It is required for #12829 to apply. ## Validation Full chain dry-run cherry-picked onto `release/0.60` with zero conflicts. `go build ./...` clean; `pkg/cli/cmd/install/kubernetes`, `cmd/pre-upgrade/cmd`, `pkg/cli/...`, `pkg/graph/...`, and `test/validation` all pass. --------- Signed-off-by: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com>
…ts and applications types (#12728) ## Summary Adds `--preview` support to `rad resource list` so environment- and application-scoped listing works with the `Radius.Core/environments` and `Radius.Core/applications` resource types. `rad resource list` is now wired through `wirePreviewSubcommand`, matching the pattern used by the `rad env` and `rad app` commands. In preview mode, the runner resolves fully-qualified `Radius.Core` resource IDs instead of bare names, and validates applications against the `Radius.Core` applications client. ## Reason for change [#12481](#12481) made the `[resourceType]` argument optional so `rad resource list` could list all resources in an environment or application. That path only worked for legacy resources. `cli.RequireEnvironmentName` reduces the workspace environment to its name, and `ListResourcesInEnvironment` re-qualifies a bare name as `Applications.Core/environments`. Filtering is exact, case-insensitive ID equality, so resources referencing `Radius.Core/environments` were silently excluded and the command returned an empty list. `-a` had the same problem, since it qualified names as `Applications.Core/applications` and validated existence through the legacy `GetApplication`. Legacy and preview environments/applications may share a name, so the client deliberately does not match both ID forms at once — that would merge results from two distinct resources. Instead, the caller supplies the exact ID it wants filtered. Fixes: #12609 ## How to test Requires a preview environment (`rad env create <env> --preview`) and a deployed preview application. ```bash # All resources in the default (Radius.Core) environment rad resource list --preview # All resources in a specific preview environment rad resource list -e my-env --preview # Typed listing scoped to a preview environment rad resource list Radius.Compute/containers -e my-env --preview # All resources in a preview application rad resource list -a my-app --preview # Full Radius.Core resource IDs are accepted rad resource list -a /planes/radius/local/resourceGroups/my-rg/providers/Radius.Core/applications/my-app --preview # RADIUS_PREVIEW=true activates preview mode RADIUS_PREVIEW=true rad resource list ``` Verify that legacy behavior is unchanged when `--preview` is omitted, and that a legacy `Applications.Core` ID passed to `-e`/`-a` under `--preview` is rejected with a clear message. ## File change summary | File | Summary of change | | ---- | ----------------- | | `cmd/rad/cmd/root.go` | Wires `rad resource list` through `wirePreviewSubcommand` so `--preview` and `RADIUS_PREVIEW=true` route to the preview runner. | | `cmd/rad/cmd/root_test.go` | Adds `Test_ResourceList_ExposesPreviewFlag`, asserting the assembled command tree exposes `--preview` on `rad resource list`. | | `pkg/cli/cmd/resource/list/list.go` | Adds `NewPreviewCommand` and a `Preview` field on the runner, sharing one implementation. In preview mode, resolves `Radius.Core` environment/application IDs (preserving full IDs, qualifying bare names, rejecting non-`Radius.Core` IDs), validates applications via the `Radius.Core` applications client, and passes full IDs to the list methods. Renames `EnvironmentName` to `EnvironmentNameOrID` to reflect that it may hold a full ID. | | `pkg/cli/cmd/resource/list/list_test.go` | Adds `Test_ValidatePreview` for environment/application ID resolution and legacy-ID rejection, plus `Test_Run` preview subtests covering typed/untyped environment and application listing and the missing-application error. Updates existing tests for the renamed field. | | `pkg/cli/clients/clients.go` | Documents on the interface that bare names target `Applications.Core` and that a full resource ID is needed for other types. | | `pkg/cli/clients/management.go` | Adds the same clarification to the four list method implementations. No behavior change. | | `pkg/cli/clients/management_test.go` | Adds a `fullyQualifyID` case asserting a full `Radius.Core` ID is preserved verbatim — the property the preview command depends on. | --------- Signed-off-by: lakshmimsft <ljavadekar@microsoft.com> (cherry picked from commit ca7b5a3) Signed-off-by: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com>
….1 (#12831) Patch release `v0.60.1` for channel `0.60`. ## Backported PRs Listed in cherry-pick (topological) order. **Gap filler** = not requested for the patch, but included because it touched the same region of a shared file between `release/0.60` and a requested commit. Without it the cherry-pick has no common merge base and conflicts. | # | Commit | PR | Role | | --- | --- | --- | --- | | 1 | `6882b5fdf` | #12640 | Requested | | 2 | `af0443809` | #12721 | Requested | | 3 | `7c6de043d` | #12733 | **Gap filler** — `.github/workflows/codeql.yml` | | 4 | `ca7b5a3e7` | #12728 | Requested | | 5 | `2eac7c1f1` | #12702 | Requested | | 6 | `b4ebe2f28` | #12751 | Requested | | 7 | `e30a2594d` | #12727 | Requested | | 8 | `3c7dfecd6` | #12769 | **Gap filler** — `.github/workflows/codeql.yml` | | 9 | `787b6ca1a` | #12765 | **Gap filler** — `build/test.mk` | | 10 | `f84184955` | #12775 | Requested | | 11 | `415d5b9c2` | #12779 | Requested | | 12 | `a1d976013` | #12782 | Requested | | 13 | `14a21bd0d` | #12786 | **Gap filler** — `build/test.mk` | | 14 | `a87146c77` | #12764 | **Gap filler** — `build/test.mk` | | 15 | `073ca3cfa` | #12758 | Requested | | 16 | `5e1f94c13` | #12785 | **Gap filler** — `pkg/cli/cmd/install/kubernetes/kubernetes.go` | | 17 | `1fd650af5` | #12742 | Requested | | 18 | `19376c3f3` | #12829 | Requested | Five of the six gap fillers are CI/test-only. #12785 is not: it adds a Helm `control-plane-readiness` Job, a `pre-upgrade wait-for-control-plane` command, UCP readiness probes, and a NetworkPolicy change. It is required for #12829 to apply. ## Validation Full chain dry-run cherry-picked onto `release/0.60` with zero conflicts. `go build ./...` clean; `pkg/cli/cmd/install/kubernetes`, `cmd/pre-upgrade/cmd`, `pkg/cli/...`, `pkg/graph/...`, and `test/validation` all pass. --------- Signed-off-by: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com> (cherry picked from commit e5938bf) Signed-off-by: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com>
…ts and applications types (#12728) ## Summary Adds `--preview` support to `rad resource list` so environment- and application-scoped listing works with the `Radius.Core/environments` and `Radius.Core/applications` resource types. `rad resource list` is now wired through `wirePreviewSubcommand`, matching the pattern used by the `rad env` and `rad app` commands. In preview mode, the runner resolves fully-qualified `Radius.Core` resource IDs instead of bare names, and validates applications against the `Radius.Core` applications client. ## Reason for change [#12481](#12481) made the `[resourceType]` argument optional so `rad resource list` could list all resources in an environment or application. That path only worked for legacy resources. `cli.RequireEnvironmentName` reduces the workspace environment to its name, and `ListResourcesInEnvironment` re-qualifies a bare name as `Applications.Core/environments`. Filtering is exact, case-insensitive ID equality, so resources referencing `Radius.Core/environments` were silently excluded and the command returned an empty list. `-a` had the same problem, since it qualified names as `Applications.Core/applications` and validated existence through the legacy `GetApplication`. Legacy and preview environments/applications may share a name, so the client deliberately does not match both ID forms at once — that would merge results from two distinct resources. Instead, the caller supplies the exact ID it wants filtered. Fixes: #12609 ## How to test Requires a preview environment (`rad env create <env> --preview`) and a deployed preview application. ```bash # All resources in the default (Radius.Core) environment rad resource list --preview # All resources in a specific preview environment rad resource list -e my-env --preview # Typed listing scoped to a preview environment rad resource list Radius.Compute/containers -e my-env --preview # All resources in a preview application rad resource list -a my-app --preview # Full Radius.Core resource IDs are accepted rad resource list -a /planes/radius/local/resourceGroups/my-rg/providers/Radius.Core/applications/my-app --preview # RADIUS_PREVIEW=true activates preview mode RADIUS_PREVIEW=true rad resource list ``` Verify that legacy behavior is unchanged when `--preview` is omitted, and that a legacy `Applications.Core` ID passed to `-e`/`-a` under `--preview` is rejected with a clear message. ## File change summary | File | Summary of change | | ---- | ----------------- | | `cmd/rad/cmd/root.go` | Wires `rad resource list` through `wirePreviewSubcommand` so `--preview` and `RADIUS_PREVIEW=true` route to the preview runner. | | `cmd/rad/cmd/root_test.go` | Adds `Test_ResourceList_ExposesPreviewFlag`, asserting the assembled command tree exposes `--preview` on `rad resource list`. | | `pkg/cli/cmd/resource/list/list.go` | Adds `NewPreviewCommand` and a `Preview` field on the runner, sharing one implementation. In preview mode, resolves `Radius.Core` environment/application IDs (preserving full IDs, qualifying bare names, rejecting non-`Radius.Core` IDs), validates applications via the `Radius.Core` applications client, and passes full IDs to the list methods. Renames `EnvironmentName` to `EnvironmentNameOrID` to reflect that it may hold a full ID. | | `pkg/cli/cmd/resource/list/list_test.go` | Adds `Test_ValidatePreview` for environment/application ID resolution and legacy-ID rejection, plus `Test_Run` preview subtests covering typed/untyped environment and application listing and the missing-application error. Updates existing tests for the renamed field. | | `pkg/cli/clients/clients.go` | Documents on the interface that bare names target `Applications.Core` and that a full resource ID is needed for other types. | | `pkg/cli/clients/management.go` | Adds the same clarification to the four list method implementations. No behavior change. | | `pkg/cli/clients/management_test.go` | Adds a `fullyQualifyID` case asserting a full `Radius.Core` ID is preserved verbatim — the property the preview command depends on. | --------- Signed-off-by: lakshmimsft <ljavadekar@microsoft.com> (cherry picked from commit ca7b5a3) Signed-off-by: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com>
….1 (#12831) Patch release `v0.60.1` for channel `0.60`. ## Backported PRs Listed in cherry-pick (topological) order. **Gap filler** = not requested for the patch, but included because it touched the same region of a shared file between `release/0.60` and a requested commit. Without it the cherry-pick has no common merge base and conflicts. | # | Commit | PR | Role | | --- | --- | --- | --- | | 1 | `6882b5fdf` | #12640 | Requested | | 2 | `af0443809` | #12721 | Requested | | 3 | `7c6de043d` | #12733 | **Gap filler** — `.github/workflows/codeql.yml` | | 4 | `ca7b5a3e7` | #12728 | Requested | | 5 | `2eac7c1f1` | #12702 | Requested | | 6 | `b4ebe2f28` | #12751 | Requested | | 7 | `e30a2594d` | #12727 | Requested | | 8 | `3c7dfecd6` | #12769 | **Gap filler** — `.github/workflows/codeql.yml` | | 9 | `787b6ca1a` | #12765 | **Gap filler** — `build/test.mk` | | 10 | `f84184955` | #12775 | Requested | | 11 | `415d5b9c2` | #12779 | Requested | | 12 | `a1d976013` | #12782 | Requested | | 13 | `14a21bd0d` | #12786 | **Gap filler** — `build/test.mk` | | 14 | `a87146c77` | #12764 | **Gap filler** — `build/test.mk` | | 15 | `073ca3cfa` | #12758 | Requested | | 16 | `5e1f94c13` | #12785 | **Gap filler** — `pkg/cli/cmd/install/kubernetes/kubernetes.go` | | 17 | `1fd650af5` | #12742 | Requested | | 18 | `19376c3f3` | #12829 | Requested | Five of the six gap fillers are CI/test-only. #12785 is not: it adds a Helm `control-plane-readiness` Job, a `pre-upgrade wait-for-control-plane` command, UCP readiness probes, and a NetworkPolicy change. It is required for #12829 to apply. ## Validation Full chain dry-run cherry-picked onto `release/0.60` with zero conflicts. `go build ./...` clean; `pkg/cli/cmd/install/kubernetes`, `cmd/pre-upgrade/cmd`, `pkg/cli/...`, `pkg/graph/...`, and `test/validation` all pass. --------- Signed-off-by: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com> (cherry picked from commit e5938bf) Signed-off-by: Dariusz Porowski <3431813+DariuszPorowski@users.noreply.github.com>
Summary
Adds
--previewsupport torad resource listso environment- and application-scoped listing works with theRadius.Core/environmentsandRadius.Core/applicationsresource types.rad resource listis now wired throughwirePreviewSubcommand, matching the pattern used by therad envandrad appcommands. In preview mode, the runner resolves fully-qualifiedRadius.Coreresource IDs instead of bare names, and validates applications against theRadius.Coreapplications client.Reason for change
#12481 made the
[resourceType]argument optional sorad resource listcould list all resources in an environment or application. That path only worked for legacy resources.cli.RequireEnvironmentNamereduces the workspace environment to its name, andListResourcesInEnvironmentre-qualifies a bare name asApplications.Core/environments. Filtering is exact, case-insensitive ID equality, so resources referencingRadius.Core/environmentswere silently excluded and the command returned an empty list.-ahad the same problem, since it qualified names asApplications.Core/applicationsand validated existence through the legacyGetApplication.Legacy and preview environments/applications may share a name, so the client deliberately does not match both ID forms at once — that would merge results from two distinct resources. Instead, the caller supplies the exact ID it wants filtered.
Fixes: #12609
How to test
Requires a preview environment (
rad env create <env> --preview) and a deployed preview application.Verify that legacy behavior is unchanged when
--previewis omitted, and that a legacyApplications.CoreID passed to-e/-aunder--previewis rejected with a clear message.File change summary
cmd/rad/cmd/root.gorad resource listthroughwirePreviewSubcommandso--previewandRADIUS_PREVIEW=trueroute to the preview runner.cmd/rad/cmd/root_test.goTest_ResourceList_ExposesPreviewFlag, asserting the assembled command tree exposes--previewonrad resource list.pkg/cli/cmd/resource/list/list.goNewPreviewCommandand aPreviewfield on the runner, sharing one implementation. In preview mode, resolvesRadius.Coreenvironment/application IDs (preserving full IDs, qualifying bare names, rejecting non-Radius.CoreIDs), validates applications via theRadius.Coreapplications client, and passes full IDs to the list methods. RenamesEnvironmentNametoEnvironmentNameOrIDto reflect that it may hold a full ID.pkg/cli/cmd/resource/list/list_test.goTest_ValidatePreviewfor environment/application ID resolution and legacy-ID rejection, plusTest_Runpreview subtests covering typed/untyped environment and application listing and the missing-application error. Updates existing tests for the renamed field.pkg/cli/clients/clients.goApplications.Coreand that a full resource ID is needed for other types.pkg/cli/clients/management.gopkg/cli/clients/management_test.gofullyQualifyIDcase asserting a fullRadius.CoreID is preserved verbatim — the property the preview command depends on.