-
Notifications
You must be signed in to change notification settings - Fork 0
/
eyedoc.go
36 lines (32 loc) · 904 Bytes
/
eyedoc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package eyedoc
import (
"context"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/client"
//"time"
)
func Tasks() []map[string]string {
/////////////// CONNECT TO SOCKET
ctx := context.Background()
cli, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
panic(err)
}
taskFilter := filters.NewArgs()
tasks, err := cli.TaskList(ctx, types.TaskListOptions{Filters: taskFilter})
/////////////////////// SCAN TASKS
var conz []map[string]string
for _, task := range tasks {
if val, ok := task.Spec.ContainerSpec.Labels["com.roo.domain"]; ok {
for _, ntrk := range task.NetworksAttachments {
ob := map[string]string{}
ob["container"] = task.ID
ob["com.roo.domain"] = val
ob["receive"] = ntrk.Addresses[0]
conz = append(conz, ob)
}
}
}
return conz
}