fix: make server path creation more robust

This commit is contained in:
2021-10-02 22:30:08 +02:00
parent db5cbfa992
commit 48290aa316
2 changed files with 34 additions and 6 deletions

View File

@ -3,14 +3,12 @@ package server
import (
"context"
"errors"
"os"
"os/user"
"path"
"strings"
"coopcloud.tech/abra/cli/internal"
"coopcloud.tech/abra/pkg/client"
"coopcloud.tech/abra/pkg/config"
"coopcloud.tech/abra/pkg/server"
"github.com/sirupsen/logrus"
"github.com/urfave/cli/v2"
)
@ -68,7 +66,10 @@ All communication between Abra and the server will use this SSH connection.
domainName := "default"
if local {
os.Mkdir(path.Join(config.ABRA_DIR, "servers", domainName), 0755)
if err := server.CreateServerDir(domainName); err != nil {
logrus.Fatal(err)
}
logrus.Info("local server has been added")
return nil
}
@ -125,9 +126,12 @@ All communication between Abra and the server will use this SSH connection.
}
logrus.Debugf("remote connection to '%s' is definitely up", domainName)
logrus.Infof("server at '%s' has been added", domainName)
os.Mkdir(path.Join(config.ABRA_DIR, "servers", domainName), 0755)
if err := server.CreateServerDir(domainName); err != nil {
logrus.Fatal(err)
}
logrus.Infof("server at '%s' has been added", domainName)
return nil
},