diff options
author | Bin Yang <bin.yang@windriver.com> | 2019-04-26 02:00:11 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-04-26 02:00:11 +0000 |
commit | 4a4ca50227f3442ffea819544527790d540a7e2a (patch) | |
tree | a9fc25f8445cc8c1909e15b33115e2d902e16f07 | |
parent | e537bbce3040d72f9db2d205f77395d99c62b5e1 (diff) | |
parent | 4095bd620f3ca4f4e6b6042f68829a895471fafa (diff) |
Merge "Use the unstructured type for decode"
-rw-r--r-- | src/k8splugin/internal/utils.go | 2 | ||||
-rw-r--r-- | src/k8splugin/plugins/generic/plugin.go | 12 |
2 files changed, 4 insertions, 10 deletions
diff --git a/src/k8splugin/internal/utils.go b/src/k8splugin/internal/utils.go index 7785733d..681b1b52 100644 --- a/src/k8splugin/internal/utils.go +++ b/src/k8splugin/internal/utils.go @@ -42,7 +42,7 @@ type ResourceData struct { } // DecodeYAML reads a YAMl file to extract the Kubernetes object definition -var DecodeYAML = func(path string, into runtime.Object) (runtime.Object, error) { +func DecodeYAML(path string, into runtime.Object) (runtime.Object, error) { if _, err := os.Stat(path); err != nil { if os.IsNotExist(err) { return nil, pkgerrors.New("File " + path + " not found") diff --git a/src/k8splugin/plugins/generic/plugin.go b/src/k8splugin/plugins/generic/plugin.go index f3b2798a..9ecaf68c 100644 --- a/src/k8splugin/plugins/generic/plugin.go +++ b/src/k8splugin/plugins/generic/plugin.go @@ -21,7 +21,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/kubernetes/scheme" utils "k8splugin/internal" "k8splugin/internal/app" @@ -38,16 +37,11 @@ func (g genericPlugin) Create(yamlFilePath string, namespace string, client *app } //Decode the yaml file to create a runtime.Object - obj, err := utils.DecodeYAML(yamlFilePath, nil) - if err != nil { - return "", pkgerrors.Wrap(err, "Decode deployment object error") - } - - //Convert the runtime.Object to an unstructured Object unstruct := &unstructured.Unstructured{} - err = scheme.Scheme.Convert(obj, unstruct, nil) + //Ignore the returned obj as we expect the data in unstruct + _, err := utils.DecodeYAML(yamlFilePath, unstruct) if err != nil { - return "", pkgerrors.Wrap(err, "Converting to unstructured object") + return "", pkgerrors.Wrap(err, "Decode deployment object error") } dynClient := client.GetDynamicClient() |