forked from helmutkemper/iotmaker.docker.builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuncFindCurrentIPV4AddressSupport.go
More file actions
56 lines (51 loc) · 1.15 KB
/
Copy pathfuncFindCurrentIPV4AddressSupport.go
File metadata and controls
56 lines (51 loc) · 1.15 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package iotmakerdockerbuilder
import (
"errors"
"github.com/docker/docker/api/types"
"github.com/helmutkemper/util"
"strings"
)
// findCurrentIPV4AddressSupport
//
// English:
//
// Support function for FindCurrentIpAddress()
//
// Input:
// networkID: Docker's network ID
//
// Output:
// IP: network IPV4 address
// err: standard error object
//
// Português: função de apoio a FindCurrentIpAddress()
//
// Entrada:
// networkID: ID da rede docker
//
// Saída:
// IP: endereço IPV4 da rede
// err: objeto de erro padrão
func (e *ContainerBuilder) findCurrentIPV4AddressSupport(networkID string) (IP string, err error) {
var res types.NetworkResource
res, err = e.dockerSys.NetworkInspect(networkID)
if err != nil {
util.TraceToLog()
return
}
var pass = false
for containerID, networkData := range res.Containers {
if containerID == e.containerID && networkData.Name == e.containerName {
pass = true
var parts = strings.Split(networkData.IPv4Address, "/")
IP = parts[0]
return
}
}
if pass == false {
util.TraceToLog()
err = errors.New("container not found on bridge network")
return
}
return
}