forked from coop-cloud/abra
feat: final round of hacks for deploy command
This commit is contained in:
parent
92c8e9aab9
commit
612fc5a531
@ -46,6 +46,16 @@ var appDeployCommand = &cli.Command{
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
abraShPath := fmt.Sprintf("%s/%s/%s", config.APPS_DIR, appEnv.Type, "abra.sh")
|
||||
abraShEnv, err := config.ReadAbraShEnvVars(abraShPath)
|
||||
if err != nil {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
for k, v := range abraShEnv {
|
||||
appEnv.Env[k] = v
|
||||
}
|
||||
appEnv.Env["STACK_NAME"] = appEnv.StackName()
|
||||
|
||||
deployOpts := options.Deploy{
|
||||
Composefiles: composeFiles,
|
||||
Namespace: appEnv.StackName(),
|
||||
|
@ -1,12 +1,14 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/Autonomic-Cooperative/godotenv"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -109,3 +111,31 @@ func EnsureAbraDirExists() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReadAbraShEnvVars(abraSh string) (map[string]string, error) {
|
||||
envVars := make(map[string]string)
|
||||
|
||||
file, err := os.Open(abraSh)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return envVars, fmt.Errorf("'%s' does not exist?", abraSh)
|
||||
}
|
||||
return envVars, err
|
||||
}
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
if strings.Contains(line, "export") {
|
||||
splitVals := strings.Split(line, "export ")
|
||||
envVarDef := splitVals[len(splitVals)-1]
|
||||
keyVal := strings.Split(envVarDef, "=")
|
||||
if len(keyVal) != 2 {
|
||||
return envVars, fmt.Errorf("couldn't parse %s", line)
|
||||
}
|
||||
envVars[keyVal[0]] = keyVal[1]
|
||||
}
|
||||
}
|
||||
|
||||
return envVars, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user