ipam/host-local: add ResolvConf argument for DNS configuration

This adds the option `resolvConf` to the host-local IPAM configuration.
If specified, the plugin will try to parse the file as a resolv.conf(5)
type file and return it in the DNS response.
This commit is contained in:
Casey Callendrello
2016-11-21 19:05:41 +01:00
committed by Casey Callendrello
parent 4406607649
commit 5cde14cd7b
7 changed files with 169 additions and 7 deletions

View File

@ -38,6 +38,9 @@ var _ = Describe("host-local Operations", func() {
Expect(err).NotTo(HaveOccurred())
defer os.RemoveAll(tmpDir)
err = ioutil.WriteFile(filepath.Join(tmpDir, "resolv.conf"), []byte("nameserver 192.0.2.3"), 0644)
Expect(err).NotTo(HaveOccurred())
conf := fmt.Sprintf(`{
"cniVersion": "0.2.0",
"name": "mynet",
@ -46,9 +49,10 @@ var _ = Describe("host-local Operations", func() {
"ipam": {
"type": "host-local",
"subnet": "10.1.2.0/24",
"dataDir": "%s"
"dataDir": "%s",
"resolvConf": "%s/resolv.conf"
}
}`, tmpDir)
}`, tmpDir, tmpDir)
args := &skel.CmdArgs{
ContainerID: "dummy",
@ -80,6 +84,8 @@ var _ = Describe("host-local Operations", func() {
Expect(err).NotTo(HaveOccurred())
Expect(string(contents)).To(Equal("10.1.2.2"))
Expect(result.DNS).To(Equal(types.DNS{Nameservers: []string{"192.0.2.3"}}))
// Release the IP
err = testutils.CmdDelWithResult(nspath, ifname, func() error {
return cmdDel(args)