MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / ListContainersByName

Method ListContainersByName

agent/utils/docker/docker.go:68–93  ·  view source on GitHub ↗
(names []string)

Source from the content-addressed store, hash-verified

66}
67
68func (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}
94func (c Client) ListAllContainers() ([]container.Summary, error) {
95 var (
96 options container.ListOptions

Callers 7

syncAppInstallStatusFunction · 0.95
SyncRuntimesStatusFunction · 0.95
checkContainerNameFunction · 0.95
checkContainerStatusFunction · 0.95

Implementers 1

terminalAIClientagent/utils/terminal/ai/client.go

Calls

no outgoing calls

Tested by

no test coverage detected