models

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Maps the kind type into an empty instance of the detail type. This allows us to quickly get back the correct type for things like json marshalling and unmarshalling. Make sure to keep this map in lockstep with the EventKind enum.

Functions

func Ptr

func Ptr[T any](v T) *T

Types

type CommonTask

type CommonTask struct {
	Settings     PipelineCommonTaskSettings `json:"settings"`
	Registration CommonTaskRegistration     `json:"registration"`
}

CommonTask is a representation of a Pipeline Common task. It combines not only the settings for the common task store exclusivly with Gofer, but also the pipeline's personal settings. This is so they can be combined and used in downstream task runs.

func (*CommonTask) FromProto

func (t *CommonTask) FromProto(pb *proto.CommonTask)

func (*CommonTask) GetCommand

func (t *CommonTask) GetCommand() *[]string

func (*CommonTask) GetDependsOn

func (t *CommonTask) GetDependsOn() map[string]RequiredParentStatus

func (*CommonTask) GetDescription

func (t *CommonTask) GetDescription() string

func (*CommonTask) GetEntrypoint

func (t *CommonTask) GetEntrypoint() *[]string

func (*CommonTask) GetID

func (t *CommonTask) GetID() string

func (*CommonTask) GetImage

func (t *CommonTask) GetImage() string

func (*CommonTask) GetRegistryAuth

func (t *CommonTask) GetRegistryAuth() *RegistryAuth

func (*CommonTask) GetVariables

func (t *CommonTask) GetVariables() []Variable

func (*CommonTask) ToProto

func (t *CommonTask) ToProto() *proto.CommonTask

type CommonTaskRegistration

type CommonTaskRegistration struct {
	Name          string           `json:"name"`
	Image         string           `json:"image"`
	RegistryAuth  *RegistryAuth    `json:"registry_auth"`
	Variables     []Variable       `json:"variables"`
	Created       int64            `json:"created"`
	Status        CommonTaskStatus `json:"status"`
	Documentation string           `json:"documentation"`
}

When installing a new common task, we allow the common task installer to pass a bunch of settings that allow us to go get that common task on future startups.

func (*CommonTaskRegistration) FromInstallCommonTaskRequest

func (c *CommonTaskRegistration) FromInstallCommonTaskRequest(proto *proto.InstallCommonTaskRequest)

func (*CommonTaskRegistration) FromProto

func (*CommonTaskRegistration) ToProto

type CommonTaskStatus

type CommonTaskStatus string
const (
	CommonTaskStatusUnknown CommonTaskStatus = "UNKNOWN" // Cannot determine status of CommonTask, should never be in this status.
	CommonTaskStatusEnabled CommonTaskStatus = "ENABLED" // Installed and able to be used by pipelines.
	/// Not available to be used by pipelines, either through lack of installation or
	/// being disabled by an admin.
	CommonTaskStatusDisabled CommonTaskStatus = "DISABLED"
)

type CustomTask

type CustomTask struct {
	ID           string                          `json:"id"`
	Description  string                          `json:"description"`
	Image        string                          `json:"image"`
	RegistryAuth *RegistryAuth                   `json:"registry_auth"`
	DependsOn    map[string]RequiredParentStatus `json:"depends_on"`
	Variables    []Variable                      `json:"variables"`
	Entrypoint   *[]string                       `json:"entrypoint"`
	Command      *[]string                       `json:"command"`
}

func (*CustomTask) FromProto

func (r *CustomTask) FromProto(t *proto.CustomTask)

func (*CustomTask) FromProtoCustomTaskConfig

func (r *CustomTask) FromProtoCustomTaskConfig(t *proto.CustomTaskConfig)

func (*CustomTask) GetCommand

func (r *CustomTask) GetCommand() *[]string

func (*CustomTask) GetDependsOn

func (r *CustomTask) GetDependsOn() map[string]RequiredParentStatus

func (*CustomTask) GetDescription

func (r *CustomTask) GetDescription() string

func (*CustomTask) GetEntrypoint

func (r *CustomTask) GetEntrypoint() *[]string

func (*CustomTask) GetID

func (r *CustomTask) GetID() string

func (*CustomTask) GetImage

func (r *CustomTask) GetImage() string

func (*CustomTask) GetRegistryAuth

func (r *CustomTask) GetRegistryAuth() *RegistryAuth

func (*CustomTask) GetVariables

func (r *CustomTask) GetVariables() []Variable

func (*CustomTask) ToProto

func (r *CustomTask) ToProto() *proto.CustomTask

type Event

