Add static compile time check to plugins 01/92401/1
authorKiran Kamineni <kiran.k.kamineni@intel.com>
Wed, 31 Jul 2019 18:48:19 +0000 (11:48 -0700)
committerKiran Kamineni <kiran.k.kamineni@intel.com>
Wed, 31 Jul 2019 18:48:23 +0000 (11:48 -0700)
Add a static compile time check to
plugins to make sure that any interface implementation
mismatch is caught at compile time rather than runtime.

Issue-ID: MULTICLOUD-666
Change-Id: I7f57774ad9384edb874cf64534f521014aea422f
Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
src/k8splugin/plugins/generic/plugin.go
src/k8splugin/plugins/namespace/plugin.go
src/k8splugin/plugins/network/plugin.go
src/k8splugin/plugins/service/plugin.go

index b9a96ab..b20cbe3 100644 (file)
@@ -23,10 +23,13 @@ import (
        "k8s.io/apimachinery/pkg/runtime/schema"
 
        utils "github.com/onap/multicloud-k8s/src/k8splugin/internal"
-       "github.com/onap/multicloud-k8s/src/k8splugin/internal/plugin"
        "github.com/onap/multicloud-k8s/src/k8splugin/internal/helm"
+       "github.com/onap/multicloud-k8s/src/k8splugin/internal/plugin"
 )
 
+// Compile time check to see if genericPlugin implements the correct interface
+var _ plugin.Reference = genericPlugin{}
+
 // ExportedVariable is what we will look for when calling the generic plugin
 var ExportedVariable genericPlugin
 
index d30f55b..feb2aa6 100644 (file)
@@ -26,6 +26,9 @@ import (
        "github.com/onap/multicloud-k8s/src/k8splugin/internal/plugin"
 )
 
+// Compile time check to see if namespacePlugin implements the correct interface
+var _ plugin.Reference = namespacePlugin{}
+
 // ExportedVariable is what we will look for when calling the plugin
 var ExportedVariable namespacePlugin
 
index ca5aa95..49aedc5 100644 (file)
@@ -14,9 +14,10 @@ limitations under the License.
 package main
 
 import (
-       v1 "github.com/onap/multicloud-k8s/src/k8splugin/plugins/network/v1"
        "regexp"
 
+       v1 "github.com/onap/multicloud-k8s/src/k8splugin/plugins/network/v1"
+
        utils "github.com/onap/multicloud-k8s/src/k8splugin/internal"
        "github.com/onap/multicloud-k8s/src/k8splugin/internal/helm"
        "github.com/onap/multicloud-k8s/src/k8splugin/internal/plugin"
@@ -25,6 +26,9 @@ import (
        "k8s.io/apimachinery/pkg/runtime/schema"
 )
 
+// Compile time check to see if networkPlugin implements the correct interface
+var _ plugin.Reference = networkPlugin{}
+
 // ExportedVariable is what we will look for when calling the plugin
 var ExportedVariable networkPlugin
 
index 2fceffc..136a134 100644 (file)
@@ -26,6 +26,9 @@ import (
        "github.com/onap/multicloud-k8s/src/k8splugin/internal/plugin"
 )
 
+// Compile time check to see if servicePlugin implements the correct interface
+var _ plugin.Reference = servicePlugin{}
+
 // ExportedVariable is what we will look for when calling the plugin
 var ExportedVariable servicePlugin