fix: list all servers
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
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.
|
||||
func ensureServerFlag() error {
|
||||
appFiles, err := config.LoadAppFiles(newAppServer)
|
||||
servers, err := config.GetServers()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
servers := appFiles.GetServers()
|
||||
|
||||
if newAppServer == "" {
|
||||
prompt := &survey.Select{
|
||||
Message: "Select app server:",
|
||||
|
@ -121,6 +121,7 @@ func ensureServerFlag() error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue