Documentation ¶
Index ¶
- Constants
- Variables
- func AddWorkflows(workflows ...*WorkflowDefinition)
- func DefaultLogger(level LogLevel, message string)
- func GetAuthorizedContext(accessToken AccessToken) context.Context
- func NewBuildApiListArtifactsRequest(b *Build, workflow string, jobName string, groupName string, pageSize int) *client.ApiListArtifactsRequest
- func NewLeveledLogger(realLogger Logger) retryablehttp.LeveledLogger
- func SetDefaultLogLevel(level LogLevel)
- func SetLogger(logger Logger)
- func Workflows(workflows ...*WorkflowDefinition)
- type AWSAuth
- type AccessToken
- type Artifact
- type ArtifactPage
- type BasicAuth
- type Build
- func (b *Build) GetAPIClient() *client.APIClient
- func (b *Build) GetArtifactData(artifactID string) ([]byte, error)
- func (b *Build) GetAuthorizedContext() context.Context
- func (b *Build) GetBuildGraph() (*client.BuildGraph, error)
- func (b *Build) GetJob(jobID JobID) (*client.Job, error)
- func (b *Build) GetJobGraph(jobID JobID) (*client.JobGraph, error)
- func (b *Build) GetLogDescriptor(logDescriptorID string) (*client.LogDescriptor, error)
- func (b *Build) ListArtifacts(workflow string, jobName string, groupName string) (*ArtifactPage, error)
- func (b *Build) ListArtifactsN(workflow string, jobName string, groupName string, pageSize int) (*ArtifactPage, error)
- func (b *Build) MustGetArtifactData(artifactID string) []byte
- func (b *Build) MustGetBuildGraph() *client.BuildGraph
- func (b *Build) MustGetJob(jobID JobID) *client.Job
- func (b *Build) MustGetJobGraph(jobID JobID) *client.JobGraph
- func (b *Build) MustGetLogDescriptor(logDescriptorID string) *client.LogDescriptor
- func (b *Build) MustListArtifacts(workflow string, jobName string, groupName string) *ArtifactPage
- func (b *Build) MustListArtifactsN(workflow string, jobName string, groupName string, pageSize int) *ArtifactPage
- func (b *Build) MustReadLogData(logDescriptorID string, expand bool) io.ReadCloser
- func (b *Build) MustReadLogText(logDescriptorID string, expand bool) io.ReadCloser
- func (b *Build) ReadLogData(logDescriptorID string, expand bool) (io.ReadCloser, error)
- func (b *Build) ReadLogText(logDescriptorID string, expand bool) (io.ReadCloser, error)
- func (b *Build) Shutdown()
- type BuildID
- type Commit
- type ContextFactory
- type DockerConfig
- func (config *DockerConfig) AWSAuth(auth *AWSAuth) *DockerConfig
- func (config *DockerConfig) BasicAuth(auth *BasicAuth) *DockerConfig
- func (config *DockerConfig) GetData() client.DockerConfigDefinition
- func (config *DockerConfig) Image(image string) *DockerConfig
- func (config *DockerConfig) Pull(pullStrategy DockerPullStrategy) *DockerConfig
- func (config *DockerConfig) Shell(shell string) *DockerConfig
- type DockerPullStrategy
- type Env
- type EventFilter
- type EventManager
- type EventType
- type Job
- func (job *Job) Artifact(artifact *Artifact) *Job
- func (job *Job) Depends(dependencies ...string) *Job
- func (job *Job) DependsOnJobArtifacts(jobs ...*Job) *Job
- func (job *Job) DependsOnJobs(jobs ...*Job) *Job
- func (job *Job) Desc(description string) *Job
- func (job *Job) Docker(dockerConfig *DockerConfig) *Job
- func (job *Job) Env(env *Env) *Job
- func (job *Job) Fingerprint(commands ...string) *Job
- func (job *Job) GetData() client.JobDefinition
- func (job *Job) GetName() ResourceName
- func (job *Job) GetReference() JobReference
- func (job *Job) Name(name ResourceName) *Job
- func (job *Job) OnCancelled(fn JobCallback) *Job
- func (job *Job) OnCompletion(fn JobCallback) *Job
- func (job *Job) OnFailure(fn JobCallback) *Job
- func (job *Job) OnStatusChanged(fn JobCallback) *Job
- func (job *Job) OnSuccess(fn JobCallback) *Job
- func (job *Job) RunsOn(labels ...string) *Job
- func (job *Job) Service(service *Service) *Job
- func (job *Job) Step(step *Step) *Job
- func (job *Job) StepExecution(executionType StepExecutionType) *Job
- func (job *Job) Type(jobType JobType) *Job
- type JobCallback
- type JobCallbackManager
- type JobID
- type JobReference
- type JobStatusChangedEvent
- type JobType
- type LogLevel
- type Logger
- type Repo
- type ResourceID
- type ResourceName
- type SecretName
- type Service
- func (service *Service) AWSAuth(auth *AWSAuth) *Service
- func (service *Service) BasicAuth(auth *BasicAuth) *Service
- func (service *Service) Env(env *Env) *Service
- func (service *Service) GetData() client.ServiceDefinition
- func (service *Service) GetName() ResourceName
- func (service *Service) Image(image string) *Service
- func (service *Service) Name(name string) *Service
- type StatefulService
- type Status
- type Step
- func (step *Step) Commands(commands ...string) *Step
- func (step *Step) Depends(stepNames ...string) *Step
- func (step *Step) DependsOnSteps(steps ...*Step) *Step
- func (step *Step) Desc(description string) *Step
- func (step *Step) GetData() client.StepDefinition
- func (step *Step) GetName() ResourceName
- func (step *Step) Name(name string) *Step
- type StepExecutionType
- type Workflow
- func (w *Workflow) GetBuild() *Build
- func (w *Workflow) GetDefinition() WorkflowDefinition
- func (w *Workflow) GetName() ResourceName
- func (w *Workflow) GetOutputOrNil(outputName string) interface{}
- func (w *Workflow) IsFailed() bool
- func (w *Workflow) IsFinished() bool
- func (w *Workflow) IsWorkflowFinished(workflowName ResourceName) bool
- func (w *Workflow) Job(job *Job) *Workflow
- func (w *Workflow) MustSubmit(waitForCallbacks ...bool) []client.JobGraph
- func (w *Workflow) MustWaitForJob(jobs ...string) *JobStatusChangedEvent
- func (w *Workflow) MustWaitForOutput(workflowName ResourceName, outputName string) interface{}
- func (w *Workflow) OnJobCancelled(jobRef JobReference, callback JobCallback)
- func (w *Workflow) OnJobCompletion(jobRef JobReference, callback JobCallback)
- func (w *Workflow) OnJobFailure(jobRef JobReference, callback JobCallback)
- func (w *Workflow) OnJobStatusChanged(jobRef JobReference, callback JobCallback)
- func (w *Workflow) OnJobSuccess(jobRef JobReference, callback JobCallback)
- func (w *Workflow) SetOutput(outputName string, value interface{})
- func (w *Workflow) Submit(waitForCallbacks ...bool) ([]client.JobGraph, error)
- func (w *Workflow) WaitForJob(jobs ...string) (*JobStatusChangedEvent, error)
- func (w *Workflow) WaitForOutput(workflowName ResourceName, outputName string) (interface{}, error)
- func (w *Workflow) WaitForWorkflow(workflowName ResourceName) *Workflow
- type WorkflowDefinition
- func (w *WorkflowDefinition) Depends(workflowName ResourceName, options ...WorkflowDependsOption) *WorkflowDefinition
- func (w *WorkflowDefinition) GetName() ResourceName
- func (w *WorkflowDefinition) Handler(handler WorkflowHandler) *WorkflowDefinition
- func (w *WorkflowDefinition) Name(name ResourceName) *WorkflowDefinition
- func (w *WorkflowDefinition) SubmitFailureIsFatal(isFatal bool) *WorkflowDefinition
- type WorkflowDependsOption
- type WorkflowHandler
- type WorkflowStats
- type WorkflowStatsMap
Constants ¶
const ( LogLevelTrace = iota LogLevelDebug LogLevelInfo LogLevelWarn LogLevelError LogLevelFatal )
const ( // WorkflowWait is an option to not start the dependent workflow until the other workflow // has completely finished (including all jobs). This is the default behaviour. WorkflowWait = WorkflowDependsOption("wait") // WorkflowConcurrent is an option to allow the dependent workflow to run concurrently with the // other workflow (as opposed to WaitForOtherWorkflowToFinish) WorkflowConcurrent = WorkflowDependsOption("concurrent") // WorkflowTerminateOnFailure will terminate the current process if the dependency workflow fails, instead // of starting the dependent workflow. This is the default behaviour. WorkflowTerminateOnFailure = WorkflowDependsOption("terminate-on-failure") // WorkflowStartOnFailure will start the dependent workflow even if the dependency workflow fails, instead // of terminating the process (as opposed to TerminateIfOtherWorkflowFails) WorkflowStartOnFailure = WorkflowDependsOption("start-on-failure") )
const BuildDefinitionSyntaxVersion = "0.3"
BuildDefinitionSyntaxVersion is the version of the syntax used when submitting build definitions. This is equivalent to the 'version' field in YAML for statically-defined builds
const BuildResourceKind = "build"
const JobResourceKind = "job"
const ResourceNameRegexStr = "^[a-zA-Z0-9\\._-]{1,100}$"
Variables ¶
var ( Log Logger = DefaultLogger DefaultLogLevel LogLevel = LogLevelInfo )
Functions ¶
func AddWorkflows ¶
func AddWorkflows(workflows ...*WorkflowDefinition)
AddWorkflows registers extra workflows to the set of workflows for the current build. This can be called from an init function prior to calling Workflows() from the main function.
func DefaultLogger ¶
DefaultLogger is used by default if SetLogger() is not called, and outputs the log messages to stdout.
func GetAuthorizedContext ¶
func GetAuthorizedContext(accessToken AccessToken) context.Context
GetAuthorizedContext returns a context that can be passed to generated OpenAPI functions to authenticate to the server. The context includes an "apikey" value containing the supplied JWT access token for authentication.
func NewLeveledLogger ¶
func NewLeveledLogger(realLogger Logger) retryablehttp.LeveledLogger
NewLeveledLogger provides a retryablehttp.LeveledLogger interface on top of the basic Logger interface. This can be provided to retryableClient so that it can produce log messages at appropriate levels.
func SetDefaultLogLevel ¶
func SetDefaultLogLevel(level LogLevel)
func SetLogger ¶
func SetLogger(logger Logger)
SetLogger sets the logger function that will be called by the client code to log messages.
func Workflows ¶
func Workflows(workflows ...*WorkflowDefinition)
Workflows defines a set of workflows for the current build, and begins processing workflows to submit jobs to the build. Returns when the workflow handler functions for all required workflows have completed.
Types ¶
type AWSAuth ¶
type AWSAuth struct {
// contains filtered or unexported fields
}
func NewAWSAuth ¶
func NewAWSAuth() *AWSAuth
func (*AWSAuth) AccessKeyID ¶
func (*AWSAuth) AccessKeyIDFromSecret ¶
func (*AWSAuth) SecretAccessKeyFromSecret ¶
type AccessToken ¶
type AccessToken string
func ParseAccessToken ¶
func ParseAccessToken(str string) (AccessToken, error)
func (AccessToken) String ¶
func (t AccessToken) String() string
func (AccessToken) Validate ¶
func (t AccessToken) Validate() error
type Artifact ¶
type Artifact struct {
// contains filtered or unexported fields
}
func NewArtifact ¶
func NewArtifact() *Artifact
func (*Artifact) GetData ¶
func (a *Artifact) GetData() client.ArtifactDefinition
func (*Artifact) GetName ¶
func (a *Artifact) GetName() ResourceName
type ArtifactPage ¶
ArtifactPage is a 'page' of artifacts, and allows the next and previous pages (if any) to be fetched.
func ListArtifacts ¶
func ListArtifacts(b *Build, request *client.ApiListArtifactsRequest) (*ArtifactPage, error)
func NewArtifactPage ¶
func NewArtifactPage( build *Build, request *client.ApiListArtifactsRequest, artifactsResult *client.ArtifactsPaginatedResponse, ) *ArtifactPage
func (*ArtifactPage) HasNext ¶
func (p *ArtifactPage) HasNext() bool
func (*ArtifactPage) HasPrev ¶
func (p *ArtifactPage) HasPrev() bool
func (*ArtifactPage) Next ¶
func (p *ArtifactPage) Next() (*ArtifactPage, error)
func (*ArtifactPage) Prev ¶
func (p *ArtifactPage) Prev() (*ArtifactPage, error)
type BasicAuth ¶
type BasicAuth struct {
// contains filtered or unexported fields
}
func NewBasicAuth ¶
func NewBasicAuth() *BasicAuth
func (*BasicAuth) PasswordFromSecret ¶
func (*BasicAuth) UsernameFromSecret ¶
type Build ¶
type Build struct { ID BuildID Name ResourceName // name for this build (may actually be a number) OwnerName string Ref string DynamicJobID JobID DynamicJobName ResourceName Repo *Repo Commit *Commit // workflowsToRun is a static list of workflows that were requested to be run when the build was queued; // an empty list means run all workflows WorkflowsToRun []ResourceName // contains filtered or unexported fields }
func MustGetBuild ¶
func MustGetBuild() *Build
func WorkflowsWithEnv ¶
func WorkflowsWithEnv( envVars map[string]string, createNewWorkflowManager bool, workflows ...*WorkflowDefinition, ) (*Build, error)
WorkflowsWithEnv defines a set of workflows for the current build for use in testing, and begins processing workflows to submit jobs to the build. The build environment variable data is sourced from the specified string map rather than from actual environment variables, to facilitate passing test values. If createNewWorkflowManager is true then the global workflow manager is replaced with a new workflow manager, effectively removing all existing registered workflows in order to start a new test. Returns when the workflow handler functions for all required workflows have completed. If an error occurs while registering or starting workflows then the error is returned rather than the process being terminated.
func (*Build) GetAPIClient ¶
GetAPIClient returns the generated OpenAPI client, for directly calling API functions.
func (*Build) GetArtifactData ¶
GetArtifactData returns the binary data for an artifact.
func (*Build) GetAuthorizedContext ¶
GetAuthorizedContext returns a context that can be passed to generated OpenAPI functions to authenticate to the server. The context includes an "apikey" value containing a JWT access token for authentication.
func (*Build) GetBuildGraph ¶
func (b *Build) GetBuildGraph() (*client.BuildGraph, error)
GetBuildGraph reads the current build graph from the server. This will include all jobs and steps in the build, together with their current statuses.
func (*Build) GetJob ¶
GetJob reads information about the job with the specified Job ID from the server. This will include the current job status. but does not include information about the steps in the job; see GetJobGraph().
func (*Build) GetJobGraph ¶
GetJobGraph reads a job graph from the server for the specified job ID. This will include all steps in the job, together with the current job status.
func (*Build) GetLogDescriptor ¶
func (b *Build) GetLogDescriptor(logDescriptorID string) (*client.LogDescriptor, error)
GetLogDescriptor returns a log descriptor containing information/metadata about a log (e.g. the log for a job or for a step).
func (*Build) ListArtifacts ¶
func (b *Build) ListArtifacts(workflow string, jobName string, groupName string) (*ArtifactPage, error)
ListArtifacts reads information about selected artifacts from the current build. The first page of results will be returned in an ArtifactPage object. Call Next() on the returned object to get the next page of results, or Prev() to get the previous page.
func (*Build) ListArtifactsN ¶
func (b *Build) ListArtifactsN(workflow string, jobName string, groupName string, pageSize int) (*ArtifactPage, error)
ListArtifactsN reads information about selected artifacts from the current build. The first page of up to pageSize results will be returned in an ArtifactPage object. Call Next() on the returned object to get the next page of results, or Prev() to get the previous page.
func (*Build) MustGetArtifactData ¶ added in v1.0.0
MustGetArtifactData returns the binary data for an artifact. Terminates this program if a persistent error occurs.
func (*Build) MustGetBuildGraph ¶ added in v1.0.0
func (b *Build) MustGetBuildGraph() *client.BuildGraph
MustGetBuildGraph reads the current build graph from the server. This will include all jobs and steps in the build, together with their current statuses. Terminates this program if a persistent error occurs.
func (*Build) MustGetJob ¶ added in v1.0.0
MustGetJob reads information about the job with the specified Job ID from the server. This will include the current job status. but does not include information about the steps in the job; see GetJobGraph(). Terminates this program if a persistent error occurs.
func (*Build) MustGetJobGraph ¶
MustGetJobGraph reads a job graph from the server for the specified job ID. This will include all steps in the job, together with the current job status. Terminates this program if a persistent error occurs.
func (*Build) MustGetLogDescriptor ¶ added in v1.0.0
func (b *Build) MustGetLogDescriptor(logDescriptorID string) *client.LogDescriptor
MustGetLogDescriptor returns a log descriptor containing information/metadata about a log (e.g. the log for a job or for a step). Terminates this program if a persistent error occurs.
func (*Build) MustListArtifacts ¶ added in v1.0.0
func (b *Build) MustListArtifacts(workflow string, jobName string, groupName string) *ArtifactPage
MustListArtifacts reads information about selected artifacts from the current build. The first page of results will be returned in an ArtifactPage object. Call Next() on the returned object to get the next page of results, or Prev() to get the previous page. Terminates this program if a persistent error occurs.
func (*Build) MustListArtifactsN ¶ added in v1.0.0
func (b *Build) MustListArtifactsN(workflow string, jobName string, groupName string, pageSize int) *ArtifactPage
MustListArtifactsN reads information about selected artifacts from the current build. The first page of up to pageSize results will be returned in an ArtifactPage object. Call Next() on the returned object to get the next page of results, or Prev() to get the previous page. Terminates this program if a persistent error occurs.
func (*Build) MustReadLogData ¶ added in v1.0.0
func (b *Build) MustReadLogData(logDescriptorID string, expand bool) io.ReadCloser
MustReadLogData returns a reader for fetching data for a log (e.g. the log for a job or for a step) as a series of JSON log entries. If expand is true then nested logs will be expanded and returned. Terminates this program if a persistent error occurs.
func (*Build) MustReadLogText ¶ added in v1.0.0
func (b *Build) MustReadLogText(logDescriptorID string, expand bool) io.ReadCloser
MustReadLogText returns a reader for fetching the data for a log in plain text (e.g. the log for a job or for a step). If expand is true then nested logs will be expanded and returned. Terminates this program if a persistent error occurs.
func (*Build) ReadLogData ¶
ReadLogData returns a reader for fetching data for a log (e.g. the log for a job or for a step) as a series of JSON log entries. If expand is true then nested logs will be expanded and returned.
func (*Build) ReadLogText ¶
ReadLogText returns a reader for fetching the data for a log in plain text (e.g. the log for a job or for a step). If expand is true then nested logs will be expanded and returned.
type ContextFactory ¶
type DockerConfig ¶
type DockerConfig struct {
// contains filtered or unexported fields
}
func NewDocker ¶
func NewDocker() *DockerConfig
func (*DockerConfig) AWSAuth ¶
func (config *DockerConfig) AWSAuth(auth *AWSAuth) *DockerConfig
AWSAuth configures AWS auth credentials for AWS ECR.
func (*DockerConfig) BasicAuth ¶
func (config *DockerConfig) BasicAuth(auth *BasicAuth) *DockerConfig
BasicAuth configures basic auth credentials for the Docker registry.
func (*DockerConfig) GetData ¶
func (config *DockerConfig) GetData() client.DockerConfigDefinition
func (*DockerConfig) Image ¶
func (config *DockerConfig) Image(image string) *DockerConfig
func (*DockerConfig) Pull ¶
func (config *DockerConfig) Pull(pullStrategy DockerPullStrategy) *DockerConfig
func (*DockerConfig) Shell ¶
func (config *DockerConfig) Shell(shell string) *DockerConfig
type DockerPullStrategy ¶
type DockerPullStrategy string
const ( DockerPullDefault DockerPullStrategy = "default" DockerPullNever DockerPullStrategy = "never" DockerPullAlways DockerPullStrategy = "always" DockerPullIfNotExists DockerPullStrategy = "if-not-exists" )
func (DockerPullStrategy) String ¶
func (ps DockerPullStrategy) String() string
type Env ¶
type Env struct {
// contains filtered or unexported fields
}
func (*Env) ValueFromSecret ¶
type EventFilter ¶
EventFilter is a function that returns true if the supplied event meets the criteria being evaluated when waiting for a job-related event. An EventFilter function should execute very quickly as it will be called frequently.
type EventManager ¶
type EventManager struct { *StatefulService // contains filtered or unexported fields }
func NewEventManager ¶
func NewEventManager( apiClient *client.APIClient, authContextFactory ContextFactory, buildID BuildID, dynamicJobID JobID, logger Logger, ) *EventManager
NewEventManager creates an event manager that will poll for events for the specified build. The returned event manager will automatically start polling immediately, and will continue until Stop() is called.
func (*EventManager) GetStatsForWorkflow ¶
func (m *EventManager) GetStatsForWorkflow(workflowName ResourceName) WorkflowStats
GetStatsForWorkflow returns statistics derived from events seen for the specified workflow. If no jobs or events have been seen for the workflow yet then a zero WorkflowStats object will be returned.
func (*EventManager) WaitForJobStatusChangedEvent ¶
func (m *EventManager) WaitForJobStatusChangedEvent(ctx context.Context, filter EventFilter, jobs ...JobReference) (*client.Event, error)
WaitForJobStatusChangedEvent waits for a JobStatusChanged event for any of the specified jobs, that passes the supplied filter. Jobs with the specified workflows/names do not need to exist at the time of calling. If any suitable event already has been received then the function will immediately return the first suitable event. If no suitable event has already been received then the function will wait until a suitable event is received. If the caller wants to wait for events newer than some previously seen event, this should be done by supplying a suitable filter function that checks the SequenceNumber of candidate events.
type EventType ¶
type EventType string
const ( // EventTypeBuildStatusChanged is a type of event to notify subscribers that the status of a build has changed. // The event resource ID should be the ID of the build. The data should be a string of type WorkflowStatus. EventTypeBuildStatusChanged EventType = "BuildStatusChanged" // EventTypeJobStatusChanged is a type of event to notify subscribers that the status of a Job has changed. // The event resource ID should be the ID of the job. The data should be a string of type WorkflowStatus. EventTypeJobStatusChanged EventType = "JobStatusChanged" // EventTypeStepStatusChanged is a type of event to notify subscribers that the status of a Step has changed. // The event resource ID should be the ID of the step. The data should be a string of type WorkflowStatus. EventTypeStepStatusChanged EventType = "StepStatusChanged" )
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
func (*Job) DependsOnJobArtifacts ¶
func (*Job) DependsOnJobs ¶
func (*Job) Docker ¶
func (job *Job) Docker(dockerConfig *DockerConfig) *Job
func (*Job) Fingerprint ¶
func (*Job) GetData ¶
func (job *Job) GetData() client.JobDefinition
func (*Job) GetName ¶
func (job *Job) GetName() ResourceName
GetName returns the name of the job (not including any workflow name).
func (*Job) GetReference ¶
func (job *Job) GetReference() JobReference
GetReference returns a reference to the job, unique within the build. This will include any workflow the job is a part of.
func (*Job) Name ¶
func (job *Job) Name(name ResourceName) *Job
func (*Job) OnCancelled ¶
func (job *Job) OnCancelled(fn JobCallback) *Job
func (*Job) OnCompletion ¶
func (job *Job) OnCompletion(fn JobCallback) *Job
func (*Job) OnFailure ¶
func (job *Job) OnFailure(fn JobCallback) *Job
func (*Job) OnStatusChanged ¶
func (job *Job) OnStatusChanged(fn JobCallback) *Job
OnStatusChanged will call a callback function each time the status of the job changes.
func (*Job) OnSuccess ¶
func (job *Job) OnSuccess(fn JobCallback) *Job
func (*Job) StepExecution ¶
func (job *Job) StepExecution(executionType StepExecutionType) *Job
type JobCallback ¶
type JobCallback func(event *JobStatusChangedEvent)
JobCallback is a function that can be called when a job has transitioned to a particular state.
type JobCallbackManager ¶
type JobCallbackManager struct {
// contains filtered or unexported fields
}
JobCallbackManager tracks callbacks requested for when a job status changes.
func NewJobCallbackManager ¶
func NewJobCallbackManager(eventManager *EventManager) *JobCallbackManager
func (*JobCallbackManager) AddSubscription ¶
func (b *JobCallbackManager) AddSubscription(subscription *jobSubscription)
func (*JobCallbackManager) BlockAndProcessCallbacks ¶
func (b *JobCallbackManager) BlockAndProcessCallbacks()
BlockAndProcessCallbacks will block and call callbacks until either all job callbacks have been run, or the build is finished. If there are no outstanding callbacks then this function will return immediately.
type JobReference ¶
type JobReference struct { Workflow ResourceName JobName ResourceName }
JobReference refers to a job within a specific workflow. An empty string for the workflow means the default workflow.
func GetJobRefOrNilFromEvent ¶
func GetJobRefOrNilFromEvent(event *client.Event) *JobReference
GetJobRefOrNilFromEvent finds and returns a job reference from the specified event, or nil if the event has no job reference.
func NewJobReference ¶
func NewJobReference(workflow ResourceName, jobName ResourceName) JobReference
func StringToJobReference ¶
func StringToJobReference(ref string) JobReference
func (JobReference) Equals ¶
func (j JobReference) Equals(ref JobReference) bool
func (JobReference) String ¶
func (j JobReference) String() string
type JobStatusChangedEvent ¶
type JobStatusChangedEvent struct { // The ID of the Job whose status has changed. JobID JobID // The name of the workflow the job is part of, or empty string for the default workflow. Workflow ResourceName // The name of the Job whose status has changed. JobName ResourceName // The new status of the Job JobStatus Status // The ID of the build this Job is a part of BuildID BuildID // The event data as it was delivered to the SDK. RawEvent *client.Event }
func NewJobStatusChangedEvent ¶
func NewJobStatusChangedEvent(rawEvent *client.Event) (*JobStatusChangedEvent, error)
type Repo ¶
type Repo struct { Name ResourceName SSHURL string Link string }
type ResourceID ¶
type ResourceID string
func ParseResourceID ¶
func ParseResourceID(str string) (ResourceID, error)
func (ResourceID) Kind ¶
func (s ResourceID) Kind() string
func (ResourceID) String ¶
func (s ResourceID) String() string
func (ResourceID) Validate ¶
func (s ResourceID) Validate() error
type ResourceName ¶
type ResourceName string
ResourceName is a mutable, human-specified identifier of a resource. ResourceName must conform to length and character set requirements (see resourceNameMaxLength and resourceNameRegex). ResourceName is unique within a parent collection e.g. a repo's name must be unique within the legal entity it belongs to. Names should not be used as persistent references to a resource as they are mutable - use ResourceID instead.
func ParseResourceName ¶
func ParseResourceName(str string) (ResourceName, error)
func ParseResourceNames ¶
func ParseResourceNames(str string) ([]ResourceName, error)
ParseResourceNames parses a comma-separated list of resource names, validating each one.
func (ResourceName) String ¶
func (s ResourceName) String() string
func (ResourceName) Validate ¶
func (s ResourceName) Validate() error
type SecretName ¶
type SecretName string
SecretName is the name of a secret used to provide a value for environment variables or authentication.
func (SecretName) String ¶
func (s SecretName) String() string
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService() *Service
func (*Service) GetData ¶
func (service *Service) GetData() client.ServiceDefinition
func (*Service) GetName ¶
func (service *Service) GetName() ResourceName
type StatefulService ¶
type StatefulService struct {
// contains filtered or unexported fields
}
StatefulService provides standard service lifecycle routines (start/stop) functionality for long-lived services that run background threads.
func NewStatefulService ¶
func NewStatefulService(ctx context.Context, log Logger, serviceName string, fn func()) *StatefulService
func (*StatefulService) Ctx ¶
func (s *StatefulService) Ctx() context.Context
Ctx returns the service's context.
func (*StatefulService) Done ¶
func (s *StatefulService) Done() <-chan struct{}
Done can be used to wait for the service to stop.
func (*StatefulService) Start ¶
func (s *StatefulService) Start()
Start the service. Panics if called more than once.
func (*StatefulService) Stop ¶
func (s *StatefulService) Stop()
Stop the service. Blocks until the service has cleaned up all background threads and exited. This function is idempotent.
type Status ¶
type Status string
const ( // StatusQueued indicates the item has been created and is waiting to be processed. StatusQueued Status = "queued" // StatusSubmitted indicates the item has been handed to a worker. StatusSubmitted Status = "submitted" // StatusRunning indicates the item is being processed. StatusRunning Status = "running" // StatusFailed indicates the item has failed during processing. StatusFailed Status = "failed" // StatusSucceeded indicates the item has successfully finished being processed. StatusSucceeded Status = "succeeded" // StatusCanceled indicates the item was canceled before it was ever processed. StatusCanceled Status = "canceled" // StatusUnknown indicates the item is in an unknown state. StatusUnknown Status = "unknown" )
func (Status) HasFailed ¶
HasFailed returns true if the status indicates the workflow has either failed or been canceled.
func (Status) HasFinished ¶
HasFinished returns true if the status indicates the workflow has finished, either succeeded, failed, or canceled.
type Step ¶
type Step struct {
// contains filtered or unexported fields
}
func (*Step) DependsOnSteps ¶
func (*Step) GetData ¶
func (step *Step) GetData() client.StepDefinition
func (*Step) GetName ¶
func (step *Step) GetName() ResourceName
type StepExecutionType ¶
type StepExecutionType string
const ( StepExecutionSequential StepExecutionType = "sequential" StepExecutionParallel StepExecutionType = "parallel" )
func (StepExecutionType) String ¶
func (t StepExecutionType) String() string
type Workflow ¶
type Workflow struct {
// contains filtered or unexported fields
}
func (*Workflow) GetDefinition ¶
func (w *Workflow) GetDefinition() WorkflowDefinition
func (*Workflow) GetName ¶
func (w *Workflow) GetName() ResourceName
func (*Workflow) GetOutputOrNil ¶
GetOutputOrNil gets a previously set output value for the workflow, by name, If no output value from this workflow exists with the specified name then nil is immediately returned.
func (*Workflow) IsFailed ¶
IsFailed returns true if any job or jobs in the workflow have failed, even if the workflow has not yet finished.
func (*Workflow) IsFinished ¶
IsFinished returns true if the workflow function has returned and there are no unfinished jobs remaining in the workflow, i.e. if the workflow is completely finished.
func (*Workflow) IsWorkflowFinished ¶
func (w *Workflow) IsWorkflowFinished(workflowName ResourceName) bool
IsWorkflowFinished returns true iff the specified workflow has completely finished.
func (*Workflow) MustSubmit ¶
MustSubmit submits all newly created jobs to the server by calling Submit(), and returns the details for the newly created jobs. If an error is returned then the error is logged and this program exits with error code 1. If waitForCallbacks is true, or not specified, MustSubmit then waits until all outstanding callbacks have been called. If waitForCallbacks is specified as false, or if after submitting new jobs there are no outstanding callbacks, then MustSubmit returns immediately.
func (*Workflow) MustWaitForJob ¶ added in v1.0.0
func (w *Workflow) MustWaitForJob(jobs ...string) *JobStatusChangedEvent
MustWaitForJob waits until any of the specified jobs is finished, then returns the event that notified that the job is finished. This event includes the job's name, ID and final status. Jobs are specified by name, including the workflow, in the format 'workflow.jobname'. Any outstanding newly created jobs will be submitted to the server before waiting, via a call to MustSubmit(). Terminates this program if the build has finished without any event arriving that indicates one of the Jobs has finished.
func (*Workflow) MustWaitForOutput ¶
func (w *Workflow) MustWaitForOutput(workflowName ResourceName, outputName string) interface{}
MustWaitForOutput waits until the workflow with the specified name has an output with the specified output name available, then returns the output value. Terminates this program if the workflow has finished without providing the output.
func (*Workflow) OnJobCancelled ¶
func (w *Workflow) OnJobCancelled(jobRef JobReference, callback JobCallback)
func (*Workflow) OnJobCompletion ¶
func (w *Workflow) OnJobCompletion(jobRef JobReference, callback JobCallback)
func (*Workflow) OnJobFailure ¶
func (w *Workflow) OnJobFailure(jobRef JobReference, callback JobCallback)
func (*Workflow) OnJobStatusChanged ¶
func (w *Workflow) OnJobStatusChanged(jobRef JobReference, callback JobCallback)
OnJobStatusChanged will call a callback function each time the status of a job changes.
func (*Workflow) OnJobSuccess ¶
func (w *Workflow) OnJobSuccess(jobRef JobReference, callback JobCallback)
func (*Workflow) SetOutput ¶
SetOutput sets an output value for the workflow, that can be used by other workflows. name is a name for the output, unique within this workflow. Any existing value with this name will be overwritten. value is the data for the output. Any object supplied as data should ideally be immutable, and at the very least be thread-safe so that it can be read by other workflows from other goroutines.
func (*Workflow) Submit ¶
Submit submits all newly created jobs to the server and returns the details for the newly created jobs. If waitForCallbacks is true, or not specified, Submit then waits until all outstanding callbacks have been called. If waitForCallbacks is specified as false, or if after submitting new jobs there are no outstanding callbacks, then Submit returns immediately.
func (*Workflow) WaitForJob ¶
func (w *Workflow) WaitForJob(jobs ...string) (*JobStatusChangedEvent, error)
WaitForJob waits until any of the specified jobs is finished, then returns the event that notified that the job is finished. This event includes the job's name, ID and final status. Jobs are specified by name, including the workflow, in the format 'workflow.jobname'. Any outstanding newly created jobs will be submitted to the server before waiting, via a call to MustSubmit().
func (*Workflow) WaitForOutput ¶
func (w *Workflow) WaitForOutput(workflowName ResourceName, outputName string) (interface{}, error)
WaitForOutput waits until the workflow with the specified name has an output with the specified output name available, then returns the output value. Returns an error if the workflow has finished without providing the output.
func (*Workflow) WaitForWorkflow ¶
func (w *Workflow) WaitForWorkflow(workflowName ResourceName) *Workflow
WaitForWorkflow waits until the workflow with the specified name has completely finished. Returns the workflow that has now finished; this can be used to check for failure by calling IsFailed()
type WorkflowDefinition ¶
type WorkflowDefinition struct {
// contains filtered or unexported fields
}
func NewWorkflow ¶
func NewWorkflow() *WorkflowDefinition
func (*WorkflowDefinition) Depends ¶
func (w *WorkflowDefinition) Depends(workflowName ResourceName, options ...WorkflowDependsOption) *WorkflowDefinition
Depends indicates that the specified workflow depends on another workflow. The specified options determine the exact behaviour; the default is to wait until the specified workflow is fully finished before running this workflow, and to terminate this process if the specified workflow fails.
func (*WorkflowDefinition) GetName ¶
func (w *WorkflowDefinition) GetName() ResourceName
func (*WorkflowDefinition) Handler ¶
func (w *WorkflowDefinition) Handler(handler WorkflowHandler) *WorkflowDefinition
func (*WorkflowDefinition) Name ¶
func (w *WorkflowDefinition) Name(name ResourceName) *WorkflowDefinition
func (*WorkflowDefinition) SubmitFailureIsFatal ¶
func (w *WorkflowDefinition) SubmitFailureIsFatal(isFatal bool) *WorkflowDefinition
type WorkflowDependsOption ¶
type WorkflowDependsOption string
type WorkflowHandler ¶
WorkflowHandler is a function that can create the jobs required for a particular workflow.
type WorkflowStats ¶
WorkflowStats contains statistics about a workflow
type WorkflowStatsMap ¶
type WorkflowStatsMap map[ResourceName]*WorkflowStats
WorkflowStatsMap maps workflow name to statistics for the workflow
Source Files ¶
- access_token.go
- artifact.go
- artifact_list.go
- build.go
- commit.go
- docker_config.go
- env.go
- event_manager.go
- events.go
- job.go
- job_callback_manager.go
- library.go
- log.go
- repo.go
- resource_types.go
- secret.go
- service.go
- stateful_service.go
- status.go
- step.go
- workflow.go
- workflow_definition.go
- workflow_dependency.go
- workflow_manager.go