Closes coop-cloud/organising#166.
This commit is contained in:
parent
6794236b77
commit
f87aad4688
@ -107,11 +107,11 @@ func ensureDomainFlag() error {
|
|||||||
|
|
||||||
// ensureServerFlag checks if the server flag was used. if not, asks the user for it.
|
// ensureServerFlag checks if the server flag was used. if not, asks the user for it.
|
||||||
func ensureServerFlag() error {
|
func ensureServerFlag() error {
|
||||||
appFiles, err := config.LoadAppFiles(newAppServer)
|
servers, err := config.GetServers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
servers := appFiles.GetServers()
|
|
||||||
if newAppServer == "" {
|
if newAppServer == "" {
|
||||||
prompt := &survey.Select{
|
prompt := &survey.Select{
|
||||||
Message: "Select app server:",
|
Message: "Select app server:",
|
||||||
@ -121,6 +121,7 @@ func ensureServerFlag() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,13 +273,18 @@ func SanitiseAppName(name string) string {
|
|||||||
|
|
||||||
// GetAppStatuses queries servers to check the deployment status of given apps
|
// GetAppStatuses queries servers to check the deployment status of given apps
|
||||||
func GetAppStatuses(appFiles AppFiles) (map[string]string, error) {
|
func GetAppStatuses(appFiles AppFiles) (map[string]string, error) {
|
||||||
servers := appFiles.GetServers()
|
statuses := map[string]string{}
|
||||||
|
|
||||||
|
servers, err := GetServers()
|
||||||
|
if err != nil {
|
||||||
|
return statuses, err
|
||||||
|
}
|
||||||
|
|
||||||
ch := make(chan stack.StackStatus, len(servers))
|
ch := make(chan stack.StackStatus, len(servers))
|
||||||
for _, server := range servers {
|
for _, server := range servers {
|
||||||
go func(s string) { ch <- stack.GetAllDeployedServices(s) }(server)
|
go func(s string) { ch <- stack.GetAllDeployedServices(s) }(server)
|
||||||
}
|
}
|
||||||
|
|
||||||
statuses := map[string]string{}
|
|
||||||
for range servers {
|
for range servers {
|
||||||
status := <-ch
|
status := <-ch
|
||||||
for _, service := range status.Services {
|
for _, service := range status.Services {
|
||||||
|
@ -21,20 +21,17 @@ var APPS_DIR = path.Join(ABRA_DIR, "apps")
|
|||||||
var REPOS_BASE_URL = "https://git.coopcloud.tech/coop-cloud"
|
var REPOS_BASE_URL = "https://git.coopcloud.tech/coop-cloud"
|
||||||
|
|
||||||
// GetServers retrieves all servers.
|
// GetServers retrieves all servers.
|
||||||
func (a AppFiles) GetServers() []string {
|
func GetServers() ([]string, error) {
|
||||||
var unique []string
|
var servers []string
|
||||||
|
|
||||||
servers := make(map[string]struct{})
|
servers, err := getAllFoldersInDirectory(ABRA_SERVER_FOLDER)
|
||||||
for _, appFile := range a {
|
if err != nil {
|
||||||
if _, ok := servers[appFile.Server]; !ok {
|
return servers, err
|
||||||
servers[appFile.Server] = struct{}{}
|
|
||||||
unique = append(unique, appFile.Server)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("retrieved servers: '%s'", unique)
|
logrus.Debugf("retrieved '%v' servers: '%s'", len(servers), servers)
|
||||||
|
|
||||||
return unique
|
return servers, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadEnv loads an app envivornment into a map.
|
// ReadEnv loads an app envivornment into a map.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user