From 21dcfcdc53cef63e5f41b9cd4d89b0e0984553ed Mon Sep 17 00:00:00 2001 From: spchan Date: Thu, 20 Feb 2020 13:44:28 +0800 Subject: [PATCH 1/2] Propagate existing CNI_ARGS to non-k8s consumers, e.g., podman Signed-off-by: Chan Shih-Ping --- pkg/ocicni/ocicni.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/ocicni/ocicni.go b/pkg/ocicni/ocicni.go index a8e2fbfa..9bae4da6 100644 --- a/pkg/ocicni/ocicni.go +++ b/pkg/ocicni/ocicni.go @@ -809,6 +809,13 @@ func buildCNIRuntimeConf(cacheDir string, podNetwork *PodNetwork, ifName string, CapabilityArgs: map[string]interface{}{}, } + // Propagate existing CNI_ARGS to non-k8s consumers + for _, kvpairs := range strings.Split(os.Getenv("CNI_ARGS"), ";"){ + if keyval := strings.Split(kvpairs, "="); len(keyval) == 2 { + rt.Args = append(rt.Args, [2]string{keyval[0], keyval[1]}) + } + } + // Add requested static IP to CNI_ARGS ip := runtimeConfig.IP if ip != "" { From c0cef6a42b97717b2461108f0f142a783403351d Mon Sep 17 00:00:00 2001 From: Chan Shih-Ping Date: Sat, 22 Feb 2020 00:37:12 +0800 Subject: [PATCH 2/2] Allow = inside environment variable body Signed-off-by: Chan Shih-Ping --- pkg/ocicni/ocicni.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/ocicni/ocicni.go b/pkg/ocicni/ocicni.go index 9bae4da6..d9d89a23 100644 --- a/pkg/ocicni/ocicni.go +++ b/pkg/ocicni/ocicni.go @@ -811,7 +811,7 @@ func buildCNIRuntimeConf(cacheDir string, podNetwork *PodNetwork, ifName string, // Propagate existing CNI_ARGS to non-k8s consumers for _, kvpairs := range strings.Split(os.Getenv("CNI_ARGS"), ";"){ - if keyval := strings.Split(kvpairs, "="); len(keyval) == 2 { + if keyval := strings.SplitN(kvpairs, "=", 2); len(keyval) == 2 { rt.Args = append(rt.Args, [2]string{keyval[0], keyval[1]}) } }