6
6
"github.com/cloudbase/garm/client"
7
7
clientControllerInfo "github.com/cloudbase/garm/client/controller_info"
8
8
clientCredentials "github.com/cloudbase/garm/client/credentials"
9
+ clientEndpoints "github.com/cloudbase/garm/client/endpoints"
9
10
clientFirstRun "github.com/cloudbase/garm/client/first_run"
10
11
clientInstances "github.com/cloudbase/garm/client/instances"
11
12
clientJobs "github.com/cloudbase/garm/client/jobs"
@@ -18,9 +19,7 @@ import (
18
19
"github.com/cloudbase/garm/params"
19
20
)
20
21
21
- // ///////////
22
- // Garm Init /
23
- // ///////////
22
+ // firstRun will initialize a new garm installation.
24
23
func firstRun (apiCli * client.GarmAPI , newUser params.NewUserParams ) (params.User , error ) {
25
24
firstRunResponse , err := apiCli .FirstRun .FirstRun (
26
25
clientFirstRun .NewFirstRunParams ().WithBody (newUser ),
@@ -41,9 +40,7 @@ func login(apiCli *client.GarmAPI, params params.PasswordLoginParams) (string, e
41
40
return loginResponse .Payload .Token , nil
42
41
}
43
42
44
- // ////////////////////////////
45
- // Credentials and Providers //
46
- // ////////////////////////////
43
+ // listCredentials lists all the credentials configured in GARM.
47
44
func listCredentials (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter ) (params.Credentials , error ) {
48
45
listCredentialsResponse , err := apiCli .Credentials .ListCredentials (
49
46
clientCredentials .NewListCredentialsParams (),
@@ -54,6 +51,69 @@ func listCredentials(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthInfo
54
51
return listCredentialsResponse .Payload , nil
55
52
}
56
53
54
+ func createGithubCredentials (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter , credentialsParams params.CreateGithubCredentialsParams ) (* params.GithubCredentials , error ) {
55
+ createCredentialsResponse , err := apiCli .Credentials .CreateCredentials (
56
+ clientCredentials .NewCreateCredentialsParams ().WithBody (credentialsParams ),
57
+ apiAuthToken )
58
+ if err != nil {
59
+ return nil , err
60
+ }
61
+ return & createCredentialsResponse .Payload , nil
62
+ }
63
+
64
+ func deleteGithubCredentials (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter , credentialsID int64 ) error {
65
+ return apiCli .Credentials .DeleteCredentials (
66
+ clientCredentials .NewDeleteCredentialsParams ().WithID (credentialsID ),
67
+ apiAuthToken )
68
+ }
69
+
70
+ func getGithubCredential (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter , credentialsID int64 ) (* params.GithubCredentials , error ) {
71
+ getCredentialsResponse , err := apiCli .Credentials .GetCredentials (
72
+ clientCredentials .NewGetCredentialsParams ().WithID (credentialsID ),
73
+ apiAuthToken )
74
+ if err != nil {
75
+ return nil , err
76
+ }
77
+ return & getCredentialsResponse .Payload , nil
78
+ }
79
+
80
+ func createGithubEndpoint (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter , endpointParams params.CreateGithubEndpointParams ) (* params.GithubEndpoint , error ) {
81
+ createEndpointResponse , err := apiCli .Endpoints .CreateGithubEndpoint (
82
+ clientEndpoints .NewCreateGithubEndpointParams ().WithBody (endpointParams ),
83
+ apiAuthToken )
84
+ if err != nil {
85
+ return nil , err
86
+ }
87
+ return & createEndpointResponse .Payload , nil
88
+ }
89
+
90
+ func listGithubEndpoints (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter ) (params.GithubEndpoints , error ) {
91
+ listEndpointsResponse , err := apiCli .Endpoints .ListGithubEndpoints (
92
+ clientEndpoints .NewListGithubEndpointsParams (),
93
+ apiAuthToken )
94
+ if err != nil {
95
+ return nil , err
96
+ }
97
+ return listEndpointsResponse .Payload , nil
98
+ }
99
+
100
+ func getGithubEndpoint (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter , endpointName string ) (* params.GithubEndpoint , error ) {
101
+ getEndpointResponse , err := apiCli .Endpoints .GetGithubEndpoint (
102
+ clientEndpoints .NewGetGithubEndpointParams ().WithName (endpointName ),
103
+ apiAuthToken )
104
+ if err != nil {
105
+ return nil , err
106
+ }
107
+ return & getEndpointResponse .Payload , nil
108
+ }
109
+
110
+ func deleteGithubEndpoint (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter , endpointName string ) error {
111
+ return apiCli .Endpoints .DeleteGithubEndpoint (
112
+ clientEndpoints .NewDeleteGithubEndpointParams ().WithName (endpointName ),
113
+ apiAuthToken )
114
+ }
115
+
116
+ // listProviders lists all the providers configured in GARM.
57
117
func listProviders (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter ) (params.Providers , error ) {
58
118
listProvidersResponse , err := apiCli .Providers .ListProviders (
59
119
clientProviders .NewListProvidersParams (),
@@ -64,9 +124,7 @@ func listProviders(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthInfoWr
64
124
return listProvidersResponse .Payload , nil
65
125
}
66
126
67
- // ////////////////////////
68
- // // Controller info ////
69
- // ////////////////////////
127
+ // getControllerInfo returns information about the GARM controller.
70
128
func getControllerInfo (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter ) (params.ControllerInfo , error ) {
71
129
controllerInfoResponse , err := apiCli .ControllerInfo .ControllerInfo (
72
130
clientControllerInfo .NewControllerInfoParams (),
@@ -77,9 +135,7 @@ func getControllerInfo(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthIn
77
135
return controllerInfoResponse .Payload , nil
78
136
}
79
137
80
- // ////////
81
- // Jobs //
82
- // ////////
138
+ // listJobs lists all the jobs configured in GARM.
83
139
func listJobs (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter ) (params.Jobs , error ) {
84
140
listJobsResponse , err := apiCli .Jobs .ListJobs (
85
141
clientJobs .NewListJobsParams (),
@@ -90,9 +146,7 @@ func listJobs(apiCli *client.GarmAPI, apiAuthToken runtime.ClientAuthInfoWriter)
90
146
return listJobsResponse .Payload , nil
91
147
}
92
148
93
- // //////////////////
94
- // / Metrics Token //
95
- // //////////////////
149
+ // getMetricsToken returns the metrics token.
96
150
func getMetricsToken (apiCli * client.GarmAPI , apiAuthToken runtime.ClientAuthInfoWriter ) (string , error ) {
97
151
getMetricsTokenResponse , err := apiCli .MetricsToken .GetMetricsToken (
98
152
clientMetricsToken .NewGetMetricsTokenParams (),
0 commit comments