func listServices(ctx context.Context, dockerClient client.APIClient) ([]dockerData, error) { serviceList, err := dockerClient.ServiceList(ctx, dockertypes.ServiceListOptions{}) if err != nil { return []dockerData{}, err } networkListArgs := filters.NewArgs() networkListArgs.Add("driver", "overlay") networkList, err := dockerClient.NetworkList(ctx, dockertypes.NetworkListOptions{Filters: networkListArgs}) networkMap := make(map[string]*dockertypes.NetworkResource) if err != nil { log.Debug("Failed to network inspect on client for docker, error: %s", err) return []dockerData{}, err } for _, network := range networkList { networkToAdd := network networkMap[network.ID] = &networkToAdd } var dockerDataList []dockerData for _, service := range serviceList { dockerData := parseService(service, networkMap) dockerDataList = append(dockerDataList, dockerData) } return dockerDataList, err }
func getServices( ctx context.Context, apiclient client.APIClient, namespace string, ) ([]swarm.Service, error) { return apiclient.ServiceList( ctx, types.ServiceListOptions{Filter: getStackFilter(namespace)}) }