/
database_list.go
45 lines (32 loc) · 995 Bytes
/
database_list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package workflows
import (
"fmt"
"io"
"github.com/stelligent/mu/common"
)
// NewDatabaseLister create a new workflow for listing databases
func NewDatabaseLister(ctx *common.Context, writer io.Writer) Executor {
workflow := new(databaseWorkflow)
return newPipelineExecutor(
workflow.databaseLister(ctx.Config.Namespace, ctx.StackManager, writer),
)
}
func (workflow *databaseWorkflow) databaseLister(namespace string, stackLister common.StackLister, writer io.Writer) Executor {
return func() error {
stacks, err := stackLister.ListStacks(common.StackTypeDatabase, namespace)
if err != nil {
return err
}
table := CreateTableSection(writer, PipeLineServiceHeader)
for _, stack := range stacks {
table.Append([]string{
Bold(stack.Tags[SvcTagKey]),
stack.Name,
fmt.Sprintf(KeyValueFormat, colorizeStackStatus(stack.Status), stack.StatusReason),
stack.LastUpdateTime.Local().Format(LastUpdateTime),
})
}
table.Render()
return nil
}
}