Skip to content

Commit

Permalink
Merge pull request #18 from gm-data/master
Browse files Browse the repository at this point in the history
  • Loading branch information
skyscrapr authored Dec 5, 2023
2 parents 3e512e1 + 3f7ec9d commit 90257fa
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cloudability/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ func (e ContainersEndpoint) GetCluster(id string) (*Cluster, error) {
return nil, err
}

// GetClusterConfig - Get an existing cluster config by ID
func (e ContainersEndpoint) GetClusterConfig(id string) (string, error) {
var result string
err := e.get(e, "provisioning/"+id+"/config", &result)
if err != nil {
return "", err
}
return result, nil
}

// NewCluster - Create a new cluster.
func (e *ContainersEndpoint) NewCluster(clusterProvisioning *Cluster) (*Cluster, error) {
clusterProvisioningPayload := new(clusterPayload)
Expand Down
29 changes: 29 additions & 0 deletions cloudability/containers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,35 @@ func TestGetCluster(t *testing.T) {
}
}

func TestGetClusterConfig(t *testing.T) {
mockYAML := `
apiVersion: v1
kind: Namespace
metadata:
name: cloudability
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: cloudability
namespace: cloudability
`

testServer := testAPI(t, "GET", "/containers/provisioning/1/config", mockYAML)
defer testServer.Close()

testClient := NewClient("testapikey")
e := testClient.Containers()
e.BaseURL, _ = url.Parse(testServer.URL)
config, err := e.GetClusterConfig("1")
if err != nil {
t.Fail()
}
if config != mockYAML {
t.Fail()
}
}

func TestNewCluster(t *testing.T) {
cluster := &Cluster{
ClusterName: "test-cluster-name",
Expand Down

0 comments on commit 90257fa

Please sign in to comment.