Documentation
¶
Overview ¶
Package vela provides a client for using the Vela API.
Usage:
import "github.com/go-vela/sdk-go/vela"
Index ¶
- func Bool(v bool) *bool
- func Bytes(v []byte) *[]byte
- func CheckResponse(r *http.Response) error
- func Int(v int) *int
- func Int64(v int64) *int64
- func IsTokenExpired(token string) bool
- func String(v string) *string
- func Strings(v []string) *[]string
- func ToContext(c context.Context, cli *Client) context.Context
- func UInt64(v uint64) *uint64
- type AdminBuildService
- type AdminCleanService
- type AdminDeploymentService
- type AdminHookService
- type AdminOIDCService
- type AdminRepoService
- type AdminSecretService
- type AdminService
- type AdminSettingsService
- type AdminStepService
- type AdminSvcService
- type AdminUserService
- type AdminWorkerService
- type AuthenticationService
- func (svc *AuthenticationService) AuthenticateWithToken(token string) (string, *Response, error)
- func (svc *AuthenticationService) ExchangeTokens(opt *OAuthExchangeOptions) (string, string, *Response, error)
- func (svc *AuthenticationService) HasAccessAndRefreshAuth() bool
- func (svc *AuthenticationService) HasAuth() bool
- func (svc *AuthenticationService) HasPersonalAccessTokenAuth() bool
- func (svc *AuthenticationService) HasTokenAuth() bool
- func (svc *AuthenticationService) IsTokenAuthExpired() (bool, error)
- func (svc *AuthenticationService) RefreshAccessToken(refreshToken string) (*Response, error)
- func (svc *AuthenticationService) SetAccessAndRefreshAuth(access, refresh string)
- func (svc *AuthenticationService) SetPersonalAccessTokenAuth(token string)
- func (svc *AuthenticationService) SetTokenAuth(token string)
- func (svc *AuthenticationService) ValidateOAuthToken() (*Response, error)
- func (svc *AuthenticationService) ValidateToken() (*Response, error)
- type AuthenticationType
- type AuthorizationService
- type BuildListOptions
- type BuildService
- func (svc *BuildService) Add(b *api.Build) (*api.Build, *Response, error)
- func (svc *BuildService) Approve(org, repo string, build int) (*Response, error)
- func (svc *BuildService) Cancel(org, repo string, build int) (*api.Build, *Response, error)
- func (svc *BuildService) Get(org, repo string, build int) (*api.Build, *Response, error)
- func (svc *BuildService) GetAll(org, repo string, opt *BuildListOptions) (*[]api.Build, *Response, error)
- func (svc *BuildService) GetBuildExecutable(org, repo string, build int) (*api.BuildExecutable, *Response, error)
- func (svc *BuildService) GetBuildToken(org, repo string, build int) (*api.Token, *Response, error)
- func (svc *BuildService) GetIDRequestToken(org, repo string, build int, opt *RequestTokenOptions) (*api.Token, *Response, error)
- func (svc *BuildService) GetIDToken(org, repo string, build int, opt *IDTokenOptions) (*api.Token, *Response, error)
- func (svc *BuildService) GetLogs(org, repo string, build int, opt *ListOptions) (*[]api.Log, *Response, error)
- func (svc *BuildService) Remove(org, repo string, build int) (*string, *Response, error)
- func (svc *BuildService) Restart(org, repo string, build int) (*api.Build, *Response, error)
- func (svc *BuildService) Update(b *api.Build) (*api.Build, *Response, error)
- type CleanOptions
- type Client
- func (c *Client) Call(method, url string, body, respType interface{}) (*Response, error)
- func (c *Client) CallWithHeaders(method, url string, body, respType interface{}, headers map[string]string) (*Response, error)
- func (c *Client) Do(req *http.Request, respType interface{}) (*Response, error)
- func (c *Client) NewRequest(method, url string, body interface{}) (*http.Request, error)
- func (c *Client) SetTimeout(d time.Duration)
- type DashboardService
- func (svc *DashboardService) Add(d *api.Dashboard) (*api.Dashboard, *Response, error)
- func (svc *DashboardService) Get(dashboard string) (*api.DashCard, *Response, error)
- func (svc *DashboardService) GetAllUser() (*[]api.DashCard, *Response, error)
- func (svc *DashboardService) Update(d *api.Dashboard) (*api.Dashboard, *Response, error)
- type DeploymentService
- func (svc *DeploymentService) Add(org, repo string, d *api.Deployment) (*api.Deployment, *Response, error)
- func (svc *DeploymentService) Get(org, repo string, deployment int) (*api.Deployment, *Response, error)
- func (svc *DeploymentService) GetAll(org, repo string, opt *ListOptions) (*[]api.Deployment, *Response, error)
- type GetQueueOptions
- type HookService
- func (svc *HookService) Add(org, repo string, h *api.Hook) (*api.Hook, *Response, error)
- func (svc *HookService) Get(org, repo string, hook int) (*api.Hook, *Response, error)
- func (svc *HookService) GetAll(org, repo string, opt *ListOptions) (*[]api.Hook, *Response, error)
- func (svc *HookService) Remove(org, repo string, hook int) (*string, *Response, error)
- func (svc *HookService) Update(org, repo string, h *api.Hook) (*api.Hook, *Response, error)
- type IDTokenOptions
- type ListOptions
- type LogService
- func (svc *LogService) AddService(org, repo string, build, service int, l *api.Log) (*Response, error)
- func (svc *LogService) AddStep(org, repo string, build, step int, l *api.Log) (*Response, error)
- func (svc *LogService) GetService(org, repo string, build, service int) (*api.Log, *Response, error)
- func (svc *LogService) GetStep(org, repo string, build, step int) (*api.Log, *Response, error)
- func (svc *LogService) RemoveService(org, repo string, build, service int) (*string, *Response, error)
- func (svc *LogService) RemoveStep(org, repo string, build, step int) (*string, *Response, error)
- func (svc *LogService) UpdateService(org, repo string, build, service int, l *api.Log) (*Response, error)
- func (svc *LogService) UpdateStep(org, repo string, build, step int, l *api.Log) (*Response, error)
- type LoginOptions
- type OAuthExchangeOptions
- type PipelineOptions
- type PipelineService
- func (svc *PipelineService) Add(org, repo string, h *api.Pipeline) (*api.Pipeline, *Response, error)
- func (svc *PipelineService) Compile(org, repo, ref string, opt *PipelineOptions) (*yaml.Build, *Response, error)
- func (svc *PipelineService) Expand(org, repo, ref string, opt *PipelineOptions) (*yaml.Build, *Response, error)
- func (svc *PipelineService) Get(org, repo, ref string) (*api.Pipeline, *Response, error)
- func (svc *PipelineService) GetAll(org, repo string, opt *ListOptions) (*[]api.Pipeline, *Response, error)
- func (svc *PipelineService) Remove(org, repo string, pipeline string) (*string, *Response, error)
- func (svc *PipelineService) Templates(org, repo, ref string, opt *PipelineOptions) (map[string]*yaml.Template, *Response, error)
- func (svc *PipelineService) Update(org, repo string, p *api.Pipeline) (*api.Pipeline, *Response, error)
- func (svc *PipelineService) Validate(org, repo, ref string, opt *PipelineOptions) (*string, *Response, error)
- func (svc *PipelineService) ValidateRaw(b64Pipeline string, opt *PipelineOptions) (*string, *Response, error)
- type QueueService
- type RepoService
- func (svc *RepoService) Add(r *api.Repo) (*api.Repo, *Response, error)
- func (svc *RepoService) Chown(org, repo string) (*string, *Response, error)
- func (svc *RepoService) Get(org, repo string) (*api.Repo, *Response, error)
- func (svc *RepoService) GetAll(opt *ListOptions) (*[]api.Repo, *Response, error)
- func (svc *RepoService) Remove(org, repo string) (*string, *Response, error)
- func (svc *RepoService) Repair(org, repo string) (*string, *Response, error)
- func (svc *RepoService) Update(org, repo string, r *api.Repo) (*api.Repo, *Response, error)
- type RequestTokenOptions
- type Response
- type SCMService
- type ScheduleService
- func (svc *ScheduleService) Add(org, repo string, s *api.Schedule) (*api.Schedule, *Response, error)
- func (svc *ScheduleService) Get(org, repo, schedule string) (*api.Schedule, *Response, error)
- func (svc *ScheduleService) GetAll(org, repo string, opt *ListOptions) (*[]api.Schedule, *Response, error)
- func (svc *ScheduleService) Remove(org, repo, schedule string) (*string, *Response, error)
- func (svc *ScheduleService) Update(org, repo string, s *api.Schedule) (*api.Schedule, *Response, error)
- type SecretService
- func (svc *SecretService) Add(engine, sType, org, name string, s *api.Secret) (*api.Secret, *Response, error)
- func (svc *SecretService) Get(engine, sType, org, name, secret string) (*api.Secret, *Response, error)
- func (svc *SecretService) GetAll(engine, sType, org, name string, opt *ListOptions) (*[]api.Secret, *Response, error)
- func (svc *SecretService) Remove(engine, sType, org, name, secret string) (*string, *Response, error)
- func (svc *SecretService) Update(engine, sType, org, name string, s *api.Secret) (*api.Secret, *Response, error)
- type StepService
- func (svc *StepService) Add(org, repo string, build int, s *api.Step) (*api.Step, *Response, error)
- func (svc *StepService) Get(org, repo string, build, step int) (*api.Step, *Response, error)
- func (svc *StepService) GetAll(org, repo string, build int, opt *ListOptions) (*[]api.Step, *Response, error)
- func (svc *StepService) Remove(org, repo string, build, step int) (*string, *Response, error)
- func (svc *StepService) Update(org, repo string, build int, s *api.Step) (*api.Step, *Response, error)
- type SvcService
- func (svc *SvcService) Add(org, repo string, build int, s *api.Service) (*api.Service, *Response, error)
- func (svc *SvcService) Get(org, repo string, build, service int) (*api.Service, *Response, error)
- func (svc *SvcService) GetAll(org, repo string, build int, opt *ListOptions) (*[]api.Service, *Response, error)
- func (svc *SvcService) Remove(org, repo string, build, service int) (*string, *Response, error)
- func (svc *SvcService) Update(org, repo string, build int, s *api.Service) (*api.Service, *Response, error)
- type UserService
- func (svc *UserService) Get(name string) (*api.User, *Response, error)
- func (svc *UserService) GetCurrent() (*api.User, *Response, error)
- func (svc *UserService) Update(name string, user *api.User) (*api.User, *Response, error)
- func (svc *UserService) UpdateCurrent(user *api.User) (*api.User, *Response, error)
- type WorkerListOptions
- type WorkerService
- func (svc *WorkerService) Add(w *api.Worker) (*api.Token, *Response, error)
- func (svc *WorkerService) Get(hostname string) (*api.Worker, *Response, error)
- func (svc *WorkerService) GetAll(opt *WorkerListOptions) (*[]api.Worker, *Response, error)
- func (svc *WorkerService) RefreshAuth(worker string) (*api.Token, *Response, error)
- func (svc *WorkerService) Remove(worker string) (*string, *Response, error)
- func (svc *WorkerService) Update(worker string, w *api.Worker) (*api.Worker, *Response, error)
Examples ¶
- BuildService.Add
- BuildService.Cancel
- BuildService.Get
- BuildService.GetAll
- BuildService.GetBuildToken
- BuildService.GetLogs
- BuildService.Remove
- BuildService.Restart
- BuildService.Update
- DeploymentService.Add
- DeploymentService.Get
- DeploymentService.GetAll
- HookService.Add
- HookService.Get
- HookService.GetAll
- HookService.Remove
- HookService.Update
- LogService.AddService
- LogService.AddStep
- LogService.GetService
- LogService.GetStep
- LogService.RemoveService
- LogService.RemoveStep
- LogService.UpdateService
- LogService.UpdateStep
- PipelineService.Add
- PipelineService.Compile
- PipelineService.Expand
- PipelineService.Get
- PipelineService.GetAll
- PipelineService.Remove
- PipelineService.Templates
- PipelineService.Update
- PipelineService.Validate
- RepoService.Add
- RepoService.Chown
- RepoService.Get
- RepoService.GetAll
- RepoService.Remove
- RepoService.Repair
- RepoService.Update
- SCMService.Sync
- SCMService.SyncAll
- ScheduleService.Add
- ScheduleService.Get
- ScheduleService.GetAll
- ScheduleService.Remove
- ScheduleService.Update
- SecretService.Add
- SecretService.Get
- SecretService.GetAll
- SecretService.Remove
- SecretService.Update
- StepService.Add
- StepService.Get
- StepService.GetAll
- StepService.Remove
- StepService.Update
- SvcService.Add
- SvcService.Get
- SvcService.GetAll
- SvcService.Remove
- SvcService.Update
- WorkerService.Add
- WorkerService.Get
- WorkerService.GetAll
- WorkerService.RefreshAuth
- WorkerService.Remove
- WorkerService.Update
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool is a helper routine that allocates a new boolean value to store v and returns a pointer to it.
func Bytes ¶
Bytes is a helper routine that allocates a new byte array value to store v and returns a pointer to it.
func CheckResponse ¶
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 ¶
Int is a helper routine that allocates a new integer value to store v and returns a pointer to it.
func 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
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 ¶
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
Strings is a helper routine that allocates a new string array value to store v and returns a pointer to it.
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) (*[]api.QueueBuild, *Response, error)
GetQueue returns the list of builds in pending and running status.
type AdminCleanService ¶ added in v0.20.0
type AdminCleanService service
AdminCleanService handles cleaning resources using the server methods of the Vela API.
func (*AdminCleanService) Clean ¶ added in v0.20.0
func (svc *AdminCleanService) Clean(e *api.Error, opt *CleanOptions) (*string, *Response, error)
Clean sets build resources older than a specified time to a proper canceled / finished state with the provided message.
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
func (svc *AdminDeploymentService) Update(d *api.Deployment) (*api.Deployment, *Response, error)
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.
type AdminOIDCService ¶ added in v0.25.0
type AdminOIDCService service
AdminOIDCService handles key rotation for OpenID Connect.
func (*AdminOIDCService) RotateOIDCKeys ¶ added in v0.25.0
func (svc *AdminOIDCService) RotateOIDCKeys() (*string, *Response, error)
RotateOIDCKeys sends a request to rotate the private keys used for creating ID tokens.
type AdminRepoService ¶ added in v0.7.0
type AdminRepoService service
AdminRepoService handles retrieving admin repos from the server methods of the Vela API.
type AdminSecretService ¶ added in v0.7.0
type AdminSecretService service
AdminSecretService handles retrieving admin secrets from the server methods of the Vela API.
type AdminService ¶ added in v0.7.0
type AdminService struct { Build *AdminBuildService Clean *AdminCleanService Deployment *AdminDeploymentService Hook *AdminHookService OIDC *AdminOIDCService Repo *AdminRepoService Secret *AdminSecretService Service *AdminSvcService Step *AdminStepService User *AdminUserService Worker *AdminWorkerService Settings *AdminSettingsService }
AdminService handles retrieving resources from the server methods of the Vela API.
type AdminSettingsService ¶ added in v0.24.0
type AdminSettingsService service
AdminSettingsService handles managing admin settings functionality from the server methods of the Vela API.
func (*AdminSettingsService) Get ¶ added in v0.24.0
func (svc *AdminSettingsService) Get() (*settings.Platform, *Response, error)
Get retrieves the active platform settings.
type AdminStepService ¶ added in v0.7.0
type AdminStepService service
AdminStepService handles retrieving admin steps from the server methods of the Vela API.
type AdminSvcService ¶ added in v0.7.0
type AdminSvcService service
AdminSvcService handles retrieving admin services from the server methods of the Vela API.
type AdminUserService ¶ added in v0.7.0
type AdminUserService service
AdminUserService handles retrieving admin users from the server methods of the Vela API.
type AdminWorkerService ¶ added in v0.19.0
type AdminWorkerService service
AdminWorkerService handles managing admin worker functionality from the server methods of the Vela API.
func (*AdminWorkerService) RegisterToken ¶ added in v0.19.0
RegisterToken generates a worker registration token 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) IsTokenAuthExpired ¶ added in v0.19.0
func (svc *AuthenticationService) IsTokenAuthExpired() (bool, error)
IsTokenAuthExpired returns whether or not the authentication token has expired.
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.
func (*AuthenticationService) ValidateOAuthToken ¶ added in v0.21.0
func (svc *AuthenticationService) ValidateOAuthToken() (*Response, error)
ValidateOAuthToken makes a request to validate user oauth tokens with the Vela server.
func (*AuthenticationService) ValidateToken ¶ added in v0.19.0
func (svc *AuthenticationService) ValidateToken() (*Response, error)
ValidateToken makes a request to validate tokens with the Vela server.
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 ¶
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 := api.Build{ Number: Int(1), Repo: &api.Repo{Org: String("github"), Name: String("octocat")}, 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("main"), 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(&req) if err != nil { fmt.Println(err) } fmt.Printf("Received response code %d, for build %+v", resp.StatusCode, build)
Output:
func (*BuildService) Approve ¶ added in v0.23.0
func (svc *BuildService) Approve(org, repo string, build int) (*Response, error)
Approve takes the build provided and approves it as an admin.
func (*BuildService) Cancel ¶ added in v0.7.0
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 ¶
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) (*[]api.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) GetBuildExecutable ¶ added in v0.21.0
func (svc *BuildService) GetBuildExecutable(org, repo string, build int) (*api.BuildExecutable, *Response, error)
GetBuildExecutable returns the executable for the provided build.
func (*BuildService) GetBuildToken ¶ added in v0.18.0
GetBuildToken returns an auth token for updating build resources.
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 token for a build from the server token, resp, err := c.Build.GetBuildToken("github", "octocat", 1) if err != nil { fmt.Println(err) } fmt.Printf("Received response code %d, for build token %+v", resp.StatusCode, token)
Output:
func (*BuildService) GetIDRequestToken ¶ added in v0.24.0
func (svc *BuildService) GetIDRequestToken(org, repo string, build int, opt *RequestTokenOptions) (*api.Token, *Response, error)
GetIDRequestToken returns an id request token for integrating with build OIDC.
func (*BuildService) GetIDToken ¶ added in v0.24.0
func (svc *BuildService) GetIDToken(org, repo string, build int, opt *IDTokenOptions) (*api.Token, *Response, error)
GetIDToken returns an ID token corresponding to the request token during a build.
func (*BuildService) GetLogs ¶
func (svc *BuildService) GetLogs(org, repo string, build int, opt *ListOptions) (*[]api.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, nil) if err != nil { fmt.Println(err) } fmt.Printf("Received response code %d, for build logs %+v", resp.StatusCode, logs)
Output:
func (*BuildService) Remove ¶
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 ¶
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 ¶
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 := api.Build{ Repo: &api.Repo{Org: String("github"), Name: String("octocat")}, Status: String("error"), Error: String(""), } // Update the step in the server build, resp, err := c.Build.Update(&req) if err != nil { fmt.Println(err) } fmt.Printf("Received response code %d, for build %+v", resp.StatusCode, build)
Output:
type CleanOptions ¶ added in v0.20.0
type CleanOptions struct {
Before int64 `url:"before,omitempty"`
}
CleanOptions specifies the optional parameters to the Clean.Clean method.
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 Dashboard *DashboardService Deployment *DeploymentService Hook *HookService Log *LogService Pipeline *PipelineService Repo *RepoService SCM *SCMService Schedule *ScheduleService Secret *SecretService Step *StepService Svc *SvcService User *UserService Worker *WorkerService Queue *QueueService // contains filtered or unexported fields }
Client is a client that manages communication with the Vela API.
func FromContext ¶
FromContext returns the Client associated with this context.
func NewClient ¶
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 ¶
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 ¶
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 ¶
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
SetTimeout sets the timeout for the http client.
type DashboardService ¶ added in v0.24.0
type DashboardService service
DashboardService handles retrieving Dashboards from the server methods of the Vela API.
func (*DashboardService) Add ¶ added in v0.24.0
Add constructs a Dashboard with the provided details.
func (*DashboardService) GetAllUser ¶ added in v0.24.0
func (svc *DashboardService) GetAllUser() (*[]api.DashCard, *Response, error)
GetAllUser returns a list of all dashboards for the authenticated user.
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
func (svc *DeploymentService) Add(org, repo string, d *api.Deployment) (*api.Deployment, *Response, error)
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 := api.Deployment{ Commit: String("48afb5bdc41ad69bf22588491333f7cf71135163"), Ref: String("refs/heads/main"), 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) (*api.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) (*[]api.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
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 := api.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("main"), 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
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) (*[]api.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
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
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 := api.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 IDTokenOptions ¶ added in v0.24.0
type IDTokenOptions struct {
Audience []string `url:"audience,omitempty"`
}
IDTokenOptions specifies the required parameters to the Build.GetIDToken method.
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 *api.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 := api.Log{ Data: Bytes([]byte("Hello World")), } // Create the log in the server resp, err := c.Log.AddService("github", "octocat", 1, 1, &req) if err != nil { fmt.Println(err) } fmt.Printf("Received response code %d for log", resp.StatusCode)
Output:
func (*LogService) AddStep ¶
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 := api.Log{ Data: Bytes([]byte("Hello World")), } // Create the log in the server resp, err := c.Log.AddStep("github", "octocat", 1, 1, &req) if err != nil { fmt.Println(err) } fmt.Printf("Received response code %d for log", resp.StatusCode)
Output:
func (*LogService) GetService ¶
func (svc *LogService) GetService(org, repo string, build, service int) (*api.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 ¶
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 ¶
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 *api.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 := api.Log{ Data: Bytes([]byte("Hello World")), } // Update the log in the server resp, err := c.Log.UpdateService("github", "octocat", 1, 1, &req) if err != nil { fmt.Println(err) } fmt.Printf("Received response code %d, for log", resp.StatusCode)
Output:
func (*LogService) UpdateStep ¶
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 := api.Log{ Data: Bytes([]byte("Hello World")), } // Update the log in the server resp, err := c.Log.UpdateStep("github", "octocat", 1, 1, &req) if err != nil { fmt.Println(err) } fmt.Printf("Received response code %d for log", resp.StatusCode)
Output:
type LoginOptions ¶ added in v0.7.0
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"` // Ruledata options Branch string `url:"branch,omitempty"` Comment string `url:"comment,omitempty"` Event string `url:"event,omitempty"` Repo string `url:"repo,omitempty"` Status string `url:"status,omitempty"` Tag string `url:"tag,omitempty"` Target string `url:"target,omitempty"` Path []string `url:"path,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 *api.Pipeline) (*api.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 := api.Pipeline{ Commit: String("48afb5bdc41ad69bf22588491333f7cf71135163"), Ref: String("refs/heads/main"), 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 default 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) // create ruledata options for pipeline call opts = &PipelineOptions{ Output: "yaml", // default Branch: "main", Comment: "comment", Event: "push", Repo: "octocat", Status: "success", Tag: "v1.0.0", Target: "production", Path: []string{"path/to/file", "README.md"}, } // 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) // create ruledata options for pipeline call opts = &PipelineOptions{ Output: "yaml", // default Branch: "main", Comment: "comment", Event: "push", Repo: "octocat", Status: "success", Tag: "v1.0.0", Target: "production", Path: []string{"path/to/file", "README.md"}, } // compile 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
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) (*[]api.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
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) // create ruledata options for pipeline call opts = &PipelineOptions{ Output: "yaml", // default Branch: "main", Comment: "comment", Event: "push", Repo: "octocat", Status: "success", Tag: "v1.0.0", Target: "production", Path: []string{"path/to/file", "README.md"}, } // compile 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 *api.Pipeline) (*api.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 := api.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 } // 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) // create ruledata options for pipeline call opts = &PipelineOptions{ Output: "yaml", // default Branch: "main", Comment: "comment", Event: "push", Repo: "octocat", Status: "success", Tag: "v1.0.0", Target: "production", Path: []string{"path/to/file", "README.md"}, } // compile 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 QueueService ¶ added in v0.21.0
type QueueService service
QueueService handles retrieving queue info from the server methods of the Vela API.
type RepoService ¶
type RepoService service
RepoService handles retrieving repos from the server methods of the Vela API.
func (*RepoService) Add ¶
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 := api.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("main"), Timeout: Int64(60), Visibility: String("public"), Private: Bool(false), Trusted: Bool(false), Active: Bool(true), AllowEvents: testEvents(), } // 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 ¶
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) (*[]api.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 ¶
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 := api.Repo{ AllowEvents: testEvents(), } // 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 RequestTokenOptions ¶ added in v0.24.0
type RequestTokenOptions struct { Image string `url:"image,omitempty"` Request string `url:"request,omitempty"` Commands bool `url:"commands,omitempty"` }
RequestTokenOptions specifies the required parameters to the Build.GetIDRequestToken method.
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 ScheduleService ¶ added in v0.20.0
type ScheduleService service
ScheduleService handles retrieving schedules from the server methods of the Vela API.
func (*ScheduleService) Add ¶ added in v0.20.0
func (svc *ScheduleService) Add(org, repo string, s *api.Schedule) (*api.Schedule, *Response, error)
Add constructs a schedule with the provided details.
Example ¶
// create a new vela client for interacting with server c, err := NewClient("http://localhost:8080", "", nil) if err != nil { fmt.Println(err) } // set new token in existing client c.Authentication.SetPersonalAccessTokenAuth("token") req := api.Schedule{ Active: Bool(true), Name: String("nightly"), Entry: String("0 0 * * *"), } // create the schedule in the server schedule, resp, err := c.Schedule.Add("github", "octocat", &req) if err != nil { fmt.Println(err) } fmt.Printf("received response code %d, for schedule %+v", resp.StatusCode, schedule)
Output:
func (*ScheduleService) Get ¶ added in v0.20.0
Get returns the provided schedule from the repo.
Example ¶
// create a new vela client for interacting with server c, err := NewClient("http://localhost:8080", "", nil) if err != nil { fmt.Println(err) } // set new token in existing client c.Authentication.SetPersonalAccessTokenAuth("token") // get a schedule from a repo in the server schedule, resp, err := c.Schedule.Get("github", "octocat", "nightly") if err != nil { fmt.Println(err) } fmt.Printf("received response code %d, for schedule %+v", resp.StatusCode, schedule)
Output:
func (*ScheduleService) GetAll ¶ added in v0.20.0
func (svc *ScheduleService) GetAll(org, repo string, opt *ListOptions) (*[]api.Schedule, *Response, error)
GetAll returns a list of all schedules from the repo.
Example ¶
// create a new vela client for interacting with server c, err := NewClient("http://localhost:8080", "", nil) if err != nil { fmt.Println(err) } // set new token in existing client c.Authentication.SetPersonalAccessTokenAuth("token") // get all the schedules from a repo in the server schedules, resp, err := c.Schedule.GetAll("github", "octocat", nil) if err != nil { fmt.Println(err) } fmt.Printf("received response code %d, for schedules %+v", resp.StatusCode, schedules)
Output:
func (*ScheduleService) Remove ¶ added in v0.20.0
func (svc *ScheduleService) Remove(org, repo, schedule string) (*string, *Response, error)
Remove deletes the provided schedule.
Example ¶
// create a new vela client for interacting with server c, err := NewClient("http://localhost:8080", "", nil) if err != nil { fmt.Println(err) } // set new token in existing client c.Authentication.SetPersonalAccessTokenAuth("token") // remove the schedule from the server schedule, resp, err := c.Schedule.Remove("github", "octocat", "nightly") if err != nil { fmt.Println(err) } fmt.Printf("received response code %d, for step %+v", resp.StatusCode, schedule)
Output:
func (*ScheduleService) Update ¶ added in v0.20.0
func (svc *ScheduleService) Update(org, repo string, s *api.Schedule) (*api.Schedule, *Response, error)
Update modifies a schedule with the provided details.
Example ¶
// create a new vela client for interacting with server c, err := NewClient("http://localhost:8080", "", nil) if err != nil { fmt.Println(err) } // set new token in existing client c.Authentication.SetPersonalAccessTokenAuth("token") req := api.Schedule{ Active: Bool(false), Name: String("nightly"), Entry: String("0 0 * * *"), } // update the schedule in the server schedule, resp, err := c.Schedule.Update("github", "octocat", &req) if err != nil { fmt.Println(err) } fmt.Printf("received response code %d, for schedule %+v", resp.StatusCode, schedule)
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 *api.Secret) (*api.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 := api.Secret{ Name: String("foo"), Value: String("bar"), Images: &[]string{"foo", "bar"}, AllowEvents: testEvents(), } // 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) (*api.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) (*[]api.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 *api.Secret) (*api.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 := api.Secret{ Name: String("foo"), Value: String("bar"), AllowEvents: testEvents(), } // 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 ¶
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 := api.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 ¶
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) (*[]api.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 ¶
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) Update ¶
func (svc *StepService) Update(org, repo string, build int, s *api.Step) (*api.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 := api.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 *api.Service) (*api.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 := api.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 ¶
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) (*[]api.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 ¶
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) Update ¶
func (svc *SvcService) Update(org, repo string, build int, s *api.Service) (*api.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 := api.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 UserService ¶ added in v0.25.0
type UserService service
UserService handles retrieving users from the server methods of the Vela API.
func (*UserService) GetCurrent ¶ added in v0.25.0
func (svc *UserService) GetCurrent() (*api.User, *Response, error)
GetCurrent returns the current user.
func (*UserService) UpdateCurrent ¶ added in v0.25.0
Update modifies the current user with the provided details.
type WorkerListOptions ¶ added in v0.23.0
type WorkerListOptions struct { Active string `url:"active,omitempty"` CheckedInBefore int64 `url:"checked_in_before,omitempty"` CheckedInAfter int64 `url:"checked_in_after,omitempty"` }
WorkerListOptions specifies the optional parameters to the Worker.GetAll method.
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 := api.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
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(opt *WorkerListOptions) (*[]api.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(nil) if err != nil { fmt.Println(err) } fmt.Printf("Received response code %d, for workers %+v", resp.StatusCode, workers)
Output:
func (*WorkerService) RefreshAuth ¶ added in v0.19.0
RefreshAuth exchanges a worker token for a new one.
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") worker := "worker_1" // Refresh a worker token with the server _, resp, err := c.Worker.RefreshAuth(worker) if err != nil { fmt.Println(err) } fmt.Printf("Received response code %d, for worker %+v", resp.StatusCode, worker)
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
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 := api.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: