WIP: status lookup for apps listing
This commit is contained in:
parent
2c83113040
commit
3bc612c44e
23
cli/app.go
23
cli/app.go
@ -52,23 +52,38 @@ var appRestoreCommand = &cli.Command{
|
|||||||
var appListCommand = &cli.Command{
|
var appListCommand = &cli.Command{
|
||||||
Name: "list",
|
Name: "list",
|
||||||
Aliases: []string{"ls"},
|
Aliases: []string{"ls"},
|
||||||
Flags: []cli.Flag{StatusFlag, ServerFlag, TypeFlag}, // FIXME: implement flags
|
Flags: []cli.Flag{StatusFlag, ServerFlag, TypeFlag},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
appFiles, err := config.LoadAppFiles(Server)
|
appFiles, err := config.LoadAppFiles(Server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatal(err)
|
logrus.Fatal(err)
|
||||||
}
|
}
|
||||||
apps, err := config.GetApps(appFiles)
|
|
||||||
sort.Sort(config.ByServerAndType(apps))
|
|
||||||
tableCol := []string{"Server", "Type", "Domain"}
|
tableCol := []string{"Server", "Type", "Domain"}
|
||||||
|
if Status {
|
||||||
|
tableCol = []string{"Server", "Type", "Domain", "Status"}
|
||||||
|
}
|
||||||
table := createTable(tableCol)
|
table := createTable(tableCol)
|
||||||
table.SetAutoMergeCellsByColumnIndex([]int{0})
|
table.SetAutoMergeCellsByColumnIndex([]int{0})
|
||||||
|
|
||||||
|
apps, err := config.GetApps(appFiles)
|
||||||
|
sort.Sort(config.ByServerAndType(apps))
|
||||||
for _, app := range apps {
|
for _, app := range apps {
|
||||||
|
var tableRow []string
|
||||||
if app.Type == Type || Type == "" {
|
if app.Type == Type || Type == "" {
|
||||||
// If type flag is set, check for it, if not, Type == ""
|
// If type flag is set, check for it, if not, Type == ""
|
||||||
table.Append([]string{app.File.Server, app.Type, app.Domain})
|
tableRow = []string{app.File.Server, app.Type, app.Domain}
|
||||||
}
|
}
|
||||||
|
if Status {
|
||||||
|
status, err := app.GetStatus()
|
||||||
|
if err != nil {
|
||||||
|
logrus.Fatal(err)
|
||||||
|
}
|
||||||
|
tableRow = []string{app.File.Server, app.Type, app.Domain, status}
|
||||||
|
}
|
||||||
|
table.Append(tableRow)
|
||||||
}
|
}
|
||||||
|
|
||||||
table.Render()
|
table.Render()
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
@ -24,6 +24,10 @@ var REPOS_BASE_URL = "https://git.coopcloud.tech/coop-cloud"
|
|||||||
type AppEnv = map[string]string
|
type AppEnv = map[string]string
|
||||||
type AppName = string
|
type AppName = string
|
||||||
|
|
||||||
|
type AppStatus struct {
|
||||||
|
Deployed bool
|
||||||
|
}
|
||||||
|
|
||||||
type App struct {
|
type App struct {
|
||||||
Name AppName
|
Name AppName
|
||||||
Type string
|
Type string
|
||||||
@ -32,6 +36,10 @@ type App struct {
|
|||||||
File AppFile
|
File AppFile
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a App) GetStatus() (string, error) {
|
||||||
|
return "unknown", nil
|
||||||
|
}
|
||||||
|
|
||||||
type ByServer []App
|
type ByServer []App
|
||||||
|
|
||||||
func (a ByServer) Len() int { return len(a) }
|
func (a ByServer) Len() int { return len(a) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user