Skip to content

Commit

Permalink
Merge pull request #7 from symbiosis-cloud/09-02-autoscaler-changes
Browse files Browse the repository at this point in the history
added is highly available and listing nodes on cluster response
  • Loading branch information
thecodeassassin authored Sep 7, 2022
2 parents 4dc00ac + ea6f38b commit e247c18
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 15 deletions.
3 changes: 2 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package symbiosis
import (
"encoding/json"
"errors"

"github.com/go-resty/resty/v2"

"reflect"
Expand Down Expand Up @@ -77,7 +78,7 @@ func newHttpClient(opts ...ClientOption) *resty.Client {
SetHostURL(APIEndpoint).
SetHeader("Content-Type", "application/json").
SetHeader("Accept", "application/json").
SetTimeout(time.Second * 10)
SetTimeout(time.Second * 90)

for _, opt := range opts {
opt(httpClient)
Expand Down
15 changes: 6 additions & 9 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ import (
"time"
)

type ClusterConfigurationInput struct {
EnableNginxIngress bool `json:"nginxIngress"`
}

type ClusterInput struct {
Name string `json:"name"`
KubeVersion string `json:"kubeVersion"`
Region string `json:"regionName"`
Nodes []ClusterNodeInput `json:"nodes"`
Configuration ClusterConfigurationInput `json:"configuration"`
Name string `json:"name"`
KubeVersion string `json:"kubeVersion"`
Region string `json:"regionName"`
Nodes []ClusterNodeInput `json:"nodes"`
IsHighlyAvailable bool `json:"isHighlyAvailable"`
}

type ClusterNodeInput struct {
Expand All @@ -31,6 +27,7 @@ type Cluster struct {
Nodes []*Node `json:"nodes"`
NodePools []*NodePool `json:"nodePools"`
CreatedAt time.Time `json:"createdAt"`
IsHighlyAvailable bool `json:"isHighlyAvailable"`
}

type ClusterList struct {
Expand Down
10 changes: 5 additions & 5 deletions cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const clusterJSON = `
"kubeVersion": "1.23.5",
"apiServerEndpoint": "does.not.matter",
"state": "ACTIVE",
"isHighlyAvailable": true,
"nodes": [
{
"id": "19fc97a5-30de-4f35-8b28-a14bf640b557",
Expand Down Expand Up @@ -176,18 +177,17 @@ func TestCreateCluster(t *testing.T) {
NodeType: "general-int-1",
},
},
KubeVersion: "1.23.5",
Region: "germany-1",
Configuration: ClusterConfigurationInput{
EnableNginxIngress: false,
},
KubeVersion: "1.23.5",
Region: "germany-1",
IsHighlyAvailable: true,
}

cluster, err := c.Cluster.Create(ClusterInput)

assert.Nil(t, err)
assert.Equal(t, fakeCluster, cluster)
assert.Equal(t, ClusterInput.Name, fakeCluster.Name)
assert.Equal(t, true, cluster.IsHighlyAvailable)

for _, node := range fakeCluster.Nodes {
assert.Equal(t, node.NodeType.Name, ClusterInput.Nodes[0].NodeType)
Expand Down
1 change: 1 addition & 0 deletions node_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type NodePool struct {
DesiredQuantity int `json:"desiredQuantity"`
Labels []NodeLabel `json:"labels"`
Taints []NodeTaint `json:"taints"`
Nodes []Node `json:"nodes"`
}

type NodePoolService struct {
Expand Down
33 changes: 33 additions & 0 deletions node_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,38 @@ const nodePoolJSON = `
"value": "encoding",
"effect": "NoSchedule"
}
],
"nodes": [
{
"id": "test",
"nodePoolId": "test",
"name": "general-1-wripks",
"nodeType": {
"id": "test",
"name": "general-1",
"memoryMi": 2048,
"storageGi": 20,
"vcpu": 1,
"product": {
"productCosts": [
{
"currency": "USD",
"unitCost": 6.00
}
]
}
},
"region": {
"id": "fdcabb92-3557-48e6-a7f5-984251295303",
"name": "germany-1"
},
"privateIPv4Address": "10.128.0.2",
"state": "ACTIVE",
"kubeState": "READY",
"kubeVersion": "1.23.9",
"priority": 1,
"createdAt": "2022-09-01T12:47:51.109104Z"
}
]
}`

Expand All @@ -56,6 +88,7 @@ func TestDescribeNodePool(t *testing.T) {
assert.Equal(t, fakeNodePool.Taints[0].Effect, EFFECT_NO_SCHEDULE)
assert.Equal(t, fakeNodePool.Taints[0].Key, "type")
assert.Equal(t, fakeNodePool.Taints[0].Value, "encoding")
assert.Equal(t, fakeNodePool.Nodes[0].Name, "general-1-wripks")

responder = httpmock.NewErrorResponder(assert.AnError)
httpmock.RegisterResponder("GET", fakeURL, responder)
Expand Down

0 comments on commit e247c18

Please sign in to comment.