@@ -67,17 +67,22 @@ type RuntimeConf struct {
67
67
CacheDir string
68
68
}
69
69
70
- type NetworkConfig struct {
71
- Network * types.NetConf
70
+ // Deprecated: Use PluginConfig instead of NetworkConfig, the NetworkConfig
71
+ // backwards-compat alias will be removed in a future release.
72
+ type NetworkConfig = PluginConfig
73
+
74
+ type PluginConfig struct {
75
+ Network * types.PluginConf
72
76
Bytes []byte
73
77
}
74
78
75
79
type NetworkConfigList struct {
76
- Name string
77
- CNIVersion string
78
- DisableCheck bool
79
- Plugins []* NetworkConfig
80
- Bytes []byte
80
+ Name string
81
+ CNIVersion string
82
+ DisableCheck bool
83
+ LoadOnlyInlinedPlugins bool
84
+ Plugins []* PluginConfig
85
+ Bytes []byte
81
86
}
82
87
83
88
type NetworkAttachment struct {
@@ -101,14 +106,14 @@ type CNI interface {
101
106
GetNetworkListCachedResult (net * NetworkConfigList , rt * RuntimeConf ) (types.Result , error )
102
107
GetNetworkListCachedConfig (net * NetworkConfigList , rt * RuntimeConf ) ([]byte , * RuntimeConf , error )
103
108
104
- AddNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) (types.Result , error )
105
- CheckNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) error
106
- DelNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) error
107
- GetNetworkCachedResult (net * NetworkConfig , rt * RuntimeConf ) (types.Result , error )
108
- GetNetworkCachedConfig (net * NetworkConfig , rt * RuntimeConf ) ([]byte , * RuntimeConf , error )
109
+ AddNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) (types.Result , error )
110
+ CheckNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) error
111
+ DelNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) error
112
+ GetNetworkCachedResult (net * PluginConfig , rt * RuntimeConf ) (types.Result , error )
113
+ GetNetworkCachedConfig (net * PluginConfig , rt * RuntimeConf ) ([]byte , * RuntimeConf , error )
109
114
110
115
ValidateNetworkList (ctx context.Context , net * NetworkConfigList ) ([]string , error )
111
- ValidateNetwork (ctx context.Context , net * NetworkConfig ) ([]string , error )
116
+ ValidateNetwork (ctx context.Context , net * PluginConfig ) ([]string , error )
112
117
113
118
GCNetworkList (ctx context.Context , net * NetworkConfigList , args * GCArgs ) error
114
119
GetStatusNetworkList (ctx context.Context , net * NetworkConfigList ) error
@@ -146,7 +151,7 @@ func NewCNIConfigWithCacheDir(path []string, cacheDir string, exec invoke.Exec)
146
151
}
147
152
}
148
153
149
- func buildOneConfig (name , cniVersion string , orig * NetworkConfig , prevResult types.Result , rt * RuntimeConf ) (* NetworkConfig , error ) {
154
+ func buildOneConfig (name , cniVersion string , orig * PluginConfig , prevResult types.Result , rt * RuntimeConf ) (* PluginConfig , error ) {
150
155
var err error
151
156
152
157
inject := map [string ]interface {}{
@@ -182,7 +187,7 @@ func buildOneConfig(name, cniVersion string, orig *NetworkConfig, prevResult typ
182
187
// capabilities include "portMappings", and the CapabilityArgs map includes a
183
188
// "portMappings" key, that key and its value are added to the "runtimeConfig"
184
189
// dictionary to be passed to the plugin's stdin.
185
- func injectRuntimeConfig (orig * NetworkConfig , rt * RuntimeConf ) (* NetworkConfig , error ) {
190
+ func injectRuntimeConfig (orig * PluginConfig , rt * RuntimeConf ) (* PluginConfig , error ) {
186
191
var err error
187
192
188
193
rc := make (map [string ]interface {})
@@ -403,7 +408,7 @@ func (c *CNIConfig) GetNetworkListCachedResult(list *NetworkConfigList, rt *Runt
403
408
404
409
// GetNetworkCachedResult returns the cached Result of the previous
405
410
// AddNetwork() operation for a network, or an error.
406
- func (c * CNIConfig ) GetNetworkCachedResult (net * NetworkConfig , rt * RuntimeConf ) (types.Result , error ) {
411
+ func (c * CNIConfig ) GetNetworkCachedResult (net * PluginConfig , rt * RuntimeConf ) (types.Result , error ) {
407
412
return c .getCachedResult (net .Network .Name , net .Network .CNIVersion , rt )
408
413
}
409
414
@@ -415,7 +420,7 @@ func (c *CNIConfig) GetNetworkListCachedConfig(list *NetworkConfigList, rt *Runt
415
420
416
421
// GetNetworkCachedConfig copies the input RuntimeConf to output
417
422
// RuntimeConf with fields updated with info from the cached Config.
418
- func (c * CNIConfig ) GetNetworkCachedConfig (net * NetworkConfig , rt * RuntimeConf ) ([]byte , * RuntimeConf , error ) {
423
+ func (c * CNIConfig ) GetNetworkCachedConfig (net * PluginConfig , rt * RuntimeConf ) ([]byte , * RuntimeConf , error ) {
419
424
return c .getCachedConfig (net .Network .Name , rt )
420
425
}
421
426
@@ -478,7 +483,7 @@ func (c *CNIConfig) GetCachedAttachments(containerID string) ([]*NetworkAttachme
478
483
return attachments , nil
479
484
}
480
485
481
- func (c * CNIConfig ) addNetwork (ctx context.Context , name , cniVersion string , net * NetworkConfig , prevResult types.Result , rt * RuntimeConf ) (types.Result , error ) {
486
+ func (c * CNIConfig ) addNetwork (ctx context.Context , name , cniVersion string , net * PluginConfig , prevResult types.Result , rt * RuntimeConf ) (types.Result , error ) {
482
487
c .ensureExec ()
483
488
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
484
489
if err != nil {
@@ -520,7 +525,7 @@ func (c *CNIConfig) AddNetworkList(ctx context.Context, list *NetworkConfigList,
520
525
return result , nil
521
526
}
522
527
523
- func (c * CNIConfig ) checkNetwork (ctx context.Context , name , cniVersion string , net * NetworkConfig , prevResult types.Result , rt * RuntimeConf ) error {
528
+ func (c * CNIConfig ) checkNetwork (ctx context.Context , name , cniVersion string , net * PluginConfig , prevResult types.Result , rt * RuntimeConf ) error {
524
529
c .ensureExec ()
525
530
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
526
531
if err != nil {
@@ -562,7 +567,7 @@ func (c *CNIConfig) CheckNetworkList(ctx context.Context, list *NetworkConfigLis
562
567
return nil
563
568
}
564
569
565
- func (c * CNIConfig ) delNetwork (ctx context.Context , name , cniVersion string , net * NetworkConfig , prevResult types.Result , rt * RuntimeConf ) error {
570
+ func (c * CNIConfig ) delNetwork (ctx context.Context , name , cniVersion string , net * PluginConfig , prevResult types.Result , rt * RuntimeConf ) error {
566
571
c .ensureExec ()
567
572
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
568
573
if err != nil {
@@ -605,7 +610,7 @@ func (c *CNIConfig) DelNetworkList(ctx context.Context, list *NetworkConfigList,
605
610
return nil
606
611
}
607
612
608
- func pluginDescription (net * types.NetConf ) string {
613
+ func pluginDescription (net * types.PluginConf ) string {
609
614
if net == nil {
610
615
return "<missing>"
611
616
}
@@ -619,7 +624,7 @@ func pluginDescription(net *types.NetConf) string {
619
624
}
620
625
621
626
// AddNetwork executes the plugin with the ADD command
622
- func (c * CNIConfig ) AddNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) (types.Result , error ) {
627
+ func (c * CNIConfig ) AddNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) (types.Result , error ) {
623
628
result , err := c .addNetwork (ctx , net .Network .Name , net .Network .CNIVersion , net , nil , rt )
624
629
if err != nil {
625
630
return nil , err
@@ -633,7 +638,7 @@ func (c *CNIConfig) AddNetwork(ctx context.Context, net *NetworkConfig, rt *Runt
633
638
}
634
639
635
640
// CheckNetwork executes the plugin with the CHECK command
636
- func (c * CNIConfig ) CheckNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) error {
641
+ func (c * CNIConfig ) CheckNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) error {
637
642
// CHECK was added in CNI spec version 0.4.0 and higher
638
643
if gtet , err := version .GreaterThanOrEqualTo (net .Network .CNIVersion , "0.4.0" ); err != nil {
639
644
return err
@@ -649,7 +654,7 @@ func (c *CNIConfig) CheckNetwork(ctx context.Context, net *NetworkConfig, rt *Ru
649
654
}
650
655
651
656
// DelNetwork executes the plugin with the DEL command
652
- func (c * CNIConfig ) DelNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) error {
657
+ func (c * CNIConfig ) DelNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) error {
653
658
var cachedResult types.Result
654
659
655
660
// Cached result on DEL was added in CNI spec version 0.4.0 and higher
@@ -709,7 +714,7 @@ func (c *CNIConfig) ValidateNetworkList(ctx context.Context, list *NetworkConfig
709
714
// ValidateNetwork checks that a configuration is reasonably valid.
710
715
// It uses the same logic as ValidateNetworkList)
711
716
// Returns a list of capabilities
712
- func (c * CNIConfig ) ValidateNetwork (ctx context.Context , net * NetworkConfig ) ([]string , error ) {
717
+ func (c * CNIConfig ) ValidateNetwork (ctx context.Context , net * PluginConfig ) ([]string , error ) {
713
718
caps := []string {}
714
719
for c , ok := range net .Network .Capabilities {
715
720
if ok {
@@ -827,7 +832,7 @@ func (c *CNIConfig) GCNetworkList(ctx context.Context, list *NetworkConfigList,
827
832
return errors .Join (errs ... )
828
833
}
829
834
830
- func (c * CNIConfig ) gcNetwork (ctx context.Context , net * NetworkConfig ) error {
835
+ func (c * CNIConfig ) gcNetwork (ctx context.Context , net * PluginConfig ) error {
831
836
c .ensureExec ()
832
837
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
833
838
if err != nil {
@@ -862,7 +867,7 @@ func (c *CNIConfig) GetStatusNetworkList(ctx context.Context, list *NetworkConfi
862
867
return nil
863
868
}
864
869
865
- func (c * CNIConfig ) getStatusNetwork (ctx context.Context , net * NetworkConfig ) error {
870
+ func (c * CNIConfig ) getStatusNetwork (ctx context.Context , net * PluginConfig ) error {
866
871
c .ensureExec ()
867
872
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
868
873
if err != nil {
0 commit comments