manifest.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. package model
  2. import (
  3. "database/sql/driver"
  4. "encoding/json"
  5. )
  6. type TcpPorts struct {
  7. Desc string `json:"desc"`
  8. ContainerPort int `json:"container_port"`
  9. }
  10. type UdpPorts struct {
  11. Desc string `json:"desc"`
  12. ContainerPort int `json:"container_port"`
  13. }
  14. /*******************使用gorm支持json************************************/
  15. type PortMap struct {
  16. ContainerPort string `json:"container"`
  17. CommendPort string `json:"host"`
  18. Protocol string `json:"protocol"`
  19. Desc string `json:"desc"`
  20. Type int `json:"type"`
  21. }
  22. type PortArray []PortMap
  23. // Value 实现方法
  24. func (p PortArray) Value() (driver.Value, error) {
  25. return json.Marshal(p)
  26. }
  27. // Scan 实现方法
  28. func (p *PortArray) Scan(input interface{}) error {
  29. return json.Unmarshal(input.([]byte), p)
  30. }
  31. /************************************************************************/
  32. /*******************使用gorm支持json************************************/
  33. type Env struct {
  34. Name string `json:"container"`
  35. Value string `json:"host"`
  36. Desc string `json:"desc"`
  37. Type int `json:"type"`
  38. }
  39. type JSON json.RawMessage
  40. type EnvArray []Env
  41. // Value 实现方法
  42. func (p EnvArray) Value() (driver.Value, error) {
  43. return json.Marshal(p)
  44. //return .MarshalJSON()
  45. }
  46. // Scan 实现方法
  47. func (p *EnvArray) Scan(input interface{}) error {
  48. return json.Unmarshal(input.([]byte), p)
  49. }
  50. /************************************************************************/
  51. /*******************使用gorm支持json************************************/
  52. type PathMap struct {
  53. ContainerPath string `json:"container"`
  54. Path string `json:"host"`
  55. Type int `json:"type"`
  56. Desc string `json:"desc"`
  57. }
  58. type PathArray []PathMap
  59. // Value 实现方法
  60. func (p PathArray) Value() (driver.Value, error) {
  61. return json.Marshal(p)
  62. }
  63. // Scan 实现方法
  64. func (p *PathArray) Scan(input interface{}) error {
  65. return json.Unmarshal(input.([]byte), p)
  66. }
  67. /************************************************************************/
  68. //type PostData struct {
  69. // Envs EnvArrey `json:"envs,omitempty"`
  70. // Udp PortArrey `json:"udp_ports"`
  71. // Tcp PortArrey `json:"tcp_ports"`
  72. // Volumes PathArrey `json:"volumes"`
  73. // Devices PathArrey `json:"devices"`
  74. // Port string `json:"port,omitempty"`
  75. // PortMap string `json:"port_map"`
  76. // CpuShares int64 `json:"cpu_shares,omitempty"`
  77. // Memory int64 `json:"memory,omitempty"`
  78. // Restart string `json:"restart,omitempty"`
  79. // EnableUPNP bool `json:"enable_upnp"`
  80. // Label string `json:"label"`
  81. // Position bool `json:"position"`
  82. //}
  83. type CustomizationPostData struct {
  84. CustomId string `json:"custom_id"`
  85. Origin string `json:"origin"`
  86. NetworkModel string `json:"network_model"`
  87. Index string `json:"index"`
  88. Icon string `json:"icon"`
  89. Image string `json:"image"`
  90. Envs EnvArray `json:"envs"`
  91. Ports PortArray `json:"ports"`
  92. Volumes PathArray `json:"volumes"`
  93. Devices PathArray `json:"devices"`
  94. //Port string `json:"port,omitempty"`
  95. PortMap string `json:"port_map"`
  96. CpuShares int64 `json:"cpu_shares"`
  97. Memory int64 `json:"memory"`
  98. Restart string `json:"restart"`
  99. EnableUPNP bool `json:"enable_upnp"`
  100. Label string `json:"label"`
  101. Description string `json:"description"`
  102. Position bool `json:"position"`
  103. HostName string `json:"host_name"`
  104. Privileged bool `json:"privileged"`
  105. CapAdd []string `json:"cap_add"`
  106. Cmd []string `json:"cmd"`
  107. }