@@ -67,18 +67,23 @@ 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
80
+ Name string
81
+ CNIVersion string
82
+ DisableCheck bool
79
83
DisableGC bool
80
- Plugins []* NetworkConfig
81
- Bytes []byte
84
+ LoadOnlyInlinedPlugins bool
85
+ Plugins []* PluginConfig
86
+ Bytes []byte
82
87
}
83
88
84
89
type NetworkAttachment struct {
@@ -102,14 +107,14 @@ type CNI interface {
102
107
GetNetworkListCachedResult (net * NetworkConfigList , rt * RuntimeConf ) (types.Result , error )
103
108
GetNetworkListCachedConfig (net * NetworkConfigList , rt * RuntimeConf ) ([]byte , * RuntimeConf , error )
104
109
105
- AddNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) (types.Result , error )
106
- CheckNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) error
107
- DelNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) error
108
- GetNetworkCachedResult (net * NetworkConfig , rt * RuntimeConf ) (types.Result , error )
109
- GetNetworkCachedConfig (net * NetworkConfig , rt * RuntimeConf ) ([]byte , * RuntimeConf , error )
110
+ AddNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) (types.Result , error )
111
+ CheckNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) error
112
+ DelNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) error
113
+ GetNetworkCachedResult (net * PluginConfig , rt * RuntimeConf ) (types.Result , error )
114
+ GetNetworkCachedConfig (net * PluginConfig , rt * RuntimeConf ) ([]byte , * RuntimeConf , error )
110
115
111
116
ValidateNetworkList (ctx context.Context , net * NetworkConfigList ) ([]string , error )
112
- ValidateNetwork (ctx context.Context , net * NetworkConfig ) ([]string , error )
117
+ ValidateNetwork (ctx context.Context , net * PluginConfig ) ([]string , error )
113
118
114
119
GCNetworkList (ctx context.Context , net * NetworkConfigList , args * GCArgs ) error
115
120
GetStatusNetworkList (ctx context.Context , net * NetworkConfigList ) error
@@ -147,7 +152,7 @@ func NewCNIConfigWithCacheDir(path []string, cacheDir string, exec invoke.Exec)
147
152
}
148
153
}
149
154
150
- func buildOneConfig (name , cniVersion string , orig * NetworkConfig , prevResult types.Result , rt * RuntimeConf ) (* NetworkConfig , error ) {
155
+ func buildOneConfig (name , cniVersion string , orig * PluginConfig , prevResult types.Result , rt * RuntimeConf ) (* PluginConfig , error ) {
151
156
var err error
152
157
153
158
inject := map [string ]interface {}{
@@ -183,7 +188,7 @@ func buildOneConfig(name, cniVersion string, orig *NetworkConfig, prevResult typ
183
188
// capabilities include "portMappings", and the CapabilityArgs map includes a
184
189
// "portMappings" key, that key and its value are added to the "runtimeConfig"
185
190
// dictionary to be passed to the plugin's stdin.
186
- func injectRuntimeConfig (orig * NetworkConfig , rt * RuntimeConf ) (* NetworkConfig , error ) {
191
+ func injectRuntimeConfig (orig * PluginConfig , rt * RuntimeConf ) (* PluginConfig , error ) {
187
192
var err error
188
193
189
194
rc := make (map [string ]interface {})
@@ -404,7 +409,7 @@ func (c *CNIConfig) GetNetworkListCachedResult(list *NetworkConfigList, rt *Runt
404
409
405
410
// GetNetworkCachedResult returns the cached Result of the previous
406
411
// AddNetwork() operation for a network, or an error.
407
- func (c * CNIConfig ) GetNetworkCachedResult (net * NetworkConfig , rt * RuntimeConf ) (types.Result , error ) {
412
+ func (c * CNIConfig ) GetNetworkCachedResult (net * PluginConfig , rt * RuntimeConf ) (types.Result , error ) {
408
413
return c .getCachedResult (net .Network .Name , net .Network .CNIVersion , rt )
409
414
}
410
415
@@ -416,7 +421,7 @@ func (c *CNIConfig) GetNetworkListCachedConfig(list *NetworkConfigList, rt *Runt
416
421
417
422
// GetNetworkCachedConfig copies the input RuntimeConf to output
418
423
// RuntimeConf with fields updated with info from the cached Config.
419
- func (c * CNIConfig ) GetNetworkCachedConfig (net * NetworkConfig , rt * RuntimeConf ) ([]byte , * RuntimeConf , error ) {
424
+ func (c * CNIConfig ) GetNetworkCachedConfig (net * PluginConfig , rt * RuntimeConf ) ([]byte , * RuntimeConf , error ) {
420
425
return c .getCachedConfig (net .Network .Name , rt )
421
426
}
422
427
@@ -482,7 +487,7 @@ func (c *CNIConfig) GetCachedAttachments(containerID string) ([]*NetworkAttachme
482
487
return attachments , nil
483
488
}
484
489
485
- func (c * CNIConfig ) addNetwork (ctx context.Context , name , cniVersion string , net * NetworkConfig , prevResult types.Result , rt * RuntimeConf ) (types.Result , error ) {
490
+ func (c * CNIConfig ) addNetwork (ctx context.Context , name , cniVersion string , net * PluginConfig , prevResult types.Result , rt * RuntimeConf ) (types.Result , error ) {
486
491
c .ensureExec ()
487
492
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
488
493
if err != nil {
@@ -524,7 +529,7 @@ func (c *CNIConfig) AddNetworkList(ctx context.Context, list *NetworkConfigList,
524
529
return result , nil
525
530
}
526
531
527
- func (c * CNIConfig ) checkNetwork (ctx context.Context , name , cniVersion string , net * NetworkConfig , prevResult types.Result , rt * RuntimeConf ) error {
532
+ func (c * CNIConfig ) checkNetwork (ctx context.Context , name , cniVersion string , net * PluginConfig , prevResult types.Result , rt * RuntimeConf ) error {
528
533
c .ensureExec ()
529
534
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
530
535
if err != nil {
@@ -566,7 +571,7 @@ func (c *CNIConfig) CheckNetworkList(ctx context.Context, list *NetworkConfigLis
566
571
return nil
567
572
}
568
573
569
- func (c * CNIConfig ) delNetwork (ctx context.Context , name , cniVersion string , net * NetworkConfig , prevResult types.Result , rt * RuntimeConf ) error {
574
+ func (c * CNIConfig ) delNetwork (ctx context.Context , name , cniVersion string , net * PluginConfig , prevResult types.Result , rt * RuntimeConf ) error {
570
575
c .ensureExec ()
571
576
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
572
577
if err != nil {
@@ -607,7 +612,7 @@ func (c *CNIConfig) DelNetworkList(ctx context.Context, list *NetworkConfigList,
607
612
return nil
608
613
}
609
614
610
- func pluginDescription (net * types.NetConf ) string {
615
+ func pluginDescription (net * types.PluginConf ) string {
611
616
if net == nil {
612
617
return "<missing>"
613
618
}
@@ -621,7 +626,7 @@ func pluginDescription(net *types.NetConf) string {
621
626
}
622
627
623
628
// AddNetwork executes the plugin with the ADD command
624
- func (c * CNIConfig ) AddNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) (types.Result , error ) {
629
+ func (c * CNIConfig ) AddNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) (types.Result , error ) {
625
630
result , err := c .addNetwork (ctx , net .Network .Name , net .Network .CNIVersion , net , nil , rt )
626
631
if err != nil {
627
632
return nil , err
@@ -635,7 +640,7 @@ func (c *CNIConfig) AddNetwork(ctx context.Context, net *NetworkConfig, rt *Runt
635
640
}
636
641
637
642
// CheckNetwork executes the plugin with the CHECK command
638
- func (c * CNIConfig ) CheckNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) error {
643
+ func (c * CNIConfig ) CheckNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) error {
639
644
// CHECK was added in CNI spec version 0.4.0 and higher
640
645
if gtet , err := version .GreaterThanOrEqualTo (net .Network .CNIVersion , "0.4.0" ); err != nil {
641
646
return err
@@ -651,7 +656,7 @@ func (c *CNIConfig) CheckNetwork(ctx context.Context, net *NetworkConfig, rt *Ru
651
656
}
652
657
653
658
// DelNetwork executes the plugin with the DEL command
654
- func (c * CNIConfig ) DelNetwork (ctx context.Context , net * NetworkConfig , rt * RuntimeConf ) error {
659
+ func (c * CNIConfig ) DelNetwork (ctx context.Context , net * PluginConfig , rt * RuntimeConf ) error {
655
660
var cachedResult types.Result
656
661
657
662
// Cached result on DEL was added in CNI spec version 0.4.0 and higher
@@ -711,7 +716,7 @@ func (c *CNIConfig) ValidateNetworkList(ctx context.Context, list *NetworkConfig
711
716
// ValidateNetwork checks that a configuration is reasonably valid.
712
717
// It uses the same logic as ValidateNetworkList)
713
718
// Returns a list of capabilities
714
- func (c * CNIConfig ) ValidateNetwork (ctx context.Context , net * NetworkConfig ) ([]string , error ) {
719
+ func (c * CNIConfig ) ValidateNetwork (ctx context.Context , net * PluginConfig ) ([]string , error ) {
715
720
caps := []string {}
716
721
for c , ok := range net .Network .Capabilities {
717
722
if ok {
@@ -834,7 +839,7 @@ func (c *CNIConfig) GCNetworkList(ctx context.Context, list *NetworkConfigList,
834
839
return errors .Join (errs ... )
835
840
}
836
841
837
- func (c * CNIConfig ) gcNetwork (ctx context.Context , net * NetworkConfig ) error {
842
+ func (c * CNIConfig ) gcNetwork (ctx context.Context , net * PluginConfig ) error {
838
843
c .ensureExec ()
839
844
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
840
845
if err != nil {
@@ -869,7 +874,7 @@ func (c *CNIConfig) GetStatusNetworkList(ctx context.Context, list *NetworkConfi
869
874
return nil
870
875
}
871
876
872
- func (c * CNIConfig ) getStatusNetwork (ctx context.Context , net * NetworkConfig ) error {
877
+ func (c * CNIConfig ) getStatusNetwork (ctx context.Context , net * PluginConfig ) error {
873
878
c .ensureExec ()
874
879
pluginPath , err := c .exec .FindInPath (net .Network .Type , c .Path )
875
880
if err != nil {
0 commit comments