Flannel: pass runtimeConfig into delegate

This commit is contained in:
Nathan Gieseker 2019-05-01 15:58:24 -07:00
parent 44297f6ba3
commit 071907f867

View File

@ -46,9 +46,10 @@ const (
type NetConf struct { type NetConf struct {
types.NetConf types.NetConf
SubnetFile string `json:"subnetFile"` SubnetFile string `json:"subnetFile"`
DataDir string `json:"dataDir"` DataDir string `json:"dataDir"`
Delegate map[string]interface{} `json:"delegate"` Delegate map[string]interface{} `json:"delegate"`
RuntimeConfig map[string]interface{} `json:"runtimeConfig,omitempty"`
} }
type subnetEnv struct { type subnetEnv struct {
@ -84,6 +85,7 @@ func loadFlannelNetConf(bytes []byte) (*NetConf, error) {
if err := json.Unmarshal(bytes, n); err != nil { if err := json.Unmarshal(bytes, n); err != nil {
return nil, fmt.Errorf("failed to load netconf: %v", err) return nil, fmt.Errorf("failed to load netconf: %v", err)
} }
return n, nil return n, nil
} }
@ -206,6 +208,10 @@ func cmdAdd(args *skel.CmdArgs) error {
} }
} }
if n.RuntimeConfig != nil {
n.Delegate["runtimeConfig"] = n.RuntimeConfig
}
return doCmdAdd(args, n, fenv) return doCmdAdd(args, n, fenv)
} }
@ -215,6 +221,13 @@ func cmdDel(args *skel.CmdArgs) error {
return err return err
} }
if nc.RuntimeConfig != nil {
if nc.Delegate == nil {
nc.Delegate = make(map[string]interface{})
}
nc.Delegate["runtimeConfig"] = nc.RuntimeConfig
}
return doCmdDel(args, nc) return doCmdDel(args, nc)
} }