forked from goodrain/rainbond
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
1460 lines (1379 loc) · 42.6 KB
/
model.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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// 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
import (
"net/url"
"time"
"fmt"
"strings"
dbmodel "github.com/goodrain/rainbond/db/model"
)
//ServiceGetCommon path参数
//swagger:parameters getVolumes getDepVolumes
type ServiceGetCommon struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
}
//ComposerStruct ComposerStruct
// swagger:parameters resolve
type ComposerStruct struct {
// in : body
Body struct {
Lang string `json:"default_runtime" validate:"default_runtime"`
Data struct {
JSON struct {
PlatForm struct {
PHP string `json:"php" validate:"php"`
}
}
Packages []string `json:"packages" validate:"packages"`
Lock struct {
PlatForm struct {
PHP string `json:"php" validate:"php"`
}
}
}
}
}
//CreateServiceStruct serviceCreate struct
// swagger:parameters createService
type CreateServiceStruct struct {
// in: path
// required: true
TenantName string `gorm:"column:tenant_name;size:32" json:"tenant_name" validate:"tenant_name"`
// in:body
Body struct {
// 租户id
// in: body
// required: false
TenantID string `gorm:"column:tenant_id;size:32" json:"tenant_id" validate:"tenant_id"`
// 应用id
// in: body
// required: false
ServiceID string `gorm:"column:service_id;size:32" json:"service_id" validate:"service_id"`
// 操作人
// in: body
// required: false
Operator string `json:"operator" validate:"operator"`
// 应用标签,value
// in: body
// required: false
ServiceLabel string `json:"service_label" validate:"service_label"`
// 节点标签,格式: v1,v2
// in: body
// required: false
NodeLabel string `json:"node_label" validate:"node_label"`
// 依赖id, 格式: []struct TenantServiceRelation
// in: body
// required: false
DependIDs []dbmodel.TenantServiceRelation `json:"depend_ids" validate:"depend_ids"`
// 持久化目录信息, 格式: []struct TenantServiceVolume
// in: body
// required: false
VolumesInfo []dbmodel.TenantServiceVolume `json:"volumes_info" validate:"volumes_info"`
// 环境变量信息, 格式: []struct TenantServiceEnvVar
// in: body
// required: false
EnvsInfo []dbmodel.TenantServiceEnvVar `json:"envs_info" validate:"envs_info"`
// 端口信息, 格式: []struct TenantServicesPort
// in: body
// required: false
PortsInfo []dbmodel.TenantServicesPort `json:"ports_info" validate:"ports_info"`
// 服务key
// in: body
// required: false
ServiceKey string `gorm:"column:service_key;size:32" json:"service_key" validate:"service_key"`
// 服务别名
// in: body
// required: true
ServiceAlias string `gorm:"column:service_alias;size:30" json:"service_alias" validate:"service_alias"`
// 服务描述
// in: body
// required: false
Comment string `gorm:"column:comment" json:"comment" validate:"comment"`
// 服务版本
// in: body
// required: false
ServiceVersion string `gorm:"column:service_version;size:32" json:"service_version" validate:"service_version"`
// 镜像名称
// in: body
// required: false
ImageName string `gorm:"column:image_name;size:100" json:"image_name" validate:"image_name"`
// 容器CPU权重
// in: body
// required: false
ContainerCPU int `gorm:"column:container_cpu;default:500" json:"container_cpu" validate:"container_cpu"`
// 容器最大内存
// in: body
// required: false
ContainerMemory int `gorm:"column:container_memory;default:128" json:"container_memory" validate:"container_memory"`
// 容器启动命令
// in: body
// required: false
ContainerCMD string `gorm:"column:container_cmd;size:2048" json:"container_cmd" validate:"container_cmd"`
// 容器环境变量
// in: body
// required: false
ContainerEnv string `gorm:"column:container_env;size:255" json:"container_env" validate:"container_env"`
// 卷名字
// in: body
// required: false
VolumePath string `gorm:"column:volume_path" json:"volume_path" validate:"volume_path"`
// 容器挂载目录
// in: body
// required: false
VolumeMountPath string `gorm:"column:volume_mount_path" json:"volume_mount_path" validate:"volume_mount_path"`
// 宿主机目录
// in: body
// required: false
HostPath string `gorm:"column:host_path" json:"host_path" validate:"host_path"`
// 扩容方式;0:无状态;1:有状态;2:分区
// in: body
// required: false
ExtendMethod string `gorm:"column:extend_method;default:'stateless';" json:"extend_method" validate:"extend_method"`
// 节点数
// in: body
// required: false
Replicas int `gorm:"column:replicas;default:1" json:"replicas" validate:"replicas"`
// 部署版本
// in: body
// required: false
DeployVersion string `gorm:"column:deploy_version" json:"deploy_version" validate:"deploy_version"`
// 服务分类:application,cache,store
// in: body
// required: false
Category string `gorm:"column:category" json:"category" validate:"category"`
// 最新操作ID
// in: body
// required: false
EventID string `gorm:"column:event_id" json:"event_id" validate:"event_id"`
// 服务类型
// in: body
// required: false
ServiceType string `gorm:"column:service_type" json:"service_type" validate:"service_type"`
// 镜像来源
// in: body
// required: false
Namespace string `gorm:"column:namespace" json:"namespace" validate:"namespace"`
// 共享类型shared、exclusive
// in: body
// required: false
VolumeType string `gorm:"column:volume_type;default:'shared'" json:"volume_type" validate:"volume_type"`
// 端口类型,one_outer;dif_protocol;multi_outer
// in: body
// required: false
PortType string `gorm:"column:port_type;default:'multi_outer'" json:"port_type" validate:"port_type"`
// 更新时间
// in: body
// required: false
UpdateTime time.Time `gorm:"column:update_time" json:"update_time" validate:"update_time"`
// 服务创建类型cloud云市服务,assistant云帮服务
// in: body
// required: false
ServiceOrigin string `gorm:"column:service_origin;default:'assistant'" json:"service_origin" validate:"service_origin"`
// 代码来源:gitlab,github
// in: body
// required: false
CodeFrom string `gorm:"column:code_from" json:"code_from" validate:"code_from"`
}
}
// UpdateServiceStruct service update
// swagger:parameters updateService
type UpdateServiceStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
//in: body
Body struct {
// 容器启动命令
// in: body
// required: false
ContainerCMD string `gorm:"column:container_cmd;size:2048" json:"container_cmd" validate:"container_cmd"`
// 镜像名称
// in: body
// required: false
ImageName string `gorm:"column:image_name;size:100" json:"image_name" validate:"image_name"`
// 容器最大内存
// in: body
// required: false
ContainerMemory int `gorm:"column:container_memory;default:128" json:"container_memory" validate:"container_memory"`
}
}
//StartStopStruct start struct
type StartStopStruct struct {
ServiceID string
TenantID string
DeployVersion string
EventID string
TaskType string
}
//LanguageSet set language
type LanguageSet struct {
ServiceID string `json:"service_id"`
Language string `json:"language"`
}
//ServiceStruct service struct
type ServiceStruct struct {
TenantID string `json:"tenant_id" validate:"tenant_id"`
// in: path
// required: true
ServiceID string `json:"service_id" validate:"service_id"`
// 服务key
// in: body
// required: false
ServiceKey string `json:"service_key" validate:"service_key"`
// 服务别名
// in: body
// required: true
ServiceAlias string `json:"service_alias" validate:"service_alias"`
// 服务描述
// in: body
// required: false
Comment string `json:"comment" validate:"comment"`
// 服务版本
// in: body
// required: false
ServiceVersion string `json:"service_version" validate:"service_version"`
// 镜像名称
// in: body
// required: false
ImageName string `json:"image_name" validate:"image_name"`
// 容器CPU权重
// in: body
// required: false
ContainerCPU int `json:"container_cpu" validate:"container_cpu"`
// 容器最大内存
// in: body
// required: false
ContainerMemory int `json:"container_memory" validate:"container_memory"`
// 容器启动命令
// in: body
// required: false
ContainerCMD string `json:"container_cmd" validate:"container_cmd"`
// 容器环境变量
// in: body
// required: false
ContainerEnv string `json:"container_env" validate:"container_env"`
// 卷名字
// in: body
// required: false
VolumePath string `json:"volume_path" validate:"volume_path"`
// 容器挂载目录
// in: body
// required: false
VolumeMountPath string `json:"volume_mount_path" validate:"volume_mount_path"`
// 宿主机目录
// in: body
// required: false
HostPath string `json:"host_path" validate:"host_path"`
// 扩容方式;0:无状态;1:有状态;2:分区
// in: body
// required: false
ExtendMethod string `json:"extend_method" validate:"extend_method"`
// 节点数
// in: body
// required: false
Replicas int `json:"replicas" validate:"replicas"`
// 部署版本
// in: body
// required: false
DeployVersion string `json:"deploy_version" validate:"deploy_version"`
// 服务分类:application,cache,store
// in: body
// required: false
Category string `json:"category" validate:"category"`
// 服务当前状态:undeploy,running,closed,unusual,starting,checking,stoping
// in: body
// required: false
CurStatus string `json:"cur_status" validate:"cur_status"`
// 最新操作ID
// in: body
// required: false
EventID string `json:"event_id" validate:"event_id"`
// 服务类型
// in: body
// required: false
ServiceType string `json:"service_type" validate:"service_type"`
// 镜像来源
// in: body
// required: false
Namespace string `json:"namespace" validate:"namespace"`
// 共享类型shared、exclusive
// in: body
// required: false
VolumeType string `json:"volume_type" validate:"volume_type"`
// 端口类型,one_outer;dif_protocol;multi_outer
// in: body
// required: false
PortType string `json:"port_type" validate:"port_type"`
// 更新时间
// in: body
// required: false
UpdateTime time.Time `json:"update_time" validate:"update_time"`
// 服务创建类型cloud云市服务,assistant云帮服务
// in: body
// required: false
ServiceOrigin string `json:"service_origin" validate:"service_origin"`
// 代码来源:gitlab,github
// in: body
// required: false
CodeFrom string `json:"code_from" validate:"code_from"`
Domain string `json:"domain" validate:"domain"`
ServiceLabel string `json:"service_label" validate:"service_label"`
NodeLabel string `json:"node_label" validate:"node_label"`
Operator string `json:"operator" validate:"operator"`
RepoURL string `json:"repo_url" validate:"repo_url"`
DependIDs []dbmodel.TenantServiceRelation `json:"depend_ids"`
VolumesInfo []dbmodel.TenantServiceVolume `json:"volumes_info"`
DepVolumesInfo []dbmodel.TenantServiceMountRelation `json:"dep_volumes_info"`
EnvsInfo []dbmodel.TenantServiceEnvVar `json:"envs_info"`
PortsInfo []dbmodel.TenantServicesPort `json:"ports_info"`
}
//DependService struct for depend service
type DependService struct {
TenantID string `json:"tenant_id"`
ServiceID string `json:"service_id"`
DepServiceID string `json:"dep_service_id"`
DepServiceType string `json:"dep_service_type"`
Action string `json:"action"`
}
//Attr attr
type Attr struct {
Action string `json:"action"`
TenantID string `json:"tenant_id"`
ServiceID string `json:"service_id"`
AttrName string `json:"env_name"`
AttrValue string `json:"env_value"`
}
// DeleteServicePort service port
// swagger:parameters deletePort
type DeleteServicePort struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
// 容器端口
// in: path
// required: true
Port int `json:"port"`
}
//TenantResources TenantResources
// swagger:parameters tenantResources
type TenantResources struct {
// in: body
Body struct {
// in: body
// required: true
TenantNames []string `json:"tenant_name" validate:"tenant_name"`
}
}
//ServicesResources ServicesResources
// swagger:parameters serviceResources
type ServicesResources struct {
// in: body
Body struct {
// in: body
// required: true
ServiceIDs []string `json:"service_ids" validate:"service_ids"`
}
}
// CommandResponse api统一返回结构
// swagger:response commandResponse
type CommandResponse struct {
// in: body
Body struct {
//参数验证错误信息
ValidationError url.Values `json:"validation_error,omitempty"`
//API错误信息
Msg string `json:"msg,omitempty"`
//单资源实体
Bean interface{} `json:"bean,omitempty"`
//资源列表
List interface{} `json:"list,omitempty"`
//数据集总数
ListAllNumber int `json:"number,omitempty"`
//当前页码数
Page int `json:"page,omitempty"`
}
}
// ServicePortInnerOrOuter service port
// swagger:parameters PortInnerController PortOuterController
type ServicePortInnerOrOuter struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
// in: path
// required: true
Port int `json:"port"`
//in: body
Body struct {
// 操作值 `close` or `open`
// in: body
// required: true
Operation string `json:"operation" validate:"operation|required|in:open,close"`
}
}
// ServiceLBPortChange change lb port
// swagger:parameters changelbport
type ServiceLBPortChange struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
// in: path
// required: true
Port int `json:"port"`
//in: body
Body struct {
// in: body
// required: true
ChangePort int `json:"change_port" validate:"change_port|required"`
}
}
//RollbackStruct struct
type RollbackStruct struct {
TenantID string `json:"tenant_id"`
ServiceID string `json:"service_id"`
EventID string `json:"event_id;default:system"`
Operator string `json:"operator"`
DeployVersion string `json:"deploy_version"`
}
//StatusList status list
type StatusList struct {
TenantID string `json:"tenant_id"`
ServiceID string `json:"service_id"`
ServiceAlias string `json:"service_alias"`
DeployVersion string `json:"deploy_version"`
Replicas int `json:"replicas"`
ContainerMem int `json:"container_memory"`
CurStatus string `json:"cur_status"`
ContainerCPU int `json:"container_cpu"`
StatusCN string `json:"status_cn"`
PodList []PodsList `json:"pod_list"`
}
//PodsList pod list
type PodsList struct {
PodIP string `json:"pod_ip"`
Phase string `json:"phase"`
PodName string `json:"pod_name"`
NodeName string `json:"node_name"`
}
//StatsInfo stats info
type StatsInfo struct {
UUID string `json:"uuid"`
CPU int `json:"cpu"`
MEM int `json:"memory"`
}
//TotalStatsInfo total stats info
type TotalStatsInfo struct {
Data []*StatsInfo `json:"data"`
}
//LicenseInfo license info
type LicenseInfo struct {
Code string `json:"code"`
Company string `json:"company"`
Node int `json:"node"`
CPU int `json:"cpu"`
MEM int `json:"memory"`
Tenant int `json:"tenant"`
EndTime string `json:"end_time"`
StartTime string `json:"start_time"`
DataCenter int `json:"data_center"`
ModuleList []string `json:"module_list"`
}
// AddTenantStruct AddTenantStruct
// swagger:parameters addTenant
type AddTenantStruct struct {
//in: body
Body struct {
// the tenant id
// in: body
// required: false
TenantID string `json:"tenant_id" validate:"tenant_id"`
// the tenant name
// in: body
// required: false
TenantName string `json:"tenant_name" validate:"tenant_name"`
// the eid
// in : body
// required: false
Eid string `json:"eid" validata:"eid"`
Token string `json:"token" validate:"token"`
}
}
// ServicesInfoStruct ServicesInfoStruct
// swagger:parameters getServiceInfo
type ServicesInfoStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
}
// SetLanguageStruct SetLanguageStruct
// swagger:parameters setLanguage
type SetLanguageStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
//in: body
Body struct {
// the tenant id
// in: body
// required: true
EventID string `json:"event_id"`
// the language
// in: body
// required: true
Language string `json:"language"`
}
}
//StartServiceStruct StartServiceStruct
//swagger:parameters startService stopService restartService
type StartServiceStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
//in: body
Body struct {
// the tenant id
// in: body
// required: false
EventID string `json:"event_id"`
}
}
//VerticalServiceStruct VerticalServiceStruct
//swagger:parameters verticalService
type VerticalServiceStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
//in: body
Body struct {
// the event id
// in: body
// required: false
EventID string `json:"event_id"`
// cpu数量
// in: body
// required: false
ContainerCPU int `json:"container_cpu"`
// 内存大小
// in: body
// required: false
ContainerMemory int `json:"container_memory"`
}
}
//HorizontalServiceStruct HorizontalServiceStruct
//swagger:parameters horizontalService
type HorizontalServiceStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
//in: body
Body struct {
// the event id
// in: body
// required: false
EventID string `json:"event_id"`
// 伸缩数量
// in: body
// required: false
NodeNUM int `json:"node_num"`
}
}
//BuildServiceStruct BuildServiceStruct
//swagger:parameters serviceBuild
type BuildServiceStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name" validate:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias" validate:"service_alias"`
//in: body
Body struct {
// the event id
// in: body
// required: false
EventID string `json:"event_id" validate:"event_id"`
// 变量
// in: body
// required: false
ENVS map[string]string `json:"envs" validate:"envs"`
// 应用构建类型
// in: body
// required: true
Kind string `json:"kind" validate:"kind|required"`
// 后续动作, 根据该值进行一键部署,如果不传值,则默认只进行构建
// in: body
// required: false
Action string `json:"action" validate:"action"`
// 镜像地址
// in: body
// required: false
ImageURL string `json:"image_url" validate:"image_url"`
// 部署的版本号
// in: body
// required: true
DeployVersion string `json:"deploy_version" validate:"deploy_version|required"`
// git地址
// in: body
// required: false
RepoURL string `json:"repo_url" validate:"repo_url"`
// branch 分支信息
// in: body
// required: false
Branch string `json:"branch" validate:"branch"`
// 操作人员
// in: body
// required: false
Lang string `json:"lang" validate:"lang"`
Runtime string `json:"runtime" validate:"runtime"`
ServiceType string `json:"service_type" validate:"service_type"`
User string `json:"user" validate:"user"`
Password string `json:"password" validate:"password"`
Operator string `json:"operator" validate:"operator"`
TenantName string `json:"tenant_name"`
ServiceAlias string `json:"service_alias"`
//用于云市代码包创建
SlugInfo struct {
SlugPath string `json:"slug_path"`
FTPHost string `json:"ftp_host"`
FTPPort string `json:"ftp_port"`
FTPUser string `json:"ftp_username"`
FTPPassword string `json:"ftp_password"`
} `json:"slug_info"`
}
}
//V1BuildServiceStruct V1BuildServiceStruct
type V1BuildServiceStruct struct {
// in: path
// required: true
ServiceID string `json:"service_id" validate:"service_id"`
Body struct {
ServiceID string `json:"service_id" validate:"service_id"`
EventID string `json:"event_id" validate:"event_id"`
ENVS string `json:"envs" validate:"envs"`
Kind string `json:"kind" validate:"kind"`
Action string `json:"action" validate:"action"`
ImageURL string `json:"image_url" validate:"image_url"`
DeployVersion string `json:"deploy_version" validate:"deploy_version|required"`
RepoURL string `json:"repo_url" validate:"repo_url"`
GitURL string `json:"gitUrl" validate:"gitUrl"`
Operator string `json:"operator" validate:"operator"`
}
}
//UpgradeServiceStruct UpgradeServiceStruct
//swagger:parameters upgradeService
type UpgradeServiceStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
//in: body
Body struct {
// the event id
// in: body
// required: false
EventID string `json:"event_id"`
// 版本号
// in: body
// required: true
DeployVersion int `json:"deploy_version"`
// 操作人员
// in: body
// required: false
Operator int `json:"operator"`
}
}
//StatusServiceStruct StatusServiceStruct
//swagger:parameters serviceStatus
type StatusServiceStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
}
//StatusServiceListStruct StatusServiceListStruct
//swagger:parameters serviceStatuslist
type StatusServiceListStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: body
// required: true
Body struct {
// 需要获取状态的服务ID列表,若不指定,返回租户所有应用的状态
// in: body
// required: true
ServiceIDs []string `json:"service_ids" validate:"service_ids|required"`
}
}
//AddServiceLabelStruct AddServiceLabelStruct
//swagger:parameters addServiceLabel updateServiceLabel
type AddServiceLabelStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
// in: body
Body struct {
// 标签值,格式为"v1"
// in: bod
// required: true
LabelValues string `json:"label_values"`
}
}
//AddNodeLabelStruct AddNodeLabelStruct
//swagger:parameters addNodeLabel deleteNodeLabel
type AddNodeLabelStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
// in: body
Body struct {
// 标签值,格式为"[v1, v2, v3]"
// in: body
// required: true
LabelValues []string `json:"label_values" validate:"label_values|required"`
}
}
//GetSingleServiceInfoStruct GetSingleServiceInfoStruct
//swagger:parameters getService deleteService
type GetSingleServiceInfoStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
}
//CheckCodeStruct CheckCodeStruct
//swagger:parameters checkCode
type CheckCodeStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: body
Body struct {
// git分支详情
// in: body
// required: true
GitURL string `json:"git_url" validate:"git_url|required"`
// git地址
// in: body
// required: true
URLRepos string `json:"url_repos" validate:"url_repos|required"`
// 检测类型, "first_check"
// in: body
// required: true
CheckType string `json:"check_type" validate:"check_type|required"`
// 代码分支
// in: body
// required: true
CodeVersion string `json:"code_version" validate:"code_version|required"`
// git project id, 0
// in: body
// required: true
GitProjectID int `json:"git_project_id" validate:"git_project_id|required"`
// git源, "gitlab_manual"
// in: body
// required: true
CodeFrom string `json:"code_from" validate:"code_from|required"`
// 租户id
// in: body
// required: false
TenantID string `json:"tenant_id" validate:"tenant_id"`
Action string `json:"action"`
// 应用id
// in: body
// required: true
ServiceID string `json:"service_id"`
}
}
//ServiceCheckStruct 应用检测,支持源码检测,镜像检测,dockerrun检测
//swagger:parameters serviceCheck
type ServiceCheckStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: body
Body struct {
//uuid
// in: body
CheckUUID string `json:"uuid"`
//检测来源类型
// in: body
// required: true
SourceType string `json:"source_type" validate:"source_type|required|in:docker-run,docker-compose,sourcecode"`
// 检测来源定义,
// 代码: https://github.com/shurcooL/githubql.git master
// docker-run: docker run --name xxx nginx:latest nginx
// docker-compose: compose全文
// in: body
// required: true
SourceBody string `json:"source_body" validate:"source_body|required"`
TenantID string
EventID string `json:"event_id"`
}
}
//GetServiceCheckInfoStruct 获取应用检测信息
//swagger:parameters getServiceCheckInfo
type GetServiceCheckInfoStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
UUID string `json:"uuid"`
}
//CloudShareStruct CloudShareStruct
//swagger:parameters sharecloud
type CloudShareStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: body
Body struct {
// 分享类型,app_slug/app_image
// in: body
// required: true
Kind string `json:"kind" validate:"kind|required|in:app_slug,app_image"`
Slug SlugShare
Image ImageShare
}
}
//PublicShare share共用结构
type PublicShare struct {
ServiceKey string `json:"service_key" validate:"service_key"`
APPVersion string `json:"app_version" validate:"app_version"`
IsOuter bool `json:"is_outer" validate:"is_outer"`
Action string `json:"action" validate:"action"`
ShareID string `json:"share_id" validate:"share_id"`
EventID string `json:"event_id" validate:"event_id"`
Dest string `json:"dest" validate:"dest|in:yb,ys"`
ServiceID string `json:"service_id" validate:"service_id"`
ShareConf ShareConfItems `json:"share_conf" validate:"share_conf"`
}
//SlugShare Slug 类型
type SlugShare struct {
PublicShare
ServiceKey string `json:"service_key" validate:"service_key"`
APPVersion string `json:"app_version" validate:"app_version"`
DeployVersion string `json:"deploy_version" validate:"deploy_version"`
TenantID string `json:"tenant_id" validate:"tenant_id"`
Dest string `json:"dest" validate:"dest|in:yb,ys"`
}
//ImageShare image 类型
type ImageShare struct {
PublicShare
Image string `json:"image" validate:"image"`
}
//ShareConfItems 分享相关配置
type ShareConfItems struct {
FTPHost string `json:"ftp_host" validate:"ftp_host"`
FTPPort int `json:"ftp_port" validate:"ftp_port"`
FTPUserName string `json:"ftp_username" valiate:"ftp_username"`
FTPPassWord string `json:"ftp_password" validate:"ftp_password"`
FTPNamespace string `json:"ftp_namespace" validate:"ftp_namespace"`
OuterRegistry string `json:"outer_registry" validate:"outer_registry"`
}
//AddDependencyStruct AddDependencyStruct
//swagger:parameters addDependency deleteDependency
type AddDependencyStruct struct {
// in: path
// required: true
TenantName string `json:"tenant_name"`
// in: path
// required: true
ServiceAlias string `json:"service_alias"`
// in: body
Body struct {
// 被依赖的应用id
// in: body
// required: true
DepServiceID string `json:"dep_service_id"`
// 被依赖的应用类型,添加时需要传值, 删除时不需要传值
// in: body
// required: false
DepServiceType string `json:"dep_service_type"`
// 不明,默认传 1, 可以不传