Skip to content

Commit 4194501

Browse files
committed
Merge pull request #144 from dustinblackman/add-networks
Add support for NetworkSettings.Networks
2 parents c5309f0 + 1fb39b4 commit 4194501

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-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: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,18 @@ 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+
MacAddress string
66+
GlobalIPv6PrefixLen int
67+
IPPrefixLen int
68+
}
69+
5870
type Volume struct {
5971
Path string
6072
HostPath string
@@ -64,6 +76,7 @@ type Volume struct {
6476
type RuntimeContainer struct {
6577
ID string
6678
Addresses []Address
79+
Networks []Network
6780
Gateway string
6881
Name string
6982
Hostname string

docker_client.go

Lines changed: 17 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,22 @@ 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+
MacAddress: v.MacAddress,
161+
GlobalIPv6PrefixLen: v.GlobalIPv6PrefixLen,
162+
IPPrefixLen: v.IPPrefixLen,
163+
}
164+
165+
runtimeContainer.Networks = append(runtimeContainer.Networks,
166+
network)
167+
}
151168
for k, v := range container.Volumes {
152169
runtimeContainer.Volumes[k] = Volume{
153170
Path: k,

0 commit comments

Comments
 (0)