fix: ensure dirs are created

Also use debug logging for help.

Closes coop-cloud/organising#183.
Closes coop-cloud/organising#183.
This commit is contained in:
decentral1se 2021-10-05 20:23:17 +02:00
parent 8bfd76fd04
commit f75e264811
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
1 changed files with 22 additions and 8 deletions

View File

@ -4,6 +4,7 @@ package cli
import (
"fmt"
"os"
"path"
"coopcloud.tech/abra/cli/app"
"coopcloud.tech/abra/cli/catalogue"
@ -82,17 +83,30 @@ func RunApp(version, commit string) {
logrus.SetOutput(os.Stderr)
logrus.AddHook(logrusStack.StandardHook())
}
paths := []string{
config.ABRA_DIR,
path.Join(config.ABRA_DIR, "servers"),
path.Join(config.ABRA_DIR, "apps"),
path.Join(config.ABRA_DIR, "vendor"),
}
for _, path := range paths {
if err := os.Mkdir(path, 0755); err != nil {
if !os.IsExist(err) {
logrus.Fatal(err)
}
logrus.Debugf("'%s' already created, moving on...", path)
continue
}
logrus.Debugf("'%s' is missing, creating...", path)
}
logrus.Debugf("abra version '%s', commit '%s'", version, commit)
return nil
}
if err := os.Mkdir(config.ABRA_DIR, 0755); err != nil {
if !os.IsExist(err) {
logrus.Fatal(err)
}
}
logrus.Debugf("abra version '%s', commit '%s'", version, commit)
if err := app.Run(os.Args); err != nil {
logrus.Fatal(err)
}