vela

package
v0.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2022 License: Apache-2.0 Imports: 20 Imported by: 30

Documentation

Overview

Package vela provides a client for using the Vela API.

Usage:

import "github.com/go-vela/sdk-go/vela"

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool is a helper routine that allocates a new boolean value to store v and returns a pointer to it.

func Bytes

func Bytes(v []byte) *[]byte

Bytes is a helper routine that allocates a new byte array value to store v and returns a pointer to it.

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range.

func Int

func Int(v int) *int

Int is a helper routine that allocates a new integer value to store v and returns a pointer to it.

func Int64

func Int64(v int64) *int64

Int64 is a helper routine that allocates a new 64 bit integer value to store v and returns a pointer to it.

func IsTokenExpired added in v0.7.0

func IsTokenExpired(token string) bool

IsTokenExpired will parse the expiration of the the given token and return a boolean depending on whether the is expired given the delta.

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

func Strings added in v0.4.0

func Strings(v []string) *[]string

Strings is a helper routine that allocates a new string array value to store v and returns a pointer to it.

func ToContext

func ToContext(c context.Context, cli *Client) context.Context

ToContext adds the Client to the context.

Types

type AdminBuildService added in v0.7.0

type AdminBuildService service

AdminBuildService handles retrieving admin builds from the server methods of the Vela API.

func (*AdminBuildService) GetQueue added in v0.8.0

func (svc *AdminBuildService) GetQueue(opt *GetQueueOptions) (*[]library.BuildQueue, *Response, error)

GetQueue returns the list of builds in pending and running status.

func (*AdminBuildService) Update added in v0.7.0

func (svc *AdminBuildService) Update(b *library.Build) (*library.Build, *Response, error)

Update modifies a build with the provided details.

type AdminDeploymentService added in v0.7.0

type AdminDeploymentService service

AdminDeploymentService handles retrieving admin deployments from the server methods of the Vela API.

func (*AdminDeploymentService) Update added in v0.7.0

Update modifies a deployment with the provided details.

type AdminHookService added in v0.7.0

type AdminHookService service

AdminHookService handles retrieving admin hooks from the server methods of the Vela API.

func (*AdminHookService) Update added in v0.7.0

func (svc *AdminHookService) Update(h *library.Hook) (*library.Hook, *Response, error)

Update modifies a hook with the provided details.

type AdminRepoService added in v0.7.0

type AdminRepoService service

AdminRepoService handles retrieving admin repos from the server methods of the Vela API.

func (*AdminRepoService) Update added in v0.7.0

func (svc *AdminRepoService) Update(r *library.Repo) (*library.Repo, *Response, error)

Update modifies a repo with the provided details.

type AdminSecretService added in v0.7.0

type AdminSecretService service

AdminSecretService handles retrieving admin secrets from the server methods of the Vela API.

func (*AdminSecretService) Update added in v0.7.0

Update modifies a secret with the provided details.

type AdminService added in v0.7.0

type AdminService struct {
	Build      *AdminBuildService
	Deployment *AdminDeploymentService
	Hook       *AdminHookService
	Repo       *AdminRepoService
	Secret     *AdminSecretService
	Service    *AdminSvcService
	Step       *AdminStepService
	User       *AdminUserService
}

AdminService handles retrieving resources from the server methods of the Vela API.

type AdminStepService added in v0.7.0

type AdminStepService service

AdminStepService handles retrieving admin steps from the server methods of the Vela API.

func (*AdminStepService) Update added in v0.7.0

func (svc *AdminStepService) Update(s *library.Step) (*library.Step, *Response, error)

Update modifies a step with the provided details.

type AdminSvcService added in v0.7.0

type AdminSvcService service

AdminSvcService handles retrieving admin services from the server methods of the Vela API.

func (*AdminSvcService) Update added in v0.7.0

Update modifies a service with the provided details.

type AdminUserService added in v0.7.0

type AdminUserService service

AdminUserService handles retrieving admin users from the server methods of the Vela API.

func (*AdminUserService) Update added in v0.7.0

func (svc *AdminUserService) Update(u *library.User) (*library.User, *Response, error)

Update modifies a user with the provided details.

type AuthenticationService

type AuthenticationService struct {
	// contains filtered or unexported fields
}

AuthenticationService contains authentication related functions.

func (*AuthenticationService) AuthenticateWithToken added in v0.7.0

func (svc *AuthenticationService) AuthenticateWithToken(token string) (string, *Response, error)

AuthenticateWithToken attempts to authenticate with the provided token, typically a personal access token created in the source provider, eg. GitHub. It will return a short-lived Vela Access Token, if successful.

func (*AuthenticationService) ExchangeTokens added in v0.7.0

func (svc *AuthenticationService) ExchangeTokens(opt *OAuthExchangeOptions) (string, string, *Response, error)

ExchangeTokens handles the last part of the OAuth flow. It uses the supplied code and state values to attempt to exchange them for Vela Access and Refresh tokens.

func (*AuthenticationService) HasAccessAndRefreshAuth added in v0.7.0

func (svc *AuthenticationService) HasAccessAndRefreshAuth() bool

HasAccessAndRefreshAuth checks if the authentication type is oauth token pair.

func (*AuthenticationService) HasAuth

func (svc *AuthenticationService) HasAuth() bool

HasAuth checks if the authentication type is set.

func (*AuthenticationService) HasPersonalAccessTokenAuth added in v0.7.0

func (svc *AuthenticationService) HasPersonalAccessTokenAuth() bool

HasPersonalAccessTokenAuth checks if the authentication type is a personal access token.

func (*AuthenticationService) HasTokenAuth

func (svc *AuthenticationService) HasTokenAuth() bool

HasTokenAuth checks if the authentication type is a plain token.

func (*AuthenticationService) RefreshAccessToken added in v0.7.0

func (svc *AuthenticationService) RefreshAccessToken(refreshToken string) (*Response, error)

RefreshAccessToken uses the supplied refresh token to attempt and refresh the access token.

func (*AuthenticationService) SetAccessAndRefreshAuth added in v0.7.0

func (svc *AuthenticationService) SetAccessAndRefreshAuth(access, refresh string)

SetAccessAndRefreshAuth sets the authentication type as oauth token pair.

func (*AuthenticationService) SetPersonalAccessTokenAuth added in v0.7.0

func (svc *AuthenticationService) SetPersonalAccessTokenAuth(token string)

SetPersonalAccessTokenAuth sets the authentication type as personal access token.

func (*AuthenticationService) SetTokenAuth

func (svc *AuthenticationService) SetTokenAuth(token string)

SetTokenAuth sets the authentication type as a plain token.

type AuthenticationType added in v0.7.0

type AuthenticationType int
const (
	// AuthenticationToken defines the
	// authentication type for auth tokens.
	AuthenticationToken AuthenticationType = iota + 1
	PersonalAccessToken
	AccessAndRefreshToken
)

type AuthorizationService

type AuthorizationService service

AuthorizationService handles user login actions against the server methods of the Vela API.

func (*AuthorizationService) GetLoginURL added in v0.7.0

func (svc *AuthorizationService) GetLoginURL(opt *LoginOptions) (string, error)

GetLoginURL returns the login url with the give login options.

type BuildListOptions added in v0.10.0

type BuildListOptions struct {
	Branch string `url:"branch,omitempty"`
	Event  string `url:"event,omitempty"`
	Status string `url:"status,omitempty"`
	Before int64  `url:"before,omitempty"`
	After  int64  `url:"after,omitempty"`

	ListOptions
}

BuildListOptions specifies the optional parameters to the Build.GetAll method.

type BuildService

type BuildService service

BuildService handles retrieving builds from the server methods of the Vela API.

func (*BuildService) Add

func (svc *BuildService) Add(org, repo string, b *library.Build) (*library.Build, *Response, error)

Add constructs a build with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Build{
	Number:       Int(1),
	Parent:       Int(1),
	Event:        String("push"),
	Status:       String("created"),
	Error:        String(""),
	Enqueued:     Int64(time.Now().UTC().Unix()),
	Created:      Int64(time.Now().UTC().Unix()),
	Started:      Int64(0),
	Finished:     Int64(0),
	Deploy:       String(""),
	Clone:        String("https://github.com/go-vela/server.git"),
	Source:       String("https://github.com/go-vela/server/abcdefghi123456789"),
	Title:        String(""),
	Message:      String(""),
	Commit:       String("abcdefghi123456789"),
	Sender:       String("someone"),
	Author:       String("someone"),
	Email:        String("someone@example.com"),
	Link:         String("https://vela.example.company.com/go-vela/server/1"),
	Branch:       String("master"),
	Ref:          String(""),
	BaseRef:      String(""),
	Host:         String("example.company.com"),
	Runtime:      String("docker"),
	Distribution: String("linux"),
}

// Create the build in the server
build, resp, err := c.Build.Add("github", "octocat", &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for build %+v", resp.StatusCode, build)
Output:

func (*BuildService) Cancel added in v0.7.0

func (svc *BuildService) Cancel(org, repo string, build int) (*library.Build, *Response, error)

Cancel takes the build provided and cancels it.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Cancel the build in the server
_, resp, err := c.Build.Cancel("github", "octocat", 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for github/octocat/1", resp.StatusCode)
Output:

func (*BuildService) Get

func (svc *BuildService) Get(org, repo string, build int) (*library.Build, *Response, error)

Get returns the provided build.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get a build from the server
build, resp, err := c.Build.Get("github", "octocat", 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for build %+v", resp.StatusCode, build)
Output:

func (*BuildService) GetAll

func (svc *BuildService) GetAll(org, repo string, opt *BuildListOptions) (*[]library.Build, *Response, error)

GetAll returns a list of all builds.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get all the builds from the server
builds, resp, err := c.Build.GetAll("github", "octocat", nil)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for builds %+v", resp.StatusCode, builds)
Output:

func (*BuildService) GetLogs

func (svc *BuildService) GetLogs(org, repo string, build int) (*[]library.Log, *Response, error)

GetLogs returns the provided build logs.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get for a build from the server
logs, resp, err := c.Build.GetLogs("github", "octocat", 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for build logs %+v", resp.StatusCode, logs)
Output:

func (*BuildService) Remove

func (svc *BuildService) Remove(org, repo string, build int) (*string, *Response, error)

Remove deletes the provided build.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Remove the build in the server
build, resp, err := c.Build.Remove("github", "octocat", 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for step %+v", resp.StatusCode, build)
Output:

func (*BuildService) Restart

func (svc *BuildService) Restart(org, repo string, build int) (*library.Build, *Response, error)

Restart takes the build provided and restarts it.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Restart the build in the server
build, resp, err := c.Build.Restart("github", "octocat", 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for step %+v", resp.StatusCode, build)
Output:

func (*BuildService) Update

func (svc *BuildService) Update(org, repo string, b *library.Build) (*library.Build, *Response, error)

Update modifies a build with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Build{
	Status: String("error"),
	Error:  String(""),
}

// Update the step in the server
build, resp, err := c.Build.Update("github", "octocat", &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for build %+v", resp.StatusCode, build)
Output:

type Client

type Client struct {

	// User agent used when communicating with the Vela API.
	UserAgent string

	// Vela service for authentication.
	Admin          *AdminService
	Authentication *AuthenticationService
	Authorization  *AuthorizationService
	Build          *BuildService
	Deployment     *DeploymentService
	Hook           *HookService
	Log            *LogService
	Pipeline       *PipelineService
	Repo           *RepoService
	SCM            *SCMService
	Secret         *SecretService
	Step           *StepService
	Svc            *SvcService
	Worker         *WorkerService
	// contains filtered or unexported fields
}

Client is a client that manages communication with the Vela API.

func FromContext

func FromContext(c context.Context) *Client

FromContext returns the Client associated with this context.

func NewClient

func NewClient(baseURL, id string, httpClient *http.Client) (*Client, error)

NewClient returns a new Vela API client. baseURL has to be the HTTP endpoint of the Vela API. If no httpClient is provided, then the http.DefaultClient will be used.

func (*Client) Call

func (c *Client) Call(method, url string, body, respType interface{}) (*Response, error)

Call is a combined function for Client.NewRequest and Client.Do.

Most API methods are quite the same. Get the URL, apply options, make a request, and get the response. Without adding special headers or something. To avoid a big amount of code duplication you can Client.Call.

method is the HTTP method you want to call. url is the URL you want to call. body is the HTTP body. respType is the type that the HTTP response will resolve to.

For more information read https://github.com/google/go-github/issues/234

func (*Client) CallWithHeaders added in v0.10.0

func (c *Client) CallWithHeaders(method, url string, body, respType interface{}, headers map[string]string) (*Response, error)

CallWithHeaders is a combined function for Client.NewRequest and Client.Do.

Most API methods are quite the same. Get the URL, apply options, make a request, and get the response. Without adding special headers or something. To avoid a big amount of code duplication you can Client.Call.

method is the HTTP method you want to call. url is the URL you want to call. body is the HTTP body. respType is the type that the HTTP response will resolve to. headers is a map of HTTP headers.

For more information read https://github.com/google/go-github/issues/234

func (*Client) Do

func (c *Client) Do(req *http.Request, respType interface{}) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by respType, or returned as an error if an API error has occurred. If respType implements the io.Writer interface, the raw response body will be written to respType, without attempting to first decode it.

func (*Client) NewRequest

func (c *Client) NewRequest(method, url string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in url, in which case it is resolved relative to the baseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.

func (*Client) SetTimeout added in v0.10.0

func (c *Client) SetTimeout(d time.Duration)

SetTimeout sets the timeout for the http client.

type DeploymentService added in v0.4.0

type DeploymentService service

DeploymentService handles retrieving deployments from the server methods of the Vela API.

func (*DeploymentService) Add added in v0.4.0

Add constructs a deployment with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Deployment{
	Commit:      String("48afb5bdc41ad69bf22588491333f7cf71135163"),
	Ref:         String("refs/heads/master"),
	Task:        String("vela-deploy"),
	Target:      String("production"),
	Description: String("Deployment request from Vela"),
}

// Create the deployment in the server
deployment, resp, err := c.Deployment.Add("github", "octocat", &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for deployment %+v", resp.StatusCode, deployment)
Output:

func (*DeploymentService) Get added in v0.4.0

func (svc *DeploymentService) Get(org, repo string, deployment int) (*library.Deployment, *Response, error)

Get returns the provided deployment.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get a build from the server
deployment, resp, err := c.Deployment.Get("github", "octocat", 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for deployment %+v", resp.StatusCode, deployment)
Output:

func (*DeploymentService) GetAll added in v0.4.0

func (svc *DeploymentService) GetAll(org, repo string, opt *ListOptions) (*[]library.Deployment, *Response, error)

GetAll returns a list of all deployments.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get all the deployments from the server
deployments, resp, err := c.Deployment.GetAll("github", "octocat", nil)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for deployments %+v", resp.StatusCode, deployments)
Output:

type GetQueueOptions added in v0.8.0

type GetQueueOptions struct {
	// Unix timestamp.
	// Returns only the builds created since the timestamp.
	// Default: 24 hours ago
	After string `url:"after,omitempty"`

	ListOptions
}

GetQueueOptions specifies the optional parameters to the AdminBuildService.GetQueue method.

type HookService added in v0.4.0

type HookService service

HookService handles retrieving hooks from the server methods of the Vela API.

func (*HookService) Add added in v0.4.0

func (svc *HookService) Add(org, repo string, h *library.Hook) (*library.Hook, *Response, error)

Add constructs a hook with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Hook{
	Number:   Int(1),
	SourceID: String("c8da1302-07d6-11ea-882f-4893bca275b8"),
	Event:    String("push"),
	Status:   String("created"),
	Error:    String(""),
	Created:  Int64(1563474076),
	Link:     String("https://github.com/github/octocat/settings/hooks/1"),
	Branch:   String("master"),
	Host:     String("github.com"),
}

// Create the hook in the server
hook, resp, err := c.Hook.Add("github", "octocat", &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for hook %+v", resp.StatusCode, hook)
Output:

func (*HookService) Get added in v0.4.0

func (svc *HookService) Get(org, repo string, hook int) (*library.Hook, *Response, error)

Get returns the provided hook.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get a hook from the server
hook, resp, err := c.Hook.Get("github", "octocat", 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for hook %+v", resp.StatusCode, hook)
Output:

func (*HookService) GetAll added in v0.4.0

func (svc *HookService) GetAll(org, repo string, opt *ListOptions) (*[]library.Hook, *Response, error)

GetAll returns a list of all hooks.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get all the hooks from the server
hooks, resp, err := c.Hook.GetAll("github", "octocat", nil)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for hooks %+v", resp.StatusCode, hooks)
Output:

func (*HookService) Remove added in v0.4.0

func (svc *HookService) Remove(org, repo string, hook int) (*string, *Response, error)

Remove deletes the provided hook.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Remove the hook in the server
hook, resp, err := c.Hook.Remove("github", "octocat", 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for step %+v", resp.StatusCode, hook)
Output:

func (*HookService) Update added in v0.4.0

func (svc *HookService) Update(org, repo string, h *library.Hook) (*library.Hook, *Response, error)

Update modifies a hook with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Hook{
	Status: String("error"),
	Error:  String(""),
}

// Update the step in the server
hook, resp, err := c.Hook.Update("github", "octocat", &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for hook %+v", resp.StatusCode, hook)
Output:

type ListOptions added in v0.3.0

type ListOptions struct {
	// For paginated result sets, page of results to retrieve.
	Page int `url:"page,omitempty"`

	// For paginated result sets, the number of results to include per page.
	PerPage int `url:"per_page,omitempty"`
}

ListOptions represents the optional parameters to various List methods that support pagination.

type LogService

type LogService service

LogService handles retrieving logs for builds from the server methods of the Vela API.

func (*LogService) AddService

func (svc *LogService) AddService(org, repo string, build, service int, l *library.Log) (*library.Log, *Response, error)

AddService constructs a service log with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Log{
	Data: Bytes([]byte("Hello World")),
}

// Create the log in the server
log, resp, err := c.Log.AddService("github", "octocat", 1, 1, &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for log %+v", resp.StatusCode, log)
Output:

func (*LogService) AddStep

func (svc *LogService) AddStep(org, repo string, build, step int, l *library.Log) (*library.Log, *Response, error)

AddStep constructs a step log with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Log{
	Data: Bytes([]byte("Hello World")),
}

// Create the log in the server
log, resp, err := c.Log.AddStep("github", "octocat", 1, 1, &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for log %+v", resp.StatusCode, log)
Output:

func (*LogService) GetService

func (svc *LogService) GetService(org, repo string, build, service int) (*library.Log, *Response, error)

GetService returns the provided service log.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get a log from the server
log, resp, err := c.Log.GetService("github", "octocat", 1, 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for log %+v", resp.StatusCode, log)
Output:

func (*LogService) GetStep

func (svc *LogService) GetStep(org, repo string, build, step int) (*library.Log, *Response, error)

GetStep returns the provided step log.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get a log from the server
log, resp, err := c.Log.GetStep("github", "octocat", 1, 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for log %+v", resp.StatusCode, log)
Output:

func (*LogService) RemoveService

func (svc *LogService) RemoveService(org, repo string, build, service int) (*string, *Response, error)

RemoveService deletes the provided service log.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Remove the log in the server
log, resp, err := c.Log.RemoveService("github", "octocat", 1, 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for log %+v", resp.StatusCode, log)
Output:

func (*LogService) RemoveStep

func (svc *LogService) RemoveStep(org, repo string, build, step int) (*string, *Response, error)

RemoveStep deletes the provided step log.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Remove the log in the server
log, resp, err := c.Log.RemoveStep("github", "octocat", 1, 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for log %+v", resp.StatusCode, log)
Output:

func (*LogService) UpdateService

func (svc *LogService) UpdateService(org, repo string, build, service int, l *library.Log) (*library.Log, *Response, error)

UpdateService modifies a service log with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Log{
	Data: Bytes([]byte("Hello World")),
}

// Update the log in the server
log, resp, err := c.Log.UpdateService("github", "octocat", 1, 1, &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for log %+v", resp.StatusCode, log)
Output:

func (*LogService) UpdateStep

func (svc *LogService) UpdateStep(org, repo string, build, step int, l *library.Log) (*library.Log, *Response, error)

UpdateStep modifies a step log with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Log{
	Data: Bytes([]byte("Hello World")),
}

// Update the log in the server
log, resp, err := c.Log.UpdateStep("github", "octocat", 1, 1, &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for log %+v", resp.StatusCode, log)
Output:

type LoginOptions added in v0.7.0

type LoginOptions struct {
	Type string `url:"type,omitempty"`
	Port string `url:"port,omitempty"`
}

LoginOptions represents the optional parameters to launch the login process.

type OAuthExchangeOptions added in v0.7.0

type OAuthExchangeOptions struct {
	Code  string `url:"code,omitempty"`
	State string `url:"state,omitempty"`
}

OAuthExchangeOptions represents the required parameters to exchange for tokens.

type PipelineOptions added in v0.7.0

type PipelineOptions struct {
	// Output of the pipeline being returned.
	//
	// Can be: json or yaml
	//
	// Default: yaml
	Output string `url:"output,omitempty"`

	// Enables expanding templates when validating a pipeline.
	//
	// Can be: true or false
	//
	// Default: true
	Template bool `url:"template,omitempty"`
}

PipelineOptions represents the optional parameters to the PipelineService.

type PipelineService added in v0.7.0

type PipelineService service

PipelineService handles retrieving pipelines from the server methods of the Vela API.

func (*PipelineService) Add added in v0.14.0

func (svc *PipelineService) Add(org, repo string, h *library.Pipeline) (*library.Pipeline, *Response, error)

Add constructs a pipeline with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Pipeline{
	Commit:  String("48afb5bdc41ad69bf22588491333f7cf71135163"),
	Ref:     String("refs/heads/master"),
	Type:    String("yaml"),
	Version: String("1"),
	Steps:   Bool(true),
}

// Create the pipeline in the server
pipeline, resp, err := c.Pipeline.Add("github", "octocat", &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)
Output:

func (*PipelineService) Compile added in v0.7.0

func (svc *PipelineService) Compile(org, repo, ref string, opt *PipelineOptions) (*yaml.Build, *Response, error)

Compile returns the provided fully compiled pipeline.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// create options for pipeline call
opts := &PipelineOptions{
	Output: "yaml", // default
}

// compile a pipeline from a repo from the server
pipeline, resp, err := c.Pipeline.Compile("github", "octocat", "48afb5bdc41ad69bf22588491333f7cf71135163", opts)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)
Output:

func (*PipelineService) Expand added in v0.7.0

func (svc *PipelineService) Expand(org, repo, ref string, opt *PipelineOptions) (*yaml.Build, *Response, error)

Expand returns the provided pipeline fully compiled.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// create options for pipeline call
opts := &PipelineOptions{
	Output: "yaml", // default
}

// expand templates for a pipeline from a repo from the server
pipeline, resp, err := c.Pipeline.Expand("github", "octocat", "48afb5bdc41ad69bf22588491333f7cf71135163", opts)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)
Output:

func (*PipelineService) Get added in v0.7.0

func (svc *PipelineService) Get(org, repo, ref string) (*library.Pipeline, *Response, error)

Get returns the provided pipeline.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// get a pipeline from a repo from the server
pipeline, resp, err := c.Pipeline.Get("github", "octocat", "48afb5bdc41ad69bf22588491333f7cf71135163")
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)
Output:

func (*PipelineService) GetAll added in v0.14.0

func (svc *PipelineService) GetAll(org, repo string, opt *ListOptions) (*[]library.Pipeline, *Response, error)

GetAll returns a list of all pipelines.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get all the pipelines from the server
pipelines, resp, err := c.Pipeline.GetAll("github", "octocat", nil)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for pipelines %+v", resp.StatusCode, pipelines)
Output:

func (*PipelineService) Remove added in v0.14.0

func (svc *PipelineService) Remove(org, repo string, pipeline string) (*string, *Response, error)

Remove deletes the provided pipeline.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Remove the pipeline in the server
pipeline, resp, err := c.Pipeline.Remove("github", "octocat", "48afb5bdc41ad69bf22588491333f7cf71135163")
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for step %+v", resp.StatusCode, pipeline)
Output:

func (*PipelineService) Templates added in v0.7.0

func (svc *PipelineService) Templates(org, repo, ref string, opt *PipelineOptions) (map[string]*yaml.Template, *Response, error)

Templates returns the provided templates for a pipeline.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// create options for pipeline call
opts := &PipelineOptions{
	Output: "yaml", // default
}

// get templates for a pipeline from a repo from the server
pipeline, resp, err := c.Pipeline.Templates("github", "octocat", "48afb5bdc41ad69bf22588491333f7cf71135163", opts)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)
Output:

func (*PipelineService) Update added in v0.14.0

func (svc *PipelineService) Update(org, repo string, p *library.Pipeline) (*library.Pipeline, *Response, error)

Update modifies a pipeline with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Pipeline{
	Commit: String("48afb5bdc41ad69bf22588491333f7cf71135163"),
	Type:   String("yaml"),
}

// Update the step in the server
pipeline, resp, err := c.Pipeline.Update("github", "octocat", &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)
Output:

func (*PipelineService) Validate added in v0.7.0

func (svc *PipelineService) Validate(org, repo, ref string, opt *PipelineOptions) (*string, *Response, error)

Validate returns the validation status of the provided pipeline.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// create options for pipeline call
opts := &PipelineOptions{
	Output:   "yaml", // default
	Template: true,   // default
}

// get templates for a pipeline from a repo from the server
pipeline, resp, err := c.Pipeline.Validate("github", "octocat", "48afb5bdc41ad69bf22588491333f7cf71135163", opts)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for pipeline %+v", resp.StatusCode, pipeline)
Output:

func (*PipelineService) ValidateRaw added in v0.9.0

func (svc *PipelineService) ValidateRaw(b64Pipeline string, opt *PipelineOptions) (*string, *Response, error)

type RepoService

type RepoService service

RepoService handles retrieving repos from the server methods of the Vela API.

func (*RepoService) Add

func (svc *RepoService) Add(r *library.Repo) (*library.Repo, *Response, error)

Add constructs a repo with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Repo{
	Org:         String("github"),
	Name:        String("octocat"),
	FullName:    String("github/octocat"),
	Link:        String("https://github.com/github/octocat"),
	Clone:       String("https://github.com/github/octocat.git"),
	Branch:      String("master"),
	Timeout:     Int64(60),
	Visibility:  String("public"),
	Private:     Bool(false),
	Trusted:     Bool(false),
	Active:      Bool(true),
	AllowPull:   Bool(true),
	AllowPush:   Bool(true),
	AllowDeploy: Bool(false),
	AllowTag:    Bool(false),
}

// Create the repo in the server
repo, resp, err := c.Repo.Add(&req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for repo %+v", resp.StatusCode, repo)
Output:

func (*RepoService) Chown

func (svc *RepoService) Chown(org, repo string) (*string, *Response, error)

Chown modifies the org of a repo.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Change orgship of the repo in the server
repo, resp, err := c.Repo.Chown("github", "octocat")
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for repo %+v", resp.StatusCode, repo)
Output:

func (*RepoService) Get

func (svc *RepoService) Get(org, repo string) (*library.Repo, *Response, error)

Get returns the provided repo.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get a repo from the server
repo, resp, err := c.Repo.Get("github", "octocat")
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for repo %+v", resp.StatusCode, repo)
Output:

func (*RepoService) GetAll

func (svc *RepoService) GetAll(opt *ListOptions) (*[]library.Repo, *Response, error)

GetAll returns a list of all repos.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get all the repos from the server
repos, resp, err := c.Repo.GetAll(nil)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for repos %+v", resp.StatusCode, repos)
Output:

func (*RepoService) Remove

func (svc *RepoService) Remove(org, repo string) (*string, *Response, error)

Remove deletes the provided repo.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Remove the repo in the server
repo, resp, err := c.Repo.Remove("github", "octocat")
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for repo %+v", resp.StatusCode, repo)
Output:

func (*RepoService) Repair

func (svc *RepoService) Repair(org, repo string) (*string, *Response, error)

Repair modifies a damaged repo webhook.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Repair the repo in the server
repo, resp, err := c.Repo.Repair("github", "octocat")
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for repo %+v", resp.StatusCode, repo)
Output:

func (*RepoService) Update

func (svc *RepoService) Update(org, repo string, r *library.Repo) (*library.Repo, *Response, error)

Update modifies a repo with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Repo{
	AllowDeploy: Bool(true),
	AllowTag:    Bool(true),
}

// Update the repo in the server
repo, resp, err := c.Repo.Update("github", "octocat", &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for repo %+v", resp.StatusCode, repo)
Output:

type Response

type Response struct {
	*http.Response

	// Values hold basic information pertaining to how to paginate
	// through response results
	NextPage  int
	PrevPage  int
	FirstPage int
	LastPage  int
}

Response represents an Vela API response. This wraps the standard http.Response returned from Vela.

type SCMService added in v0.12.0

type SCMService service

SCMService handles syncing repos from the server methods of the Vela API.

func (*SCMService) Sync added in v0.12.0

func (svc *SCMService) Sync(org, repo string) (*string, *Response, error)

Sync synchronizes a repo between the database and the SCM.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Change orgship of the repo in the server
repo, resp, err := c.SCM.Sync("github", "octocat")
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for repo %+v", resp.StatusCode, repo)
Output:

func (*SCMService) SyncAll added in v0.12.0

func (svc *SCMService) SyncAll(org string) (*string, *Response, error)

Sync synchronizes all org repos between the database and the SCM.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Change orgship of the repo in the server
org, resp, err := c.SCM.SyncAll("github")
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for repo %+v", resp.StatusCode, org)
Output:

type SecretService

type SecretService service

SecretService handles retrieving secrets from the server methods of the Vela API.

func (*SecretService) Add

func (svc *SecretService) Add(engine, sType, org, name string, s *library.Secret) (*library.Secret, *Response, error)

Add constructs a secret with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Secret{
	Name:   String("foo"),
	Value:  String("bar"),
	Images: &[]string{"foo", "bar"},
	Events: &[]string{"foo", "bar"},
}

// Create the secret in the server
secret, resp, err := c.Secret.Add("native", "repo", "github", "octocat", &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for secret %+v", resp.StatusCode, secret)
Output:

func (*SecretService) Get

func (svc *SecretService) Get(engine, sType, org, name, secret string) (*library.Secret, *Response, error)

Get returns the provided secret.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get the secret from the server
secret, resp, err := c.Secret.Get("native", "repo", "github", "octocat", "foo")
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for secret %+v", resp.StatusCode, secret)
Output:

func (*SecretService) GetAll

func (svc *SecretService) GetAll(engine, sType, org, name string, opt *ListOptions) (*[]library.Secret, *Response, error)

GetAll returns a list of all secrets.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get all the secrets from the server
secrets, resp, err := c.Secret.GetAll("native", "repo", "github", "octocat", nil)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for secrets %+v", resp.StatusCode, secrets)
Output:

func (*SecretService) Remove

func (svc *SecretService) Remove(engine, sType, org, name, secret string) (*string, *Response, error)

Remove deletes the provided secret.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Remove the secret in the server
secret, resp, err := c.Secret.Remove("native", "repo", "github", "octocat", "foo")
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for secret %+v", resp.StatusCode, secret)
Output:

func (*SecretService) Update

func (svc *SecretService) Update(engine, sType, org, name string, s *library.Secret) (*library.Secret, *Response, error)

Update modifies a secret with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Secret{
	Name:   String("foo"),
	Value:  String("bar"),
	Events: &[]string{"barf", "foob"},
}

// Update the secret in the server
secret, resp, err := c.Secret.Update("native", "repo", "github", "octocat", &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for secret %+v", resp.StatusCode, secret)
Output:

type StepService

type StepService service

StepService handles retrieving steps for builds from the server methods of the Vela API.

func (*StepService) Add

func (svc *StepService) Add(org, repo string, build int, s *library.Step) (*library.Step, *Response, error)

Add constructs a step with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Step{
	Number:       Int(1),
	Name:         String("clone"),
	Status:       String("pending"),
	Error:        String(""),
	ExitCode:     Int(0),
	Created:      Int64(time.Now().UTC().Unix()),
	Started:      Int64(0),
	Finished:     Int64(0),
	Host:         String("example.company.com"),
	Runtime:      String("docker"),
	Distribution: String("linux"),
}

// Create the step in the server
step, resp, err := c.Step.Add("github", "octocat", 1, &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for step %+v", resp.StatusCode, step)
Output:

func (*StepService) Get

func (svc *StepService) Get(org, repo string, build, step int) (*library.Step, *Response, error)

Get returns the provided step.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get a step from the server
step, resp, err := c.Step.Get("github", "octocat", 1, 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for step %+v", resp.StatusCode, step)
Output:

func (*StepService) GetAll

func (svc *StepService) GetAll(org, repo string, build int, opt *ListOptions) (*[]library.Step, *Response, error)

GetAll returns a list of all steps.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get all the steps from the server
steps, resp, err := c.Step.GetAll("github", "octocat", 1, nil)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for steps %+v", resp.StatusCode, steps)
Output:

func (*StepService) Remove

func (svc *StepService) Remove(org, repo string, build, step int) (*string, *Response, error)

Remove deletes the provided step.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Remove the step in the server
step, resp, err := c.Step.Remove("github", "octocat", 1, 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for step %+v", resp.StatusCode, step)
Output:

func (*StepService) Stream added in v0.10.0

func (svc *StepService) Stream(org, repo string, build, step int, rc io.ReadCloser) (*Response, error)

Stream opens a connection to the stream endpoint for the step.

func (*StepService) Update

func (svc *StepService) Update(org, repo string, build int, s *library.Step) (*library.Step, *Response, error)

Update modifies a step with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Step{
	Status: String("error"),
	Error:  String("Something in the runtime broke"),
}

// Update the step in the server
step, resp, err := c.Step.Update("github", "octocat", 1, &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for step %+v", resp.StatusCode, step)
Output:

type SvcService

type SvcService service

SvcService handles retrieving services for builds from the server methods of the Vela API.

func (*SvcService) Add

func (svc *SvcService) Add(org, repo string, build int, s *library.Service) (*library.Service, *Response, error)

Add constructs a service with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Service{
	Number:   Int(1),
	Name:     String("clone"),
	Status:   String("pending"),
	Error:    String(""),
	ExitCode: Int(0),
	Created:  Int64(time.Now().UTC().Unix()),
	Started:  Int64(0),
	Finished: Int64(0),
}

// Create the service in the server
service, resp, err := c.Svc.Add("github", "octocat", 1, &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for service %+v", resp.StatusCode, service)
Output:

func (*SvcService) Get

func (svc *SvcService) Get(org, repo string, build, service int) (*library.Service, *Response, error)

Get returns the provided service.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get a service from the server
service, resp, err := c.Svc.Get("github", "octocat", 1, 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for service %+v", resp.StatusCode, service)
Output:

func (*SvcService) GetAll

func (svc *SvcService) GetAll(org, repo string, build int, opt *ListOptions) (*[]library.Service, *Response, error)

GetAll returns a list of all services.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get all the services from the server
services, resp, err := c.Svc.GetAll("github", "octocat", 1, nil)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for services %+v", resp.StatusCode, services)
Output:

func (*SvcService) Remove

func (svc *SvcService) Remove(org, repo string, build, service int) (*string, *Response, error)

Remove deletes the provided service.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Remove the service in the server
service, resp, err := c.Svc.Remove("github", "octocat", 1, 1)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for service %+v", resp.StatusCode, service)
Output:

func (*SvcService) Stream added in v0.10.0

func (svc *SvcService) Stream(org, repo string, build, service int, rc io.ReadCloser) (*Response, error)

Stream opens a connection to the stream endpoint for the service.

func (*SvcService) Update

func (svc *SvcService) Update(org, repo string, build int, s *library.Service) (*library.Service, *Response, error)

Update modifies a service with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Service{
	Status: String("error"),
	Error:  String("Something in the runtime broke"),
}

// Update the service in the server
service, resp, err := c.Svc.Update("github", "octocat", 1, &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for service %+v", resp.StatusCode, service)
Output:

type WorkerService added in v0.7.0

type WorkerService service

WorkerService handles retrieving workers from the server methods of the Vela API.

func (*WorkerService) Add added in v0.7.0

Add constructs a worker with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Worker{
	ID:       Int64(1),
	Hostname: String("worker_1"),
	Address:  String("http://vela:8080"),
	Routes: Strings([]string{
		"large",
		"docker",
		"large:docker",
	}),
	Active:        Bool(true),
	LastCheckedIn: Int64(1602612590),
}

// Create the worker in the server
worker, resp, err := c.Worker.Add(&req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for worker %+v", resp.StatusCode, worker)
Output:

func (*WorkerService) Get added in v0.7.0

func (svc *WorkerService) Get(hostname string) (*library.Worker, *Response, error)

Get returns the provided worker.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get a worker from the server
worker, resp, err := c.Worker.Get("worker_1")
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for worker %+v", resp.StatusCode, worker)
Output:

func (*WorkerService) GetAll added in v0.7.0

func (svc *WorkerService) GetAll() (*[]library.Worker, *Response, error)

GetAll returns a list of all workers.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Get all the workers from the server
workers, resp, err := c.Worker.GetAll()
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for workers %+v", resp.StatusCode, workers)
Output:

func (*WorkerService) Remove added in v0.7.0

func (svc *WorkerService) Remove(worker string) (*string, *Response, error)

Remove deletes the provided worker.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

// Remove the worker in the server
worker, resp, err := c.Worker.Remove("worker_1")
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for worker %+v", resp.StatusCode, worker)
Output:

func (*WorkerService) Update added in v0.7.0

func (svc *WorkerService) Update(worker string, w *library.Worker) (*library.Worker, *Response, error)

Update modifies a worker with the provided details.

Example
// Create a new vela client for interacting with server
c, _ := NewClient("http://localhost:8080", "", nil)

// Set new token in existing client
c.Authentication.SetPersonalAccessTokenAuth("token")

req := library.Worker{
	Active: Bool(false),
}

// Update the worker in the server
worker, resp, err := c.Worker.Update("worker_1", &req)
if err != nil {
	fmt.Println(err)
}

fmt.Printf("Received response code %d, for worker %+v", resp.StatusCode, worker)
Output:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL