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

@ -49,6 +49,7 @@ type NetConf struct {
SubnetFile string `json:"subnetFile"`
DataDir string `json:"dataDir"`
Delegate map[string]interface{} `json:"delegate"`
RuntimeConfig map[string]interface{} `json:"runtimeConfig,omitempty"`
}
type subnetEnv struct {
@ -84,6 +85,7 @@ func loadFlannelNetConf(bytes []byte) (*NetConf, error) {
if err := json.Unmarshal(bytes, n); err != nil {
return nil, fmt.Errorf("failed to load netconf: %v", err)
}
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)
}
@ -215,6 +221,13 @@ func cmdDel(args *skel.CmdArgs) error {
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)
}