-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathmain.go
52 lines (43 loc) · 1.38 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
package main
import (
"code.cloudfoundry.org/cli/plugin"
"fmt"
"github.com/andreasf/cf-mysql-plugin/cfmysql"
"os"
)
func main() {
if len(os.Args) == 1 {
fmt.Fprintf(os.Stderr, "This executable is a cf plugin. "+
"Run `cf install-plugin %s` to install it\nand `cf mysql service-name` "+
"to use it.\n",
os.Args[0])
os.Exit(1)
}
mysqlPlugin := newPlugin()
plugin.Start(mysqlPlugin)
os.Exit(mysqlPlugin.GetExitCode())
}
func newPlugin() *cfmysql.MysqlPlugin {
httpClientFactory := cfmysql.NewHttpClientFactory()
osWrapper := cfmysql.NewOsWrapper()
requestDumper := cfmysql.NewRequestDumper(osWrapper, os.Stderr)
http := cfmysql.NewHttpWrapper(httpClientFactory, requestDumper)
apiClient := cfmysql.NewApiClient(http)
sshRunner := cfmysql.NewSshRunner()
netWrapper := cfmysql.NewNetWrapper()
waiter := cfmysql.NewPortWaiter(netWrapper)
randWrapper := cfmysql.NewRandWrapper()
cfService := cfmysql.NewCfService(apiClient, sshRunner, waiter, http, randWrapper, os.Stderr)
execWrapper := cfmysql.NewExecWrapper()
ioUtilWrapper := cfmysql.NewIoUtilWrapper()
runner := cfmysql.NewMysqlRunner(execWrapper, ioUtilWrapper, osWrapper)
portFinder := cfmysql.NewPortFinder()
return cfmysql.NewMysqlPlugin(cfmysql.PluginConf{
In: os.Stdin,
Out: os.Stdout,
Err: os.Stderr,
CfService: cfService,
PortFinder: portFinder,
MysqlRunner: runner,
})
}