Repository: kubernetes/dashboard
Pull request #5713 (2020-12-10 08:52:45)

change storageClasses to items
make the storageClasses return with items, some as pv and pvc.

![image](https://user-images.githubusercontent.com/433500/101748779-f1a71180-3b07-11eb-9645-cb5c9be86f98.png)


k8s-ci-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes/dashboard/pull/5713#" title="Author self-approved">helight</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **maciaszczykm** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @maciaszczykm` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes%2Fdashboard).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/kubernetes/dashboard/blob/master/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["maciaszczykm"]} -->
maciaszczykm: Anything new that is added to the API response structures should be used in the UI. Otherwise it is a waste of resources.
maciaszczykm: /lgtm
/approve
k8s-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/kubernetes/dashboard/pull/5713#" title="Author self-approved">helight</a>*, *<a href="https://github.com/kubernetes/dashboard/pull/5713#issuecomment-742381462" title="Approved">maciaszczykm</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=kubernetes%2Fdashboard).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/kubernetes/dashboard/blob/master/OWNERS)~~ [maciaszczykm]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
codecov[bot]: # [Codecov](https://codecov.io/gh/kubernetes/dashboard/pull/5713?src=pr&el=h1) Report
> Merging [#5713](https://codecov.io/gh/kubernetes/dashboard/pull/5713?src=pr&el=desc) (0bb3f1a) into [master](https://codecov.io/gh/kubernetes/dashboard/commit/bed43d0ff72920a19b4efff2b90e74fcae7a09f6?el=desc) (bed43d0) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/kubernetes/dashboard/pull/5713/graphs/tree.svg?width=650&height=150&src=pr&token=Wj7jysJ9A5)](https://codecov.io/gh/kubernetes/dashboard/pull/5713?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master    #5713   +/-   ##
=======================================
  Coverage   44.37%   44.37%           
=======================================
  Files         214      214           
  Lines        9124     9124           
  Branches      113      113           
=======================================
  Hits         4049     4049           
  Misses       4801     4801           
  Partials      274      274           
```


| [Impacted Files](https://codecov.io/gh/kubernetes/dashboard/pull/5713?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/app/backend/resource/storageclass/list.go](https://codecov.io/gh/kubernetes/dashboard/pull/5713/diff?src=pr&el=tree#diff-c3JjL2FwcC9iYWNrZW5kL3Jlc291cmNlL3N0b3JhZ2VjbGFzcy9saXN0Lmdv) | `92.30% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/kubernetes/dashboard/pull/5713?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/kubernetes/dashboard/pull/5713?src=pr&el=footer). Last update [bed43d0...0bb3f1a](https://codecov.io/gh/kubernetes/dashboard/pull/5713?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/src/app/backend/resource/storageclass/list.go b/src/app/backend/resource/storageclass/list.go
index 9a8dff727..7e0d3c9d6 100644
--- a/src/app/backend/resource/storageclass/list.go
+++ b/src/app/backend/resource/storageclass/list.go
@@ -27,8 +27,8 @@ import (
 
 // StorageClassList holds a list of Storage Class objects in the cluster.
 type StorageClassList struct {
-	ListMeta       api.ListMeta   `json:"listMeta"`
-	StorageClasses []StorageClass `json:"storageClasses"`
+	ListMeta api.ListMeta   `json:"listMeta"`
+	Items    []StorageClass `json:"items"`
 
 	// List of non-critical errors, that occurred during resource retrieval.
 	Errors []error `json:"errors"`
@@ -71,9 +71,9 @@ func toStorageClassList(storageClasses []storage.StorageClass, nonCriticalErrors
 	dsQuery *dataselect.DataSelectQuery) *StorageClassList {
 
 	storageClassList := &StorageClassList{
-		StorageClasses: make([]StorageClass, 0),
-		ListMeta:       api.ListMeta{TotalItems: len(storageClasses)},
-		Errors:         nonCriticalErrors,
+		Items:    make([]StorageClass, 0),
+		ListMeta: api.ListMeta{TotalItems: len(storageClasses)},
+		Errors:   nonCriticalErrors,
 	}
 
 	storageClassCells, filteredTotal := dataselect.GenericDataSelectWithFilter(toCells(storageClasses), dsQuery)
@@ -81,7 +81,7 @@ func toStorageClassList(storageClasses []storage.StorageClass, nonCriticalErrors
 	storageClassList.ListMeta = api.ListMeta{TotalItems: filteredTotal}
 
 	for _, storageClass := range storageClasses {
-		storageClassList.StorageClasses = append(storageClassList.StorageClasses, toStorageClass(&storageClass))
+		storageClassList.Items = append(storageClassList.Items, toStorageClass(&storageClass))
 	}
 
 	return storageClassList
diff --git a/src/app/frontend/common/components/resourcelist/storageclass/component.ts b/src/app/frontend/common/components/resourcelist/storageclass/component.ts
index a52e9405a..f5cb031af 100644
--- a/src/app/frontend/common/components/resourcelist/storageclass/component.ts
+++ b/src/app/frontend/common/components/resourcelist/storageclass/component.ts
@@ -50,7 +50,7 @@ export class StorageClassListComponent extends ResourceListBase<StorageClassList
   }
 
   map(storageClassList: StorageClassList): StorageClass[] {
-    return storageClassList.storageClasses;
+    return storageClassList.items;
   }
 
   getDisplayColumns(): string[] {
diff --git a/src/app/frontend/typings/backendapi.ts b/src/app/frontend/typings/backendapi.ts
index 0b7dcc867..6fd55cbde 100644
--- a/src/app/frontend/typings/backendapi.ts
+++ b/src/app/frontend/typings/backendapi.ts
@@ -207,7 +207,7 @@ export interface StatefulSetList extends ResourceList {
 }
 
 export interface StorageClassList extends ResourceList {
-  storageClasses: StorageClass[];
+  items: StorageClass[];
 }
 
 // Simple detail types


Test patch:
diff --git a/src/app/backend/resource/storageclass/list_test.go b/src/app/backend/resource/storageclass/list_test.go
index 4cdcfa355..2bcdc2497 100644
--- a/src/app/backend/resource/storageclass/list_test.go
+++ b/src/app/backend/resource/storageclass/list_test.go
@@ -44,7 +44,7 @@ func TestGetStorageClassList(t *testing.T) {
 			expectedActions: []string{"list"},
 			expected: &StorageClassList{
 				ListMeta: api.ListMeta{TotalItems: 1},
-				StorageClasses: []StorageClass{
+				Items: []StorageClass{
 					{
 						ObjectMeta: api.ObjectMeta{
 							Name:   "storage-1",