Skip to content

Commit

Permalink
kubernetes: add name field to associated resources (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
MorrisLaw authored Feb 17, 2021
1 parent f07b337 commit 40f38d9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 9 deletions.
12 changes: 9 additions & 3 deletions kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,15 @@ type ClusterlintOwner struct {

// KubernetesAssociatedResources represents a cluster's associated resources
type KubernetesAssociatedResources struct {
Volumes []string `json:"volumes"`
VolumeSnapshots []string `json:"volume_snapshots"`
LoadBalancers []string `json:"load_balancers"`
Volumes []*AssociatedResource `json:"volumes"`
VolumeSnapshots []*AssociatedResource `json:"volume_snapshots"`
LoadBalancers []*AssociatedResource `json:"load_balancers"`
}

// AssociatedResource is the object to represent a Kubernetes cluster associated resource's Id and Name.
type AssociatedResource struct {
ID string `json:"id"`
Name string `json:"name"`
}

type kubernetesClustersRoot struct {
Expand Down
45 changes: 39 additions & 6 deletions kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1013,15 +1013,48 @@ func TestKubernetesClusters_ListAssociatedResourcesForDeletion(t *testing.T) {

kubeSvc := client.Kubernetes
expectedRes := &KubernetesAssociatedResources{
Volumes: []string{"2241"},
VolumeSnapshots: []string{"2425"},
LoadBalancers: []string{"4235"},
Volumes: []*AssociatedResource{
{
ID: "2241",
Name: "test-volume-1",
},
},
VolumeSnapshots: []*AssociatedResource{
{
ID: "2425",
Name: "test-volume-snapshot-1",
},
},
LoadBalancers: []*AssociatedResource{
{
ID: "4235",
Name: "test-load-balancer-1",
},
},
}
jBlob := `
{
"volumes": ["2241"],
"volume_snapshots": ["2425"],
"load_balancers": ["4235"]
"volumes":
[
{
"id": "2241",
"name":"test-volume-1"
}
],
"volume_snapshots":
[
{
"id":"2425",
"name":"test-volume-snapshot-1"
}
],
"load_balancers":
[
{
"id":"4235",
"name":"test-load-balancer-1"
}
]
}
`

Expand Down

0 comments on commit 40f38d9

Please sign in to comment.