type Event struct {
	ID      int64            // Unique identifier for event.
	Kind    EventKind        // The type of event it is.
	Details EventKindDetails // A struct of details about the specific event.
	Emitted int64            // Time event was performed in epoch milliseconds.
}

A single event type

func NewEvent

func NewEvent(details EventKindDetails) *Event

func (*Event) ToProto

func (e *Event) ToProto() (*proto.Event, error)

type EventCompletedRun

type EventCompletedRun struct {
	NamespaceID string    `json:"namespace_id"`
	PipelineID  string    `json:"pipeline_id"`
	RunID       int64     `json:"run_id"`
	Status      RunStatus `json:"status"`
}

func (EventCompletedRun) Kind

func (e EventCompletedRun) Kind() EventKind

type EventCompletedTaskRun

type EventCompletedTaskRun struct {
	NamespaceID string        `json:"namespace_id"`
	PipelineID  string        `json:"pipeline_id"`
	RunID       int64         `json:"run_id"`
	TaskRunID   string        `json:"task_run_id"`
	Status      TaskRunStatus `json:"status"`
}

func (EventCompletedTaskRun) Kind

type EventCreatedNamespace

type EventCreatedNamespace struct {
	NamespaceID string `json:"namespace_id"`
}

func (EventCreatedNamespace) Kind

type EventCreatedPipeline

type EventCreatedPipeline struct {
	NamespaceID string `json:"namespace_id"`
	PipelineID  string `json:"pipeline_id"`
}

func (EventCreatedPipeline) Kind

type EventCreatedTaskRun

type EventCreatedTaskRun struct {
	NamespaceID string `json:"namespace_id"`
	PipelineID  string `json:"pipeline_id"`
	RunID       int64  `json:"run_id"`
	TaskRunID   string `json:"task_run_id"`
}

func (EventCreatedTaskRun) Kind

func (e EventCreatedTaskRun) Kind() EventKind

type EventDeletedNamespace

type EventDeletedNamespace struct {
	NamespaceID string `json:"namespace_id"`
}

func (EventDeletedNamespace) Kind

type EventDeletedPipeline

type EventDeletedPipeline struct {
	NamespaceID string `json:"namespace_id"`
	PipelineID  string `json:"pipeline_id"`
}

func (EventDeletedPipeline) Kind

type EventDisabledCommonTask

type EventDisabledCommonTask struct {
	Name  string `json:"name"`
	Image string `json:"image"`
}

func (EventDisabledCommonTask) Kind

type EventDisabledPipeline

type EventDisabledPipeline struct {
	NamespaceID string `json:"namespace_id"`
	PipelineID  string `json:"pipeline_id"`
}

func (EventDisabledPipeline) Kind

type EventDisabledTrigger

type EventDisabledTrigger struct {
	Name  string `json:"name"`
	Image string `json:"image"`
}

func (EventDisabledTrigger) Kind

type EventEnabledCommonTask

type EventEnabledCommonTask struct {
	Name  string `json:"name"`
	Image string `json:"image"`
}

func (EventEnabledCommonTask) Kind

type EventEnabledPipeline

type EventEnabledPipeline struct {
	NamespaceID string `json:"namespace_id"`
	PipelineID  string `json:"pipeline_id"`
}

func (EventEnabledPipeline) Kind

type EventEnabledTrigger

type EventEnabledTrigger struct {
	Name  string `json:"name"`
	Image string `json:"image"`
}

func (EventEnabledTrigger) Kind

func (e EventEnabledTrigger) Kind() EventKind

type EventEvictedPipelineObject

type EventEvictedPipelineObject struct {
	NamespaceID string `json:"namespace_id"`
	PipelineID  string `json:"pipeline_id"`
	Key         string `json:"key"`
}

func (EventEvictedPipelineObject) Kind

type EventExpiredRunObjects

type EventExpiredRunObjects struct {
	NamespaceID string `json:"namespace_id"`
	PipelineID  string `json:"pipeline_id"`
	RunID       int64  `json:"run_id"`
}

func (EventExpiredRunObjects) Kind

type EventFiredTriggerEvent

type EventFiredTriggerEvent struct {
	NamespaceID string            `json:"namespace_id"`
	PipelineID  string            `json:"pipeline_id"`
	Name        string            `json:"name"`
	Label       string            `json:"label"`
	Result      TriggerResult     `json:"result"`
	Metadata    map[string]string `json:"metadata"`
}

func (EventFiredTriggerEvent) Kind

type EventInstalledCommonTask

type EventInstalledCommonTask struct {
	Name  string `json:"name"`
	Image string `json:"image"`
}

func (EventInstalledCommonTask) Kind

type EventInstalledTrigger

type EventInstalledTrigger struct {
	Name  string `json:"name"`
	Image string `json:"image"`
}

func (EventInstalledTrigger) Kind

type EventKind

type EventKind string

Make sure to keep changes to these enums in lockstep with EventKindMap

const (
	// The Any kind is a special event kind that denotes the caller wants to listen for any event.
	// It should not be used as a normal event type(for example do not publish anything with it).
	// It is internal only and not passed back on event streaming.
	EventKindAny EventKind = "ANY"

	EventKindCreatedNamespace EventKind = "CREATED_NAMESPACE"
	EventKindDeletedNamespace EventKind = "DELETED_NAMESPACE"

	EventKindDisabledPipeline EventKind = "DISABLED_PIPELINE"
	EventKindEnabledPipeline  EventKind = "ENABLED_PIPELINE"
	EventKindCreatedPipeline  EventKind = "CREATED_PIPELINE"
	EventKindDeletedPipeline  EventKind = "DELETED_PIPELINE"

	EventKindStartedRun   EventKind = "STARTED_RUN"
	EventKindCompletedRun EventKind = "COMPLETED_RUN"

	EventKindCreatedTaskRun   EventKind = "CREATED_TASKRUN"
	EventKindStartedTaskRun   EventKind = "STARTED_TASKRUN"
	EventKindCompletedTaskRun EventKind = "COMPLETED_TASKRUN"

	EventKindInstalledTrigger   EventKind = "INSTALLED_TRIGGER"
	EventKindUninstalledTrigger EventKind = "UNINSTALLED_TRIGGER"
	EventKindEnabledTrigger     EventKind = "ENABLED_TRIGGER"
	EventKindDisabledTrigger    EventKind = "DISABLED_TRIGGER"

	EventKindInstalledCommonTask   EventKind = "INSTALLED_COMMON_TASK"
	EventKindUninstalledCommonTask EventKind = "UNINSTALLED_COMMON_TASK"
	EventKindEnabledCommonTask     EventKind = "ENABLED_COMMON_TASK"
	EventKindDisabledCommonTask    EventKind = "DISABLED_COMMON_TASK"

	EventKindFiredTriggerEvent     EventKind = "FIRED_TRIGGER_EVENT"
	EventKindProcessedTriggerEvent EventKind = "PROCESSED_TRIGGER_EVENT"
	EventKindResolvedTriggerEvent  EventKind = "RESOLVED_TRIGGER_EVENT"

	EventKindExpiredRunObjects     EventKind = "EXPIRED_RUN_OBJECTS"
	EventKindEvictedPipelineObject EventKind = "EVICTED_PIPELINE_OBJECT"
)

type EventKindDetails

type EventKindDetails interface {
	Kind() EventKind
}

type EventProcessedTriggerEvent

type EventProcessedTriggerEvent struct {
	NamespaceID string `json:"namespace_id"`
	PipelineID  string `json:"pipeline_id"`
	Name        string `json:"name"`
	Label       string `json:"label"`
}

func (EventProcessedTriggerEvent) Kind

type EventResolvedTriggerEvent

type EventResolvedTriggerEvent struct {
	NamespaceID string            `json:"namespace_id"`
	PipelineID  string            `json:"pipeline_id"`
	Name        string            `json:"name"`
	Label       string            `json:"label"`
	Result      TriggerResult     `json:"result"`
	Metadata    map[string]string `json:"metadata"`
}

func (EventResolvedTriggerEvent) Kind

type EventStartedRun

type EventStartedRun struct {
	NamespaceID string `json:"namespace_id"`
	PipelineID  string `json:"pipeline_id"`
	RunID       int64  `json:"run_id"`
}

func (EventStartedRun) Kind

func (e EventStartedRun) Kind() EventKind

type EventStartedTaskRun

type EventStartedTaskRun struct {
	NamespaceID string `json:"namespace_id"`
	PipelineID  string `json:"pipeline_id"`
	RunID       int64  `json:"run_id"`
	TaskRunID   string `json:"task_run_id"`
}

func (EventStartedTaskRun) Kind

func (e EventStartedTaskRun) Kind() EventKind

type EventUninstalledCommonTask

type EventUninstalledCommonTask struct {
	Name string `json:"name"`
}

func (EventUninstalledCommonTask) Kind

type EventUninstalledTrigger

type EventUninstalledTrigger struct {
	Name  string `json:"name"`
	Image string `json:"image"`
}

func (EventUninstalledTrigger) Kind

type Namespace

type Namespace struct {
	ID          string `json:"id"`          // Unique identifier; user defined.
	Name        string `json:"name"`        // Humanized name; great for reading from UIs.
	Description string `json:"description"` // Short description on what namespace is used for.
	Created     int64  `json:"created"`     // The creation time in epoch milli.
	Modified    int64  `json:"modified"`    // The modified time in epoch milli;
}

Namespace represents a division of pipelines. Normally it is used to divide teams or logically different sections of workloads. It is the highest level unit.

func NewNamespace

func NewNamespace(id, name, description string) *Namespace

func (*Namespace) FromProto

func (n *Namespace) FromProto(proto *proto.Namespace)

func (*Namespace) ToProto

func (n *Namespace) ToProto() *proto.Namespace

type ObjectStoreKey

type ObjectStoreKey struct {
	Key     string `json:"key"`
	Created int64  `json:"created"`
}

func NewObjectStoreKey

func NewObjectStoreKey(key string) *ObjectStoreKey

func (*ObjectStoreKey) ToProto

func (s *ObjectStoreKey) ToProto() *proto.ObjectStoreKey

type Pipeline

type Pipeline struct {
	Namespace   string `json:"namespace"`   // The namespace this pipeline belongs to.
	ID          string `json:"id"`          // Unique identifier; user defined.
	Name        string `json:"name"`        // Name refers to a human readable pipeline name.
	Description string `json:"description"` // Description of pipeline's purpose and other details.
	/// Controls how many runs can be active at any single time. 0 indicates unbounded with respect to bounds
	/// enforced by Gofer.
	Parallelism int64 `json:"parallelism"`
	Created     int64 `json:"created"` // Time pipeline was created in epoch milliseconds.
	/// The current state of the pipeline. Pipelines can be disabled to stop execution of runs/tasks.
	Modified int64 `json:"modified"`
	// The current running state of the pipeline. This is used to determine if the pipeline should continue to process
	// runs or not and properly convey that to the user.
	State PipelineState `json:"state"`
	// Map for quickly finding user created pipeline tasks; assists with DAG generation.
	CustomTasks map[string]CustomTask `json:"custom_tasks"`
	// Map for quickly finding gofer provided pipeline tasks; assists with DAG generation.
	CommonTasks map[string]PipelineCommonTaskSettings `json:"common_tasks"`
	// Triggers is a listing of trigger labels to the their trigger subscription objects
	Triggers map[string]PipelineTriggerSettings `json:"triggers"`
	// There are certain things that might occur within a pipeline that the user will have to fix to restore full
	// functionality of the pipeline[^1]. Errors is a way to describe to the user which problems their pipeline might
	// have.
	//
	// [^1]: For example, if you turn off Gofer and it restores trigger connections but one trigger is not available anymore
	// Then we would use errors to message the user that this thing that was previously part of your pipeline will not
	// work anymore. These cases should be rare, but are important to get right.
	Errors []PipelineError `json:"errors"`
}

/ A collection of logically grouped tasks. A task is a unit of work wrapped in a docker container. / Pipeline is a secondary level unit being contained within namespaces and containing runs.

func NewPipeline

func NewPipeline(namespace string, pb *proto.PipelineConfig) *Pipeline

func (*Pipeline) FromProto

func (p *Pipeline) FromProto(proto *proto.Pipeline)

func (*Pipeline) ToProto

func (p *Pipeline) ToProto() *proto.Pipeline

type PipelineCommonTaskSettings

type PipelineCommonTaskSettings struct {
	Name string `json:"name"` // A global unique identifier for a specific type of common task.
	// A user defined identifier for the common_task so that a pipeline with multiple common_tasks can be differentiated.
	Label       string                          `json:"label"`
	Description string                          `json:"description"`
	DependsOn   map[string]RequiredParentStatus `json:"depends_on"`
	Settings    map[string]string               `json:"settings"`
}

func (*PipelineCommonTaskSettings) FromProto

func (*PipelineCommonTaskSettings) FromProtoCommonTaskConfig

func (t *PipelineCommonTaskSettings) FromProtoCommonTaskConfig(p *proto.CommonTaskConfig)

func (*PipelineCommonTaskSettings) ToProto

type PipelineError

type PipelineError struct {
	Kind        PipelineErrorKind
	Description string
}

func (*PipelineError) FromProto

func (p *PipelineError) FromProto(proto *proto.Pipeline_Error)

func (*PipelineError) ToProto

func (p *PipelineError) ToProto() *proto.Pipeline_Error

type PipelineErrorKind

type PipelineErrorKind string
const (
	PipelineErrorKindUnknown                    PipelineErrorKind = "UNKNOWN"
	PipelineErrorKindTriggerSubscriptionFailure PipelineErrorKind = "TRIGGER_SUBSCRIPTION_FAILURE"
)

type PipelineState

type PipelineState string
const (
	PipelineStateUnknown  PipelineState = "UNKNOWN"
	PipelineStateActive   PipelineState = "ACTIVE"
	PipelineStateDisabled PipelineState = "DISABLED"
)

type PipelineTriggerSettings

type PipelineTriggerSettings struct {
	Name string // A global unique identifier.
	// A user defined identifier for the trigger so that a pipeline with multiple triggers can be differentiated.
	Label    string
	Settings map[string]string
}

Every time a pipeline attempts to subscribe to a trigger, it passes certain values back to that trigger for certain functionality. Since triggers keep no permanent state, these settings are kept here so that when triggers are restarted they can be restored with proper settings.

func (*PipelineTriggerSettings) FromProto

func (*PipelineTriggerSettings) FromProtoTriggerConfig

func (t *PipelineTriggerSettings) FromProtoTriggerConfig(p *proto.PipelineTriggerConfig)

func (*PipelineTriggerSettings) ToProto

type RegistryAuth

type RegistryAuth struct {
	User string `json:"user"`
	Pass string `json:"pass"`
}

func (*RegistryAuth) FromProto

func (t *RegistryAuth) FromProto(pb *proto.RegistryAuth)

func (*RegistryAuth) ToProto

func (t *RegistryAuth) ToProto() *proto.RegistryAuth

type RequiredParentStatus

type RequiredParentStatus string
const (
	RequiredParentStatusUnknown RequiredParentStatus = "UNKNOWN"
	RequiredParentStatusAny     RequiredParentStatus = "ANY"
	RequiredParentStatusSuccess RequiredParentStatus = "SUCCESS"
	RequiredParentStatusFailure RequiredParentStatus = "FAILURE"
)

func (*RequiredParentStatus) FromStr

type Run

type Run struct {
	Namespace           string           `json:"namespace"`             // Unique ID of namespace.
	Pipeline            string           `json:"pipeline"`              // The unique ID of the related pipeline.
	ID                  int64            `json:"id"`                    // UniqueID of a run. Auto-incrementing and cannot be zero.
	Started             int64            `json:"started"`               // Time of run start in epoch milli.
	Ended               int64            `json:"ended"`                 // Time of run finish in epoch milli.
	State               RunState         `json:"state"`                 // The current state of the run.
	Status              RunStatus        `json:"status"`                // The current status of the run.
	StatusReason        *RunStatusReason `json:"status_reason"`         // Contains more information about a run's current status.
	TaskRuns            []string         `json:"task_runs"`             // The unique ID of each task run.
	Trigger             TriggerInfo      `json:"trigger"`               // Information about which trigger was responsible for the run's execution.
	Variables           []Variable       `json:"variables"`             // Environment variables to be injected into each child task run. These are usually injected by the trigger.
	StoreObjectsExpired bool             `json:"store_objects_expired"` // Tracks whether objects for this run have expired already.
}

A run is one or more tasks being executed on behalf of some trigger. Run is a third level unit containing tasks and being contained in a pipeline.

func NewRun

func NewRun(namespace, pipeline string, trigger TriggerInfo, variables []Variable) *Run

func (*Run) FromProto

func (r *Run) FromProto(proto *proto.Run)

func (*Run) ToProto

func (r *Run) ToProto() *proto.Run

type RunState

type RunState string
const (
	RunStateUnknown RunState = "UNKNOWN" // The state of the run is unknown.
	// Before the tasks in a run is sent to a scheduler it must complete various steps like
	// validation checking. This state represents that step where the run and task_runs are
	// pre-checked.
	RunStatePending  RunState = "PENDING"
	RunStateRunning  RunState = "RUNNING"  // Currently running.
	RunStateComplete RunState = "COMPLETE" // All tasks have been resolved and the run is no longer being executed.

)

type RunStatus

type RunStatus string
const (
	// Could not determine current state of the status. Should only be in this state if
	// the run has not yet completed.
	RunStatusUnknown    RunStatus = "UNKNOWN"
	RunStatusFailed     RunStatus = "FAILED"     // One or more tasks in run have failed.
	RunStatusSuccessful RunStatus = "SUCCESSFUL" // All tasks in run have completed with a non-failure state.
	RunStatusCancelled  RunStatus = "CANCELLED"  // One or more tasks in a run have been cancelled.
)

type RunStatusReason

type RunStatusReason struct {
	Reason      RunStatusReasonKind `json:"kind"`        // The specific type of run failure. Good for documentation about what it might be.
	Description string              `json:"description"` // The description of why the run might have failed.
}

func (*RunStatusReason) FromProto

func (r *RunStatusReason) FromProto(proto *proto.RunStatusReason)

func (*RunStatusReason) ToProto

func (r *RunStatusReason) ToProto() *proto.RunStatusReason

type RunStatusReasonKind

type RunStatusReasonKind string
const (
	// Gofer has no idea who the run got into this state.
	RunStatusReasonKindUnknown RunStatusReasonKind = "UNKNOWN"
	// While executing the run one or more tasks exited with an abnormal exit code.
	RunStatusReasonKindAbnormalExit RunStatusReasonKind = "ABNORMAL_EXIT"
	// While executing the run one or more tasks could not be scheduled.
	RunStatusReasonKindSchedulerError RunStatusReasonKind = "SCHEDULER_ERROR"
	// The run could not be executed as requested due to user defined attributes given.
	RunStatusReasonKindFailedPrecondition RunStatusReasonKind = "FAILED_PRECONDITION"
	// One or more tasks could not be completed due to a user cancelling the run.
	RunStatusReasonKindUserCancelled RunStatusReasonKind = "USER_CANCELLED"
	// One or more tasks could not be completed due to the system or admin cancelling the run.
	RunStatusReasonKindAdminCancelled RunStatusReasonKind = "ADMIN_CANCELLED"
)

type SecretStoreKey

type SecretStoreKey struct {
	Key     string `json:"key"`
	Created int64  `json:"created"`
}

func NewSecretStoreKey

func NewSecretStoreKey(key string) *SecretStoreKey

func (*SecretStoreKey) ToProto

func (s *SecretStoreKey) ToProto() *proto.SecretStoreKey

type Task

type Task interface {
	GetID() string
	GetDescription() string
	GetImage() string
	GetRegistryAuth() *RegistryAuth
	GetDependsOn() map[string]RequiredParentStatus
	GetVariables() []Variable
	GetEntrypoint() *[]string
	GetCommand() *[]string
	// contains filtered or unexported methods
}

A task represents a single unit of execution in Gofer. Tasks can be either Custom Tasks or Common Tasks which each have their own advantages and disadvantages.

type TaskKind

type TaskKind string

type TaskRun

type TaskRun struct {
	Namespace   string `json:"namespace"`    // Unique identifier for namespace.
	Pipeline    string `json:"pipeline"`     // Unique pipeline ID of task run.
	Run         int64  `json:"run"`          // Unique run ID of task run; sequential.
	ID          string `json:"id"`           // Unique ID for task run; taken from the taskID.
	Created     int64  `json:"created"`      // Time of task run creation in epoch milliseconds.
	Started     int64  `json:"started"`      // Time of task run actual start in epoch milliseconds.
	Ended       int64  `json:"ended"`        // Time of task run completion in epoch milliseconds.
	ExitCode    *int64 `json:"exit_code"`    // The exit code of the task run.
	LogsExpired bool   `json:"logs_expired"` // If the logs have past their retention time.
	// If the logs have been removed. This can be due to user request or automatic action based on expiry time.
	LogsRemoved  bool                 `json:"logs_removed"`
	State        TaskRunState         `json:"state"`
	Status       TaskRunStatus        `json:"status"`
	StatusReason *TaskRunStatusReason `json:"status_reason"` // Extra information about the current status.
	Variables    []Variable           `json:"variables"`     // The environment variables injected during this particular task run.
	Task         Task                 `json:"task"`          // Task information.
}

A task run is a specific execution of a task/container. It represents a 4th level unit in the hierarchy:

namespace -> pipeline -> run -> taskrun

func NewTaskRun

func NewTaskRun(namespace, pipeline string, run int64, task Task) *TaskRun

func (*TaskRun) FromProto

func (r *TaskRun) FromProto(pb *proto.TaskRun)

func (*TaskRun) ToProto

func (r *TaskRun) ToProto() *proto.TaskRun

type TaskRunState

type TaskRunState string
const (
	TaskRunStateUnknown    TaskRunState = "UNKNOWN"    // Unknown state, should never be in this state.
	TaskRunStateProcessing TaskRunState = "PROCESSING" // Pre-scheduling validation and prep.
	TaskRunStateWaiting    TaskRunState = "WAITING"    // Waiting to be scheduled.
	TaskRunStateRunning    TaskRunState = "RUNNING"    // Currently running as reported by scheduler.
	TaskRunStateComplete   TaskRunState = "COMPLETE"
)

type TaskRunStatus

type TaskRunStatus string
const (
	TaskRunStatusUnknown    TaskRunStatus = "UNKNOWN"
	TaskRunStatusFailed     TaskRunStatus = "FAILED"     // Has encountered an issue, either container issue or scheduling issue.
	TaskRunStatusSuccessful TaskRunStatus = "SUCCESSFUL" // Finished with a proper error code.
	TaskRunStatusCancelled  TaskRunStatus = "CANCELLED"  // Cancelled mid run due to user requested cancellation.
	TaskRunStatusSkipped    TaskRunStatus = "SKIPPED"    // Not run due to dependencies not being met.
)

type TaskRunStatusReason

type TaskRunStatusReason struct {
	Reason      TaskRunStatusReasonKind `json:"reason"`      // Specific type; useful for documentation.
	Description string                  `json:"description"` // Details about type.
}

func (*TaskRunStatusReason) FromProto

func (t *TaskRunStatusReason) FromProto(proto *proto.TaskRunStatusReason)

func (*TaskRunStatusReason) ToProto

type TaskRunStatusReasonKind

type TaskRunStatusReasonKind string
const (
	TaskRunStatusReasonKindUnknown            TaskRunStatusReasonKind = "UNKNOWN"             // Unknown state, should never be in this state.
	TaskRunStatusReasonKindAbnormalExit       TaskRunStatusReasonKind = "ABNORMAL_EXIT"       // A non-zero exit code has been received.
	TaskRunStatusReasonKindSchedulerError     TaskRunStatusReasonKind = "SCHEDULER_ERROR"     // Encountered an error with the backend scheduler.
	TaskRunStatusReasonKindFailedPrecondition TaskRunStatusReasonKind = "FAILED_PRECONDITION" // User error in task run parameters.
	TaskRunStatusReasonKindCancelled          TaskRunStatusReasonKind = "CANCELLED"           // User invoked cancellation.
	TaskRunStatusReasonKindOrphaned           TaskRunStatusReasonKind = "ORPHANED"            // Task run was lost due to extreme internal error.
)

type Token

type Token struct {
	Hash       string            `json:"hash"`       // SHA-256 hash of the secret ID.
	Created    int64             `json:"created"`    // Create time in epoch millisecond
	Kind       TokenKind         `json:"kind"`       // The type of token. Management tokens are essentially root.
	Namespaces []string          `json:"namespaces"` // List of namespaces this token has access to.
	Metadata   map[string]string `json:"metadata"`   // Extra information about this token in label form.
	Expires    int64             `json:"expiry"`     // When the token would expire.
	Disabled   bool              `json:"disabled"`   // Disabled tokens cannot be used.
}

Token is a representation of the API key, belonging to an owner.

func NewToken

func NewToken(hash string, kind TokenKind, namespaces []string, metadata map[string]string, expiry time.Duration) *Token

func (*Token) FromProto

func (t *Token) FromProto(proto *proto.Token)

func (*Token) ToProto

func (t *Token) ToProto() *proto.Token

type TokenKind

type TokenKind string
const (
	TokenKindUnknown    TokenKind = "UNKNOWN"
	TokenKindManagement TokenKind = "MANAGEMENT"
	TokenKindClient     TokenKind = "CLIENT"
)

type Trigger

type Trigger struct {
	Registration TriggerRegistration `json:"registration"`

	// URL is the network address used to communicate with the trigger by the main process.
	URL           string       `json:"url"`
	Started       int64        `json:"started"` // The start time of the trigger in epoch milliseconds.
	State         TriggerState `json:"state"`
	Documentation string       `json:"documentation"` // The documentation link for this specific trigger.
	// Key is a trigger's authentication key used to validate requests from the Gofer main service.
	// On every request the Gofer service passes this key so that it is impossible for other service to contact
	// and manipulate triggers directly.
	Key *string `json:"-"`
}

func (*Trigger) ToProto

func (t *Trigger) ToProto() *proto.Trigger

type TriggerInfo

type TriggerInfo struct {
	Name string // The trigger kind responsible for starting the run.
	// The trigger label responsible for starting the run. The label is a user chosen name
	// for the trigger to differentiate it from other pipeline triggers of the same kind.
	Label string
}

Information about which trigger was responsible for the run's execution.

func (*TriggerInfo) FromProto

func (t *TriggerInfo) FromProto(proto *proto.Run_RunTriggerInfo)

func (*TriggerInfo) ToProto

func (t *TriggerInfo) ToProto() *proto.Run_RunTriggerInfo

type TriggerRegistration

type TriggerRegistration struct {
	Name         string        `json:"name"`
	Image        string        `json:"image"`
	RegistryAuth *RegistryAuth `json:"registry_auth"`
	Variables    []Variable    `json:"variables"`
	Created      int64         `json:"created"`
	Status       TriggerStatus `json:"status"`
}

When installing a new trigger, we allow the trigger installer to pass a bunch of settings that allow us to go get that trigger on future startups.

func (*TriggerRegistration) FromInstallTriggerRequest

func (c *TriggerRegistration) FromInstallTriggerRequest(proto *proto.InstallTriggerRequest)

type TriggerResult

type TriggerResult struct {
	Details string              `json:"details"` // details about the trigger's current result.
	Status  TriggerResultStatus `json:"state"`
}

func (*TriggerResult) FromProto

func (t *TriggerResult) FromProto(p *proto.TriggerResult)

func (*TriggerResult) ToProto

func (t *TriggerResult) ToProto() *proto.TriggerResult

type TriggerResultStatus

type TriggerResultStatus string

TriggerResultState is a description of what has happened as a result of a 'trigger event' being resolved. Normally when a trigger fires, it passes down some information to the Gofer handler on how a pipeline might be executed. This execution detail might contain some extra information on why or, particularly, why not a trigger has fired and a pipeline should be run.

For example: A trigger that evaluates whether a pipeline should run on a specific date might also skip certain holidays. In this case it would pass down an "skipped" event result to inform the user that their pipeline would have ran, but did not due to holiday.

Footnote: In this example, it is somewhat arguable that an event should not have happened in the first place. but the counter-argument would be that we can conceive of a world where a user might want to understand WHY a trigger did not go off for a particular date and the difference between the trigger just not understanding that it *should have* executed vs the trigger **intentionally** skipping that date.

const (
	TriggerResultStateUnknown TriggerResultStatus = "UNKNOWN" // Event did not have a result; should never be in this state.
	TriggerResultStateSuccess TriggerResultStatus = "SUCCESS" // Trigger evaluation was successful.
	TriggerResultStateFailure TriggerResultStatus = "FAILURE" // Trigger evaluation was not successful.
	TriggerResultStateSkipped TriggerResultStatus = "SKIPPED" // Trigger evaluation was skipped
)

type TriggerState

type TriggerState string
const (
	TriggerStateUnknown    TriggerState = "UNKNOWN"    // Unknown state, can be in this state because of an error.
	TriggerStateProcessing TriggerState = "PROCESSING" // Pre-scheduling validation and prep.
	TriggerStateRunning    TriggerState = "RUNNING"    // Currently running as reported by scheduler.
	TriggerStateExited     TriggerState = "EXITED"     // Trigger has exited; usually because of an error.
)

type TriggerStatus

type TriggerStatus string
const (
	TriggerStatusUnknown TriggerStatus = "UNKNOWN" // Cannot determine status of Trigger, should never be in this status.
	TriggerStatusEnabled TriggerStatus = "ENABLED" // Installed and able to be used by pipelines.
	/// Not available to be used by pipelines, either through lack of installation or
	/// being disabled by an admin.
	TriggerStatusDisabled TriggerStatus = "DISABLED"
)

type Variable

type Variable struct {
	Key    string         `json:"key"`
	Value  string         `json:"value"`
	Source VariableSource `json:"source"` // Where the variable originated from
}

A variable is a key value pair that is used either in a run or task level. The variable is inserted as an environment variable to an eventual task run. It can be owned by different parts of the system which control where the potentially sensitive variables might show up.

func (*Variable) FromProto

func (v *Variable) FromProto(proto *proto.Variable)

func (*Variable) ToProto

func (v *Variable) ToProto() *proto.Variable

type VariableSource

type VariableSource string
const (
	VariableSourceUnknown        VariableSource = "UNKNOWN"
	VariableSourcePipelineConfig VariableSource = "PIPELINE_CONFIG"
	VariableSourceSystem         VariableSource = "SYSTEM"
	VariableSourceRunOptions     VariableSource = "RUN_OPTIONS"
	VariableSourceTrigger        VariableSource = "TRIGGER"
)

Jump to

Keyboard shortcuts

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