fix: list all servers

Closes coop-cloud/organising#166.
This commit is contained in:
2021-09-16 09:26:12 +02:00
parent 6794236b77
commit f87aad4688
3 changed files with 17 additions and 14 deletions

View File

@ -273,13 +273,18 @@ func SanitiseAppName(name string) string {
// GetAppStatuses queries servers to check the deployment status of given apps
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))
for _, server := range servers {
go func(s string) { ch <- stack.GetAllDeployedServices(s) }(server)
}
statuses := map[string]string{}
for range servers {
status := <-ch
for _, service := range status.Services {

View File

@ -21,20 +21,17 @@ var APPS_DIR = path.Join(ABRA_DIR, "apps")
var REPOS_BASE_URL = "https://git.coopcloud.tech/coop-cloud"
// GetServers retrieves all servers.
func (a AppFiles) GetServers() []string {
var unique []string
func GetServers() ([]string, error) {
var servers []string
servers := make(map[string]struct{})
for _, appFile := range a {
if _, ok := servers[appFile.Server]; !ok {
servers[appFile.Server] = struct{}{}
unique = append(unique, appFile.Server)
}
servers, err := getAllFoldersInDirectory(ABRA_SERVER_FOLDER)
if err != nil {
return servers, err
}
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.