-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
55 lines (45 loc) · 1 KB
/
main.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
46
47
48
49
50
51
52
53
54
55
package main
import (
"cloud-monitor/cloudman"
"cloud-monitor/config"
"cloud-monitor/driver"
"cloud-monitor/printer"
"fmt"
"log"
"os"
"strings"
)
func main() {
log.SetFlags(log.LstdFlags | log.Lshortfile)
if len(os.Args) == 3 && os.Args[1] == "-c" {
config.ConfPath = os.Args[2]
} else {
log.Println("provide config file path with -c parameter")
return
}
log.SetFlags(log.LstdFlags | log.Lshortfile)
d, err := driver.NewDriver()
if err != nil {
log.Println(err)
return
}
type printStruct struct {
Resp []cloudman.InstanceListResponse
Cloud string
}
printChan := make(chan printStruct, len(d.CloudList))
for _, cloud := range d.CloudList {
go func(c cloudman.Cloud) {
list, _ := c.GetInstanceListAllRegions()
printChan <- printStruct{
Resp: list,
Cloud: strings.Replace(fmt.Sprintf("%T", c), "*cloudman.", "", -1),
}
}(cloud)
}
for j := 0; j < len(d.CloudList); j++ {
// table printer
data := <-printChan
printer.PrintTable(data.Resp, data.Cloud)
}
}