()
| 202 | } |
| 203 | |
| 204 | func (u *ContainerService) LoadStatus() (dto.ContainerStatus, error) { |
| 205 | var data dto.ContainerStatus |
| 206 | client, err := docker.NewDockerClient() |
| 207 | if err != nil { |
| 208 | return data, err |
| 209 | } |
| 210 | defer client.Close() |
| 211 | c := context.Background() |
| 212 | |
| 213 | images, _ := client.ImageList(c, image.ListOptions{All: true}) |
| 214 | data.ImageCount = len(images) |
| 215 | repo, _ := imageRepoRepo.List() |
| 216 | data.RepoCount = len(repo) |
| 217 | templates, _ := composeRepo.List() |
| 218 | data.ComposeTemplateCount = len(templates) |
| 219 | networks, _ := client.NetworkList(c, network.ListOptions{}) |
| 220 | data.NetworkCount = len(networks) |
| 221 | volumes, _ := client.VolumeList(c, volume.ListOptions{}) |
| 222 | data.VolumeCount = len(volumes.Volumes) |
| 223 | data.ComposeCount = loadComposeCount(client) |
| 224 | containers, _ := client.ContainerList(c, container.ListOptions{All: true}) |
| 225 | data.ContainerCount = len(containers) |
| 226 | for _, item := range containers { |
| 227 | switch item.State { |
| 228 | case "created": |
| 229 | data.Created++ |
| 230 | case "running": |
| 231 | data.Running++ |
| 232 | case "paused": |
| 233 | data.Paused++ |
| 234 | case "restarting": |
| 235 | data.Restarting++ |
| 236 | case "dead": |
| 237 | data.Dead++ |
| 238 | case "exited": |
| 239 | data.Exited++ |
| 240 | case "removing": |
| 241 | data.Removing++ |
| 242 | } |
| 243 | } |
| 244 | return data, nil |
| 245 | } |
| 246 | func (u *ContainerService) ContainerItemStats(req dto.OperationWithName) (dto.ContainerItemStats, error) { |
| 247 | var data dto.ContainerItemStats |
| 248 | client, err := docker.NewDockerClient() |
nothing calls this directly
no test coverage detected