Make PLUGINS_DIR to be required than optional 77/64077/1
authorShashank Kumar Shankar <shashank.kumar.shankar@intel.com>
Fri, 31 Aug 2018 21:57:54 +0000 (14:57 -0700)
committerShashank Kumar Shankar <shashank.kumar.shankar@intel.com>
Fri, 31 Aug 2018 21:59:38 +0000 (14:59 -0700)
This patch makes sure PLUGINS_DIR is not optional since its better
explicitly pass the plugins directory.

Change-Id: I08da5cf1563527d8b713fa106aa05b37a26c95cb
Issue-ID: MULTICLOUD-301
Signed-off-by: Shashank Kumar Shankar <shashank.kumar.shankar@intel.com>
src/k8splugin/api/api.go

index 651d931..53db3fb 100644 (file)
@@ -28,7 +28,7 @@ import (
 
 // CheckEnvVariables checks for required Environment variables
 func CheckEnvVariables() error {
-       envList := []string{"CSAR_DIR", "KUBE_CONFIG_DIR", "DATABASE_TYPE", "DATABASE_IP"}
+       envList := []string{"CSAR_DIR", "KUBE_CONFIG_DIR", "PLUGINS_DIR", "DATABASE_TYPE", "DATABASE_IP"}
        for _, env := range envList {
                if _, ok := os.LookupEnv(env); !ok {
                        return pkgerrors.New("environment variable " + env + " not set")
@@ -60,10 +60,7 @@ func CheckDatabaseConnection() error {
 
 // LoadPlugins loads all the compiled .so plugins
 func LoadPlugins() error {
-       pluginsDir, ok := os.LookupEnv("PLUGINS_DIR")
-       if !ok {
-               pluginsDir, _ = filepath.Abs(filepath.Dir(os.Args[0]))
-       }
+       pluginsDir := os.Getenv("PLUGINS_DIR")
        err := filepath.Walk(pluginsDir,
                func(path string, info os.FileInfo, err error) error {
                        if strings.Contains(path, ".so") {