/
pluginModel.go
435 lines (412 loc) · 11.4 KB
/
pluginModel.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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
// Copyright (C) 2014-2018 Goodrain Co., Ltd.
// RAINBOND, Application Management Platform
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package model
//CreatePluginStruct CreatePluginStruct
//swagger:parameters createPlugin
type CreatePluginStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: body
Body struct {
//插件id
//in: body
//required: true
PluginID string `json:"plugin_id" validate:"plugin_id|required"`
//in: body
//required: true
PluginName string `json:"plugin_name" validate:"plugin_name|required"`
//插件用途描述
//in: body
//required: false
PluginInfo string `json:"plugin_info" validate:"plugin_info"`
// 插件docker地址
// in:body
// required: false
ImageURL string `json:"image_url" validate:"image_url"`
//git地址
//in: body
//required: false
GitURL string `json:"git_url" validate:"git_url"`
//构建模式
//in: body
//required: false
BuildModel string `json:"build_model" validate:"build_model"`
//插件模式
//in: body
//required: false
PluginModel string `json:"plugin_model" validate:"plugin_model"`
//租户id
//in: body
//required: false
TenantID string `json:"tenant_id" validate:"tenant_id"`
}
}
//UpdatePluginStruct UpdatePluginStruct
//swagger:parameters updatePlugin
type UpdatePluginStruct struct {
// 租户名称
// in: path
// required: true
TenantName string `json:"tenant_name" validate:"tenant_name|required"`
// 插件id
// in: path
// required: true
PluginID string `json:"plugin_id" validate:"tenant_name|required"`
// in: body
Body struct {
//插件名称
//in: body
//required: false
PluginName string `json:"plugin_name" validate:"plugin_name"`
//插件用途描述
//in: body
//required: false
PluginInfo string `json:"plugin_info" validate:"plugin_info"`
//插件docker地址
//in: body
//required: false
ImageURL string `json:"image_url" validate:"image_url"`
//git地址
//in: body
//required: false
GitURL string `json:"git_url" validate:"git_url"`
//构建模式
//in: body
//required: false
BuildModel string `json:"build_model" validate:"build_model"`
//插件模式
//in: body
//required: false
PluginModel string `json:"plugin_model" validate:"plugin_model"`
}
}
//DeletePluginStruct deletePluginStruct
//swagger:parameters deletePlugin
type DeletePluginStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name" validate:"tenant_name|required"`
// in: path
// required: true
PluginID string `json:"plugin_id" validate:"plugin_id|required"`
}
//ENVStruct ENVStruct
//swagger:parameters adddefaultenv updatedefaultenv
type ENVStruct struct {
// 租户名称
// in: path
// required: true
TenantName string `json:"tenant_name" validate:"tenant_name"`
// 插件id
// in: path
// required: true
PluginID string `json:"plugin_id" validate:"plugin_id"`
// 构建版本
// in: path
// required; true
VersionID string `json:"version_id" validate:"version_id"`
//in : body
Body struct {
//in: body
//required: true
EVNInfo []*PluginDefaultENV
}
}
//DeleteENVstruct DeleteENVstruct
//swagger:parameters deletedefaultenv
type DeleteENVstruct struct {
// 租户名称
// in: path
// required: true
TenantName string `json:"tenant_name" validate:"tenant_name|required"`
// 插件id
// in: path
// required: true
PluginID string `json:"plugin_id" validate:"plugin_id|required"`
// 构建版本
// in: path
// required; true
VersionID string `json:"version_id" validate:"version_id|required"`
//配置项名称
//in: path
//required: true
ENVName string `json:"env_name" validate:"env_name|required"`
}
//PluginDefaultENV 插件默认环境变量
type PluginDefaultENV struct {
//对应插件id
//in: body
//required: true
PluginID string `json:"plugin_id" validate:"plugin_id"`
//构建版本id
//in: body
//required: true
VersionID string `json:"version_id" validate:"version_id"`
//配置项名称
//in: body
//required: true
ENVName string `json:"env_name" validate:"env_name"`
//配置项值
//in: body
//required: true
ENVValue string `json:"env_value" validate:"env_value"`
//是否可以被使用者修改
//in :body
//required: false
IsChange bool `json:"is_change" validate:"is_change|bool"`
}
//BuildPluginStruct BuildPluginStruct
//swagger:parameters buildPlugin
type BuildPluginStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name" validate:"tenant_name"`
// in: path
// required: true
PluginID string `json:"plugin_id" validate:"plugin_id"`
//in: body
Body struct {
// the event id
// in: body
// required: false
EventID string `json:"event_id" validate:"event_id"`
// 插件CPU权重, 默认125
// in: body
// required: true
PluginCPU int `json:"plugin_cpu" validate:"plugin_cpu|required"`
// 插件最大内存, 默认50
// in: body
// required: true
PluginMemory int `json:"plugin_memory" validate:"plugin_memory|required"`
// 插件cmd, 默认50
// in: body
// required: false
PluginCMD string `json:"plugin_cmd" validate:"plugin_cmd"`
// 插件的版本号
// in: body
// required: true
BuildVersion string `json:"build_version" validate:"build_version|required"`
// 插件构建版本号
// in: body
// required: true
DeployVersion string `json:"deploy_version" validate:"deploy_version"`
// git地址分支信息,默认为master
// in: body
// required: false
RepoURL string `json:"repo_url" validate:"repo_url"`
// 版本信息, 协助选择插件版本
// in:body
// required: true
Info string `json:"info" validate:"info"`
// 操作人
// in: body
// required: false
Operator string `json:"operator" validate:"operator"`
//租户id
// in: body
// required: true
TenantID string `json:"tenant_id" validate:"tenant_id"`
// 镜像地址
// in: body
// required: false
BuildImage string `json:"build_image" validate:"build_image"`
//ImageInfo
ImageInfo struct {
HubURL string `json:"hub_url"`
HubUser string `json:"hub_user"`
HubPassword string `json:"hub_password"`
Namespace string `json:"namespace"`
IsTrust bool `json:"is_trust,omitempty"`
} `json:"ImageInfo" validate:"ImageInfo"`
}
}
//PluginBuildVersionStruct PluginBuildVersionStruct
//swagger:parameters deletePluginVersion pluginVersion
type PluginBuildVersionStruct struct {
//in: path
//required: true
TenantName string `json:"tenant_name" validate:"tenant_name"`
//in: path
//required: true
PluginID string `json:"plugin_id" validate:"plugin_id"`
//in: path
//required: true
VersionID string `json:"version_id" validate:"version_id"`
}
//AllPluginBuildVersionStruct AllPluginBuildVersionStruct
//swagger:parameters allPluginVersions
type AllPluginBuildVersionStruct struct {
//in: path
//required: true
TenantName string `json:"tenant_name" validate:"tenant_name"`
//in: path
//required: true
PluginID string `json:"plugin_id" validate:"plugin_id"`
}
//PluginSetStruct PluginSetStruct
//swagger:parameters updatePluginSet addPluginSet
type PluginSetStruct struct {
//in: path
//required: true
TenantName string `json:"tenant_name"`
//in: path
//required: true
ServiceAlias string `json:"service_alias"`
// in: body
Body struct {
//plugin id
//in: body
//required: true
PluginID string `json:"plugin_id" validate:"plugin_id"`
// plugin version
//in: body
//required: true
VersionID string `json:"version_id" validate:"version_id"`
// plugin is uesd
//in: body
//required: false
Switch bool `json:"switch" validate:"switch|bool"`
// plugin cpu size default 125
// in: body
// required: false
PluginCPU int `json:"plugin_cpu" validate:"plugin_cpu"`
// plugin memory size default 64
// in: body
// required: false
PluginMemory int `json:"plugin_memory" validate:"plugin_memory"`
// app plugin config
// in: body
// required: true
ConfigEnvs ConfigEnvs `json:"config_envs" validate:"config_envs"`
}
}
//GetPluginsStruct GetPluginsStruct
//swagger:parameters getPlugins
type GetPluginsStruct struct {
//in: path
//required: true
TenantName string `json:"tenant_name"`
}
//GetPluginSetStruct GetPluginSetStruct
//swagger:parameters getPluginSet
type GetPluginSetStruct struct {
//in: path
//required: true
TenantName string `json:"tenant_name"`
//in: path
//required: true
ServiceAlias string `json:"service_alias"`
}
//DeletePluginSetStruct DeletePluginSetStruct
//swagger:parameters deletePluginRelation
type DeletePluginSetStruct struct {
//in: path
//required: true
TenantName string `json:"tenant_name"`
//in: path
//required: true
ServiceAlias string `json:"service_alias"`
//插件id
//in: path
//required: true
PluginID string `json:"plugin_id"`
}
//GetPluginEnvStruct GetPluginEnvStruct
//swagger:parameters getPluginEnv getPluginDefaultEnv
type GetPluginEnvStruct struct {
//租户名称
//in: path
//required: true
TenantName string `json:"tenant_name"`
// 插件id
// in: path
// required: true
PluginID string `json:"plugin_id"`
// 构建版本id
// in: path
// required: true
VersionID string `json:"version_id"`
}
//GetVersionEnvStruct GetVersionEnvStruct
//swagger:parameters getVersionEnvs
type GetVersionEnvStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
// 插件id
// in: path
// required: true
PluginID string `json:"plugin_id"`
}
//SetVersionEnv SetVersionEnv
//swagger:parameters setVersionEnv updateVersionEnv
type SetVersionEnv struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
// 插件id
// in: path
// required: true
PluginID string `json:"plugin_id"`
//in: body
Body struct {
TenantID string `json:"tenant_id"`
ServiceID string `json:"service_id"`
// 环境变量
// in: body
// required: true
ConfigEnvs ConfigEnvs `json:"config_envs" validate:"config_envs"`
}
}
//ConfigEnvs Config
type ConfigEnvs struct {
NormalEnvs []*VersionEnv `json:"normal_envs" validate:"normal_envs"`
ComplexEnvs *ResourceSpec `json:"complex_envs" validate:"complex_envs"`
}
//VersionEnv VersionEnv
type VersionEnv struct {
//变量名
//in:body
//required: true
EnvName string `json:"env_name" validate:"env_name"`
//变量值
//in:body
//required: true
EnvValue string `json:"env_value" validate:"env_value"`
}
//TransPlugins TransPlugins
type TransPlugins struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
//in: body
Body struct {
// 从该租户安装
// in: body
// required: true
FromTenantName string `json:"from_tenant_name" validate:"from_tenant_name"`
// 插件id
// in: body
// required: true
PluginsID []string `json:"plugins_id" validate:"plugins_id"`
}
}