Пример #1
0
func createClient(c *cli.Context) *wercker.Client {
	endpoint := c.GlobalString("endpoint")
	config := &wercker.Config{
		Endpoint: endpoint,
	}

	if c.GlobalBool("anonymous") {
		config.Credentials = credentials.Anonymous()
	} else {
		token := c.GlobalString("token")
		if token != "" {
			config.Credentials = credentials.Token(token)
		}
	}

	client := wercker.NewClient(config)

	return client
}
Пример #2
0
package wercker

import (
	"net/http"

	"github.com/wercker/go-wercker-api/credentials"
)

var defaultCredentialsProvider = credentials.NewMultiProvider(
	&credentials.EnvProvider{},
	credentials.Anonymous(),
)

var defaultConfig = &Config{
	Credentials: defaultCredentialsProvider,
	Endpoint:    "https://app.wercker.com",
	HTTPClient:  http.DefaultClient,
}

// Config contains all configurable settings which will be used when making
// requests
type Config struct {
	Credentials credentials.Provider
	Endpoint    string
	HTTPClient  *http.Client
}

// Copy will create a shallow copy of the Copy object
func (o *Config) Copy() *Config {
	newConfig := &Config{
		Credentials: o.Credentials,