refactor entries added by hostAlias into a separate method and be explicit about the source
This commit is contained in:
parent
a4996c99d4
commit
ceb33bde29
@ -266,6 +266,19 @@ func managedHostsFileContent(hostIP, hostName, hostDomainName string, hostAliase
|
||||
} else {
|
||||
buffer.WriteString(fmt.Sprintf("%s\t%s\n", hostIP, hostName))
|
||||
}
|
||||
hostsFileContent := buffer.Bytes()
|
||||
hostsFileContent = append(hostsFileContent, hostsEntriesFromHostAliases(hostAliases)...)
|
||||
return hostsFileContent
|
||||
}
|
||||
|
||||
func hostsEntriesFromHostAliases(hostAliases []v1.HostAlias) []byte {
|
||||
if len(hostAliases) == 0 {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
var buffer bytes.Buffer
|
||||
buffer.WriteString("\n")
|
||||
buffer.WriteString("# Entries added by HostAliases.\n")
|
||||
// write each IP/hostname pair as an entry into hosts file
|
||||
for _, hostAlias := range hostAliases {
|
||||
for _, hostname := range hostAlias.Hostnames {
|
||||
|
@ -287,6 +287,8 @@ fe00::0 ip6-mcastprefix
|
||||
fe00::1 ip6-allnodes
|
||||
fe00::2 ip6-allrouters
|
||||
203.0.113.1 podFoo.domainFoo podFoo
|
||||
|
||||
# Entries added by HostAliases.
|
||||
123.45.67.89 foo
|
||||
123.45.67.89 bar
|
||||
123.45.67.89 baz
|
||||
@ -308,6 +310,8 @@ fe00::0 ip6-mcastprefix
|
||||
fe00::1 ip6-allnodes
|
||||
fe00::2 ip6-allrouters
|
||||
203.0.113.1 podFoo.domainFoo podFoo
|
||||
|
||||
# Entries added by HostAliases.
|
||||
123.45.67.89 foo
|
||||
123.45.67.89 bar
|
||||
123.45.67.89 baz
|
||||
|
Loading…
Reference in New Issue
Block a user