summaryrefslogtreecommitdiffstats
path: root/src/k8splugin/krd/plugins.go
diff options
context:
space:
mode:
authorVictor Morales <victor.morales@intel.com>2018-09-25 08:39:05 -0700
committerVictor Morales <victor.morales@intel.com>2018-09-25 08:39:05 -0700
commit5fe7119d93b68b1ee916dbe6a2c678395469df19 (patch)
tree0334e32aa1090c757eba9fcc9f66dfddcd02649a /src/k8splugin/krd/plugins.go
parentb7e7f8f659439ac1db7b42ad47828def65eb094c (diff)
Add UTs for plugins module
The KRD plugins module wasn't cover by Unit Tests that ensure their functionality. This change create Unit Tests that guarantees basic use cases. Change-Id: Idac9179bfb7b805ebadc60d9d1a41e73a6f13be7 Signed-off-by: Victor Morales <victor.morales@intel.com> Issue-ID: MULTICLOUD-301
Diffstat (limited to 'src/k8splugin/krd/plugins.go')
-rw-r--r--src/k8splugin/krd/plugins.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/k8splugin/krd/plugins.go b/src/k8splugin/krd/plugins.go
index 41b83226..9ccb04fa 100644
--- a/src/k8splugin/krd/plugins.go
+++ b/src/k8splugin/krd/plugins.go
@@ -38,21 +38,25 @@ type ResourceData struct {
// DecodeYAML reads a YAMl file to extract the Kubernetes object definition
var DecodeYAML = func(path string) (runtime.Object, error) {
- if _, err := os.Stat(path); os.IsNotExist(err) {
- return nil, pkgerrors.New("File " + path + " not found")
+ if _, err := os.Stat(path); err != nil {
+ if os.IsNotExist(err) {
+ return nil, pkgerrors.New("File " + path + " not found")
+ } else {
+ return nil, pkgerrors.Wrap(err, "Stat file error")
+ }
}
- log.Println("Reading deployment YAML")
+ log.Println("Reading YAML file")
rawBytes, err := ioutil.ReadFile(path)
if err != nil {
- return nil, pkgerrors.Wrap(err, "Deployment YAML file read error")
+ return nil, pkgerrors.Wrap(err, "Read YAML file error")
}
log.Println("Decoding deployment YAML")
decode := scheme.Codecs.UniversalDeserializer().Decode
obj, _, err := decode(rawBytes, nil, nil)
if err != nil {
- return nil, pkgerrors.Wrap(err, "Deserialize deployment error")
+ return nil, pkgerrors.Wrap(err, "Deserialize YAML error")
}
return obj, nil