*: reflect SPEC's DNS changes in implementation
authorStefan Junker <mail@stefanjunker.de>
Wed, 27 Jan 2016 11:12:16 +0000 (12:12 +0100)
committerStefan Junker <mail@stefanjunker.de>
Fri, 29 Jan 2016 09:39:28 +0000 (10:39 +0100)
* DNS is now a type which will result in a JSON dictionary in
  configurations and results
* Minor refactoring, making use of type embedding

pkg/types/types.go
plugins/main/bridge/bridge.go
plugins/main/ipvlan/ipvlan.go
plugins/main/macvlan/macvlan.go
plugins/main/ptp/ptp.go

index e5558be..6ae4a64 100644 (file)
@@ -61,13 +61,14 @@ type NetConf struct {
        IPAM struct {
                Type string `json:"type,omitempty"`
        } `json:"ipam,omitempty"`
+       DNS DNS `json:"dns"`
 }
 
 // Result is what gets returned from the plugin (via stdout) to the caller
 type Result struct {
        IP4 *IPConfig `json:"ip4,omitempty"`
        IP6 *IPConfig `json:"ip6,omitempty"`
-       DNS []string  `json:"dns,omitempty"`
+       DNS DNS       `json:"dns,omitempty"`
 }
 
 func (r *Result) Print() error {
@@ -81,6 +82,14 @@ type IPConfig struct {
        Routes  []Route
 }
 
+// DNS contains values interesting for DNS resolvers
+type DNS struct {
+       Nameservers []string `json:"nameservers,omitempty"`
+       Domain      string   `json:"domain,omitempty"`
+       Search      []string `json:"search,omitempty"`
+       Options     []string `json:"options,omitempty"`
+}
+
 type Route struct {
        Dst net.IPNet
        GW  net.IP
index c4d8594..49c0aa5 100644 (file)
@@ -35,11 +35,10 @@ const defaultBrName = "cni0"
 
 type NetConf struct {
        types.NetConf
-       BrName string   `json:"bridge"`
-       IsGW   bool     `json:"isGateway"`
-       IPMasq bool     `json:"ipMasq"`
-       MTU    int      `json:"mtu"`
-       DNS    []string `json:"dns"`
+       BrName string `json:"bridge"`
+       IsGW   bool   `json:"isGateway"`
+       IPMasq bool   `json:"ipMasq"`
+       MTU    int    `json:"mtu"`
 }
 
 func init() {
index 3697735..8591977 100644 (file)
@@ -31,10 +31,9 @@ import (
 
 type NetConf struct {
        types.NetConf
-       Master string   `json:"master"`
-       Mode   string   `json:"mode"`
-       MTU    int      `json:"mtu"`
-       DNS    []string `json:"dns"`
+       Master string `json:"master"`
+       Mode   string `json:"mode"`
+       MTU    int    `json:"mtu"`
 }
 
 func init() {
index 812d91f..f6891a3 100644 (file)
@@ -31,10 +31,9 @@ import (
 
 type NetConf struct {
        types.NetConf
-       Master string   `json:"master"`
-       Mode   string   `json:"mode"`
-       MTU    int      `json:"mtu"`
-       DNS    []string `json:"dns"`
+       Master string `json:"master"`
+       Mode   string `json:"mode"`
+       MTU    int    `json:"mtu"`
 }
 
 func init() {
index a51b42f..3cb8f64 100644 (file)
@@ -41,9 +41,8 @@ func init() {
 
 type NetConf struct {
        types.NetConf
-       IPMasq bool     `json:"ipMasq"`
-       MTU    int      `json:"mtu"`
-       DNS    []string `json:"dns"`
+       IPMasq bool `json:"ipMasq"`
+       MTU    int  `json:"mtu"`
 }
 
 func setupContainerVeth(netns, ifName string, mtu int, pr *types.Result) (string, error) {