-
Notifications
You must be signed in to change notification settings - Fork 717
Closed
Description
https://github.com/containerd/nerdctl/blob/master/pkg/netutil/netutil_unix.go#L37-L56
Now the cni plugin is generated through a fixed template, it is difficult to be extended to support more network parameters, like --ip-range.
I think we can refactor it in the follow way:
const ConfigListTemplate = `{
"cniVersion": "0.4.0",
"name": "{{.Name}}",
"nerdctlID": {{.ID}},
"nerdctlLabels": {{.Labels}},
"plugins": {{.Plugins}}
}`
type ConfigListTemplateOpts struct {
ID int
Name string // e.g. "nerdctl"
Labels string // e.g. `{"version":"1.1.0"}`
Plugins string
}
func GenerateConfigList(e *CNIEnv, labels []string, id int, name, cidr string) (*NetworkConfigList, error) {
...
plugins := []CNIPlugin{bridge, NewPortMapPlugin()...]
pluginJson, err := json.Marshal(plugins)
if err != nil {
return nil, err
}
}Metadata
Metadata
Assignees
Labels
No labels