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

Function loadComposeCount

agent/app/service/container.go:2111–2135  ·  view source on GitHub ↗
(client *client.Client)

Source from the content-addressed store, hash-verified

2109}
2110
2111func loadComposeCount(client *client.Client) int {
2112 options := container.ListOptions{All: true}
2113 options.Filters = filters.NewArgs()
2114 options.Filters.Add("label", composeProjectLabel)
2115 list, err := client.ContainerList(context.Background(), options)
2116 if err != nil {
2117 return 0
2118 }
2119 composeCreatedByLocal, _ := composeRepo.ListRecord()
2120 composeMap := make(map[string]struct{})
2121 for _, container := range list {
2122 if name, ok := container.Labels[composeProjectLabel]; ok {
2123 if _, has := composeMap[name]; !has {
2124 composeMap[name] = struct{}{}
2125 }
2126 }
2127 }
2128 for _, compose := range composeCreatedByLocal {
2129 if _, has := composeMap[compose.Name]; !has {
2130 composeMap[compose.Name] = struct{}{}
2131 }
2132 }
2133
2134 return len(composeMap)
2135}
2136func loadContainerPortForInfo(itemPorts []container.Port) []dto.PortHelper {
2137 var exposedPorts []dto.PortHelper
2138 samePortMap := make(map[string]dto.PortHelper)

Callers 1

LoadStatusMethod · 0.85

Calls 1

ListRecordMethod · 0.65

Tested by

no test coverage detected