Skip to content

Commit 8f6ff1a

Browse files
author
Dustin Blackman
committed
add support for NetworkSettings.Networks
1 parent c5309f0 commit 8f6ff1a

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

GLOCKFILE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
github.com/BurntSushi/toml f87ce853111478914f0bcffa34d43a93643e6eda
22
github.com/Sirupsen/logrus 6ebb4e7b3c24b9fef150d7693e728cb1ebadf1f5
33
github.com/docker/docker 2606a2e4d3bf810ec82e373a6cd334e22e504e83
4-
github.com/fsouza/go-dockerclient 1399676f53e6ccf46e0bf00751b21bed329bc60e
4+
github.com/fsouza/go-dockerclient 54afc1babbc57f075f958f84904251332bd8fd73

docker-gen.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ type Address struct {
5555
HostIP string
5656
}
5757

58+
type Network struct {
59+
IP string
60+
Name string
61+
Gateway string
62+
EndpointID string
63+
IPv6Gateway string
64+
GlobalIPv6Address string
65+
}
66+
5867
type Volume struct {
5968
Path string
6069
HostPath string
@@ -64,6 +73,7 @@ type Volume struct {
6473
type RuntimeContainer struct {
6574
ID string
6675
Addresses []Address
76+
Networks []Network
6777
Gateway string
6878
Name string
6979
Hostname string

docker_client.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ func getContainers(client *docker.Client) ([]*RuntimeContainer, error) {
124124
Hostname: container.Config.Hostname,
125125
Gateway: container.NetworkSettings.Gateway,
126126
Addresses: []Address{},
127+
Networks: []Network{},
127128
Env: make(map[string]string),
128129
Volumes: make(map[string]Volume),
129130
Node: SwarmNode{},
@@ -148,6 +149,19 @@ func getContainers(client *docker.Client) ([]*RuntimeContainer, error) {
148149
address)
149150

150151
}
152+
for k, v := range container.NetworkSettings.Networks {
153+
network := Network{
154+
IP: v.IPAddress,
155+
Name: k,
156+
Gateway: v.Gateway,
157+
EndpointID: v.EndpointID,
158+
IPv6Gateway: v.IPv6Gateway,
159+
GlobalIPv6Address: v.GlobalIPv6Address,
160+
}
161+
162+
runtimeContainer.Networks = append(runtimeContainer.Networks,
163+
network)
164+
}
151165
for k, v := range container.Volumes {
152166
runtimeContainer.Volumes[k] = Volume{
153167
Path: k,

0 commit comments

Comments
 (0)