(names []string)
| 66 | } |
| 67 | |
| 68 | func (c Client) ListContainersByName(names []string) ([]container.Summary, error) { |
| 69 | var ( |
| 70 | options container.ListOptions |
| 71 | namesMap = make(map[string]bool) |
| 72 | res []container.Summary |
| 73 | ) |
| 74 | options.All = true |
| 75 | if len(names) > 0 { |
| 76 | var array []filters.KeyValuePair |
| 77 | for _, n := range names { |
| 78 | namesMap["/"+n] = true |
| 79 | array = append(array, filters.Arg("name", n)) |
| 80 | } |
| 81 | options.Filters = filters.NewArgs(array...) |
| 82 | } |
| 83 | containers, err := c.cli.ContainerList(context.Background(), options) |
| 84 | if err != nil { |
| 85 | return nil, err |
| 86 | } |
| 87 | for _, con := range containers { |
| 88 | if _, ok := namesMap[con.Names[0]]; ok { |
| 89 | res = append(res, con) |
| 90 | } |
| 91 | } |
| 92 | return res, nil |
| 93 | } |
| 94 | func (c Client) ListAllContainers() ([]container.Summary, error) { |
| 95 | var ( |
| 96 | options container.ListOptions |
no outgoing calls
no test coverage detected