summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/mock_files/mock_plugins
diff options
context:
space:
mode:
authorKiran Kamineni <kiran.k.kamineni@intel.com>2019-05-30 14:43:06 -0700
committerKiran Kamineni <kiran.k.kamineni@intel.com>2019-06-06 17:32:41 -0700
commitd780f1b30c98a27d269e3e05423e9e54e0e022f6 (patch)
tree3d01a1fab1a846206ae714f94838de2f0a659e13 /src/k8splugin/mock_files/mock_plugins
parentf006c55c0793a0cacac5aa45ba7f13fd5c6ef5f4 (diff)
Plugin code refactoring
The plugin code has been refactored to implement a common interface. This will allow us to do plugin validation at loadtime of the plugin instead of at runtime. This also makes the code calling the plugins cleaner and easier to read. Issue-ID: MULTICLOUD-557 Change-Id: Ice2bcc9b850d7c0e1707dcc42132c63dd77472a7 Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
Diffstat (limited to 'src/k8splugin/mock_files/mock_plugins')
-rw-r--r--src/k8splugin/mock_files/mock_plugins/mockplugin.go31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/k8splugin/mock_files/mock_plugins/mockplugin.go b/src/k8splugin/mock_files/mock_plugins/mockplugin.go
index bdc2130c..0c3d246d 100644
--- a/src/k8splugin/mock_files/mock_plugins/mockplugin.go
+++ b/src/k8splugin/mock_files/mock_plugins/mockplugin.go
@@ -14,30 +14,43 @@ limitations under the License.
package main
import (
- "k8s.io/client-go/kubernetes"
+ "k8splugin/internal/helm"
+ "k8splugin/internal/plugin"
- utils "k8splugin/internal"
+ "k8s.io/apimachinery/pkg/runtime/schema"
)
-func main() {}
+// ExportedVariable is what we will look for when calling the plugin
+var ExportedVariable mockPlugin
+
+type mockPlugin struct {
+}
// Create object in a specific Kubernetes resource
-func Create(data *utils.ResourceData, client kubernetes.Interface) (string, error) {
+func (p mockPlugin) Create(yamlFilePath string, namespace string, client plugin.KubernetesConnector) (string, error) {
return "resource-name", nil
}
// List of existing resources
-func List(namespace string, client kubernetes.Interface) ([]string, error) {
- returnVal := []string{"resource-name-1", "resource-name-2"}
+func (p mockPlugin) List(gvk schema.GroupVersionKind, namespace string,
+ client plugin.KubernetesConnector) ([]helm.KubernetesResource, error) {
+ returnVal := []helm.KubernetesResource{
+ {
+ Name: "resource-name-1",
+ },
+ {
+ Name: "resource-name-2",
+ },
+ }
return returnVal, nil
}
// Delete existing resources
-func Delete(name string, namespace string, client kubernetes.Interface) error {
+func (p mockPlugin) Delete(resource helm.KubernetesResource, namespace string, client plugin.KubernetesConnector) error {
return nil
}
// Get existing resource host
-func Get(name string, namespace string, client kubernetes.Interface) (string, error) {
- return name, nil
+func (p mockPlugin) Get(resource helm.KubernetesResource, namespace string, client plugin.KubernetesConnector) (string, error) {
+ return resource.Name, nil
}