From 159399ba3aa62861b14d1841f720a5709a79aa23 Mon Sep 17 00:00:00 2001 From: David Dymko Date: Mon, 18 Oct 2021 11:55:39 -0400 Subject: [PATCH 1/2] add tag support for nodepools --- kubernetes.go | 5 ++++- kubernetes_test.go | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/kubernetes.go b/kubernetes.go index 509e156..16ec40d 100644 --- a/kubernetes.go +++ b/kubernetes.go @@ -62,6 +62,7 @@ type NodePool struct { PlanID string `json:"plan_id"` Status string `json:"status"` Count int `json:"count"` + Tag string `json:"tag"` Nodes []Node `json:"nodes"` } @@ -96,11 +97,13 @@ type NodePoolReq struct { NodeQuantity int `json:"node_quantity"` Label string `json:"label"` Plan string `json:"plan"` + Tag string `json:"tag"` } // NodePoolReqUpdate struct used to update a node pool type NodePoolReqUpdate struct { - NodeQuantity int `json:"node_quantity"` + NodeQuantity int `json:"node_quantity"` + Tag string `json:"tag,omitempty"` } type vkeClustersBase struct { diff --git a/kubernetes_test.go b/kubernetes_test.go index 5edab58..c2a206e 100644 --- a/kubernetes_test.go +++ b/kubernetes_test.go @@ -216,6 +216,7 @@ func TestKubernetesHandler_ListClusters(t *testing.T) { "plan_id": "vc2-1c-2gb", "status": "pending", "count": 1, + "tag": "mytag", "nodes": [ { "id": "38364f79-17e3-4f1f-b7df-d9494bce0e4a", @@ -264,6 +265,7 @@ func TestKubernetesHandler_ListClusters(t *testing.T) { PlanID: "vc2-1c-2gb", Status: "pending", Count: 1, + Tag: "mytag", Nodes: []Node{ { ID: "38364f79-17e3-4f1f-b7df-d9494bce0e4a", @@ -354,6 +356,7 @@ func TestKubernetesHandler_CreateNodePool(t *testing.T) { "label": "nodepool-48959140", "plan_id": "vc2-1c-2gb", "status": "pending", + "tag": "mytag", "count": 1, "nodes": [ { @@ -372,6 +375,7 @@ func TestKubernetesHandler_CreateNodePool(t *testing.T) { NodeQuantity: 1, Label: "nodepool-48959140", Plan: "vc2-1c-2gb", + Tag: "mytag", } np, err := client.Kubernetes.CreateNodePool(ctx, "1", createReq) if err != nil { @@ -385,6 +389,7 @@ func TestKubernetesHandler_CreateNodePool(t *testing.T) { PlanID: "vc2-1c-2gb", Status: "pending", Count: 1, + Tag: "mytag", Nodes: []Node{ { ID: "3e1ca1e0-25be-4977-907a-3dee42b9bb15", @@ -420,6 +425,7 @@ func TestKubernetesHandler_GetNodePool(t *testing.T) { "plan_id": "vc2-1c-2gb", "status": "pending", "count": 1, + "tag": "mytag", "nodes": [ { "id": "3e1ca1e0-25be-4977-907a-3dee42b9bb15", @@ -445,6 +451,7 @@ func TestKubernetesHandler_GetNodePool(t *testing.T) { PlanID: "vc2-1c-2gb", Status: "pending", Count: 1, + Tag: "mytag", Nodes: []Node{ { ID: "3e1ca1e0-25be-4977-907a-3dee42b9bb15", @@ -480,6 +487,7 @@ func TestKubernetesHandler_ListNodePools(t *testing.T) { "plan_id": "vc2-1c-2gb", "status": "pending", "count": 1, + "tag": "mytag", "nodes": [ { "id": "3e1ca1e0-25be-4977-907a-3dee42b9bb15", @@ -513,6 +521,7 @@ func TestKubernetesHandler_ListNodePools(t *testing.T) { PlanID: "vc2-1c-2gb", Status: "pending", Count: 1, + Tag: "mytag", Nodes: []Node{ { ID: "3e1ca1e0-25be-4977-907a-3dee42b9bb15", @@ -562,6 +571,7 @@ func TestKubernetesHandler_UpdateNodePool(t *testing.T) { "plan_id": "vc2-1c-2gb", "status": "active", "count": 1, + "tag": "mytag", "nodes": [ { "id": "f2e11430-76e5-4dc6-a1c9-ef5682c21ddf", @@ -588,6 +598,7 @@ func TestKubernetesHandler_UpdateNodePool(t *testing.T) { PlanID: "vc2-1c-2gb", Status: "active", Count: 1, + Tag: "mytag", Nodes: []Node{ { ID: "f2e11430-76e5-4dc6-a1c9-ef5682c21ddf", From e5dd8b35b49a9b97d2e7622ebe4b92ad0a113500 Mon Sep 17 00:00:00 2001 From: David Dymko Date: Mon, 18 Oct 2021 14:15:12 -0400 Subject: [PATCH 2/2] omitempty for node quantity --- kubernetes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kubernetes.go b/kubernetes.go index a48f149..9fdc800 100644 --- a/kubernetes.go +++ b/kubernetes.go @@ -102,7 +102,7 @@ type NodePoolReq struct { // NodePoolReqUpdate struct used to update a node pool type NodePoolReqUpdate struct { - NodeQuantity int `json:"node_quantity"` + NodeQuantity int `json:"node_quantity,omitempty"` Tag string `json:"tag,omitempty"` }