config.go 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. package model
  2. import "go-common/library/time"
  3. var (
  4. //ConfigIng config ing.
  5. ConfigIng = int8(1)
  6. //ConfigEnd config end.
  7. ConfigEnd = int8(2)
  8. )
  9. // Config config.
  10. type Config struct {
  11. ID int64 `json:"id" gorm:"primary_key"`
  12. AppID int64 `json:"app_id"`
  13. Name string `json:"name"`
  14. Comment string `json:"comment"`
  15. From int64 `json:"from"`
  16. State int8 `json:"state"`
  17. Mark string `json:"mark"`
  18. Operator string `json:"operator"`
  19. IsDelete int8 `json:"is_delete"`
  20. NewCommon int64 `gorm:"-" json:"new_common"`
  21. Ctime time.Time `json:"ctime"`
  22. Mtime time.Time `json:"mtime"`
  23. }
  24. // TableName config.
  25. func (Config) TableName() string {
  26. return "config"
  27. }
  28. //BuildFile file.
  29. type BuildFile struct {
  30. *Config
  31. LastConf *Config `json:"last_conf"`
  32. }
  33. //ConfigRes configRes.
  34. type ConfigRes struct {
  35. Files []*Config `json:"files"`
  36. BuildFiles []*BuildFile `json:"build_files"`
  37. BuildNewFile []*Config `json:"build_new_file"`
  38. }
  39. //ConfigRefs ConfigRefs.
  40. type ConfigRefs struct {
  41. Configs []*ConfigRef `json:"configs"`
  42. Ref *ConfigRef `json:"ref"`
  43. Name string `json:"name"`
  44. DeleteMAX int64 `json:"delete_max"`
  45. }
  46. //ConfigRef configRef.
  47. type ConfigRef struct {
  48. ID int64 `json:"id"`
  49. Mark string `json:"mark"`
  50. IsDelete int8 `json:"is_delete"`
  51. }
  52. //ConfigSearch config search resp.
  53. type ConfigSearch struct {
  54. App string `json:"app"`
  55. TreeID int64 `json:"tree_id"`
  56. Builds []string `json:"build"`
  57. ConfID int64 `json:"config_id"`
  58. Mark string `json:"mark"`
  59. ConfName string `json:"conf_name"`
  60. ConfValues []string `json:"conf_value"`
  61. }
  62. //CanalTagUpdateReq ...
  63. type CanalTagUpdateReq struct {
  64. AppName string `form:"app_name" validate:"required"`
  65. Env string `form:"env" validate:"required"`
  66. Zone string `form:"zone" validate:"required"`
  67. ConfigIDs string `form:"config_ids"`
  68. TreeID int64 `form:"tree_id" validate:"required"`
  69. Token string `form:"token" validate:"required"`
  70. User string `form:"user" validate:"required"`
  71. Mark string `form:"mark" default:"canal发版"`
  72. Build string `form:"build" default:"docker-1"`
  73. Force int8 `form:"force"`
  74. }
  75. //CanalNameConfigsReq ...
  76. type CanalNameConfigsReq struct {
  77. Env string `form:"env" validate:"required"`
  78. Zone string `form:"zone" validate:"required"`
  79. AppName string `form:"app_name" validate:"required"`
  80. Name string `form:"name" validate:"required"`
  81. TreeID int64 `form:"tree_id" validate:"required"`
  82. Token string `form:"token" validate:"required"`
  83. }
  84. //CanalConfigCreateReq ...
  85. type CanalConfigCreateReq struct {
  86. AppName string `form:"app_name" validate:"required"`
  87. Env string `form:"env" validate:"required"`
  88. Zone string `form:"zone" validate:"required"`
  89. Name string `form:"name" validate:"required"`
  90. State int8 `form:"state" validate:"required"`
  91. From int64 `form:"from" default:"0"`
  92. Comment string `form:"comment" validate:"required"`
  93. Mark string `form:"mark" validate:"required"`
  94. TreeID int64 `form:"tree_id" validate:"required"`
  95. User string `form:"user" validate:"required"`
  96. Token string `form:"token" valildate:"required"`
  97. }
  98. //CreateConfigReq ...
  99. type CreateConfigReq struct {
  100. AppName string `form:"app_name" validate:"required"`
  101. Env string `form:"env" validate:"required"`
  102. Zone string `form:"zone" validate:"required"`
  103. Name string `form:"name" validate:"required"`
  104. State int8 `form:"state" validate:"required"`
  105. From int64 `form:"from" default:"0"`
  106. Comment string `form:"comment" validate:"required"`
  107. Mark string `form:"mark" validate:"required"`
  108. TreeID int64 `form:"tree_id" validate:"required"`
  109. SkipLint bool `form:"skiplint"`
  110. }
  111. //UpdateConfValueReq ...
  112. type UpdateConfValueReq struct {
  113. Name string `form:"name"`
  114. ID int64 `form:"config_id" validate:"required"`
  115. Mtime int64 `form:"mtime" validate:"required"`
  116. State int8 `form:"state" validate:"required"`
  117. Comment string `form:"comment" validate:"required"`
  118. Mark string `form:"mark" validate:"required"`
  119. NewCommon int64 `form:"new_common"`
  120. Ignore int8 `form:"ignore"`
  121. SkipLint bool `form:"skiplint"`
  122. }
  123. //ValueReq ...
  124. type ValueReq struct {
  125. ConfigID int64 `form:"config_id" validate:"required"`
  126. }
  127. //ConfigsByBuildIDReq ...
  128. type ConfigsByBuildIDReq struct {
  129. BuildID int64 `form:"build_id" validate:"required"`
  130. }
  131. //ConfigsByTagIDReq ...
  132. type ConfigsByTagIDReq struct {
  133. TagID int64 `form:"tag_id" validate:"required"`
  134. }
  135. //ConfigsByAppNameReq ...
  136. type ConfigsByAppNameReq struct {
  137. Env string `form:"env" validate:"required"`
  138. Zone string `form:"zone" validate:"required"`
  139. AppName string `form:"app_name" validate:"required"`
  140. TreeID int64 `form:"tree_id" validate:"required"`
  141. }
  142. //ConfigSearchAllReq ...
  143. type ConfigSearchAllReq struct {
  144. Env string `form:"env" validate:"required"`
  145. Zone string `form:"zone" validate:"required"`
  146. Like string `form:"like" validate:"required"`
  147. }
  148. //ConfigSearchAppReq ...
  149. type ConfigSearchAppReq struct {
  150. Env string `form:"env" validate:"required"`
  151. Zone string `form:"zone" validate:"required"`
  152. AppName string `form:"app_name" validate:"required"`
  153. Like string `form:"like" validate:"required"`
  154. BuildID int64 `form:"build_id" validate:"required"`
  155. TreeID int64 `form:"tree_id" validate:"required"`
  156. }
  157. //ConfigsByNameReq ...
  158. type ConfigsByNameReq struct {
  159. Env string `form:"env" validate:"required"`
  160. Zone string `form:"zone" validate:"required"`
  161. AppName string `form:"app_name" validate:"required"`
  162. Name string `form:"name" validate:"required"`
  163. TreeID int64 `form:"tree_id" validate:"required"`
  164. }
  165. //ConfigsReq ...
  166. type ConfigsReq struct {
  167. Env string `form:"env" validate:"required"`
  168. Zone string `form:"zone" validate:"required"`
  169. AppName string `form:"app_name" validate:"required"`
  170. BuildID int64 `form:"build_id"`
  171. TreeID int64 `form:"tree_id" validate:"required"`
  172. }
  173. //ConfigRefsReq ...
  174. type ConfigRefsReq struct {
  175. Env string `form:"env" validate:"required"`
  176. Zone string `form:"zone" validate:"required"`
  177. AppName string `form:"app_name" validate:"required"`
  178. BuildID int64 `form:"build_id" validate:"required"`
  179. TreeID int64 `form:"tree_id" validate:"required"`
  180. }
  181. //NamesByAppNameReq ...
  182. type NamesByAppNameReq struct {
  183. Env string `form:"env" validate:"required"`
  184. Zone string `form:"zone" validate:"required"`
  185. AppName string `form:"app_name" validate:"required"`
  186. TreeID int64 `form:"tree_id" validate:"required"`
  187. }
  188. //DiffReq ...
  189. type DiffReq struct {
  190. ConfigID int64 `form:"config_id" validate:"required"`
  191. BuildID int64 `form:"build_id"`
  192. }
  193. //ConfigDelReq ...
  194. type ConfigDelReq struct {
  195. ConfigID int64 `form:"config_id" validate:"required"`
  196. }
  197. //ConfigBuildInfosReq ...
  198. type ConfigBuildInfosReq struct {
  199. Env string `form:"env" validate:"required"`
  200. Zone string `form:"zone" validate:"required"`
  201. AppName string `form:"app_name" validate:"required"`
  202. BuildID int64 `form:"build_id"`
  203. TreeID int64 `form:"tree_id" validate:"required"`
  204. }
  205. //ConfigUpdateReq ...
  206. type ConfigUpdateReq struct {
  207. AppName string `form:"app_name" validate:"required"`
  208. Env string `form:"env" validate:"required"`
  209. Zone string `form:"zone" validate:"required"`
  210. TreeID int64 `form:"tree_id" validate:"required"`
  211. Data string `form:"data" validate:"required"`
  212. Token string `form:"token" validate:"required"`
  213. User string `form:"user" validate:"required"`
  214. }
  215. //TagUpdateReq ...
  216. type TagUpdateReq struct {
  217. AppName string `form:"app_name" validate:"required"`
  218. Env string `form:"env" validate:"required"`
  219. Zone string `form:"zone" validate:"required"`
  220. ConfigIDs string `form:"config_ids"`
  221. Mark string `form:"mark" validate:"required"`
  222. Build string `form:"build" validate:"required"`
  223. TreeID int64 `form:"tree_id" validate:"required"`
  224. Token string `form:"token" validate:"required"`
  225. User string `form:"user" validate:"required"`
  226. Names string `form:"names"`
  227. Increment int `form:"increment"`
  228. Force int8 `form:"force"`
  229. }
  230. //SetTokenReq ...
  231. type SetTokenReq struct {
  232. Env string `form:"env" validate:"required"`
  233. Zone string `form:"zone" validate:"required"`
  234. App string `form:"service" validate:"required"`
  235. Token string `form:"token" validate:"required"`
  236. TreeID int64 `form:"tree_id" validate:"required"`
  237. }
  238. //HostsReq ...
  239. type HostsReq struct {
  240. Env string `form:"env" validate:"required"`
  241. Zone string `form:"zone" validate:"required"`
  242. App string `form:"service" validate:"required"`
  243. TreeID int64 `form:"tree_id" validate:"required"`
  244. }