-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcluster.go
More file actions
62 lines (49 loc) · 1.3 KB
/
cluster.go
File metadata and controls
62 lines (49 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package codefresh
import "fmt"
type (
IClusterAPI interface {
GetClusterCredentialsByAccountId(selector string) (*Cluster, error)
GetAccountClusters() ([]*ClusterMinified, error)
}
cluster struct {
codefresh *codefresh
}
Cluster struct {
Auth struct {
Bearer string
} `json:"auth"`
Ca string `json:"ca"`
Url string `json:"url"`
}
ClusterMinified struct {
Cluster struct {
Name string `json:"name"`
} `json:"cluster"`
BehindFirewall bool `json:"behindFirewall"`
Selector string `json:"selector"`
Provider string `json:"provider"`
}
)
func newClusterAPI(codefresh *codefresh) IClusterAPI {
return &cluster{codefresh}
}
func (p *cluster) GetClusterCredentialsByAccountId(selector string) (*Cluster, error) {
r := &Cluster{}
resp, err := p.codefresh.requestAPI(&requestOptions{
path: fmt.Sprintf("/api/clusters/%s/credentials", selector),
method: "GET",
})
err = p.codefresh.decodeResponseInto(resp, &r)
defer resp.Body.Close()
return r, err
}
func (p *cluster) GetAccountClusters() ([]*ClusterMinified, error) {
r := make([]*ClusterMinified, 0)
resp, err := p.codefresh.requestAPI(&requestOptions{
path: fmt.Sprintf("/api/clusters"),
method: "GET",
})
err = p.codefresh.decodeResponseInto(resp, &r)
defer resp.Body.Close()
return r, err
}