diff options
author | 2019-08-05 07:19:37 +0000 | |
---|---|---|
committer | 2019-08-05 07:19:37 +0000 | |
commit | 7c4eb36248331166a6fc3e57fb304a8113edc175 (patch) | |
tree | 9f9354cd49d0103c89cd9791c387a43ec8eb7f14 /src/k8splugin/plugins/network/plugin.go | |
parent | 4798f0f660de48e43e79626685e8b28bac7f2615 (diff) | |
parent | 1b282801d6a7a0e9104984895911b828da402623 (diff) |
Merge changes I46d47e64,I14d8eb6b
* changes:
Add test case for loading vFW Helm chart
Correct cni retrieval process from resource name
Diffstat (limited to 'src/k8splugin/plugins/network/plugin.go')
-rw-r--r-- | src/k8splugin/plugins/network/plugin.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/k8splugin/plugins/network/plugin.go b/src/k8splugin/plugins/network/plugin.go index ca5aa959..84a5fe51 100644 --- a/src/k8splugin/plugins/network/plugin.go +++ b/src/k8splugin/plugins/network/plugin.go @@ -31,14 +31,16 @@ var ExportedVariable networkPlugin type networkPlugin struct { } -func extractData(data string) (cniType, networkName string) { +func extractData(data string) (cniType, networkName string, err error) { re := regexp.MustCompile("_") split := re.Split(data, -1) - if len(split) != 3 { + if len(split) != 2 { + err = pkgerrors.New("Couldn't split resource '" + data + + "' into CNI type and Network name") return } - cniType = split[1] - networkName = split[2] + cniType = split[0] + networkName = split[1] return } @@ -82,7 +84,11 @@ func (p networkPlugin) List(gvk schema.GroupVersionKind, namespace string, // Delete an existing Network func (p networkPlugin) Delete(resource helm.KubernetesResource, namespace string, client plugin.KubernetesConnector) error { - cniType, networkName := extractData(resource.Name) + cniType, networkName, err := extractData(resource.Name) + if err != nil { + return pkgerrors.Wrap(err, "Error extracting CNI type from resource") + } + typePlugin, ok := utils.LoadedPlugins[cniType+"-network"] if !ok { return pkgerrors.New("No plugin for resource " + cniType + " found") |