Use local_storage_path config for locating bundles
diff --git a/apidGatewayDeploy_suite_test.go b/apidGatewayDeploy_suite_test.go index e2546a1..24a8894 100644 --- a/apidGatewayDeploy_suite_test.go +++ b/apidGatewayDeploy_suite_test.go
@@ -27,8 +27,7 @@ tmpDir, err = ioutil.TempDir("", "api_test") Expect(err).NotTo(HaveOccurred()) - config.Set("data_path", tmpDir) - config.Set(configBundleDir, tmpDir) + config.Set("local_storage_path", tmpDir) // init() will create the tables apid.InitializePlugins()
diff --git a/init.go b/init.go index 7fe5ebe..d6c2298 100644 --- a/init.go +++ b/init.go
@@ -4,12 +4,12 @@ "github.com/30x/apid" "github.com/30x/apidGatewayDeploy/github" "os" - "path/filepath" "database/sql" + "path" ) const ( - configBundleDir = "gatewaydeploy_bundle_dir" + configBundleDirKey = "gatewaydeploy_bundle_dir" configGithubAccessToken = "gatewaydeploy_github_accesstoken" ) @@ -29,17 +29,15 @@ github.Init(services) config := services.Config() - config.SetDefault(configBundleDir, "/var/tmp") + config.SetDefault(configBundleDirKey, "bundles") var err error - dir := config.GetString(configBundleDir) - if err := os.MkdirAll(dir, 0700); err != nil { + relativeBundlePath := config.GetString(configBundleDirKey) + if err := os.MkdirAll(relativeBundlePath, 0700); err != nil { log.Panicf("Failed bundle directory creation: %v", err) } - bundlePath, err = filepath.Abs(dir) - if err != nil { - log.Panicf("Cant find Abs Path : %v", err) - } + storagePath := config.GetString("local_storage_path") + bundlePath := path.Join(storagePath, relativeBundlePath) log.Infof("Bundle directory path is %s", bundlePath) gitHubAccessToken = config.GetString(configGithubAccessToken)