api_params.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. NFd int `json:",omitempty"`
  32. NGoroutines int `json:",omitempty"`
  33. MemoryLimit bool `json:",omitempty"`
  34. SwapLimit bool `json:",omitempty"`
  35. IPv4Forwarding bool `json:",omitempty"`
  36. LXCVersion string `json:",omitempty"`
  37. NEventsListener int `json:",omitempty"`
  38. KernelVersion string `json:",omitempty"`
  39. IndexServerAddress string `json:",omitempty"`
  40. }
  41. APITop struct {
  42. Titles []string
  43. Processes [][]string
  44. }
  45. APIRmi struct {
  46. Deleted string `json:",omitempty"`
  47. Untagged string `json:",omitempty"`
  48. }
  49. APIContainers struct {
  50. ID string `json:"Id"`
  51. Image string
  52. Command string
  53. Created int64
  54. Status string
  55. Ports []APIPort
  56. SizeRw int64
  57. SizeRootFs int64
  58. Names []string
  59. }
  60. APIContainersOld struct {
  61. ID string `json:"Id"`
  62. Image string
  63. Command string
  64. Created int64
  65. Status string
  66. Ports string
  67. SizeRw int64
  68. SizeRootFs int64
  69. }
  70. APIID struct {
  71. ID string `json:"Id"`
  72. }
  73. APIRun struct {
  74. ID string `json:"Id"`
  75. Warnings []string `json:",omitempty"`
  76. }
  77. APIPort struct {
  78. PrivatePort int64
  79. PublicPort int64
  80. Type string
  81. IP string
  82. }
  83. APIVersion struct {
  84. Version string
  85. GitCommit string `json:",omitempty"`
  86. GoVersion string `json:",omitempty"`
  87. }
  88. APIWait struct {
  89. StatusCode int
  90. }
  91. APIAuth struct {
  92. Status string
  93. }
  94. APIImageConfig struct {
  95. ID string `json:"Id"`
  96. *Config
  97. }
  98. APICopy struct {
  99. Resource string
  100. HostPath string
  101. }
  102. )
  103. func (api APIImages) ToLegacy() []APIImagesOld {
  104. outs := []APIImagesOld{}
  105. for _, repotag := range api.RepoTags {
  106. components := strings.SplitN(repotag, ":", 2)
  107. outs = append(outs, APIImagesOld{
  108. ID: api.ID,
  109. Repository: components[0],
  110. Tag: components[1],
  111. Created: api.Created,
  112. Size: api.Size,
  113. VirtualSize: api.VirtualSize,
  114. })
  115. }
  116. return outs
  117. }
  118. func (api APIContainers) ToLegacy() *APIContainersOld {
  119. return &APIContainersOld{
  120. ID: api.ID,
  121. Image: api.Image,
  122. Command: api.Command,
  123. Created: api.Created,
  124. Status: api.Status,
  125. Ports: displayablePorts(api.Ports),
  126. SizeRw: api.SizeRw,
  127. SizeRootFs: api.SizeRootFs,
  128. }
  129. }