etchosts: allow adding multiple container ips
Signed-off-by: Kamil Domański <kamil@domanski.co>
This commit is contained in:
parent
55adbae783
commit
226fde5cdd
3 changed files with 10 additions and 7 deletions
|
@ -498,11 +498,11 @@ func (ep *endpoint) sbJoin(sb *sandbox, options ...EndpointOption) (err error) {
|
|||
}
|
||||
|
||||
if doUpdateHostsFile(n, sb) {
|
||||
address := ""
|
||||
var addresses []string
|
||||
if ip := ep.getFirstInterfaceAddress(); ip != nil {
|
||||
address = ip.String()
|
||||
addresses = append(addresses, ip.String())
|
||||
}
|
||||
if err = sb.updateHostsFile(address); err != nil {
|
||||
if err = sb.updateHostsFile(addresses); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,8 +98,8 @@ func (sb *sandbox) buildHostsFile() error {
|
|||
return etchosts.Build(sb.config.hostsPath, "", sb.config.hostName, sb.config.domainName, extraContent)
|
||||
}
|
||||
|
||||
func (sb *sandbox) updateHostsFile(ifaceIP string) error {
|
||||
if ifaceIP == "" {
|
||||
func (sb *sandbox) updateHostsFile(ifaceIPs []string) error {
|
||||
if ifaceIPs == nil || len(ifaceIPs) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,10 @@ func (sb *sandbox) updateHostsFile(ifaceIP string) error {
|
|||
mhost = fmt.Sprintf("%s %s", fqdn, parts[0])
|
||||
}
|
||||
|
||||
extraContent := []etchosts.Record{{Hosts: mhost, IP: ifaceIP}}
|
||||
var extraContent []etchosts.Record
|
||||
for _, ip := range ifaceIPs {
|
||||
extraContent = append(extraContent, etchosts.Record{Hosts: mhost, IP: ip})
|
||||
}
|
||||
|
||||
sb.addHostsEntries(extraContent)
|
||||
return nil
|
||||
|
|
|
@ -18,7 +18,7 @@ func (sb *sandbox) setupResolutionFiles() error {
|
|||
func (sb *sandbox) restorePath() {
|
||||
}
|
||||
|
||||
func (sb *sandbox) updateHostsFile(ifaceIP string) error {
|
||||
func (sb *sandbox) updateHostsFile(ifaceIP []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue