*: add "dns" field to the configuration

appc/cni#76 added a "dns" field in the result JSON. But before this
patch, the plugins had no way of knowing which name server to return.

There could be two ways of knowing which name server to return:
1. add it as an extra argument ("CNI_ARGS")
2. add it in the network configuration as a convenience (received via
   stdin)

I chose the second way because it is easier. In the case of rkt, it
means the user could just add the DNS name servers in
/etc/rkt/net.d/mynetwork.conf.
This commit is contained in:
Alban Crequy
2016-01-26 18:54:56 +01:00
parent 03d4ba4ffb
commit 2f9ef4adb7
6 changed files with 27 additions and 13 deletions

View File

@ -41,8 +41,9 @@ func init() {
type NetConf struct {
types.NetConf
IPMasq bool `json:"ipMasq"`
MTU int `json:"mtu"`
IPMasq bool `json:"ipMasq"`
MTU int `json:"mtu"`
DNS []string `json:"dns"`
}
func setupContainerVeth(netns, ifName string, mtu int, pr *types.Result) (string, error) {
@ -185,6 +186,7 @@ func cmdAdd(args *skel.CmdArgs) error {
}
}
result.DNS = conf.DNS
return result.Print()
}