forked from brooklyncentral/brooklyn-cli-legacy
/
brooklyn.go
39 lines (36 loc) · 1.26 KB
/
brooklyn.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
package main
import (
"github.com/brooklyncentral/brooklyn-cli/app"
"github.com/brooklyncentral/brooklyn-cli/command_factory"
"github.com/brooklyncentral/brooklyn-cli/command_runner"
"github.com/brooklyncentral/brooklyn-cli/net"
"github.com/brooklyncentral/brooklyn-cli/io"
"os"
"path/filepath"
)
func getNetworkCredentialsFromConfig(yamlMap map[string]interface{}) (string, string, string){
var target, username, password string
target, found := yamlMap["target"].(string)
if found {
auth, found := yamlMap["auth"].(map[string]interface{})
if found {
creds := auth[target].(map[string]interface{})
username, found = creds["username"].(string)
if found {
password, found = creds["password"].(string)
}
}
}
return target, username, password
}
func main() {
config := io.GetConfig()
target, username, password := getNetworkCredentialsFromConfig(config.Map)
//target, username, password := "http://192.168.50.101:8081", "brooklyn", "Sns4Hh9j7l"
network := net.NewNetwork(target, username, password)
cmdFactory := command_factory.NewFactory(network, config)
cmdRunner := command_runner.NewRunner(cmdFactory)
metaDatas := cmdFactory.CommandMetadatas()
theApp := app.NewApp(filepath.Base(os.Args[0]), cmdRunner, metaDatas...)
theApp.Run(os.Args)
}