@@ -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
@@ -144,7 +149,7 @@ func NewCNIConfigWithCacheDir(path []string, cacheDir string, exec invoke.Exec)
144
149
}
145
150
}
146
151
147
- func buildOneConfig (name , cniVersion string , orig * NetworkConfig , prevResult types.Result , rt * RuntimeConf ) (* NetworkConfig , error ) {
152
+ func buildOneConfig (name , cniVersion string , orig * PluginConfig , prevResult types.Result , rt * RuntimeConf ) (* PluginConfig , error ) {
148
153
var err error
149
154
150
155
inject := map [string ]interface {}{
@@ -180,7 +185,7 @@ func buildOneConfig(name, cniVersion string, orig *NetworkConfig, prevResult typ
180
185
// capabilities include "portMappings", and the CapabilityArgs map includes a
181
186
// "portMappings" key, that key and its value are added to the "runtimeConfig"
182
187
// dictionary to be passed to the plugin's stdin.
183
- func injectRuntimeConfig (orig * NetworkConfig , rt * RuntimeConf ) (* NetworkConfig , error ) {
188
+ func injectRuntimeConfig (orig * PluginConfig , rt * RuntimeConf ) (* PluginConfig , error ) {
184
189
var err error
185
190
186
191
rc := make (map [string ]interface {})
@@ -401,7 +406,7 @@ func (c *CNIConfig) GetNetworkListCachedResult(list *NetworkConfigList, rt *Runt
401
406
402
407
// GetNetworkCachedResult returns the cached Result of the previous
403
408
// AddNetwork() operation for a network, or an error.
404
- func (c * CNIConfig ) GetNetworkCachedResult (net * NetworkConfig , rt * RuntimeConf ) (types.Result , error ) {
409
+ func (c * CNIConfig ) GetNetworkCachedResult (net * PluginConfig , rt * RuntimeConf ) (types.Result , error ) {
405
410
return c .getCachedResult (net .Network .Name , net .Network .CNIVersion , rt )
406
411
}
407
412
@@ -413,7 +418,7 @@ func (c *CNIConfig) GetNetworkListCachedConfig(list *NetworkConfigList, rt *Runt
413
418
414
419
// GetNetworkCachedConfig copies the input RuntimeConf to output
415
420
// RuntimeConf with fields updated with info from the cached Config.
416
- func (c * CNIConfig ) GetNetworkCachedConfig (net * NetworkConfig , rt * RuntimeConf ) ([]byte , * RuntimeConf , error ) {
421
+ func (c * CNIConfig ) GetNetworkCachedConfig (net * PluginConfig , rt * RuntimeConf ) ([]byte , * RuntimeConf , error ) {
417
422
return c .getCachedConfig (net .Network .Name , rt )
418
423
}
419
424
@@ -476,7 +481,7 @@ func (c *CNIConfig) GetCachedAttachments(containerID string) ([]*NetworkAttachme
476
481
return attachments , nil
477
482
}
478
483
479
- func (c * CNIConfig ) addNetwork (ctx context.Context , name , cniVersion string , net * NetworkConfig , prevResult types.Result , rt * RuntimeConf ) (types.Result , error ) {
484
+ func (c * CNIConfig ) addNetwork (ctx context.Context , name , cniVersion string , net * PluginConfig , prevResult types.Result , rt * RuntimeConf ) (types.Result , error ) {
480
485
c .ensureExec ()
481
486
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
482
487
if err != nil {
@@ -518,7 +523,7 @@ func (c *CNIConfig) AddNetworkList(ctx context.Context, list *NetworkConfigList,
518
523
return result , nil
519
524
}
520
525
521
- func (c * CNIConfig ) checkNetwork (ctx context.Context , name , cniVersion string , net * NetworkConfig , prevResult types.Result , rt * RuntimeConf ) error {
526
+ func (c * CNIConfig ) checkNetwork (ctx context.Context , name , cniVersion string , net * PluginConfig , prevResult types.Result , rt * RuntimeConf ) error {
522
527
c .ensureExec ()
523
528
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
524
529
if err != nil {
@@ -560,7 +565,7 @@ func (c *CNIConfig) CheckNetworkList(ctx context.Context, list *NetworkConfigLis
560
565
return nil
561
566
}
562
567
563
- func (c * CNIConfig ) delNetwork (ctx context.Context , name , cniVersion string , net * NetworkConfig , prevResult types.Result , rt * RuntimeConf ) error {
568
+ func (c * CNIConfig ) delNetwork (ctx context.Context , name , cniVersion string , net * PluginConfig , prevResult types.Result , rt * RuntimeConf ) error {
564
569
c .ensureExec ()
565
570
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
566
571
if err != nil {
@@ -603,7 +608,7 @@ func (c *CNIConfig) DelNetworkList(ctx context.Context, list *NetworkConfigList,
603
608
return nil
604
609
}
605
610
606
- func pluginDescription (net * types.NetConf ) string {
611
+ func pluginDescription (net * types.PluginConf ) string {
607
612
if net == nil {
608
613
return "<missing>"
609
614
}
@@ -617,7 +622,7 @@ func pluginDescription(net *types.NetConf) string {
617
622
}
618
623
619
624
// AddNetwork executes the plugin with the ADD command
620
- func (c * CNIConfig ) AddNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) (types.Result , error ) {
625
+ func (c * CNIConfig ) AddNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) (types.Result , error ) {
621
626
result , err := c .addNetwork (ctx , net .Network .Name , net .Network .CNIVersion , net , nil , rt )
622
627
if err != nil {
623
628
return nil , err
@@ -631,7 +636,7 @@ func (c *CNIConfig) AddNetwork(ctx context.Context, net *NetworkConfig, rt *Runt
631
636
}
632
637
633
638
// CheckNetwork executes the plugin with the CHECK command
634
- func (c * CNIConfig ) CheckNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) error {
639
+ func (c * CNIConfig ) CheckNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) error {
635
640
// CHECK was added in CNI spec version 0.4.0 and higher
636
641
if gtet , err := version .GreaterThanOrEqualTo (net .Network .CNIVersion , "0.4.0" ); err != nil {
637
642
return err
@@ -647,7 +652,7 @@ func (c *CNIConfig) CheckNetwork(ctx context.Context, net *NetworkConfig, rt *Ru
647
652
}
648
653
649
654
// DelNetwork executes the plugin with the DEL command
650
- func (c * CNIConfig ) DelNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) error {
655
+ func (c * CNIConfig ) DelNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) error {
651
656
var cachedResult types.Result
652
657
653
658
// Cached result on DEL was added in CNI spec version 0.4.0 and higher
@@ -707,7 +712,7 @@ func (c *CNIConfig) ValidateNetworkList(ctx context.Context, list *NetworkConfig
707
712
// ValidateNetwork checks that a configuration is reasonably valid.
708
713
// It uses the same logic as ValidateNetworkList)
709
714
// Returns a list of capabilities
710
- func (c * CNIConfig ) ValidateNetwork (ctx context.Context , net * NetworkConfig ) ([]string , error ) {
715
+ func (c * CNIConfig ) ValidateNetwork (ctx context.Context , net * PluginConfig ) ([]string , error ) {
711
716
caps := []string {}
712
717
for c , ok := range net .Network .Capabilities {
713
718
if ok {
@@ -819,7 +824,7 @@ func (c *CNIConfig) GCNetworkList(ctx context.Context, list *NetworkConfigList,
819
824
return errors .Join (errs ... )
820
825
}
821
826
822
- func (c * CNIConfig ) gcNetwork (ctx context.Context , net * NetworkConfig ) error {
827
+ func (c * CNIConfig ) gcNetwork (ctx context.Context , net * PluginConfig ) error {
823
828
c .ensureExec ()
824
829
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
825
830
if err != nil {
@@ -854,7 +859,7 @@ func (c *CNIConfig) GetStatusNetworkList(ctx context.Context, list *NetworkConfi
854
859
return nil
855
860
}
856
861
857
- func (c * CNIConfig ) getStatusNetwork (ctx context.Context , net * NetworkConfig ) error {
862
+ func (c * CNIConfig ) getStatusNetwork (ctx context.Context , net * PluginConfig ) error {
858
863
c .ensureExec ()
859
864
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
860
865
if err != nil {
0 commit comments