This repository has been archived by the owner on Mar 14, 2024. It is now read-only.
/
apps_client.go
329 lines (269 loc) · 9.91 KB
/
apps_client.go
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
// Code generated by go-swagger; DO NOT EDIT.
package apps
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-openapi/runtime"
strfmt "github.com/go-openapi/strfmt"
)
// New creates a new apps API client.
func New(transport runtime.ClientTransport, formats strfmt.Registry) *Client {
return &Client{transport: transport, formats: formats}
}
/*
Client for apps API
*/
type Client struct {
transport runtime.ClientTransport
formats strfmt.Registry
}
/*
CreateClusterApp installs an app
Install an app on a tenant cluster by posting to this endpoint.
The spec field represents the app we'll be installing, and so spec.name refers to
the name of the chart that installs this app in the catalog.
The response you get on a succesful create includes the status of the app. However
since the App is still initialising and this is an asynchronous operation, it is
likely that the fields in this status object will be all empty values.
To check on the status of your app, perform a GET to /v4/clusters/{cluster_id}/apps/,
and check the status field of the app.
### Example PUT request
```json
{
"spec": {
"catalog": "sample-catalog",
"name": "prometheus-chart",
"namespace": "prometheus",
"version": "0.2.0",
}
}
```
### About the user_config field in the response
This field is not editable by you, but is set automatically by the API
if a configmap named `{app_name}-user-values` exists in the tenant cluster
namespace on the control plane.
The `/v4/clusters/{cluster_id}/apps/{app_name}/config/` endpoints allows
you to create such a configmap using this API.
It is recommended to create your config before creating your app. This
will result in a faster deploy.
However, you can create your config after creating the app if you wish,
this API will take care of setting the `user_config` field of the app
correctly for you.
### Why can't I just set the `user_config` value myself?
It simplifies usage while also being a security measure.
Furthermore it is also a security measure and ensures that users of this
API can't access arbitrary configmaps of the control plane.
This API will only allow you to edit or access configmaps that adhere
to a strict naming convention.
*/
func (a *Client) CreateClusterApp(params *CreateClusterAppParams, authInfo runtime.ClientAuthInfoWriter) (*CreateClusterAppOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewCreateClusterAppParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "createClusterApp",
Method: "PUT",
PathPattern: "/v4/clusters/{cluster_id}/apps/{app_name}/",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"https"},
Params: params,
Reader: &CreateClusterAppReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*CreateClusterAppOK), nil
}
/*
DeleteClusterApp deletes an app
This operation allows a user to delete an app.
*/
func (a *Client) DeleteClusterApp(params *DeleteClusterAppParams, authInfo runtime.ClientAuthInfoWriter) (*DeleteClusterAppOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewDeleteClusterAppParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "deleteClusterApp",
Method: "DELETE",
PathPattern: "/v4/clusters/{cluster_id}/apps/{app_name}/",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"https"},
Params: params,
Reader: &DeleteClusterAppReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*DeleteClusterAppOK), nil
}
/*
GetAppCatalogs gets a list of app catalogs configured on your installation
Returns an array of app catalog objects, which contains further metadata,
including a URL to fetch the full index of each catalog.
#### About the Labels
- `application.giantswarm.io/catalog-type`
Describes the type of catalog.
- `managed` - Apps in this catalog are managed by Giant Swarm.
- `incubator` - Apps in this catalog are a work in progress. They're
made with your Giant Swarm cluster in mind though, so
they should work. Feedback is appreciated on these apps.
- `test` - Apps in this catalog will soon graduate to incubator status,
you most likely will not see any `test` catalogs on your
installations.
- `community` - Apps in this catalog are provided by the kubernetes
community. They will most likely not work without making
some changes to the security settings of your cluster.
App Catalogs can also be labeled as `internal`, however these catalogs
contain apps that run on our control planes. These `internal` app catalogs
will be filtered out and never shown when calling this endpoint.
For more details on app catalogs visit: https://docs.giantswarm.io/basics/app-catalog/
### Example
```json
[
{
"metadata": {
"name": "sample-catalog",
"labels": {
"application.giantswarm.io/catalog-type": "test",
"app-operator.giantswarm.io/version": "1.0.0",
},
},
"spec": {
"description": "Giant Swarm's Sample Catalog with a few apps to test things out.",
"logoURL": "https://s.giantswarm.io/app-catalog/1/images/sample-catalog.png",
"storage": {
"URL": "https://giantswarm.github.com/sample-catalog/",
"type": "helm"
},
"title": "Sample Catalog"
}
}
]
```
*/
func (a *Client) GetAppCatalogs(params *GetAppCatalogsParams, authInfo runtime.ClientAuthInfoWriter) (*GetAppCatalogsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetAppCatalogsParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "getAppCatalogs",
Method: "GET",
PathPattern: "/v4/appcatalogs/",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"https"},
Params: params,
Reader: &GetAppCatalogsReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*GetAppCatalogsOK), nil
}
/*
GetClusterApps gets cluster apps
Returns an array of apps installed on a given cluster.
### Example
```json
[
{
"metadata": {
"name": "my-awesome-prometheus",
},
"spec": {
"catalog": "sample-catalog"
"name": "prometheus-chart",
"namespace": "giantswarm",
"version": "0.2.0",
"user_config": {
"configmap": {
"name": "prometheus-user-values",
"namespace": "123ab"
}
}
},
"status": {
"app_version": "1.0.0",
"release": {
"last_deployed": "2019-04-08T12:34:00Z",
"status": "DEPLOYED"
},
"version": "0.2.0",
}
}
]
```
*/
func (a *Client) GetClusterApps(params *GetClusterAppsParams, authInfo runtime.ClientAuthInfoWriter) (*GetClusterAppsOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewGetClusterAppsParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "getClusterApps",
Method: "GET",
PathPattern: "/v4/clusters/{cluster_id}/apps/",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"https"},
Params: params,
Reader: &GetClusterAppsReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*GetClusterAppsOK), nil
}
/*
ModifyClusterApp modifies an app
This operation allows you to modify an existing app.
The following attributes can be modified:
- `version`: Changing this field lets you upgrade or downgrade an app.
`catalog`, `name`, `namespace`, and `user_config` are not editable. If you need to move or rename an app, you should instead delete the app and make it again.
The request body must conform with the [JSON Patch Merge (RFC 7386)](https://tools.ietf.org/html/rfc7386) standard.
Requests have to be sent with the `Content-Type: application/merge-patch+json` header.
*/
func (a *Client) ModifyClusterApp(params *ModifyClusterAppParams, authInfo runtime.ClientAuthInfoWriter) (*ModifyClusterAppOK, error) {
// TODO: Validate the params before sending
if params == nil {
params = NewModifyClusterAppParams()
}
result, err := a.transport.Submit(&runtime.ClientOperation{
ID: "modifyClusterApp",
Method: "PATCH",
PathPattern: "/v4/clusters/{cluster_id}/apps/{app_name}/",
ProducesMediaTypes: []string{"application/json"},
ConsumesMediaTypes: []string{"application/json"},
Schemes: []string{"https"},
Params: params,
Reader: &ModifyClusterAppReader{formats: a.formats},
AuthInfo: authInfo,
Context: params.Context,
Client: params.HTTPClient,
})
if err != nil {
return nil, err
}
return result.(*ModifyClusterAppOK), nil
}
// SetTransport changes the transport on the client
func (a *Client) SetTransport(transport runtime.ClientTransport) {
a.transport = transport
}