fix: reference env from config dir

This commit is contained in:
Jose Diaz-Gonzalez
2024-03-14 02:52:16 -04:00
parent 9e7e2440ff
commit bf7da51a56
5 changed files with 18 additions and 17 deletions

View File

@@ -10,11 +10,11 @@ import (
var (
testAppName = "test-app-1"
testAppDir = strings.Join([]string{"/home/dokku/", testAppName}, "")
testAppDir = strings.Join([]string{"/var/lib/dokku/config/config/", testAppName}, "")
testEnvFile = strings.Join([]string{testAppDir, "/ENV"}, "")
testEnvLine = "export testKey=TESTING"
testAppName2 = "01-test-app-1"
testAppDir2 = strings.Join([]string{"/home/dokku/", testAppName2}, "")
testAppDir2 = strings.Join([]string{"/var/lib/dokku/config/config/", testAppName2}, "")
testEnvFile2 = strings.Join([]string{testAppDir2, "/ENV"}, "")
testEnvLine2 = "export testKey=TESTING"
)

View File

@@ -2,6 +2,7 @@ package config
import (
"os"
"path/filepath"
"strings"
"testing"
@@ -12,9 +13,9 @@ import (
var (
testAppName = "test-app-1"
dokkuRoot = common.MustGetEnv("DOKKU_ROOT")
testAppDir = strings.Join([]string{dokkuRoot, testAppName}, "/")
globalConfigFile = strings.Join([]string{dokkuRoot, "ENV"}, "/")
dokkuLibRoot = common.MustGetEnv("DOKKU_LIB_ROOT")
testAppDir = filepath.Join(dokkuLibRoot, "config", testAppName)
globalConfigFile = filepath.Join(dokkuLibRoot, "config", "--global", "ENV")
)
func setupTests() (err error) {

View File

@@ -392,9 +392,9 @@ func loadFromFileJSON(name string, filename string) (env *Env, err error) {
}, nil
}
func getAppFile(appName string) (string, error) {
return filepath.Join(common.MustGetEnv("DOKKU_ROOT"), appName, "ENV"), nil
return filepath.Join(common.MustGetEnv("DOKKU_LIB_ROOT"), "config", appName, "ENV"), nil
}
func getGlobalFile() string {
return filepath.Join(common.MustGetEnv("DOKKU_ROOT"), "ENV")
return filepath.Join(common.MustGetEnv("DOKKU_ROOT"), "config", "--global", "ENV")
}

View File

@@ -4,16 +4,16 @@ load test_helper
setup() {
global_setup
[[ -f ${DOKKU_ROOT}/ENV ]] && mv -f ${DOKKU_ROOT}/ENV ${DOKKU_ROOT}/ENV.bak
sudo -H -u dokku /bin/bash -c "echo 'export global_test=true' > ${DOKKU_ROOT}/ENV"
mkdir -p "${DOKKU_LIB_ROOT}/config/--global"
[[ -f ${DOKKU_LIB_ROOT}/config/--global/ENV ]] && mv -f ${DOKKU_LIB_ROOT}/config/--global/ENV ${DOKKU_LIB_ROOT}/config/--global/ENV.bak
sudo -H -u dokku /bin/bash -c "echo 'export global_test=true' > ${DOKKU_LIB_ROOT}/config/--global/ENV"
create_app
}
teardown() {
destroy_app
ls -la ${DOKKU_ROOT}
if [[ -f ${DOKKU_ROOT}/ENV.bak ]]; then
mv -f ${DOKKU_ROOT}/ENV.bak ${DOKKU_ROOT}/ENV
if [[ -f ${DOKKU_LIB_ROOT}/config/--global/ENV.bak ]]; then
mv -f ${DOKKU_LIB_ROOT}/config/--global/ENV.bak ${DOKKU_LIB_ROOT}/config/--global/ENV
fi
global_teardown
}

View File

@@ -4,16 +4,16 @@ load test_helper
setup() {
global_setup
[[ -f ${DOKKU_ROOT}/ENV ]] && mv -f ${DOKKU_ROOT}/ENV ${DOKKU_ROOT}/ENV.bak
sudo -H -u dokku /bin/bash -c "echo 'export global_test=true' > ${DOKKU_ROOT}/ENV"
mkdir -p "${DOKKU_LIB_ROOT}/config/--global"
[[ -f ${DOKKU_LIB_ROOT}/config/--global/ENV ]] && mv -f ${DOKKU_LIB_ROOT}/config/--global/ENV ${DOKKU_LIB_ROOT}/config/--global/ENV.bak
sudo -H -u dokku /bin/bash -c "echo 'export global_test=true' > ${DOKKU_LIB_ROOT}/config/--global/ENV"
create_app
}
teardown() {
destroy_app
ls -la ${DOKKU_ROOT}
if [[ -f ${DOKKU_ROOT}/ENV.bak ]]; then
mv -f ${DOKKU_ROOT}/ENV.bak ${DOKKU_ROOT}/ENV
if [[ -f ${DOKKU_LIB_ROOT}/config/--global/ENV.bak ]]; then
mv -f ${DOKKU_LIB_ROOT}/config/--global/ENV.bak ${DOKKU_LIB_ROOT}/config/--global/ENV
fi
global_teardown
}