File tree Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Expand file tree Collapse file tree 2 files changed +61
-0
lines changed Original file line number Diff line number Diff line change
1
+ package codefresh
2
+
3
+ import "fmt"
4
+
5
+ type (
6
+ IClusterAPI interface {
7
+ GetClusterCredentialsByAccountId (selector string ) (* Cluster , error )
8
+ GetAccountClusters () ([]* ClusterMinified , error )
9
+ }
10
+
11
+ cluster struct {
12
+ codefresh Codefresh
13
+ }
14
+
15
+ Cluster struct {
16
+ Auth struct {
17
+ Bearer string
18
+ } `json:"auth"`
19
+ Ca string `json:"ca"`
20
+ Url string `json:"url"`
21
+ }
22
+
23
+ ClusterMinified struct {
24
+ Cluster struct {
25
+ Name string `json:"name"`
26
+ } `json:"cluster"`
27
+
28
+ BehindFirewall bool `json:"behindFirewall"`
29
+ Selector string `json:"selector"`
30
+ Provider string `json:"provider"`
31
+ }
32
+ )
33
+
34
+ func newClusterAPI (codefresh Codefresh ) IClusterAPI {
35
+ return & cluster {codefresh }
36
+ }
37
+
38
+ func (p * cluster ) GetClusterCredentialsByAccountId (selector string ) (* Cluster , error ) {
39
+ r := & Cluster {}
40
+ resp , err := p .codefresh .requestAPI (& requestOptions {
41
+ path : fmt .Sprintf ("/api/clusters/%s/credentials" , selector ),
42
+ method : "GET" ,
43
+ })
44
+ err = p .codefresh .decodeResponseInto (resp , & r )
45
+ return r , err
46
+ }
47
+
48
+ func (p * cluster ) GetAccountClusters () ([]* ClusterMinified , error ) {
49
+ r := make ([]* ClusterMinified , 0 )
50
+ resp , err := p .codefresh .requestAPI (& requestOptions {
51
+ path : fmt .Sprintf ("/api/clusters" ),
52
+ method : "GET" ,
53
+ })
54
+ err = p .codefresh .decodeResponseInto (resp , & r )
55
+ return r , err
56
+ }
Original file line number Diff line number Diff line change 20
20
RuntimeEnvironments () IRuntimeEnvironmentAPI
21
21
Workflows () IWorkflowAPI
22
22
Progresses () IProgressAPI
23
+ Clusters () IClusterAPI
23
24
}
24
25
)
25
26
@@ -56,6 +57,10 @@ func (c *codefresh) Progresses() IProgressAPI {
56
57
return newProgressAPI (c )
57
58
}
58
59
60
+ func (c * codefresh ) Clusters () IClusterAPI {
61
+ return newClusterAPI (c )
62
+ }
63
+
59
64
func (c * codefresh ) requestAPI (opt * requestOptions ) (* http.Response , error ) {
60
65
var body []byte
61
66
finalURL := fmt .Sprintf ("%s%s" , c .host , opt .path )
You can’t perform that action at this time.
0 commit comments