Ejemplo n.º 1
0
func initClient(c *cli.Context) error {
	configFile := c.String("config_file")
	var config *gitkit.Config
	var err error
	if configFile != "" {
		config, err = gitkit.LoadConfig(configFile)
		if err != nil {
			return err
		}
	} else {
		config = &gitkit.Config{}
	}
	// It is required but not used.
	config.WidgetURL = "http://localhost"
	// Command line flags overwrite the values in config file.
	if c.IsSet("client_id") {
		config.ClientID = c.String("client_id")
	}
	if c.IsSet("google_app_credentials_path") {
		config.GoogleAppCredentialsPath = c.String("google_app_credentials_path")
	}

	if client, err = gitkit.New(context.Background(), config); err != nil {
		return err
	}
	return nil
}
Ejemplo n.º 2
0
func initClient(c *cli.Context) error {
	configFile := c.String("config_file")
	var config *gitkit.Config
	var err error
	if configFile != "" {
		config, err = gitkit.LoadConfig(configFile)
		if err != nil {
			return err
		}
	} else {
		config = &gitkit.Config{}
	}
	// It is required but not used.
	config.WidgetURL = "http://localhost"
	// Command line flags overwrite the values in config file.
	if c.IsSet("client_id") {
		config.ClientID = c.String("client_id")
	}
	if c.IsSet("server_api_key") {
		config.ServerAPIKey = c.String("server_api_key")
	}
	if c.IsSet("service_account") {
		config.ServiceAccount = c.String("service_account")
	}
	if c.IsSet("key_path") {
		config.PEMKeyPath = c.String("key_path")
	}

	if client, err = gitkit.New(config); err != nil {
		return err
	}
	return nil
}