@@ -3,6 +3,7 @@ package cni
33
44import (
55 "context"
6+ "encoding/json"
67 "fmt"
78 "io/ioutil"
89 "path/filepath"
@@ -21,14 +22,15 @@ const (
2122
2223// CNIToolConfig .
2324type CNIToolConfig struct {
24- CNIPath string `json:"cni_path"`
25- NetConfPath string `json:"net_conf_path"`
26- NetNS string `json:"net_ns"`
27- Args string `json:"args"`
28- IfName string `json:"if_name"`
29- Cmd string `json:"cmd"`
30- ContainerID string `json:"container_id"`
31- Handler func ([]byte ) ([]byte , error )
25+ CNIPath string `json:"cni_path"`
26+ NetConfPath string `json:"net_conf_path"`
27+ NetNS string `json:"net_ns"`
28+ Args string `json:"args"`
29+ CapabilityArgs string `json:"capability_args"`
30+ IfName string `json:"if_name"`
31+ Cmd string `json:"cmd"`
32+ ContainerID string `json:"container_id"`
33+ Handler func ([]byte ) ([]byte , error )
3234}
3335
3436func parseArgs (args string ) ([][2 ]string , error ) {
@@ -144,13 +146,21 @@ func Run(config CNIToolConfig) error {
144146 }
145147 }
146148
149+ var capabilityArgs map [string ]interface {}
150+ if len (config .CapabilityArgs ) > 0 {
151+ if err = json .Unmarshal ([]byte (config .CapabilityArgs ), & capabilityArgs ); err != nil {
152+ return err
153+ }
154+ }
155+
147156 cninet := libcni .NewCNIConfig (filepath .SplitList (config .CNIPath ), nil )
148157
149158 rt := & libcni.RuntimeConf {
150- ContainerID : config .ContainerID ,
151- NetNS : config .NetNS ,
152- IfName : config .IfName ,
153- Args : cniArgs ,
159+ ContainerID : config .ContainerID ,
160+ NetNS : config .NetNS ,
161+ IfName : config .IfName ,
162+ Args : cniArgs ,
163+ CapabilityArgs : capabilityArgs ,
154164 }
155165
156166 switch config .Cmd {
0 commit comments