Handle PodSandboxConfig.DNSConfig.Options

DNSConfig can pass "options" settings in now, so add them to the
resolv.conf that we're generating, too.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
Nalin Dahyabhai 2016-10-24 10:57:40 -04:00
parent 23d86cd866
commit ec1bc4d6a8
2 changed files with 13 additions and 3 deletions

View file

@ -74,10 +74,11 @@ func removeFile(path string) error {
return nil
}
func parseDNSOptions(servers, searches []string, path string) error {
func parseDNSOptions(servers, searches, options []string, path string) error {
nServers := len(servers)
nSearches := len(searches)
if nServers == 0 && nSearches == 0 {
nOptions := len(options)
if nServers == 0 && nSearches == 0 && nOptions == 0 {
return copyFile("/etc/resolv.conf", path)
}
@ -107,5 +108,13 @@ func parseDNSOptions(servers, searches []string, path string) error {
}
}
if nOptions > 0 {
data := fmt.Sprintf("options %s\n", strings.Join(options, " "))
_, err = f.Write([]byte(data))
if err != nil {
return err
}
}
return nil
}