Exemplo n.º 1
0
func initialize(c *gcli.Context) *ogcli.OpsGenieClient {
	if c.IsSet("v") {
		verbose = true
		printVerboseMessage("Will execute command in verbose mode.")
	}
	readConfigFile(c)
	apiKey := grabAPIKey(c)
	cli := new(ogcli.OpsGenieClient)
	cli.SetAPIKey(apiKey)
	if apiURL := cfg.Get("opsgenie.api.url"); apiURL != "" {
		cli.SetOpsGenieAPIUrl(apiURL)
	}
	proxyHost := cfg.Get("proxyHost")
	proxyPort, err := strconv.Atoi(cfg.Get("proxyPort"))
	if err == nil && proxyPort != 0 && proxyHost != "" {
		cli.SetProxyConfiguration(proxyConf(proxyHost, proxyPort))
	}
	cli.SetHTTPTransportSettings(connectionConf())
	return cli
}