Skip to content

Instantly share code, notes, and snippets.

@Billy99
Created February 9, 2021 00:27
Show Gist options
  • Select an option

  • Save Billy99/de304c553644bf1e2106fa722f4a550c to your computer and use it in GitHub Desktop.

Select an option

Save Billy99/de304c553644bf1e2106fa722f4a550c to your computer and use it in GitHub Desktop.
$ git diff pkg/types/conf.go
diff --git a/pkg/types/conf.go b/pkg/types/conf.go
index b0ca491..2420c67 100644
--- a/pkg/types/conf.go
+++ b/pkg/types/conf.go
@@ -143,10 +143,13 @@ func LoadDelegateNetConf(bytes []byte, net *NetworkSelectionElement, deviceID st
}
// mergeCNIRuntimeConfig creates CNI runtimeconfig from delegate
-func mergeCNIRuntimeConfig(runtimeConfig *RuntimeConfig, delegate *DelegateNetConf) *RuntimeConfig {
- logging.Debugf("mergeCNIRuntimeConfig: %v %v", runtimeConfig, delegate)
- if runtimeConfig == nil {
- runtimeConfig = &RuntimeConfig{}
+func mergeCNIRuntimeConfig(origRuntimeConfig *RuntimeConfig, delegate *DelegateNetConf) *RuntimeConfig {
+ logging.Debugf("mergeCNIRuntimeConfig: %v %v", origRuntimeConfig, delegate)
+ var runtimeConfig RuntimeConfig
+ if origRuntimeConfig == nil {
+ runtimeConfig = RuntimeConfig{}
+ } else {
+ runtimeConfig = *origRuntimeConfig
}
// multus inject RuntimeConfig only in case of non MasterPlugin.
@@ -172,8 +175,7 @@ func mergeCNIRuntimeConfig(runtimeConfig *RuntimeConfig, delegate *DelegateNetCo
}
logging.Debugf("mergeCNIRuntimeConfig: add runtimeConfig for net-attach-def: %v", runtimeConfig)
}
-
- return runtimeConfig
+ return &runtimeConfig
}
// CreateCNIRuntimeConf create CNI RuntimeConf for a delegate. If delegate configuration
@@ -181,8 +183,8 @@ func mergeCNIRuntimeConfig(runtimeConfig *RuntimeConfig, delegate *DelegateNetCo
func CreateCNIRuntimeConf(args *skel.CmdArgs, k8sArgs *K8sArgs, ifName string, rc *RuntimeConfig, delegate *DelegateNetConf) (*libcn
logging.Debugf("LoadCNIRuntimeConf: %v, %v, %s, %v %v", args, k8sArgs, ifName, rc, delegate)
var cniDeviceInfoFile string
+ var delegateRc *RuntimeConfig
- delegateRc := rc
if delegate != nil {
delegateRc = mergeCNIRuntimeConfig(delegateRc, delegate)
if delegateRc.CNIDeviceInfoFile == "" && delegate.Name != "" {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment