sdk

package module
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: Apache-2.0 Imports: 14 Imported by: 16

Documentation

Index

Constants

View Source
const (
	// ProjectRoleAssignmentKind represents the canonical ProjectRoleAssignment
	// kind string
	ProjectRoleAssignmentKind = "ProjectRoleAssignment"

	// ProjectRoleAssignmentListKind represents the canonical
	// ProjectRoleAssignmentList kind string
	ProjectRoleAssignmentListKind = "ProjectRoleAssignmentList"
)
View Source
const (
	// RoleAssignmentKind represents the canonical RoleAssignment kind string
	RoleAssignmentKind = "RoleAssignment"

	// RoleAssignmentListKind represents the canonical RoleAssignmentList kind
	// string
	RoleAssignmentListKind = "RoleAssignmentList"

	// PrincipalTypeServiceAccount represents a principal that is a
	// ServiceAccount.
	PrincipalTypeServiceAccount PrincipalType = "SERVICE_ACCOUNT"
	// PrincipalTypeUser represents a principal that is a User.
	PrincipalTypeUser PrincipalType = "USER"
)
View Source
const EventKind = "Event"

EventKind represents the canonical Event kind string

View Source
const JobKind = "Job"

JobKind represents the canonical Job kind string

View Source
const ProjectKind = "Project"

ProjectKind represents the canonical Project kind string

View Source
const ProjectRoleScopeGlobal = "*"

ProjectRoleScopeGlobal represents an unbounded project scope.

View Source
const RoleScopeGlobal = "*"

RoleScopeGlobal represents an unbounded scope.

View Source
const UserKind = "User"

UserKind represents the canonical User kind string

Variables

This section is empty.

Functions

func ValidateGitCloneURL

func ValidateGitCloneURL(url string) error

ValidateProjectID checks if a given git clone URL is valid by ensuring it begins with "http://", "https://", or "git@" and ends with ".git"

func ValidateProjectID

func ValidateProjectID(id string) error

ValidateProjectID checks if a given id is valid.

Types

type APIClient

type APIClient interface {
	Authn() AuthnClient
	Authz() SystemAuthzClient
	Core() CoreClient
	System() SystemClient
}

APIClient is the general interface for the Brigade API. It does little more than expose functions for obtaining more specialized clients for different areas of concern, like User management or Project management.

func NewAPIClient

func NewAPIClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) APIClient

NewAPIClient returns a Brigade client.

type AuthnClient

type AuthnClient interface {
	// WhoAmI returns a PrincipalReference for the currently authenticated
	// principal.
	WhoAmI(context.Context) (PrincipalReference, error)
	// ServiceAccounts returns a specialized client for ServiceAccount management.
	ServiceAccounts() ServiceAccountsClient
	// Sessions returns a specialized client for Session management.
	Sessions() SessionsClient
	// Users returns a specialized client for User management.
	Users() UsersClient
}

AuthnClient is the root of a tree of more specialized API clients for dealing with identity and authentication.

func NewAuthnClient

func NewAuthnClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) AuthnClient

NewAuthnClient returns an AuthnClient, which is the root of a tree of more specialized API clients for dealing with identity and authentication. It will initialize all clients in the tree so they are ready for immediate use.

type CancelManyEventsResult

type CancelManyEventsResult struct {
	// Count represents the number of Events canceled.
	Count int64 `json:"count"`
}

CancelManyEventsResult represents a summary of a mass Event cancellation operation.

type ContainerSpec

type ContainerSpec struct {
	// Image specifies the OCI image on which the container should be based.
	Image string `json:"image,omitempty"`
	// ImagePullPolicy specifies whether a container host already having the
	// specified OCI image should attempt to re-pull that image prior to launching
	// a new container.
	ImagePullPolicy ImagePullPolicy `json:"imagePullPolicy,omitempty"`
	// Command specifies the command to be executed by the OCI container. This
	// can be used to optionally override the default command specified by the OCI
	// image itself.
	Command []string `json:"command,omitempty"`
	// Arguments specifies arguments to the command executed by the OCI container.
	Arguments []string `json:"arguments,omitempty"`
	// Environment is a map of key/value pairs that specify environment variables
	// to be set within the OCI container.
	Environment map[string]string `json:"environment,omitempty"`
}

ContainerSpec represents the technical details of an OCI container.

type CoreClient

type CoreClient interface {
	// Events returns a specialized client for Event management.
	Events() EventsClient
	// Projects returns a specialized client for Project management.
	Projects() ProjectsClient
	// Substrate returns a specialized client for monitoring the state of the
	// substrate.
	Substrate() SubstrateClient
}

CoreClient is the root of a tree of more specialized API clients for dealing with Brigade's primary entities -- Projects, Events, and their constituent elements.

func NewCoreClient

func NewCoreClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) CoreClient

NewCoreClient returns an CoreClient, which is the root of a tree of more specialized API clients for dealing with Brigade's primary entities -- Projects, Events, and their constituent elements. It will initialize all clients in the tree so they are ready for immediate use.

type DeleteManyEventsResult

type DeleteManyEventsResult struct {
	// Count represents the number of Events deleted.
	Count int64 `json:"count"`
}

DeleteManyEventsResult represents a summary of a mass Event deletion operation.

type Event

type Event struct {
	// ObjectMeta contains Event metadata.
	meta.ObjectMeta `json:"metadata"`
	// ProjectID specifies the Project this Event is for. Often, this field will
	// be left blank, in which case the Event is matched against subscribed
	// Projects on the basis of the Source, Type, Qualifiers, and Labels fields,
	// then used as a template to create a discrete Event for each subscribed
	// Project.
	ProjectID string `json:"projectID,omitempty"`
	// Source specifies the source of the Event, e.g. what gateway created it.
	// Gateways should populate this field with a unique string that clearly
	// identifies themself as the source of the event. The ServiceAccount used by
	// each gateway can be authorized (by a admin) to only create events having a
	// specified value in the Source field, thereby eliminating the possibility of
	// gateways maliciously creating events that spoof events from another
	// gateway.
	Source string `json:"source,omitempty"`
	// SourceState encapsulates opaque, source-specific (e.g. gateway-specific)
	// state.
	SourceState *SourceState `json:"sourceState,omitempty"`
	// Type specifies the exact event that has occurred in the upstream system.
	// Values are opaque and source-specific.
	Type string `json:"type,omitempty"`
	// Qualifiers provide critical disambiguation of an Event's type. A Project is
	// considered subscribed to an Event IF AND ONLY IF (in addition to matching
	// the Event's Source and Type) it matches ALL of the Event's qualifiers
	// EXACTLY. To demonstrate the usefulness of this, consider any event from a
	// hypothetical GitHub gateway. If, by design, that gateway does not intend
	// for any Project to subscribe to ALL Events (i.e. regardless of which
	// repository they originated from), then that gateway can QUALIFY Events it
	// emits into Brigade's event bus with repo=<repository name>. Projects
	// wishing to subscribe to Events from the GitHub gateway MUST include that
	// Qualifier in their EventSubscription. Note that the Qualifiers field's
	// "MUST match" subscription semantics differ from the Labels field's "MAY
	// match" subscription semantics.
	Qualifiers map[string]string `json:"qualifiers,omitempty"`
	// Labels convey supplementary Event details that Projects may OPTIONALLY use
	// to narrow EventSubscription criteria. A Project is considered subscribed to
	// an Event if (in addition to matching the Event's Source, Type, and
	// Qualifiers) the Event has ALL labels expressed in the Project's
	// EventSubscription. If the Event has ADDITIONAL labels, not mentioned by the
	// EventSubscription, these do not preclude a match. To demonstrate the
	// usefulness of this, consider any event from a hypothetical Slack gateway.
	// If, by design, that gateway intends for Projects to select between
	// subscribing to ALL Events or ONLY events originating from a specific
	// channel, then that gateway can LABEL Events it emits into Brigade's event
	// bus with channel=<channel name>. Projects wishing to subscribe to ALL
	// Events from the Slack gateway MAY omit that Label from their
	// EventSubscription, while Projects wishing to subscribe to only Events
	// originating from a specific channel MAY include that Label in their
	// EventSubscription. Note that the Labels field's "MAY match" subscription
	// semantics differ from the Qualifiers field's "MUST match" subscription
	// semantics.
	Labels map[string]string `json:"labels,omitempty"`
	// ShortTitle is an optional, succinct title for the Event, ideal for use in
	// lists or in scenarios where UI real estate is constrained.
	ShortTitle string `json:"shortTitle,omitempty"`
	// LongTitle is an optional, detailed title for the Event.
	LongTitle string `json:"longTitle,omitempty"`
	// Git contains git-specific Event details. These can be used to override
	// similar details defined at the Project level. This is useful for scenarios
	// wherein an Event may need to convey an alternative source, branch, etc.
	Git *GitDetails `json:"git,omitempty"`
	// Payload optionally contains Event details provided by the upstream system
	// that was the original source of the event. Payloads MUST NOT contain
	// sensitive information. Since Projects SUBSCRIBE to Events, the potential
	// exists for any Project to express an interest in any or all Events. This
	// being the case, sensitive details must never be present in payloads. The
	// common workaround work this constraint (which is also a sensible practice
	// to begin with) is that event payloads may contain REFERENCES to sensitive
	// details that are useful only to properly configured Workers.
	Payload string `json:"payload,omitempty"`
	// Summary is a counterpart to Payload. If Payload is free-form Worker input,
	// then Summary is free-form Worker output. It can optionally be set by a
	// Worker to provide a summary of the work completed by the Worker and its
	// Jobs.
	Summary string `json:"summary,omitempty" bson:"summary,omitempty"`
	// Worker contains details of the Worker assigned to handle the Event.
	Worker *Worker `json:"worker,omitempty"`
}

Event represents an occurrence in some upstream system. Once accepted into the system, Brigade amends each Event with a plan for handling it in the form of a Worker. An Event's status is, implicitly, the status of its Worker.

func (Event) MarshalJSON

func (e Event) MarshalJSON() ([]byte, error)

MarshalJSON amends Event instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type EventCancelManyOptions

type EventCancelManyOptions struct{}

EventCancelManyOptions represents useful, optional settings for canceling many Events. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type EventCancelOptions

type EventCancelOptions struct{}

EventCancelOptions represents useful, optional settings for canceling an Event. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type EventCloneOptions

type EventCloneOptions struct{}

EventCloneOptions represents useful, optional settings for cloning an existing Event. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type EventCreateOptions

type EventCreateOptions struct{}

EventCreateOptions represents useful, optional settings for creating a new Event. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type EventDeleteManyOptions

type EventDeleteManyOptions struct{}

EventDeleteManyOptions represents useful, optional settings for deleting many Events. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type EventDeleteOptions

type EventDeleteOptions struct{}

EventDeleteOptions represents useful, optional settings for deleting an Event. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type EventGetOptions

type EventGetOptions struct{}

EventGetOptions represents useful, optional criteria for retrieval of an Event. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type EventList

type EventList struct {
	// ListMeta contains list metadata.
	meta.ListMeta `json:"metadata"`
	// Items is a slice of Events.
	Items []Event `json:"items,omitempty"`
}

EventList is an ordered and pageable list of Events.

func (EventList) MarshalJSON

func (e EventList) MarshalJSON() ([]byte, error)

MarshalJSON amends EventList instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type EventRetryOptions

type EventRetryOptions struct{}

EventRetryOptions represents useful, optional settings for retrying an existing Event. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type EventSourceStateUpdateOptions

type EventSourceStateUpdateOptions struct{}

EventSourceStateUpdateOptions represents useful, optional settings for updating an Event's SourceState. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type EventSubscription

type EventSubscription struct {
	// Source specifies the origin of an Event (e.g. a gateway). This is a
	// required field.
	Source string `json:"source,omitempty"`
	// Types enumerates specific Events of interest from the specified Source.
	// This is useful in narrowing a subscription when a Source also emits many
	// Event types that are NOT of interest. This is a required field. The value
	// "*" may be utilized to denote that ALL events originating from the
	// specified Source are of interest.
	Types []string `json:"types,omitempty"`
	// Qualifiers specifies an EXACT set of key/value pairs with which an Event
	// MUST also be qualified for a Project to be considered subscribed. To
	// demonstrate the usefulness of this, consider any event from a hypothetical
	// GitHub gateway. If, by design, that gateway does not intend for any Project
	// to subscribe to ALL Events (i.e. regardless of which repository they
	// originated from), then that gateway can QUALIFY Events it emits into
	// Brigade's event bus with repo=<repository name>. Projects wishing to
	// subscribe to Events from the GitHub gateway MUST include that Qualifier in
	// their EventSubscription. Note that the Qualifiers field's "MUST match"
	// subscription semantics differ from the Labels field's "MAY match"
	// subscription semantics.
	Qualifiers map[string]string `json:"qualifiers,omitempty"`
	// Labels optionally specifies filter criteria as key/value pairs with which
	// an Event MUST also be labeled for a Project to be considered subscribed. If
	// the Event has ADDITIONAL labels, not mentioned by this EventSubscription,
	// these do not preclude a match. To demonstrate the usefulness of this,
	// consider any event from a hypothetical Slack gateway. If, by design, that
	// gateway intends for Projects to select between subscribing to ALL Events or
	// ONLY events originating from a specific channel, then that gateway can
	// LABEL Events it emits into Brigade's event bus with channel=<channel name>.
	// Projects wishing to subscribe to ALL Events from the Slack gateway MAY omit
	// that Label from their EventSubscription, while Projects wishing to
	// subscribe to only Events originating from a specific channel MAY include
	// that Label in their EventSubscription. Note that the Labels field's "MAY
	// match" subscription semantics differ from the Qualifiers field's "MUST
	// match" subscription semantics.
	Labels map[string]string `json:"labels,omitempty"`
}

EventSubscription defines a set of Events of interest. ProjectSpecs utilize these in defining the Events that should trigger the execution of a new Worker. An Event matches a subscription if it meets ALL of the specified criteria.

type EventSummary

type EventSummary struct {
	// Text is the Event summary as (optionally) provided by a Worker.
	Text string `json:"text,omitempty"`
}

EventSummary encapsulates an opaque, Worker-specific summary of an Event.

func (EventSummary) MarshalJSON

func (e EventSummary) MarshalJSON() ([]byte, error)

MarshalJSON amends EventSummary instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type EventSummaryUpdateOptions

type EventSummaryUpdateOptions struct{}

EventSummaryUpdateOptions represents useful, optional settings for updating an Event's summary. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type EventsClient

type EventsClient interface {
	// Create creates one new Event if the Event provided references a Project by
	// ID. Otherwise, the Event provided is treated as a template and zero or more
	// discrete Events may be created-- one for each subscribed Project. An
	// EventList is returned containing all newly created Events.
	Create(context.Context, Event, *EventCreateOptions) (EventList, error)
	// List returns an EventList, with its Items (Events) ordered by age, newest
	// first. Criteria for which Events should be retrieved can be specified using
	// the EventsSelector parameter.
	List(context.Context, *EventsSelector, *meta.ListOptions) (EventList, error)
	// Get retrieves a single Event specified by its identifier.
	Get(context.Context, string, *EventGetOptions) (Event, error)
	// Clones a pre-existing Event, removing the original's metadata and Worker
	// config in the process.  A new Event is created using the rest of the
	// details preserved from the original.
	Clone(context.Context, string, *EventCloneOptions) (Event, error)
	// UpdateSourceState updates source-specific (e.g. gateway-specific) Event
	// state.
	UpdateSourceState(
		context.Context,
		string,
		SourceState,
		*EventSourceStateUpdateOptions,
	) error
	// UpdateSummary updates the Worker-specific Event summary.
	UpdateSummary(
		context.Context,
		string,
		EventSummary,
		*EventSummaryUpdateOptions,
	) error
	// Cancel cancels a single Event specified by its identifier.
	Cancel(context.Context, string, *EventCancelOptions) error
	// CancelMany cancels multiple Events specified by the EventListOptions
	// parameter.
	CancelMany(
		context.Context,
		EventsSelector,
		*EventCancelManyOptions,
	) (CancelManyEventsResult, error)
	// Delete deletes a single Event specified by its identifier.
	Delete(context.Context, string, *EventDeleteOptions) error
	// DeleteMany deletes multiple Events specified by the EventListOptions
	// parameter.
	DeleteMany(
		context.Context,
		EventsSelector,
		*EventDeleteManyOptions,
	) (DeleteManyEventsResult, error)
	// Retry copies an Event, including Worker configuration and Jobs, and
	// creates a new Event from this information. Where possible, job results
	// are inherited and the job not re-scheduled, for example when a job has
	// succeeded and does not make use of a shared workspace.
	Retry(context.Context, string, *EventRetryOptions) (Event, error)

	// Workers returns a specialized client for Worker management.
	Workers() WorkersClient

	// Logs returns a specialized client for Log management.
	Logs() LogsClient
}

EventsClient is the specialized client for managing Events with the Brigade API.

func NewEventsClient

func NewEventsClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) EventsClient

NewEventsClient returns a specialized client for managing Events.

type EventsSelector

type EventsSelector struct {
	// ProjectID specifies that only Events belonging to the indicated Project
	// should be selected.
	ProjectID string
	// Source specifies that only Events from the indicated source should be
	// selected.
	Source string
	// SourceState specifies that only Events having all of the indicated source
	// state key/value pairs should be selected.
	SourceState map[string]string
	// Type specifies that only Events having the indicated type should be
	// selected.
	Type string
	// WorkerPhases specifies that only Events with their Workers in any of the
	// indicated phases should be selected.
	WorkerPhases []WorkerPhase
	// Qualifiers specifies that only Events qualified with these key/value pairs
	// should be selected.
	Qualifiers map[string]string
	// Labels specifies that only Events labeled with these key/value pairs should
	// be selected.
	Labels map[string]string
}

EventsSelector represents useful filter criteria when selecting multiple Events for API group operations like list, cancel, or delete.

type GitConfig

type GitConfig struct {
	// CloneURL specifies the location from where a source code repository may
	// be cloned.
	CloneURL string `json:"cloneURL,omitempty"`
	// Commit specifies a revision (by SHA) to be checked out. If non-empty, this
	// field takes precedence over any value in the Ref field.
	Commit string `json:"commit,omitempty"`
	// Ref is a symbolic reference to a revision to be checked out. If non-empty,
	// the value of the Commit field supercedes any value in this field. Example
	// uses of this field include referencing a branch (refs/heads/<branch name>)
	// or a tag (refs/tags/<tag name>). If left blank, this field is interpreted
	// as a reference to the repository's default branch.
	Ref string `json:"ref,omitempty"`
	// InitSubmodules indicates whether to clone the repository's submodules.
	InitSubmodules bool `json:"initSubmodules"`
}

GitConfig represents git-specific Worker details.

type GitDetails

type GitDetails struct {
	// CloneURL specifies the location from where a source code repository may
	// be cloned.
	CloneURL string `json:"cloneURL,omitempty"`
	// Commit specifies a revision (by SHA) to be checked out. If non-empty, this
	// field takes precedence over any value in the Ref field.
	Commit string `json:"commit,omitempty"`
	// Ref is a symbolic reference to a revision to be checked out. If non-empty,
	// the value of the Commit field supercedes any value in this field. Example
	// uses of this field include referencing a branch (refs/heads/<branch name>)
	// or a tag (refs/tags/<tag name>). If left blank, this field is interpreted
	// as a reference to the repository's default branch.
	Ref string `json:"ref,omitempty"`
}

GitDetails represents git-specific Event details. These may override Project-level GitConfig.

type ImagePullPolicy

type ImagePullPolicy string

ImagePullPolicy represents a policy for whether container hosts already having a certain OCI image should attempt to re-pull that image prior to launching a new container based on that image.

const (
	// ImagePullPolicyIfNotPresent represents a policy wherein container hosts
	// only attempt to pull an OCI image if that image does not already exist on
	// the host.
	ImagePullPolicyIfNotPresent ImagePullPolicy = "IfNotPresent"
	// ImagePullPolicyAlways represents a policy wherein container hosts will
	// always attempt to re-pull an OCI image before launching a container based
	// on that image.
	ImagePullPolicyAlways ImagePullPolicy = "Always"
)

type Job

type Job struct {
	// Name is the Job's name. It should be unique among a given Worker's Jobs.
	Name string `json:"name"`
	// Created indicates the time at which a Job was created. This is recorded by
	// the system. Clients must leave the value of this field set to nil when
	// using the API to create a Job.
	Created *time.Time `json:"created,omitempty"`
	// Spec is the technical blueprint for the Job.
	Spec JobSpec `json:"spec"`
	// Status contains details of the Job's current state.
	Status *JobStatus `json:"status,omitempty"`
}

Job represents a component spawned by a Worker to complete a single task in the course of handling an Event.

func (Job) MarshalJSON

func (j Job) MarshalJSON() ([]byte, error)

MarshalJSON amends Job instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type JobCleanupOptions

type JobCleanupOptions struct{}

JobCleanupOptions represents useful, optional settings for cleaning up after a Job. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type JobContainerSpec

type JobContainerSpec struct {
	// ContainerSpec encapsulates generic specifications for an OCI container.
	ContainerSpec `json:",inline"`
	// WorkingDirectory specifies the OCI container's working directory.
	WorkingDirectory string `json:"workingDirectory,omitempty"`
	// WorkspaceMountPath specifies the path in the OCI container's file system
	// where, if applicable, the Worker's shared workspace should be mounted. If
	// left blank, the Job implicitly does not use the Worker's shared workspace.
	WorkspaceMountPath string `json:"workspaceMountPath,omitempty"`
	// SourceMountPath specifies the path in the OCI container's file system
	// where, if applicable, source code retrieved from a VCS repository should be
	// mounted. If left blank, the Job implicitly does not use source code
	// retrieved from a VCS repository.
	SourceMountPath string `json:"sourceMountPath,omitempty"`
	// Privileged indicates whether the OCI container should operate in a
	// "privileged" (relaxed permissions) mode. This is commonly used to effect
	// "Docker-in-Docker" ("DinD") scenarios wherein one of a Job's OCI containers
	// must run its own Docker daemon. Note this field REQUESTS privileged status
	// for the container, but that may be disallowed by Project-level
	// configuration.
	Privileged bool `json:"privileged"`
}

JobContainerSpec amends the ContainerSpec type with additional Job-specific fields.

type JobCreateOptions

type JobCreateOptions struct{}

JobCreateOptions represents useful, optional settings for creating a new Job. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type JobHost

type JobHost struct {
	// OS specifies which "family" of operating system is required on a substrate
	// node to host a Job. Valid values are "linux" and "windows". When empty,
	// Brigade assumes "linux".
	OS OSFamily `json:"os,omitempty"`
	// NodeSelector specifies labels that must be present on the substrate node to
	// host a Job. This provides an opaque mechanism for communicating Job needs
	// such as specific hardware like an SSD or GPU.
	NodeSelector map[string]string `json:"nodeSelector,omitempty"`
}

JobHost represents criteria for selecting a suitable host (substrate node) for a Job.

type JobPhase

type JobPhase string

JobPhase represents where a Job is within its lifecycle.

const (
	// JobPhaseAborted represents the state wherein a Job was forcefully
	// stopped during execution.
	JobPhaseAborted JobPhase = "ABORTED"
	// JobPhaseCanceled represents the state wherein a pending Job was
	// canceled prior to execution.
	JobPhaseCanceled JobPhase = "CANCELED"
	// JobPhaseFailed represents the state wherein a Job has run to
	// completion but experienced errors.
	JobPhaseFailed JobPhase = "FAILED"
	// JobPhasePending represents the state wherein a Job is awaiting
	// execution.
	JobPhasePending JobPhase = "PENDING"
	// JobPhaseRunning represents the state wherein a Job is currently
	// being executed.
	JobPhaseRunning JobPhase = "RUNNING"
	// JobPhaseSchedulingFailed represents the state wherein a job was not
	// scheduled due to some unexpected and unrecoverable error encountered by the
	// scheduler.
	JobPhaseSchedulingFailed JobPhase = "SCHEDULING_FAILED"
	// JobPhaseStarting represents the state wherein a Job is starting on the
	// substrate but isn't running yet.
	JobPhaseStarting JobPhase = "STARTING"
	// JobPhaseSucceeded represents the state where a Job has run to
	// completion without error.
	JobPhaseSucceeded JobPhase = "SUCCEEDED"
	// JobPhaseTimedOut represents the state wherein a Job has has not completed
	// within a designated timeframe.
	JobPhaseTimedOut JobPhase = "TIMED_OUT"
	// JobPhaseUnknown represents the state wherein a Job's state is unknown. Note
	// that this is possible if and only if the underlying Job execution substrate
	// (Kubernetes), for some unanticipated reason, does not know the Job's
	// (Pod's) state.
	JobPhaseUnknown JobPhase = "UNKNOWN"
)

func (JobPhase) IsTerminal

func (j JobPhase) IsTerminal() bool

IsTerminal returns a bool indicating whether the JobPhase is terminal.

type JobPolicies

type JobPolicies struct {
	// AllowPrivileged specifies whether the Worker is permitted to launch Jobs
	// that utilize privileged containers.
	AllowPrivileged bool `json:"allowPrivileged"`
}

JobPolicies represents policies for any Jobs spawned by a Worker.

type JobSpec

type JobSpec struct {
	// PrimaryContainer specifies the details of an OCI container that forms the
	// cornerstone of the Job. Job success or failure is tied to completion and
	// exit code of this container.
	PrimaryContainer JobContainerSpec `json:"primaryContainer"`
	// SidecarContainers specifies the details of supplemental, "sidecar"
	// containers. Their completion and exit code do not directly impact Job
	// status. Brigade does not understand dependencies between a Job's multiple
	// containers and cannot enforce any specific startup or shutdown order. When
	// such dependencies exist (for instance, a primary container than cannot
	// proceed with a suite of tests until a database is launched and READY in a
	// sidecar container), then logic within those containers must account for
	// these constraints.
	SidecarContainers map[string]JobContainerSpec `json:"sidecarContainers,omitempty"` // nolint: lll
	// TimeoutDuration specifies the time duration that must elapse before a
	// running Job should be considered to have timed out. This duration string
	// is a sequence of decimal numbers, each with optional fraction and a unit
	// suffix, such as "300ms", "3.14s" or "2h45m".
	// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
	TimeoutDuration string `json:"timeoutDuration,omitempty"`
	// Host specifies criteria for selecting a suitable host (substrate node) for
	// the Job. This is useful in cases where a Job requires a specific,
	// non-default operating system (i.e. Windows) or specific hardware (e.g. a
	// GPU.)
	Host *JobHost `json:"host,omitempty"`
	// Fallible specifies whether the job is permitted to fail WITHOUT causing the
	// worker process to fail. The API server does not use this field directly,
	// but it is information that may be valuable to gateways that report job
	// success/failure upstream to original event sources.
	//
	// Note that omitempty keeps this compatible with older API servers (whose
	// schema-based validation will reject the unknown field) as long as it's not
	// set to true.
	Fallible bool `json:"fallible,omitempty"`
}

JobSpec is the technical blueprint for a Job.

type JobStartOptions

type JobStartOptions struct{}

JobStartOptions represents useful, optional settings for starting a Job. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type JobStatus

type JobStatus struct {
	// Started indicates the time the Job began execution.
	Started *time.Time `json:"started,omitempty"`
	// Ended indicates the time the Job concluded execution. It will be nil
	// for a Job that is not done executing.
	Ended *time.Time `json:"ended,omitempty"`
	// Phase indicates where the Job is in its lifecycle.
	Phase JobPhase `json:"phase,omitempty"`
}

JobStatus represents the status of a Job.

func (JobStatus) MarshalJSON

func (j JobStatus) MarshalJSON() ([]byte, error)

MarshalJSON amends JobStatus instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type JobStatusGetOptions

type JobStatusGetOptions struct{}

JobStatusGetOptions represents useful, optional criteria for retrieving a Job's status. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type JobStatusUpdateOptions

type JobStatusUpdateOptions struct{}

JobStatusUpdateOptions represents useful, optional settings for updating a Job's status. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type JobStatusWatchOptions

type JobStatusWatchOptions struct{}

JobStatusWatchOptions represents useful, optional criteria for establishing a stream of a Job's Status. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type JobTimeoutOptions

type JobTimeoutOptions struct{}

JobTimeoutOptions represents useful, optional settings for timing out a Job. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type JobsClient

type JobsClient interface {
	// Create, given an Event identifier and Job, creates a new pending Job
	// and schedules it for execution.
	Create(
		ctx context.Context,
		eventID string,
		job Job,
		opts *JobCreateOptions,
	) error
	// Start initiates execution of a pending Job.
	Start(
		ctx context.Context,
		eventID string,
		jobName string,
		opts *JobStartOptions,
	) error
	// GetStatus, given an Event identifier and Job name, returns the Job's
	// status.
	GetStatus(
		ctx context.Context,
		eventID string,
		jobName string,
		opts *JobStatusGetOptions,
	) (JobStatus, error)
	// WatchStatus, given an Event identifier and Job name, returns a channel
	// over which the Job's status is streamed. The channel receives a new
	// JobStatus every time there is any change in that status.
	WatchStatus(
		ctx context.Context,
		eventID string,
		jobName string,
		opts *JobStatusWatchOptions,
	) (<-chan JobStatus, <-chan error, error)
	// UpdateStatus, given an Event identifier and Job name, updates the status
	// of that Job.
	UpdateStatus(
		ctx context.Context,
		eventID string,
		jobName string,
		status JobStatus,
		opts *JobStatusUpdateOptions,
	) error
	Cleanup(
		ctx context.Context,
		eventID,
		jobName string,
		opts *JobCleanupOptions,
	) error
	// Timeout, given an Event identifier and Job name, executes timeout logic
	// for a Job that has exceeded its timeout limit.
	Timeout(
		ctx context.Context,
		eventID,
		jobName string,
		opts *JobTimeoutOptions,
	) error
}

JobsClient is the specialized client for managing Event Jobs with the Brigade API.

func NewJobsClient

func NewJobsClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) JobsClient

NewJobsClient returns a specialized client for managing Event Jobs.

type KubernetesConfig

type KubernetesConfig struct {
	// ImagePullSecrets enumerates any image pull secrets that Kubernetes may use
	// when pulling the OCI image on which a Worker's or Job's container is based.
	// This field only needs to be utilized in the case of private, custom Worker
	// or Job images. The image pull secrets in question must be created
	// out-of-band by a sufficiently authorized user of the Kubernetes cluster.
	ImagePullSecrets []string `json:"imagePullSecrets,omitempty"`
}

KubernetesConfig represents Kubernetes-specific Worker or Job configuration.

type KubernetesDetails

type KubernetesDetails struct {
	// Namespace is the dedicated Kubernetes namespace for the Project. This is
	// NOT specified by clients when creating a new Project. The namespace is
	// created by / assigned by the system. This detail is a necessity to prevent
	// clients from naming existing namespaces in an attempt to hijack them.
	Namespace string `json:"namespace,omitempty"`
}

KubernetesDetails represents Kubernetes-specific configuration.

type LogEntry

type LogEntry struct {
	// Time is the time the line was written.
	Time *time.Time `json:"time,omitempty"`
	// Message is a single line of log output from an OCI container.
	Message string `json:"message,omitempty"`
}

LogEntry represents one line of output from an OCI container.

type LogLevel

type LogLevel string

LogLevel represents the desired granularity of Worker log output.

const (
	// LogLevelDebug represents DEBUG level granularity in Worker log output.
	LogLevelDebug LogLevel = "DEBUG"
	// LogLevelInfo represents INFO level granularity in Worker log output.
	LogLevelInfo LogLevel = "INFO"
	// LogLevelWarn represents WARN level granularity in Worker log output.
	LogLevelWarn LogLevel = "WARN"
	// LogLevelError represents ERROR level granularity in Worker log output.
	LogLevelError LogLevel = "ERROR"
)

type LogStreamOptions

type LogStreamOptions struct {
	// Follow indicates whether the stream should conclude after the last
	// available line of logs has been sent to the client (false) or remain open
	// until closed by the client (true), continuing to send new lines as they
	// become available.
	Follow bool `json:"follow"`
}

LogStreamOptions represents useful options for streaming logs from some container of a Worker or Job.

type LogsClient

type LogsClient interface {
	// Stream returns a channel over which logs for an Event's Worker, or using
	// the LogsSelector parameter, a Job spawned by that Worker (or a specific
	// container thereof), are streamed.
	Stream(
		ctx context.Context,
		eventID string,
		selector *LogsSelector,
		opts *LogStreamOptions,
	) (<-chan LogEntry, <-chan error, error)
}

LogsClient is the specialized client for managing Logs with the Brigade API.

func NewLogsClient

func NewLogsClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) LogsClient

NewLogsClient returns a specialized client for managing Event Logs.

type LogsSelector

type LogsSelector struct {
	// Job specifies, by name, a Job spawned by some Worker. If not specified, log
	// streaming operations presume logs are desired for the Worker itself.
	Job string
	// Container specifies, by name, a container belonging to some Worker or, if
	// Job is specified, that Job. If not specified, log streaming operations
	// presume logs are desired from a container having the same name as the
	// selected Worker or Job.
	Container string
}

LogsSelector represents useful criteria for selecting logs to be streamed from any container belonging to some Worker OR any container belonging to Jobs spawned by that Worker.

type OSFamily

type OSFamily string

OSFamily represents a type of operating system.

const (
	// OSFamilyLinux represents a Linux-based OS.
	OSFamilyLinux OSFamily = "linux"
	// OSFamilyWindows represents a Windows-based OS.
	OSFamilyWindows OSFamily = "windows"
)

type PingOptions

type PingOptions struct{}

PingOptions represents useful, optional criteria for pinging a Brigade API server. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type PingResponse

type PingResponse struct {
	Version string
	Commit  string
}

PingResponse represents the expected response object returned by the API Server's v2/ping endpoint

type PrincipalReference

type PrincipalReference struct {
	// Type qualifies what kind of principal is referenced by the ID field-- for
	// instance, a User or a ServiceAccount.
	Type PrincipalType `json:"type,omitempty"`
	// ID references a principal. The Type qualifies what type of principal that
	// is-- for instance, a User or a ServiceAccount.
	ID string `json:"id,omitempty"`
}

PrincipalReference is a reference to any sort of security principal (human user, service account, etc.)

type PrincipalType

type PrincipalType string

PrincipalType is a type whose values can be used to disambiguate one type of principal from another. For instance, when assigning a Role to a principal via a RoleAssignment, a PrincipalType field is used to indicate whether the value of the PrincipalID field reflects a User ID or a ServiceAccount ID.

type Project

type Project struct {
	// ObjectMeta contains Project metadata.
	meta.ObjectMeta `json:"metadata"`
	// Description is a natural language description of the Project.
	Description string `json:"description,omitempty"`
	// Spec is an instance of a ProjectSpec that pairs EventSubscriptions with
	// a WorkerTemplate.
	Spec ProjectSpec `json:"spec"`
	// Kubernetes contains Kubernetes-specific details of the Project's
	// environment. These details are populated by Brigade so that sufficiently
	// authorized Kubernetes users may obtain the information needed to directly
	// modify a Project's environment to facilitate certain advanced use cases.
	// Clients MUST leave the value of this field nil when using the API to create
	// or update a Project.
	Kubernetes *KubernetesDetails `json:"kubernetes,omitempty"`
}

Project is Brigade's fundamental configuration, management, and isolation construct.

  • Configuration: Users define Projects to pair EventSubscriptions with template WorkerSpecs.
  • Management: Project administrators govern Project access by granting and revoking project-level Roles to/from principals (such as Users or ServiceAccounts)
  • Isolation: All workloads (Workers and Jobs) spawned to handle a given Project's Events are isolated from other Projects' workloads in the underlying workload execution substrate.

