go-wercker-api is the official wercker client for the wercker API.
Caution: Both the API and this client are under active development. This client may introduce breaking changes, so be sure to vendor in this client.
To start using this client, import this package and create a new client:
import "github.com/wercker/go-wercker-api"
client := wercker.NewClient(nil)
This will create a new client with the default config. If you want to override
the default config, then you need to create a wercker.Config
object and
pass this wercker.NewClient
:
import "github.com/wercker/go-wercker-api"
options := &wercker.Config{}
client := wercker.NewClient(options)
The client uses a Provider
to get the credentials for the user. By default it
uses the following strategy:
- Retrieve the token from the environment variable
$WERCKER_TOKEN
- Retrieve the token from file
~/.wercker/credentials
- Fallback to anonymous user
If you retrieved your wercker token through other means, then you can use the
credentials.Token
method to create a static Provider
:
import "github.com/wercker/go-wercker-api"
import "github.com/wercker/go-wercker-api/credentials"
token := "... your token ..."
options := &wercker.Config{Credentials: credentials.Token(token)}
client := wercker.NewClient(options)
...