예제 #1
0
func NewInstaller(terminal *term.Terminal, basedir string, api *api.Api, instanceRepo *instance.Repo, agentConfig *agent.Config, flags Flags) *Installer {
	if agentConfig.ApiHostname == "" {
		agentConfig.ApiHostname = agent.DEFAULT_API_HOSTNAME
	}
	if agentConfig.PidFile == "" {
		agentConfig.PidFile = agent.DEFAULT_PIDFILE
	}
	hostname, _ := os.Hostname()
	defaultDSN := mysql.DSN{
		Username: flags.String["mysql-user"],
		Password: flags.String["mysql-pass"],
		Hostname: flags.String["mysql-host"],
		Port:     flags.String["mysql-port"],
		Socket:   flags.String["mysql-socket"],
	}
	installer := &Installer{
		term:         terminal,
		basedir:      basedir,
		api:          api,
		instanceRepo: instanceRepo,
		agentConfig:  agentConfig,
		flags:        flags,
		// --
		hostname:   hostname,
		defaultDSN: defaultDSN,
	}
	return installer
}
예제 #2
0
func NewInstaller(term *Terminal, basedir string, api pct.APIConnector, agentConfig *agent.Config, flags Flags) *Installer {
	if agentConfig.ApiHostname == "" {
		agentConfig.ApiHostname = agent.DEFAULT_API_HOSTNAME
	}
	hostname, _ := os.Hostname()
	installer := &Installer{
		term:        term,
		basedir:     basedir,
		api:         api,
		agentConfig: agentConfig,
		flags:       flags,
		// --
		hostname: hostname,
	}
	return installer
}