diff --git a/.ai/checkpoints/sp-resource-show-deleted.md b/.ai/checkpoints/sp-resource-show-deleted.md new file mode 100644 index 0000000..45e7072 --- /dev/null +++ b/.ai/checkpoints/sp-resource-show-deleted.md @@ -0,0 +1,61 @@ +# Checkpoint: SP Resource — show-deleted Support + +- **Branch:** `add-show-deleted-sp-resource` +- **Base:** `main` (commit `3f7b012`) +- **Date:** 2026-04-09 +- **Status:** Complete + +--- + +## Scope + +Adds `--show-deleted` flag support to `dcm sp resource list` and +`dcm sp resource get` commands. When set, the flag passes `show_deleted=true` as +a query parameter to the Service Provider Resource Manager API and adds a +`DELETION STATUS` column to the table output showing the `deletion_status` field +from the response. + +### Requirements Addressed + +| ID | Description | Status | +|----|-------------|--------| +| REQ-SPR-010 (updated) | Added `--show-deleted` to list flags | Done | +| REQ-SPR-035 (new) | `dcm sp resource get` supports optional `--show-deleted` flag | Done | +| REQ-SPR-060 (new) | `--show-deleted` passes `show_deleted=true` query parameter on list and get | Done | +| REQ-SPR-070 (new) | `--show-deleted` adds `DELETION STATUS` column to table output | Done | + +### Tests Implemented (4 specs) + +| TC ID | Description | Status | +|-------|-------------|--------| +| TC-U154 | List with `--show-deleted` — passes `show_deleted=true`, displays `DELETION STATUS` column with `PENDING` | Pass | +| TC-U155 | List without `--show-deleted` — does not send `show_deleted`, no `DELETION STATUS` column | Pass | +| TC-U156 | Get with `--show-deleted` — passes `show_deleted=true`, displays `DELETION STATUS` column with `PENDING` | Pass | +| TC-U157 | Get without `--show-deleted` — does not send `show_deleted`, no `DELETION STATUS` column | Pass | + +--- + +## Files Created / Modified + +| File | Change | Purpose | +|------|--------|---------| +| `go.mod` / `go.sum` | Modified | Updated `service-provider-manager` dependency from `20260324` to `20260402` for `ShowDeleted` params and `GetInstanceParams` type | +| `internal/commands/helpers.go` | Modified | Updated `spmclient` import path from `pkg/client` to `pkg/client/provider` (upstream package restructuring) | +| `internal/commands/sp_provider.go` | Modified | Updated `spmapi` import path from `api/v1alpha1` to `api/v1alpha1/provider` (upstream package restructuring) | +| `internal/commands/sp_resource.go` | Modified | Added `spResourceWithDeletedTableDef`, `--show-deleted` flag on list and get, conditional table def selection, `ShowDeleted` param passing, updated `GetInstance` call to include `GetInstanceParams` | +| `internal/commands/sp_resource_test.go` | Modified | Added `sampleDeletedSPResourceResponse()` helper and 4 new test specs | +| `.ai/specs/dcm-cli.spec.md` | Modified | Added REQ-SPR-035/060/070, AC-SPR-035/036/045/046, updated table output section | +| `.ai/test-plans/dcm-cli-unit.test-plan.md` | Modified | Added TC-U154–TC-U157, updated coverage matrix and totals | +| `.ai/checkpoints/sp-resource-show-deleted.md` | Created | This checkpoint | + +--- + +## Key Design Decisions + +1. **Dependency update required** — The `service-provider-manager` module was updated from `20260324` to `20260402` because the newer version introduces `ShowDeleted` on `ListInstancesParams`, the new `GetInstanceParams` type (with `ShowDeleted`), and changes the `GetInstance` client method signature to accept `*GetInstanceParams`. + +2. **Upstream package restructuring** — The `20260402` version moved provider types and client from `api/v1alpha1` / `pkg/client` to `api/v1alpha1/provider` / `pkg/client/provider` subpackages. Import paths in `helpers.go` and `sp_provider.go` were updated accordingly. + +3. **Conditional table definition** — Rather than always showing the `DELETION STATUS` column (which would be empty for most use cases), two table definitions are used: `spResourceTableDef` (default 4 columns) and `spResourceWithDeletedTableDef` (5 columns including `DELETION STATUS`). The flag value selects which definition is passed to the formatter. + +4. **Flag defaults to false** — `--show-deleted` defaults to `false`, matching the API default. The query parameter is only sent when the flag is explicitly set to `true`, keeping default requests unchanged. diff --git a/.ai/specs/dcm-cli.spec.md b/.ai/specs/dcm-cli.spec.md index 620fd3e..57746b2 100644 --- a/.ai/specs/dcm-cli.spec.md +++ b/.ai/specs/dcm-cli.spec.md @@ -1018,19 +1018,30 @@ SP health check. | ID | Requirement | Priority | Notes | |----|-------------|----------|-------| -| REQ-SPR-010 | `dcm sp resource list` MUST list SP resources (service type instances) with optional `--provider`, `--page-size`, `--page-token` flags | MUST | | +| REQ-SPR-010 | `dcm sp resource list` MUST list SP resources (service type instances) with optional `--provider`, `--show-deleted`, `--page-size`, `--page-token` flags | MUST | | | REQ-SPR-020 | `dcm sp resource list` MUST display SP resources in the configured output format | MUST | | | REQ-SPR-030 | `dcm sp resource get` MUST accept an `INSTANCE_ID` positional argument and display the SP resource | MUST | | +| REQ-SPR-035 | `dcm sp resource get` MUST support an optional `--show-deleted` flag | MUST | | | REQ-SPR-040 | Missing `INSTANCE_ID` argument for `get` MUST result in a usage error (exit code 2) | MUST | | | REQ-SPR-050 | All SP resource commands MUST use the generated SP Resource Manager client | MUST | | +| REQ-SPR-060 | When `--show-deleted` is set, `list` and `get` MUST pass `show_deleted=true` as a query parameter to the API | MUST | | +| REQ-SPR-070 | When `--show-deleted` is set, table output MUST include an additional `DELETION STATUS` column displaying the `deletion_status` field | MUST | | #### Table Output Columns +Default: ``` ID PROVIDER STATUS CREATED my-instance kubevirt-123 READY 2026-03-09T10:00:00Z ``` +With `--show-deleted`: +``` +ID PROVIDER STATUS DELETION STATUS CREATED +my-instance kubevirt-123 READY 2026-03-09T10:00:00Z +deleted-instance kubevirt-123 DELETED PENDING 2026-03-09T10:00:00Z +``` + #### Acceptance Criteria ##### AC-SPR-010: List SP resources @@ -1055,6 +1066,22 @@ my-instance kubevirt-123 READY 2026-03-09T10:00:00Z - **When** `dcm sp resource list --provider kubevirt-123` is invoked - **Then** the GET request MUST include `provider=kubevirt-123` as a query parameter +##### AC-SPR-035: List SP resources with show-deleted + +- **Validates:** REQ-SPR-010, REQ-SPR-060, REQ-SPR-070 +- **Given** SP resources exist in the system, including soft-deleted ones +- **When** `dcm sp resource list --show-deleted` is invoked +- **Then** the GET request MUST include `show_deleted=true` as a query parameter +- **And** the table output MUST include a `DELETION STATUS` column + +##### AC-SPR-036: List SP resources without show-deleted omits deletion status column + +- **Validates:** REQ-SPR-070 +- **Given** SP resources exist in the system +- **When** `dcm sp resource list` is invoked without `--show-deleted` +- **Then** the `show_deleted` query parameter MUST NOT be sent +- **And** the table output MUST NOT include a `DELETION STATUS` column + ##### AC-SPR-040: Get SP resource - **Validates:** REQ-SPR-030 @@ -1063,6 +1090,22 @@ my-instance kubevirt-123 READY 2026-03-09T10:00:00Z - **Then** a GET request MUST be sent to `/api/v1alpha1/service-type-instances/my-instance` - **And** the SP resource MUST be displayed in the configured output format +##### AC-SPR-045: Get SP resource with show-deleted + +- **Validates:** REQ-SPR-035, REQ-SPR-060, REQ-SPR-070 +- **Given** a soft-deleted SP resource with ID `deleted-instance` exists +- **When** `dcm sp resource get deleted-instance --show-deleted` is invoked +- **Then** the GET request MUST include `show_deleted=true` as a query parameter +- **And** the table output MUST include a `DELETION STATUS` column + +##### AC-SPR-046: Get SP resource without show-deleted omits deletion status column + +- **Validates:** REQ-SPR-070 +- **Given** an SP resource with ID `my-instance` exists +- **When** `dcm sp resource get my-instance` is invoked without `--show-deleted` +- **Then** the `show_deleted` query parameter MUST NOT be sent +- **And** the table output MUST NOT include a `DELETION STATUS` column + ##### AC-SPR-050: Get without INSTANCE_ID - **Validates:** REQ-SPR-040 @@ -1651,11 +1694,11 @@ REQ-OUT-090, REQ-OUT-110, REQ-OUT-120 | REQ-CIT-NNN | 4.6: Catalog Item Commands | 11 | | REQ-CIN-NNN | 4.7: Catalog Instance Commands | 11 | | REQ-VER-NNN | 4.8: Version Command | 3 | -| REQ-SPR-NNN | 4.9: SP Resource Commands | 5 | +| REQ-SPR-NNN | 4.9: SP Resource Commands | 8 | | REQ-CMP-NNN | 4.10: Shell Completion Command | 6 | | REQ-SPP-NNN | 4.11: SP Provider Commands | 5 | | REQ-XC-ERR-NNN | 5.1: Error Handling | 7 | | REQ-XC-INP-NNN | 5.2: Input File Parsing | 3 | | REQ-XC-CLI-NNN | 5.3: Generated Client Usage | 6 | | REQ-XC-PAG-NNN | 5.4: Pagination | 3 | -| **Total** | | **106** | +| **Total** | | **109** | diff --git a/.ai/test-plans/dcm-cli-unit.test-plan.md b/.ai/test-plans/dcm-cli-unit.test-plan.md index fbdaf67..b273aed 100644 --- a/.ai/test-plans/dcm-cli-unit.test-plan.md +++ b/.ai/test-plans/dcm-cli-unit.test-plan.md @@ -952,6 +952,24 @@ test classes. Instead: - **When:** `dcm sp resource get my-instance` is executed - **Then:** A GET request is sent to `/api/v1alpha1/service-type-instances/my-instance` AND the SP resource is displayed +### TC-U156: Get SP resource with show-deleted + +- **Requirement:** REQ-SPR-035, REQ-SPR-060, REQ-SPR-070 +- **Acceptance Criteria:** AC-SPR-045 +- **Type:** Unit +- **Given:** A mock server returning 200 with a soft-deleted SP resource (with `deletion_status: "PENDING"`) +- **When:** `dcm sp resource get deleted-instance --show-deleted` is executed +- **Then:** The GET request includes `show_deleted=true` as a query parameter AND the table output includes a `DELETION STATUS` column AND the `PENDING` value is displayed + +### TC-U157: Get SP resource without show-deleted omits deletion status column + +- **Requirement:** REQ-SPR-070 +- **Acceptance Criteria:** AC-SPR-046 +- **Type:** Unit +- **Given:** A mock server returning 200 with an SP resource +- **When:** `dcm sp resource get my-instance` is executed without `--show-deleted` +- **Then:** The `show_deleted` query parameter is NOT sent AND the table output does NOT include a `DELETION STATUS` column + ### TC-U125: Get SP resource without INSTANCE_ID fails - **Requirement:** REQ-SPR-040 @@ -961,6 +979,24 @@ test classes. Instead: - **When:** `dcm sp resource get` is executed - **Then:** The CLI exits with code 2 and displays a usage error +### TC-U154: List SP resources with show-deleted + +- **Requirement:** REQ-SPR-010, REQ-SPR-060, REQ-SPR-070 +- **Acceptance Criteria:** AC-SPR-035 +- **Type:** Unit +- **Given:** A mock server returning 200 with a list including a soft-deleted SP resource (with `deletion_status: "PENDING"`) +- **When:** `dcm sp resource list --show-deleted` is executed +- **Then:** The GET request includes `show_deleted=true` as a query parameter AND the table output includes a `DELETION STATUS` column AND the `PENDING` value is displayed + +### TC-U155: List SP resources without show-deleted omits deletion status column + +- **Requirement:** REQ-SPR-070 +- **Acceptance Criteria:** AC-SPR-036 +- **Type:** Unit +- **Given:** A mock server returning 200 with a list of SP resources +- **When:** `dcm sp resource list` is executed without `--show-deleted` +- **Then:** The `show_deleted` query parameter is NOT sent AND the table output does NOT include a `DELETION STATUS` column + ### TC-U126: List SP resources returns empty list - **Requirement:** REQ-SPR-010, REQ-SPR-020 @@ -1564,7 +1600,7 @@ dedicated test class or `Describe` block. | REQ-OUT-020 | TC-U009 (table is default) | Covered | | REQ-OUT-030 | TC-U017 | Covered | | REQ-OUT-040 | TC-U009, TC-U010, TC-U018 | Covered | -| REQ-OUT-050 | TC-U009, TC-U010, TC-U041, TC-U057, TC-U079, TC-U128, TC-U146 | Covered | +| REQ-OUT-050 | TC-U009, TC-U010, TC-U041, TC-U057, TC-U079, TC-U128, TC-U146, TC-U154, TC-U156 | Covered | | REQ-OUT-060 | TC-U011 | Covered | | REQ-OUT-070 | TC-U012 | Covered | | REQ-OUT-080 | TC-U014, TC-U015 | Covered | @@ -1614,11 +1650,14 @@ dedicated test class or `Describe` block. | REQ-CIN-110 | TC-U076, TC-U078, TC-U151 | Covered | | REQ-CIN-120 | TC-U150, TC-U152, TC-U153 | Covered | | REQ-CIN-130 | TC-U150 | Covered | -| REQ-SPR-010 | TC-U121, TC-U122, TC-U123 | Covered | +| REQ-SPR-010 | TC-U121, TC-U122, TC-U123, TC-U154 | Covered | | REQ-SPR-020 | TC-U121 | Covered | | REQ-SPR-030 | TC-U124 | Covered | +| REQ-SPR-035 | TC-U156 | Covered | | REQ-SPR-040 | TC-U125 | Covered | | REQ-SPR-050 | TC-U131 (via TC-U121, TC-U124) | Covered | +| REQ-SPR-060 | TC-U154, TC-U156 | Covered | +| REQ-SPR-070 | TC-U154, TC-U155, TC-U156, TC-U157 | Covered | | REQ-SPP-010 | TC-U139, TC-U140, TC-U141 | Covered | | REQ-SPP-020 | TC-U139 | Covered | | REQ-SPP-030 | TC-U142 | Covered | @@ -1662,7 +1701,7 @@ dedicated test class or `Describe` block. | REQ-XC-TLS-070 | TC-U095, TC-U096 | Covered | | REQ-XC-TLS-080 | TC-U090, TC-U097 | Covered | -**Total:** 117 test case IDs — 91 in behavioural test classes, 26 in the utility +**Total:** 121 test case IDs — 95 in behavioural test classes, 26 in the utility index (tested transitively through higher-level behavioural tests). --- diff --git a/go.mod b/go.mod index 7f69546..6c5216a 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.25.5 require ( github.com/dcm-project/catalog-manager v0.0.0-20260408124701-1315c44e39b9 github.com/dcm-project/policy-manager v0.0.0-20260310132113-15bd45617e87 - github.com/dcm-project/service-provider-manager v0.0.0-20260324094657-8aad860d86d2 + github.com/dcm-project/service-provider-manager v0.0.0-20260402145323-bf3185a968d6 github.com/onsi/ginkgo/v2 v2.28.1 github.com/onsi/gomega v1.39.1 github.com/spf13/cobra v1.10.2 diff --git a/go.sum b/go.sum index f31451f..62abfde 100644 --- a/go.sum +++ b/go.sum @@ -12,8 +12,8 @@ github.com/dcm-project/catalog-manager v0.0.0-20260408124701-1315c44e39b9 h1:+J3 github.com/dcm-project/catalog-manager v0.0.0-20260408124701-1315c44e39b9/go.mod h1:Xx+nYzmOFKpo0nlSHe3/jHVz3t2dIhN3ov3w+8P2jjU= github.com/dcm-project/policy-manager v0.0.0-20260310132113-15bd45617e87 h1:IgIFK8eWeNHLloVuwbGZLzun8LHA6d5nqVrct7nB+S8= github.com/dcm-project/policy-manager v0.0.0-20260310132113-15bd45617e87/go.mod h1:a9eT8Ws0Gy/6FJGp+dWmrB4s/hyfVE0PQPats/aQW0E= -github.com/dcm-project/service-provider-manager v0.0.0-20260324094657-8aad860d86d2 h1:A0AJ0Yog5w34xA2JSjeEKkehQn7kqObala8IVX6OjkM= -github.com/dcm-project/service-provider-manager v0.0.0-20260324094657-8aad860d86d2/go.mod h1:c2guzDY66gCS9WeqyjsKYLsS7yr17wOvwDku6m8RfxU= +github.com/dcm-project/service-provider-manager v0.0.0-20260402145323-bf3185a968d6 h1:chOdC2Aq4wYBPwewSBZvE8nLQtllhqBTGIcVd9VfUG4= +github.com/dcm-project/service-provider-manager v0.0.0-20260402145323-bf3185a968d6/go.mod h1:enkKEIkI/KahXsXWW/hrWYAIFVy1VkpYSlCMRrOE8Qo= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= diff --git a/internal/commands/helpers.go b/internal/commands/helpers.go index f76def3..ca09d6a 100644 --- a/internal/commands/helpers.go +++ b/internal/commands/helpers.go @@ -14,7 +14,7 @@ import ( "time" catalogclient "github.com/dcm-project/catalog-manager/pkg/client" - spmclient "github.com/dcm-project/service-provider-manager/pkg/client" + spmclient "github.com/dcm-project/service-provider-manager/pkg/client/provider" sprmclient "github.com/dcm-project/service-provider-manager/pkg/client/resource_manager" "github.com/dcm-project/cli/internal/config" diff --git a/internal/commands/sp_provider.go b/internal/commands/sp_provider.go index c49fd6c..323e483 100644 --- a/internal/commands/sp_provider.go +++ b/internal/commands/sp_provider.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - spmapi "github.com/dcm-project/service-provider-manager/api/v1alpha1" + spmapi "github.com/dcm-project/service-provider-manager/api/v1alpha1/provider" "github.com/dcm-project/cli/internal/config" "github.com/dcm-project/cli/internal/output" diff --git a/internal/commands/sp_resource.go b/internal/commands/sp_resource.go index ed2fd44..ff39f2a 100644 --- a/internal/commands/sp_resource.go +++ b/internal/commands/sp_resource.go @@ -28,6 +28,23 @@ var spResourceTableDef = &output.TableDef{ }, } +var spResourceWithDeletedTableDef = &output.TableDef{ + Headers: []string{"ID", "PROVIDER", "STATUS", "DELETION STATUS", "CREATED"}, + RowFunc: func(resource any) []string { + m, ok := resource.(map[string]any) + if !ok { + return []string{"", "", "", "", ""} + } + return []string{ + stringifyValue(m, "id"), + stringifyValue(m, "provider_name"), + stringifyValue(m, "status"), + stringifyValue(m, "deletion_status"), + stringifyValue(m, "create_time"), + } + }, +} + func newSPResourceCommand() *cobra.Command { cmd := &cobra.Command{ Use: "resource", @@ -52,7 +69,14 @@ func newSPResourceListCommand() *cobra.Command { listCmd += fmt.Sprintf(" --page-size %d", pageSize) } - formatter, err := newFormatter(cmd, spResourceTableDef, listCmd) + showDeleted, _ := cmd.Flags().GetBool("show-deleted") + + tableDef := spResourceTableDef + if showDeleted { + tableDef = spResourceWithDeletedTableDef + } + + formatter, err := newFormatter(cmd, tableDef, listCmd) if err != nil { return err } @@ -68,6 +92,9 @@ func newSPResourceListCommand() *cobra.Command { if provider, _ := cmd.Flags().GetString("provider"); provider != "" { params.Provider = &provider } + if showDeleted { + params.ShowDeleted = &showDeleted + } client, err := newSPResourceClient(cfg) if err != nil { @@ -107,22 +134,36 @@ func newSPResourceListCommand() *cobra.Command { cmd.Flags().Int32("page-size", 0, "Maximum results per page") cmd.Flags().String("page-token", "", "Token for next page") cmd.Flags().String("provider", "", "Filter by provider") + cmd.Flags().Bool("show-deleted", false, "Include soft-deleted resources") return cmd } func newSPResourceGetCommand() *cobra.Command { - return &cobra.Command{ + cmd := &cobra.Command{ Use: "get INSTANCE_ID", Short: "Get an SP resource by ID", Args: ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { cfg := config.FromCommand(cmd) - formatter, err := newFormatter(cmd, spResourceTableDef, "sp resource get") + + showDeleted, _ := cmd.Flags().GetBool("show-deleted") + + tableDef := spResourceTableDef + if showDeleted { + tableDef = spResourceWithDeletedTableDef + } + + formatter, err := newFormatter(cmd, tableDef, "sp resource get") if err != nil { return err } + params := &sprmapi.GetInstanceParams{} + if showDeleted { + params.ShowDeleted = &showDeleted + } + client, err := newSPResourceClient(cfg) if err != nil { return fmt.Errorf("creating SP resource client: %w", err) @@ -131,7 +172,7 @@ func newSPResourceGetCommand() *cobra.Command { ctx, cancel := requestContext(cmd) defer cancel() - resp, err := client.GetInstance(ctx, args[0]) + resp, err := client.GetInstance(ctx, args[0], params) if err != nil { return connectionError(err, cfg) } @@ -149,4 +190,8 @@ func newSPResourceGetCommand() *cobra.Command { return formatter.FormatOne(result) }, } + + cmd.Flags().Bool("show-deleted", false, "Show soft-deleted resource") + + return cmd } diff --git a/internal/commands/sp_resource_test.go b/internal/commands/sp_resource_test.go index 5488880..096c89e 100644 --- a/internal/commands/sp_resource_test.go +++ b/internal/commands/sp_resource_test.go @@ -25,6 +25,19 @@ func sampleSPResourceResponse() map[string]any { } } +// sampleDeletedSPResourceResponse returns a sample soft-deleted SP resource JSON response body. +func sampleDeletedSPResourceResponse() map[string]any { + return map[string]any{ + "id": "deleted-instance", + "path": "service-type-instances/deleted-instance", + "provider_name": "kubevirt-123", + "status": "DELETED", + "deletion_status": "PENDING", + "create_time": "2026-03-09T10:00:00Z", + "spec": map[string]any{}, + } +} + // emptySPResourceListResponse returns a standard empty SP resource list response body. func emptySPResourceListResponse() map[string]any { return map[string]any{ @@ -128,6 +141,45 @@ var _ = Describe("SP Resource Commands", func() { Expect(err).NotTo(HaveOccurred()) }) + It("should pass show_deleted query parameter", func() { + server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + Expect(r.URL.Query().Get("show_deleted")).To(Equal("true")) + + writeJSONResponse(w, http.StatusOK, map[string]any{ + "instances": []any{sampleSPResourceResponse(), sampleDeletedSPResourceResponse()}, + "next_page_token": "", + }) + })) + + err := executeCommand("sp", "resource", "list", "--show-deleted") + Expect(err).NotTo(HaveOccurred()) + + out := outBuf.String() + Expect(out).To(ContainSubstring("DELETION STATUS")) + Expect(out).To(ContainSubstring("my-instance")) + Expect(out).To(ContainSubstring("deleted-instance")) + Expect(out).To(ContainSubstring("PENDING")) + }) + + It("should not include deletion status column without --show-deleted", func() { + server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + Expect(r.URL.Query().Get("show_deleted")).To(BeEmpty()) + + writeJSONResponse(w, http.StatusOK, map[string]any{ + "instances": []any{sampleSPResourceResponse()}, + "next_page_token": "", + }) + })) + + err := executeCommand("sp", "resource", "list") + Expect(err).NotTo(HaveOccurred()) + + out := outBuf.String() + Expect(out).NotTo(ContainSubstring("DELETION STATUS")) + Expect(out).To(ContainSubstring("my-instance")) + Expect(out).ToNot(ContainSubstring("deleted-instance")) + }) + // TC-U126: List SP resources returns empty list It("TC-U126: should display empty result for empty list", func() { server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) { @@ -179,6 +231,37 @@ var _ = Describe("SP Resource Commands", func() { Expect(out).To(ContainSubstring("READY")) }) + It("should pass show_deleted query parameter on get", func() { + server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + Expect(r.URL.Query().Get("show_deleted")).To(Equal("true")) + + writeJSONResponse(w, http.StatusOK, sampleDeletedSPResourceResponse()) + })) + + err := executeCommand("sp", "resource", "get", "deleted-instance", "--show-deleted") + Expect(err).NotTo(HaveOccurred()) + + out := outBuf.String() + Expect(out).To(ContainSubstring("DELETION STATUS")) + Expect(out).To(ContainSubstring("deleted-instance")) + Expect(out).To(ContainSubstring("PENDING")) + }) + + It("should not include deletion status column on get without --show-deleted", func() { + server = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + Expect(r.URL.Query().Get("show_deleted")).To(BeEmpty()) + + writeJSONResponse(w, http.StatusOK, sampleSPResourceResponse()) + })) + + err := executeCommand("sp", "resource", "get", "my-instance") + Expect(err).NotTo(HaveOccurred()) + + out := outBuf.String() + Expect(out).NotTo(ContainSubstring("DELETION STATUS")) + Expect(out).To(ContainSubstring("my-instance")) + }) + // TC-U125: Get SP resource without INSTANCE_ID fails It("TC-U125: should return a UsageError when INSTANCE_ID is missing", func() { err := executeCommand("sp", "resource", "get")