api_params.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. package docker
  2. import "strings"
  3. type (
  4. APIHistory struct {
  5. ID string `json:"Id"`
  6. Tags []string `json:",omitempty"`
  7. Created int64
  8. CreatedBy string `json:",omitempty"`
  9. Size int64
  10. }
  11. APIImages struct {
  12. ID string `json:"Id"`
  13. RepoTags []string `json:",omitempty"`
  14. Created int64
  15. Size int64
  16. VirtualSize int64
  17. ParentId string `json:",omitempty"`
  18. }
  19. APIImagesOld struct {
  20. Repository string `json:",omitempty"`
  21. Tag string `json:",omitempty"`
  22. ID string `json:"Id"`
  23. Created int64
  24. Size int64
  25. VirtualSize int64
  26. }
  27. APIInfo struct {
  28. Debug bool
  29. Containers int
  30. Images int
  31. Driver string `json:",omitempty"`
  32. DriverStatus [][2]string `json:",omitempty"`
  33. NFd int `json:",omitempty"`
  34. NGoroutines int `json:",omitempty"`
  35. MemoryLimit bool `json:",omitempty"`
  36. SwapLimit bool `json:",omitempty"`
  37. IPv4Forwarding bool `json:",omitempty"`
  38. LXCVersion string `json:",omitempty"`
  39. NEventsListener int `json:",omitempty"`
  40. KernelVersion string `json:",omitempty"`
  41. IndexServerAddress string `json:",omitempty"`
  42. }
  43. APITop struct {
  44. Titles []string
  45. Processes [][]string
  46. }
  47. APIRmi struct {
  48. Deleted string `json:",omitempty"`
  49. Untagged string `json:",omitempty"`
  50. }
  51. APIContainers struct {
  52. ID string `json:"Id"`
  53. Image string
  54. Command string
  55. Created int64
  56. Status string
  57. Ports []APIPort
  58. SizeRw int64
  59. SizeRootFs int64
  60. Names []string
  61. }
  62. APIContainersOld struct {
  63. ID string `json:"Id"`
  64. Image string
  65. Command string
  66. Created int64
  67. Status string
  68. Ports string
  69. SizeRw int64
  70. SizeRootFs int64
  71. }
  72. APIID struct {
  73. ID string `json:"Id"`
  74. }
  75. APIRun struct {
  76. ID string `json:"Id"`
  77. Warnings []string `json:",omitempty"`
  78. }
  79. APIPort struct {
  80. PrivatePort int64
  81. PublicPort int64
  82. Type string
  83. IP string
  84. }
  85. APIVersion struct {
  86. Version string
  87. GitCommit string `json:",omitempty"`
  88. GoVersion string `json:",omitempty"`
  89. }
  90. APIWait struct {
  91. StatusCode int
  92. }
  93. APIAuth struct {
  94. Status string
  95. }
  96. APIImageConfig struct {
  97. ID string `json:"Id"`
  98. *Config
  99. }
  100. APICopy struct {
  101. Resource string
  102. HostPath string
  103. }
  104. APIContainer struct {
  105. *Container
  106. HostConfig *HostConfig
  107. }
  108. )
  109. func (api APIImages) ToLegacy() []APIImagesOld {
  110. outs := []APIImagesOld{}
  111. for _, repotag := range api.RepoTags {
  112. components := strings.SplitN(repotag, ":", 2)
  113. outs = append(outs, APIImagesOld{
  114. ID: api.ID,
  115. Repository: components[0],
  116. Tag: components[1],
  117. Created: api.Created,
  118. Size: api.Size,
  119. VirtualSize: api.VirtualSize,
  120. })
  121. }
  122. return outs
  123. }
  124. func (api APIContainers) ToLegacy() *APIContainersOld {
  125. return &APIContainersOld{
  126. ID: api.ID,
  127. Image: api.Image,
  128. Command: api.Command,
  129. Created: api.Created,
  130. Status: api.Status,
  131. Ports: displayablePorts(api.Ports),
  132. SizeRw: api.SizeRw,
  133. SizeRootFs: api.SizeRootFs,
  134. }
  135. }