Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for nodepool labels #296

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 21 additions & 19 deletions kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,19 @@ type Cluster struct {

// NodePool represents a pool of nodes that are grouped by their label and plan type
type NodePool struct {
ID string `json:"id"`
DateCreated string `json:"date_created"`
DateUpdated string `json:"date_updated"`
Label string `json:"label"`
Plan string `json:"plan"`
Status string `json:"status"`
NodeQuantity int `json:"node_quantity"`
MinNodes int `json:"min_nodes"`
MaxNodes int `json:"max_nodes"`
AutoScaler bool `json:"auto_scaler"`
Tag string `json:"tag"`
Nodes []Node `json:"nodes"`
ID string `json:"id"`
DateCreated string `json:"date_created"`
DateUpdated string `json:"date_updated"`
Label string `json:"label"`
Plan string `json:"plan"`
Status string `json:"status"`
NodeQuantity int `json:"node_quantity"`
MinNodes int `json:"min_nodes"`
MaxNodes int `json:"max_nodes"`
AutoScaler bool `json:"auto_scaler"`
Tag string `json:"tag"`
Labels map[string]string `json:"labels"`
Nodes []Node `json:"nodes"`
}

// Node represents a node that will live within a nodepool
Expand Down Expand Up @@ -104,13 +105,14 @@ type ClusterReqUpdate struct {

// NodePoolReq struct used to create a node pool
type NodePoolReq struct {
NodeQuantity int `json:"node_quantity"`
Label string `json:"label"`
Plan string `json:"plan"`
Tag string `json:"tag"`
MinNodes int `json:"min_nodes,omitempty"`
MaxNodes int `json:"max_nodes,omitempty"`
AutoScaler *bool `json:"auto_scaler"`
NodeQuantity int `json:"node_quantity"`
Label string `json:"label"`
Plan string `json:"plan"`
Tag string `json:"tag"`
MinNodes int `json:"min_nodes,omitempty"`
MaxNodes int `json:"max_nodes,omitempty"`
AutoScaler *bool `json:"auto_scaler"`
Labels map[string]string `json:"labels,omitempty"`
}

// NodePoolReqUpdate struct used to update a node pool
Expand Down
12 changes: 12 additions & 0 deletions kubernetes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,10 @@ func TestKubernetesHandler_CreateNodePool(t *testing.T) {
"max_nodes": 2,
"auto_scaler": true,
"tag": "mytag",
"labels": {
"vultr.com/label1": "value1",
"vultr.com/label2": "value2"
},
"nodes": [
{
"id": "3e1ca1e0-25be-4977-907a-3dee42b9bb15",
Expand All @@ -396,6 +400,10 @@ func TestKubernetesHandler_CreateNodePool(t *testing.T) {
Label: "nodepool-48959140",
Plan: "vc2-1c-2gb",
Tag: "mytag",
Labels: map[string]string{
"vultr.com/label1": "value1",
"vultr.com/label2": "value2",
},
}
np, _, err := client.Kubernetes.CreateNodePool(ctx, "1", createReq)
if err != nil {
Expand All @@ -413,6 +421,10 @@ func TestKubernetesHandler_CreateNodePool(t *testing.T) {
MaxNodes: 2,
AutoScaler: true,
Tag: "mytag",
Labels: map[string]string{
"vultr.com/label1": "value1",
"vultr.com/label2": "value2",
},
Nodes: []Node{
{
ID: "3e1ca1e0-25be-4977-907a-3dee42b9bb15",
Expand Down