func (Project) MarshalJSON

func (p Project) MarshalJSON() ([]byte, error)

MarshalJSON amends Project instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type ProjectAuthzClient

type ProjectAuthzClient interface {
	// RoleAssignments returns a specialized client for managing project-level
	// RoleAssignments.
	RoleAssignments() ProjectRoleAssignmentsClient
}

ProjectAuthzClient is the specialized client for managing project-level authorization concerns with the Brigade API.

func NewProjectAuthzClient

func NewProjectAuthzClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) ProjectAuthzClient

NewProjectAuthzClient returns a specialized client for managing project-level authorization concerns.

type ProjectCreateOptions

type ProjectCreateOptions struct{}

ProjectCreateOptions represents useful, optional settings for creating a new Project. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type ProjectDeleteOptions

type ProjectDeleteOptions struct{}

ProjectDeleteOptions represents useful, optional settings for deleting a Project. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type ProjectGetOptions

type ProjectGetOptions struct{}

ProjectGetOptions represents useful, optional criteria for retrieving a Project. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type ProjectList

type ProjectList struct {
	// ListMeta contains list metadata.
	meta.ListMeta `json:"metadata"`
	// Items is a slice of Projects.
	Items []Project `json:"items,omitempty"`
}

ProjectList is an ordered and pageable list of Projects.

func (ProjectList) MarshalJSON

func (p ProjectList) MarshalJSON() ([]byte, error)

MarshalJSON amends ProjectList instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type ProjectRoleAssignment

type ProjectRoleAssignment struct {
	// ProjectID qualifies the scope of the Role.
	ProjectID string `json:"projectID,omitempty"`
	// Role assigns a Role to the specified principal.
	Role Role `json:"role"`
	// Principal specifies the principal to whom the Role is assigned.
	Principal PrincipalReference `json:"principal"`
}

ProjectRoleAssignment represents the assignment of a ProjectRole to a principal such as a User or ServiceAccount.

func (ProjectRoleAssignment) MarshalJSON

func (p ProjectRoleAssignment) MarshalJSON() ([]byte, error)

MarshalJSON amends ProjectRoleAssignment instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type ProjectRoleAssignmentGrantOptions

type ProjectRoleAssignmentGrantOptions struct{}

ProjectRoleAssignmentGrantOptions represents useful, optional settings for granting a project-level Role to a principal. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type ProjectRoleAssignmentList

type ProjectRoleAssignmentList struct {
	// ListMeta contains list metadata.
	meta.ListMeta `json:"metadata"`
	// Items is a slice of ProjectRoleAssignments.
	Items []ProjectRoleAssignment `json:"items,omitempty"`
}

ProjectRoleAssignmentList is an ordered and pageable list of ProjectRoleAssignments.

func (ProjectRoleAssignmentList) MarshalJSON

func (p ProjectRoleAssignmentList) MarshalJSON() ([]byte, error)

MarshalJSON amends ProjectRoleAssignmentList instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type ProjectRoleAssignmentRevokeOptions

type ProjectRoleAssignmentRevokeOptions struct{}

ProjectRoleAssignmentRevokeOptions represents useful, optional settings for revoking a project-level Role from a principal. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type ProjectRoleAssignmentsClient

type ProjectRoleAssignmentsClient interface {
	// Grant grants the project-level Role specified by the ProjectRoleAssignment
	// to the principal also specified by the ProjectRoleAssignment.
	Grant(
		ctx context.Context,
		projectID string,
		projectRoleAssignment ProjectRoleAssignment,
		opts *ProjectRoleAssignmentGrantOptions,
	) error
	// List returns a ProjectRoleAssignmentsList, with its Items
	// (ProjectRoleAssignments) ordered by principal type, principalID, project,
	// and role. Criteria for which ProjectRoleAssignments should be retrieved can
	// be specified using the ProjectRoleAssignmentsSelector parameter.
	List(
		ctx context.Context,
		selector *ProjectRoleAssignmentsSelector,
		opts *meta.ListOptions,
	) (ProjectRoleAssignmentList, error)
	// Revoke revokes the project-level Role specified by the
	// ProjectRoleAssignment for the principal also specified by the
	// ProjectRoleAssignment.
	Revoke(
		ctx context.Context,
		projectID string,
		projectRoleAssignment ProjectRoleAssignment,
		opts *ProjectRoleAssignmentRevokeOptions,
	) error
}

ProjectRoleAssignmentsClient is the specialized client for managing ProjectRoleAssignments with the Brigade API.

func NewProjectRoleAssignmentsClient

func NewProjectRoleAssignmentsClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) ProjectRoleAssignmentsClient

NewProjectRoleAssignmentsClient returns a specialized client for managing project-level RoleAssignments.

type ProjectRoleAssignmentsSelector

type ProjectRoleAssignmentsSelector struct {
	// Principal specifies that only ProjectRoleAssignments for the specified
	// Principal should be selected.
	Principal *PrincipalReference
	// ProjectID specifies that only ProjectRoleAssignments for the specified
	// Project should be selected.
	ProjectID string
	// Role specified that only ProjectRoleAssignments for the specified Role
	// should be selected.
	Role Role
}

ProjectRoleAssignmentsSelector represents useful filter criteria when selecting multiple ProjectRoleAssignments for API group operations like list.

type ProjectSpec

type ProjectSpec struct {
	// EventSubscriptions defines a set of trigger conditions under which a new
	// Worker should be created.
	EventSubscriptions []EventSubscription `json:"eventSubscriptions,omitempty"`
	// WorkerTemplate is a prototypical WorkerSpec.
	WorkerTemplate WorkerSpec `json:"workerTemplate"`
}

ProjectSpec is the technical component of a Project. It pairs EventSubscriptions with a prototypical WorkerSpec that is used as a template for creating new Workers.

type ProjectUpdateOptions

type ProjectUpdateOptions struct {
	// CreateIfNotFound when set to true will cause a non-existing Project to be
	// created instead of updated.
	CreateIfNotFound bool
}

ProjectUpdateOptions represents useful, optional settings for updating a Project.

type ProjectsClient

type ProjectsClient interface {
	// Create creates a new Project.
	Create(context.Context, Project, *ProjectCreateOptions) (Project, error)
	// CreateFromBytes creates a new Project using raw (unprocessed by the client)
	// bytes, presumably originating from a file. This is the preferred way to
	// create Projects defined by an end user since server-side validation will
	// then be applied directly to the Project definition as the user has written
	// it (i.e. WITHOUT any normalization or corrections the client may have made
	// when unmarshaling the original data or when marshaling the outbound
	// request).
	CreateFromBytes(
		context.Context,
		[]byte,
		*ProjectCreateOptions,
	) (Project, error)
	// List returns a ProjectList, with its Items (Projects) ordered
	// alphabetically by Project ID.
	List(
		context.Context,
		*ProjectsSelector,
		*meta.ListOptions,
	) (ProjectList, error)
	// Get retrieves a single Project specified by its identifier.
	Get(context.Context, string, *ProjectGetOptions) (Project, error)
	// Update updates an existing Project.
	Update(context.Context, Project, *ProjectUpdateOptions) (Project, error)
	// UpdateFromBytes updates an existing Project using raw (unprocessed by the
	// client) bytes, presumably originating from a file. This is the preferred
	// way to update Projects defined by an end user since server-side validation
	// will then be applied directly to the Project definition as the user has
	// written it (i.e. WITHOUT any normalization or corrections the client may
	// have made when unmarshaling the original data or when marshaling the
	// outbound request).
	UpdateFromBytes(
		context.Context,
		string,
		[]byte,
		*ProjectUpdateOptions,
	) (Project, error)
	// Delete deletes a single Project specified by its identifier.
	Delete(context.Context, string, *ProjectDeleteOptions) error

	// Authz returns a specialized client for managing project-level authorization
	// concerns.
	Authz() ProjectAuthzClient

	// Secrets returns a specialized client for Secret management.
	Secrets() SecretsClient
}

ProjectsClient is the specialized client for managing Projects with the Brigade API.

func NewProjectsClient

func NewProjectsClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) ProjectsClient

NewProjectsClient returns a specialized client for managing Projects.

type ProjectsSelector

type ProjectsSelector struct{}

ProjectsSelector represents useful filter criteria when selecting multiple Projects for API group operations like list. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type Role

type Role string

Role is a type whose value maps to a well-defined Brigade Role.

const (

	// RoleProjectAdmin is the name of a project-level Role that enables a
	// principal to manage a specific Project.
	RoleProjectAdmin Role = "PROJECT_ADMIN"

	// RoleProjectDeveloper is the name of a project-level Role that enables a
	// principal to update a specific project.
	RoleProjectDeveloper Role = "PROJECT_DEVELOPER"

	// RoleProjectUser is the name of project-level Role that enables a principal
	// to create and manage Events for a specific Project.
	RoleProjectUser Role = "PROJECT_USER"
)
const (
	// RoleAdmin is the name of a system-level Role that enables principals to
	// manage Users, ServiceAccounts, and system-level permissions for Users and
	// ServiceAccounts.
	RoleAdmin Role = "ADMIN"

	// RoleEventCreator is the name of a system-level Role that enables principals
	// to create Events for all Projects-- provided the Events have a specific
	// value in the Source field. This is useful for Event gateways, which should
	// be able to create Events for all Projects, but should NOT be able to
	// impersonate other gateways.
	RoleEventCreator Role = "EVENT_CREATOR"

	// RoleProjectCreator is the name of a system-level Role that enables
	// principals to create new Projects.
	RoleProjectCreator Role = "PROJECT_CREATOR"

	// RoleReader is the name of a system-level Role that enables global read
	// access.
	RoleReader Role = "READER"
)

type RoleAssignment

type RoleAssignment struct {
	// Role assigns a Role to the specified principal.
	Role Role `json:"role"`
	// Principal specifies the principal to whom the Role is assigned.
	Principal PrincipalReference `json:"principal"`
	// Scope qualifies the scope of the Role. The value is opaque and has meaning
	// only in relation to a specific Role.
	Scope string `json:"scope,omitempty"`
}

RoleAssignment represents the assignment of a Role to a principal such as a User or ServiceAccount.

func (RoleAssignment) MarshalJSON

func (r RoleAssignment) MarshalJSON() ([]byte, error)

MarshalJSON amends RoleAssignment instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type RoleAssignmentGrantOptions

type RoleAssignmentGrantOptions struct{}

RoleAssignmentGrantOptions represents useful, optional settings for granting a Role to a Principal. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type RoleAssignmentList

type RoleAssignmentList struct {
	// ListMeta contains list metadata.
	meta.ListMeta `json:"metadata"`
	// Items is a slice of RoleAssignments.
	Items []RoleAssignment `json:"items,omitempty"`
}

RoleAssignmentList is an ordered and pageable list of RoleAssignments.

func (RoleAssignmentList) MarshalJSON

func (r RoleAssignmentList) MarshalJSON() ([]byte, error)

MarshalJSON amends RoleAssignmentList instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type RoleAssignmentRevokeOptions

type RoleAssignmentRevokeOptions struct{}

RoleAssignmentRevokeOptions represents useful, optional settings for revoking a Role from a Principal. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type RoleAssignmentsClient

type RoleAssignmentsClient interface {
	// Grant grants the system-level Role specified by the RoleAssignment to the
	// principal also specified by the RoleAssignment.
	Grant(
		context.Context,
		RoleAssignment,
		*RoleAssignmentGrantOptions,
	) error
	// List returns a RoleAssignmentsList, with its Items (RoleAssignments)
	// ordered by principal type, principalID, role, and scope. Criteria for which
	// RoleAssignments should be retrieved can be specified using the
	// RoleAssignmentsSelector parameter.
	List(
		context.Context,
		*RoleAssignmentsSelector,
		*meta.ListOptions,
	) (RoleAssignmentList, error)
	// Revoke revokes the system-level Role specified by the RoleAssignment for
	// the principal also specified by the RoleAssignment.
	Revoke(
		context.Context,
		RoleAssignment,
		*RoleAssignmentRevokeOptions,
	) error
}

RoleAssignmentsClient is the specialized client for managing RoleAssignments with the Brigade API.

func NewRoleAssignmentsClient

func NewRoleAssignmentsClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) RoleAssignmentsClient

NewRoleAssignmentsClient returns a specialized client for managing RoleAssignments.

type RoleAssignmentsSelector

type RoleAssignmentsSelector struct {
	// Principal specifies that only RoleAssignments for the specified Principal
	// should be selected.
	Principal *PrincipalReference
	// Role specifies that only RoleAssignments for the specified Role should be
	// selected.
	Role Role
}

RoleAssignmentsSelector represents useful filter criteria when selecting multiple RoleAssignments for API group operations like list.

type RootSessionCreateOptions

type RootSessionCreateOptions struct{}

RootSessionCreateOptions represents useful, optional settings for the creation of a root Session. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type RunningJobCountOptions

type RunningJobCountOptions struct{}

RunningJobCountOptions represents useful, optional criteria for the retrieval of a count of running Jobs. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type RunningWorkerCountOptions

type RunningWorkerCountOptions struct{}

RunningWorkerCountOptions represents useful, optional criteria for the retrieval of a count of running Workers. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type Secret

type Secret struct {
	// Key is a key by which the secret can referred.
	Key string `json:"key,omitempty"`
	// Value is the sensitive information. This is a write-only field.
	Value string `json:"value,omitempty"`
}

Secret represents Project-level sensitive information.

func (Secret) MarshalJSON

func (s Secret) MarshalJSON() ([]byte, error)

MarshalJSON amends Secret instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type SecretList

type SecretList struct {
	// ListMeta contains list metadata.
	meta.ListMeta `json:"metadata"`
	// Items is a slice of Secrets.
	Items []Secret `json:"items,omitempty"`
}

SecretList is an ordered and pageable list of Secrets.

func (SecretList) MarshalJSON

func (s SecretList) MarshalJSON() ([]byte, error)

MarshalJSON amends SecretList instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type SecretSetOptions

type SecretSetOptions struct{}

SecretSetOptions represents useful, optional settings for assigning a new value to a Project Secret. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type SecretUnsetOptions

type SecretUnsetOptions struct{}

SecretUnsetOptions represents useful, optional settings for un-assigning a value from a Project Secret. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type SecretsClient

type SecretsClient interface {
	// List returns a SecretList whose Items (Secrets) contain Keys only and not
	// Values (all Value fields are empty). i.e. Once a secret is set, end clients
	// are unable to retrieve values.
	List(
		ctx context.Context,
		projectID string,
		opts *meta.ListOptions,
	) (SecretList, error)
	// Set sets the value of a new Secret or updates the value of an existing
	// Secret. If the specified Key does not exist, it is created. If the
	// specified Key does exist, its corresponding Value is overwritten.
	Set(
		ctx context.Context,
		projectID string,
		secret Secret,
		opts *SecretSetOptions,
	) error
	// Unset clears the value of an existing Secret. If the specified Key does not
	// exist, no error is returned.
	Unset(
		ctx context.Context,
		projectID string,
		key string,
		opts *SecretUnsetOptions,
	) error
}

SecretsClient is the specialized client for managing Secrets with the Brigade API.

func NewSecretsClient

func NewSecretsClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) SecretsClient

NewSecretsClient returns a specialized client for managing Secrets.

type ServiceAccount

type ServiceAccount struct {
	// ObjectMeta encapsulates ServiceAccount metadata.
	meta.ObjectMeta `json:"metadata"`
	// Description is a natural language description of the ServiceAccount's
	// purpose.
	Description string `json:"description,omitempty"`
	// Locked indicates when the ServiceAccount has been locked out of the system
	// by an administrator. If this field's value is nil, the ServiceAccount is
	// not locked.
	Locked *time.Time `json:"locked,omitempty"`
}

ServiceAccount represents a non-human Brigade user, such as an Event gateway.

func (ServiceAccount) MarshalJSON

func (s ServiceAccount) MarshalJSON() ([]byte, error)

MarshalJSON amends ServiceAccount instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type ServiceAccountCreateOptions

type ServiceAccountCreateOptions struct{}

ServiceAccountCreateOptions represents useful, optional settings for the creation of new ServiceAccounts. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type ServiceAccountDeleteOptions

type ServiceAccountDeleteOptions struct{}

ServiceAccountDeleteOptions represents useful, optional settings for the deletion of a ServiceAccount. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type ServiceAccountGetOptions

type ServiceAccountGetOptions struct{}

ServiceAccountGetOptions represents useful, optional criteria for the retrieval of a ServiceAccount. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type ServiceAccountList

type ServiceAccountList struct {
	// ListMeta contains list metadata.
	meta.ListMeta `json:"metadata"`
	// Items is a slice of ServiceAccounts.
	Items []ServiceAccount `json:"items,omitempty"`
}

ServiceAccountList is an ordered and pageable list of ServiceAccounts.

func (ServiceAccountList) MarshalJSON

func (s ServiceAccountList) MarshalJSON() ([]byte, error)

MarshalJSON amends ServiceAccountList instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type ServiceAccountLockOptions

type ServiceAccountLockOptions struct{}

ServiceAccountLockOptions represents useful, optional settings for the locking of a ServiceAccount. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type ServiceAccountUnlockOptions

type ServiceAccountUnlockOptions struct{}

ServiceAccountUnlockOptions represents useful, optional settings for the unlocking of a ServiceAccount. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type ServiceAccountsClient

type ServiceAccountsClient interface {
	// Create creates a new ServiceAccount.
	Create(
		context.Context,
		ServiceAccount,
		*ServiceAccountCreateOptions,
	) (Token, error)
	// List returns a ServiceAccountList.
	List(
		context.Context,
		*ServiceAccountsSelector,
		*meta.ListOptions,
	) (ServiceAccountList, error)
	// Get retrieves a single ServiceAccount specified by its identifier.
	Get(
		context.Context,
		string,
		*ServiceAccountGetOptions,
	) (ServiceAccount, error)

	// Lock revokes system access for a single ServiceAccount specified by its
	// identifier.
	Lock(context.Context, string, *ServiceAccountLockOptions) error
	// Unlock restores system access for a single ServiceAccount (after presumably
	// having been revoked) specified by its identifier. It returns a new Token.
	Unlock(context.Context, string, *ServiceAccountUnlockOptions) (Token, error)

	// Delete deletes a single ServiceAccount specified by its identifier.
	Delete(context.Context, string, *ServiceAccountDeleteOptions) error
}

ServiceAccountsClient is the specialized client for managing ServiceAccounts with the Brigade API.

func NewServiceAccountsClient

func NewServiceAccountsClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) ServiceAccountsClient

NewServiceAccountsClient returns a specialized client for managing ServiceAccounts.

type ServiceAccountsSelector

type ServiceAccountsSelector struct{}

ServiceAccountsSelector represents useful filter criteria when selecting multiple ServiceAccounts for API group operations like list. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type SessionDeleteOptions

type SessionDeleteOptions struct{}

SessionDeleteOptions represents useful, optional settings for the deletion of a Session. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type SessionsClient

type SessionsClient interface {
	// CreateRootSession creates a Session for the root user (if enabled by the
	// system administrator) and returns a Token with a short expiry period
	// (determined by a system administrator). In contrast to most other
	// operations exposed by the Brigade API, a valid token is not required to
	// invoke this.
	CreateRootSession(
		ctx context.Context,
		password string,
		opts *RootSessionCreateOptions,
	) (Token, error)
	// CreateUserSession creates a new User Session and initiates an
	// authentication workflow with a third-party identity provider. It returns
	// ThirdPartyAuthDetails containing all information required to continue the
	// authentication process.
	CreateUserSession(
		context.Context,
		*UserSessionCreateOptions,
	) (ThirdPartyAuthDetails, error)
	// Delete deletes the Session identified by the token in use by this client.
	Delete(context.Context, *SessionDeleteOptions) error
}

SessionsClient is the specialized client for managing Brigade API Sessions.

func NewSessionsClient

func NewSessionsClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) SessionsClient

NewSessionsClient returns a specialized client for managing Brigade API Sessions.

type SourceState

type SourceState struct {
	// State is a map of arbitrary and opaque key/value pairs that the source of
	// an Event (e.g. the gateway that created it) can use to store
	// source-specific state.
	State map[string]string `json:"state,omitempty"`
}

SourceState encapsulates opaque, source-specific (e.g. gateway-specific) state.

func (SourceState) MarshalJSON

func (s SourceState) MarshalJSON() ([]byte, error)

MarshalJSON amends SourceState instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type SubstrateClient

type SubstrateClient interface {
	// CountRunningWorkers returns a count of Workers currently executing on the
	// substrate.
	CountRunningWorkers(
		context.Context,
		*RunningWorkerCountOptions,
	) (SubstrateWorkerCount, error)
	// CountRunningJobs returns a count of Jobs currently executing on the
	// substrate.
	CountRunningJobs(
		context.Context,
		*RunningJobCountOptions,
	) (SubstrateJobCount, error)
}

SubstrateClient is the specialized client for monitoring the substrate.

func NewSubstrateClient

func NewSubstrateClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) SubstrateClient

NewSubstrateClient returns a specialized client for monitoring the substrate.

type SubstrateJobCount

type SubstrateJobCount struct {
	// Count is the cardinality of Jobs currently executing on the substrate.
	Count int `json:"count"`
}

SubstrateJobCount represents a count of Workers currently executing on the substrate.

type SubstrateWorkerCount

type SubstrateWorkerCount struct {
	// Count is the cardinality of Workers currently executing on the substrate.
	Count int `json:"count"`
}

SubstrateWorkerCount represents a count of Workers currently executing on the substrate.

type SystemAuthzClient

type SystemAuthzClient interface {
	// RoleAssignments returns a specialized client for managing RoleAssignments.
	RoleAssignments() RoleAssignmentsClient
}

SystemAuthzClient is the root of a tree of more specialized API clients for handling system-wide authorization concerns.

func NewSystemAuthzClient

func NewSystemAuthzClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) SystemAuthzClient

NewSystemAuthzClient returns an SystemAuthzClient, which is the root of a tree of more specialized API clients for handling system-wide authorization concerns. It will initialize all clients in the tree so they are ready for immediate use.

type SystemClient

type SystemClient interface {
	// Ping sends a GET request to the API Server's versioned ping endpoint
	Ping(context.Context, *PingOptions) (PingResponse, error)

	// UnversionedPing sends a GET request to the API Server's unversioned
	// ping endpoint
	UnversionedPing(context.Context) ([]byte, error)
}

SystemClient is the client for system checks involving the Brigade API.

func NewSystemClient

func NewSystemClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) SystemClient

NewSystemClient returns a client to access system-related Brigade API endpoints.

type ThirdPartyAuthDetails

type ThirdPartyAuthDetails struct {
	// AuthURL is a URL that can be requested in a user's web browser to complete
	// authentication via a third-party identity provider.
	AuthURL string `json:"authURL,omitempty"`
	// Token is an opaque bearer token issued by Brigade to correlate a User with
	// a Session. It remains unactivated (useless) until the authentication
	// workflow is successfully completed. Clients may expect that that the token
	// expires (at an interval determined by a system administrator) and, for
	// simplicity, is NOT refreshable. When the token has expired,
	// re-authentication is required.
	Token string `json:"token,omitempty"`
}

ThirdPartyAuthDetails encapsulates all information required for a client authenticating by means of a third-party identity provider to complete the authentication workflow.

func (ThirdPartyAuthDetails) MarshalJSON

func (t ThirdPartyAuthDetails) MarshalJSON() ([]byte, error)

MarshalJSON amends ThirdPartyAuthDetails instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type Token

type Token struct {
	Value string `json:"value,omitempty"`
}

Token represents an opaque bearer token used to authenticate to the Brigade API.

type User

type User struct {
	// ObjectMeta encapsulates User metadata.
	meta.ObjectMeta `json:"metadata"`
	// Name is the given name and surname of the User.
	Name string `json:"name,omitempty"`
	// Locked indicates when the User has been locked out of the system by an
	// administrator. If this field's value is nil, the User is not locked.
	Locked *time.Time `json:"locked,omitempty"`
}

User represents a (human) Brigade user.

func (User) MarshalJSON

func (u User) MarshalJSON() ([]byte, error)

MarshalJSON amends User instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type UserDeleteOptions

type UserDeleteOptions struct{}

UserDeleteOptions represents useful, optional settings for the deletion of a User. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type UserGetOptions

type UserGetOptions struct{}

UserGetOptions represents useful, optional criteria for the retrieval of a User. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type UserList

type UserList struct {
	// ListMeta contains list metadata.
	meta.ListMeta `json:"metadata"`
	// Items is a slice of Users.
	Items []User `json:"items,omitempty"`
}

UserList is an ordered and pageable list of Users.

func (UserList) MarshalJSON

func (u UserList) MarshalJSON() ([]byte, error)

MarshalJSON amends UserList instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type UserLockOptions

type UserLockOptions struct{}

UserLockOptions represents useful, optional settings for the locking of a User. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type UserSessionCreateOptions

type UserSessionCreateOptions struct {
	// SuccessURL indicates where users should be redirected to after successful
	// completion of a third-party authentication workflow. If this is left
	// unspecified, users will be redirected to a default success page.
	SuccessURL string
}

UserSessionCreateOptions encapsulates user-specified options when creating a new Session that will authenticate using a third-party identity provider.

type UserUnlockOptions

type UserUnlockOptions struct{}

UserUnlockOptions represents useful, optional settings for the unlocking of a User. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type UsersClient

type UsersClient interface {
	// List returns a UserList.
	List(context.Context, *UsersSelector, *meta.ListOptions) (UserList, error)
	// Get retrieves a single User specified by their identifier.
	Get(context.Context, string, *UserGetOptions) (User, error)

	// Lock revokes system access for a single User specified by their identifier.
	// Implementations MUST also delete or invalidate any and all of the User's
	// existing Sessions.
	Lock(context.Context, string, *UserLockOptions) error
	// Unlock restores system access for a single User (after presumably having
	// been revoked) specified by their identifier.
	Unlock(context.Context, string, *UserUnlockOptions) error

	// Delete deletes a single User specified by their identifier.
	Delete(context.Context, string, *UserDeleteOptions) error
}

UsersClient is the specialized client for managing Users with the Brigade API.

func NewUsersClient

func NewUsersClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) UsersClient

NewUsersClient returns a specialized client for managing Users.

type UsersSelector

type UsersSelector struct{}

UsersSelector represents useful filter criteria when selecting multiple Users for API group operations like list. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type Worker

type Worker struct {
	// Spec is the technical blueprint for the Worker.
	Spec WorkerSpec `json:"spec"`
	// Status contains details of the Worker's current state.
	Status WorkerStatus `json:"status"`
	// Jobs contains details of all Jobs spawned by the Worker during handling of
	// the Event.
	Jobs []Job `json:"jobs,omitempty"`
}

Worker represents a component that orchestrates handling of a single Event.

func (*Worker) Job

func (w *Worker) Job(jobName string) (Job, bool)

Job retrieves a Job by name. It returns a boolean indicating whether the returned Job is the one requested (true) or a zero value (false) because no Job with the specified name belongs to this Worker.

type WorkerCleanupOptions

type WorkerCleanupOptions struct{}

WorkerCleanupOptions represents useful, optional settings for cleaning up after a Worker. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type WorkerPhase

type WorkerPhase string

WorkerPhase represents where a Worker is within its lifecycle.

const (
	// WorkerPhaseAborted represents the state wherein a worker was forcefully
	// stopped during execution.
	WorkerPhaseAborted WorkerPhase = "ABORTED"
	// WorkerPhaseCanceled represents the state wherein a pending worker was
	// canceled prior to execution.
	WorkerPhaseCanceled WorkerPhase = "CANCELED"
	// WorkerPhaseFailed represents the state wherein a worker has run to
	// completion but experienced errors.
	WorkerPhaseFailed WorkerPhase = "FAILED"
	// WorkerPhasePending represents the state wherein a worker is awaiting
	// execution.
	WorkerPhasePending WorkerPhase = "PENDING"
	// WorkerPhaseRunning represents the state wherein a worker is currently
	// being executed.
	WorkerPhaseRunning WorkerPhase = "RUNNING"
	// WorkerPhaseSchedulingFailed represents the state wherein a worker was not
	// scheduled due to some unexpected and unrecoverable error encountered by the
	// scheduler.
	WorkerPhaseSchedulingFailed WorkerPhase = "SCHEDULING_FAILED"
	// WorkerPhaseStarting represents the state wherein a Worker is starting on
	// the substrate but isn't running yet.
	WorkerPhaseStarting WorkerPhase = "STARTING"
	// WorkerPhaseSucceeded represents the state where a worker has run to
	// completion without error.
	WorkerPhaseSucceeded WorkerPhase = "SUCCEEDED"
	// WorkerPhaseTimedOut represents the state wherein a worker has has not
	// completed within a designated timeframe.
	WorkerPhaseTimedOut WorkerPhase = "TIMED_OUT"
	// WorkerPhaseUnknown represents the state wherein a worker's state is
	// unknown. Note that this is possible if and only if the underlying Worker
	// execution substrate (Kubernetes), for some unanticipated reason, does not
	// know the Worker's (Pod's) state.
	WorkerPhaseUnknown WorkerPhase = "UNKNOWN"
)

func WorkerPhasesAll

func WorkerPhasesAll() []WorkerPhase

WorkerPhasesAll returns a slice of WorkerPhases containing ALL possible phases. Note that instead of utilizing a package-level slice, this a function returns ad-hoc copies of the slice in order to preclude the possibility of this important collection being modified at runtime by a client.

func WorkerPhasesNonTerminal

func WorkerPhasesNonTerminal() []WorkerPhase

WorkerPhasesNonTerminal returns a slice of WorkerPhases containing ALL phases that are considered non-terminal. Note that instead of utilizing a package-level slice, this a function returns ad-hoc copies of the slice in order to preclude the possibility of this important collection being modified at runtime by a client.

func WorkerPhasesTerminal

func WorkerPhasesTerminal() []WorkerPhase

WorkerPhasesTerminal returns a slice of WorkerPhases containing ALL phases that are considered terminal. Note that instead of utilizing a package-level slice, this a function returns ad-hoc copies of the slice in order to preclude the possibility of this important collection being modified at runtime by a client.

func (WorkerPhase) IsTerminal

func (w WorkerPhase) IsTerminal() bool

IsTerminal returns a bool indicating whether the WorkerPhase is terminal.

type WorkerSpec

type WorkerSpec struct {
	// Container specifies the details of an OCI container that forms the
	// cornerstone of the Worker.
	Container *ContainerSpec `json:"container,omitempty"`
	// UseWorkspace indicates whether the Worker and/or any Jobs it may spawn
	// requires access to a shared workspace. When false, no such workspace is
	// provisioned prior to Worker creation.
	UseWorkspace bool `json:"useWorkspace"`
	// WorkspaceSize specifies the size of a volume that will be provisioned as
	// a shared workspace for the Worker and any Jobs it spawns.
	// The value can be expressed in bytes (as a plain integer) or as a
	// fixed-point integer using one of these suffixes: E, P, T, G, M, K.
	// Power-of-two equivalents may also be used: Ei, Pi, Ti, Gi, Mi, Ki.
	WorkspaceSize string `json:"workspaceSize,omitempty"`
	// Git contains git-specific Worker details.
	Git *GitConfig `json:"git,omitempty"`
	// Kubernetes contains Kubernetes-specific Worker details.
	Kubernetes *KubernetesConfig `json:"kubernetes,omitempty"`
	// JobPolicies specifies policies for any Jobs spawned by the Worker.
	JobPolicies *JobPolicies `json:"jobPolicies,omitempty"`
	// LogLevel specifies the desired granularity of Worker log output.
	LogLevel LogLevel `json:"logLevel,omitempty"`
	// ConfigFilesDirectory specifies a directory within the Worker's workspace
	// where any relevant configuration files (e.g. brigade.js, package.json,
	// etc.) can be located.
	ConfigFilesDirectory string `json:"configFilesDirectory,omitempty"`
	// DefaultConfigFiles is a map of configuration file names to configuration
	// file content. This is useful for Workers that do not integrate with any
	// source control system and would like to embed configuration (e.g.
	// package.json) or scripts (e.g. brigade.js) directly within the WorkerSpec.
	DefaultConfigFiles map[string]string `json:"defaultConfigFiles,omitempty"`
	// TimeoutDuration specifies the time duration that must elapse before a
	// running Job should be considered to have timed out. This duration string
	// is a possibly signed sequence of decimal numbers, each with optional
	// fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m".
	// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
	TimeoutDuration string `json:"timeoutDuration,omitempty"`
}

WorkerSpec is the technical blueprint for a Worker.

type WorkerStartOptions

type WorkerStartOptions struct{}

WorkerStartOptions represents useful, optional settings for starting a Worker. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type WorkerStatus

type WorkerStatus struct {
	// Started indicates the time the Worker began execution. It will be nil for
	// a Worker that is not yet executing.
	Started *time.Time `json:"started,omitempty"`
	// Ended indicates the time the Worker concluded execution. It will be nil
	// for a Worker that is not done executing (or hasn't started).
	Ended *time.Time `json:"ended,omitempty"`
	// Phase indicates where the Worker is in its lifecycle.
	Phase WorkerPhase `json:"phase,omitempty"`
}

WorkerStatus represents the status of a Worker.

func (WorkerStatus) MarshalJSON

func (w WorkerStatus) MarshalJSON() ([]byte, error)

MarshalJSON amends WorkerStatus instances with type metadata so that clients do not need to be concerned with the tedium of doing so.

type WorkerStatusGetOptions

type WorkerStatusGetOptions struct{}

WorkerStatusGetOptions represents useful, optional criteria for retrieval of a Worker's Status. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type WorkerStatusUpdateOptions

type WorkerStatusUpdateOptions struct{}

WorkerStatusUpdateOptions represents useful, optional settings for updating a Worker's Status. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type WorkerStatusWatchOptions

type WorkerStatusWatchOptions struct{}

WorkerStatusWatchOptions represents useful, optional criteria for establishing a stream of a Worker's Status. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type WorkerTimeoutOptions

type WorkerTimeoutOptions struct{}

WorkerTimeoutOptions represents useful, optional settings for timing out a Worker. It currently has no fields, but exists to preserve the possibility of future expansion without having to change client function signatures.

type WorkersClient

type WorkersClient interface {
	// Start starts the indicated Event's Worker on Brigade's workload execution
	// substrate.
	Start(ctx context.Context, eventID string, opts *WorkerStartOptions) error
	// Get returns an Event's Worker's status.
	GetStatus(
		ctx context.Context,
		eventID string,
		opts *WorkerStatusGetOptions,
	) (WorkerStatus, error)
	// WatchStatus returns a channel over which an Event's Worker's status is
	// streamed. The channel receives a new WorkerStatus every time there is any
	// change in that status.
	WatchStatus(
		ctx context.Context,
		eventID string,
		opts *WorkerStatusWatchOptions,
	) (<-chan WorkerStatus, <-chan error, error)
	// UpdateStatus updates the status of an Event's Worker.
	UpdateStatus(
		ctx context.Context,
		eventID string,
		status WorkerStatus,
		opts *WorkerStatusUpdateOptions,
	) error
	Cleanup(
		ctx context.Context,
		eventID string,
		opts *WorkerCleanupOptions,
	) error
	// Timeout executes timeout logic for an Event's Worker when it has exceeded
	// its timeout limit.
	Timeout(ctx context.Context, eventID string, opts *WorkerTimeoutOptions) error

	Jobs() JobsClient
}

WorkersClient is the specialized client for managing Event Workers with the Brigade API.

func NewWorkersClient

func NewWorkersClient(
	apiAddress string,
	apiToken string,
	opts *restmachinery.APIClientOptions,
) WorkersClient

NewWorkersClient returns a specialized client for managing Event Workers.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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