MCPcopy Index your code
hub / github.com/docker/cli / taskNames

Function taskNames

cli/command/system/completion.go:283–303  ·  view source on GitHub ↗

taskNames contacts the API to get a list of service names. In case of an error, an empty list is returned.

(dockerCLI completion.APIClientProvider, cmd *cobra.Command)

Source from the content-addressed store, hash-verified

281// taskNames contacts the API to get a list of service names.
282// In case of an error, an empty list is returned.
283func taskNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command) []string {
284 res, err := dockerCLI.Client().TaskList(cmd.Context(), client.TaskListOptions{})
285 if err != nil || len(res.Items) == 0 {
286 return []string{}
287 }
288
289 resolver := idresolver.New(dockerCLI.Client(), false)
290 names := make([]string, 0, len(res.Items))
291 for _, task := range res.Items {
292 serviceName, err := resolver.Resolve(cmd.Context(), swarm.Service{}, task.ServiceID)
293 if err != nil {
294 continue
295 }
296 if task.Slot != 0 {
297 names = append(names, fmt.Sprintf("%v.%v", serviceName, task.Slot))
298 } else {
299 names = append(names, fmt.Sprintf("%v.%v", serviceName, task.NodeID))
300 }
301 }
302 return names
303}
304
305// volumeNames contacts the API to get a list of volume names.
306// In case of an error, an empty list is returned.

Callers 1

completeObjectNamesFunction · 0.85

Calls 3

ResolveMethod · 0.80
ClientMethod · 0.65
TaskListMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…