api

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: 44 Imported by: 0

Documentation

Overview

Package api controls the bulk of the Gofer API logic.

Index

Constants

View Source
const (
	ObjectPipelineKeyFmt    = "%s_%s_%s"         // <namespaceid>_<pipelineid>_<key>
	ObjectRunKeyFmt         = "%s_%s_%d_%s"      // <namespaceid>_<pipelineid>_<runid>_<key>
	GlobalSecretKeyFmt      = "global_secret_%s" // global_secret<key>
	PipelineSecretKeyFmt    = "%s_%s_%s"         // <namespaceid>_<pipelineid>_<key>
	TaskContainerIDFmt      = "%s_%s_%d_%s"      // <namespaceid>_<pipelineid>_<runid>_<taskrunid>
	TriggerContainerIDFmt   = "trigger_%s"       // trigger_<name>
	InstallerContainerIDFmt = "installer_%s"     // installer_<randomly-generated-value>
	TaskRunFilePath         = "%s/%s_%s_%d_%s"   // folder/<namespaceid>_<pipelineid>_<runid>_<taskrunid>
)
View Source
const (
	// GOFEREOF is a special string marker we include at the end of log files.
	// It denotes that no further logs will be written. This is to provide the functionality for downstream
	// applications to follow log files and not also have to monitor the container for state to know when
	// logs will no longer be printed.
	GOFEREOF string = "GOFER_EOF"
)

Variables

View Source
var (
	// ErrPipelineNotActive is returned when a request is made against a pipeline that is not in the active state.
	ErrPipelineNotActive = errors.New("api: pipeline is not in state 'active'")

	// ErrPipelineActive is returned when a request is made against a pipeline in the active state.
	ErrPipelineActive = errors.New("api: pipeline is in state 'active'")

	// ErrPipelineRunsInProgress is returned when a request is made against a pipeline with currently in progress runs.
	ErrPipelineRunsInProgress = errors.New("api: pipeline has runs which are still in progress")

	// ErrPipelineConfigNotValid is returned when a pipeline configuration contains is not valid for the trigger requested.
	ErrPipelineConfigNotValid = errors.New("api: pipeline configuration is invalid")

	// ErrTriggerNotFound is returned when a pipeline configuration contains a trigger that was not registered with the API.
	ErrTriggerNotFound = errors.New("api: trigger is not found")
)

Functions

func StartExternalEventsService added in v0.1.0

func StartExternalEventsService(config *config.API, api *API)

StartExternalEventsService starts the external events http service, which is used to pass external events (like a github webhook) to triggers.

Types

type API

type API struct {

	// We opt out of forward compatibility with this embedded interface. This is required by GRPC.
	//
	// We don't embed the "proto.UnimplementedGoferServer" as there should never(I assume this will come back to bite me)
	// be an instance where we add proto methods without also updating the server to support those methods.
	// There is the added benefit that without it embedded we get compile time errors when a function isn't correctly
	// implemented. Saving us from weird "Unimplemented" RPC bugs.
	proto.UnsafeGoferServer
	// contains filtered or unexported fields
}

API represents the main Gofer service API. It is run using a GRPC/HTTP combined server. This main API handles 99% of interactions with the gofer service itself and is only missing the hooks for the gofer events service.

func NewAPI

func NewAPI(config *config.API, storage storage.DB, scheduler scheduler.Engine, objectStore objectStore.Engine,
	secretStore secretStore.Engine,
) (*API, error)

NewAPI creates a new instance of the main Gofer API service.

func (*API) BootstrapToken

func (api *API) BootstrapToken(ctx context.Context, request *proto.BootstrapTokenRequest) (*proto.BootstrapTokenResponse, error)

func (*API) CancelAllRuns

func (api *API) CancelAllRuns(ctx context.Context, request *proto.CancelAllRunsRequest) (*proto.CancelAllRunsResponse, error)

func (*API) CancelRun

func (api *API) CancelRun(ctx context.Context, request *proto.CancelRunRequest) (*proto.CancelRunResponse, error)

func (*API) CancelTaskRun

func (api *API) CancelTaskRun(ctx context.Context, request *proto.CancelTaskRunRequest) (*proto.CancelTaskRunResponse, error)

func (*API) CreateNamespace

func (api *API) CreateNamespace(ctx context.Context, request *proto.CreateNamespaceRequest) (*proto.CreateNamespaceResponse, error)

func (*API) CreatePipeline added in v0.3.0

func (api *API) CreatePipeline(ctx context.Context, request *proto.CreatePipelineRequest) (*proto.CreatePipelineResponse, error)

func (*API) CreateToken

func (api *API) CreateToken(ctx context.Context, request *proto.CreateTokenRequest) (*proto.CreateTokenResponse, error)

func (*API) DeleteGlobalSecret added in v0.3.0

func (api *API) DeleteGlobalSecret(ctx context.Context, request *proto.DeleteGlobalSecretRequest) (*proto.DeleteGlobalSecretResponse, error)

func (*API) DeleteNamespace

func (api *API) DeleteNamespace(ctx context.Context, request *proto.DeleteNamespaceRequest) (*proto.DeleteNamespaceResponse, error)

func (*API) DeletePipeline added in v0.3.0

func (api *API) DeletePipeline(ctx context.Context, request *proto.DeletePipelineRequest) (*proto.DeletePipelineResponse, error)

func (*API) DeletePipelineObject

func (api *API) DeletePipelineObject(ctx context.Context, request *proto.DeletePipelineObjectRequest) (*proto.DeletePipelineObjectResponse, error)

func (*API) DeletePipelineSecret added in v0.3.0

func (api *API) DeletePipelineSecret(ctx context.Context, request *proto.DeletePipelineSecretRequest) (*proto.DeletePipelineSecretResponse, error)

func (*API) DeleteRunObject

func (api *API) DeleteRunObject(ctx context.Context, request *proto.DeleteRunObjectRequest) (*proto.DeleteRunObjectResponse, error)

func (*API) DeleteTaskRunLogs

func (api *API) DeleteTaskRunLogs(ctx context.Context, request *proto.DeleteTaskRunLogsRequest) (*proto.DeleteTaskRunLogsResponse, error)

func (*API) DeleteToken

func (api *API) DeleteToken(ctx context.Context, request *proto.DeleteTokenRequest) (*proto.DeleteTokenResponse, error)

func (*API) DisableCommonTask added in v0.3.0

func (api *API) DisableCommonTask(ctx context.Context, request *proto.DisableCommonTaskRequest) (*proto.DisableCommonTaskResponse, error)

func (*API) DisablePipeline

func (api *API) DisablePipeline(ctx context.Context, request *proto.DisablePipelineRequest) (*proto.DisablePipelineResponse, error)

func (*API) DisableToken added in v0.3.0

func (api *API) DisableToken(ctx context.Context, request *proto.DisableTokenRequest) (*proto.DisableTokenResponse, error)

func (*API) DisableTrigger added in v0.3.0

func (api *API) DisableTrigger(ctx context.Context, request *proto.DisableTriggerRequest) (*proto.DisableTriggerResponse, error)

func (*API) EnableCommonTask added in v0.3.0

func (api *API) EnableCommonTask(ctx context.Context, request *proto.EnableCommonTaskRequest) (*proto.EnableCommonTaskResponse, error)

func (*API) EnablePipeline

func (api *API) EnablePipeline(ctx context.Context, request *proto.EnablePipelineRequest) (*proto.EnablePipelineResponse, error)

func (*API) EnableToken added in v0.3.0

func (api *API) EnableToken(ctx context.Context, request *proto.EnableTokenRequest) (*proto.EnableTokenResponse, error)

func (*API) EnableTrigger added in v0.3.0

func (api *API) EnableTrigger(ctx context.Context, request *proto.EnableTriggerRequest) (*proto.EnableTriggerResponse, error)

func (*API) GetCommonTask added in v0.3.0

func (api *API) GetCommonTask(ctx context.Context, request *proto.GetCommonTaskRequest) (*proto.GetCommonTaskResponse, error)

func (*API) GetCommonTaskInstallInstructions added in v0.3.0

func (*API) GetEvent added in v0.1.0

func (api *API) GetEvent(ctx context.Context, request *proto.GetEventRequest) (*proto.GetEventResponse, error)

func (*API) GetGlobalSecret added in v0.3.0

func (api *API) GetGlobalSecret(ctx context.Context, request *proto.GetGlobalSecretRequest) (*proto.GetGlobalSecretResponse, error)

func (*API) GetNamespace

func (api *API) GetNamespace(ctx context.Context, request *proto.GetNamespaceRequest) (*proto.GetNamespaceResponse, error)

func (*API) GetPipeline

func (api *API) GetPipeline(ctx context.Context, request *proto.GetPipelineRequest) (*proto.GetPipelineResponse, error)

func (*API) GetPipelineObject

func (api *API) GetPipelineObject(ctx context.Context, request *proto.GetPipelineObjectRequest) (*proto.GetPipelineObjectResponse, error)

func (*API) GetPipelineSecret added in v0.3.0

func (api *API) GetPipelineSecret(ctx context.Context, request *proto.GetPipelineSecretRequest) (*proto.GetPipelineSecretResponse, error)

func (*API) GetRun

func (api *API) GetRun(ctx context.Context, request *proto.GetRunRequest) (*proto.GetRunResponse, error)

func (*API) GetRunObject

func (api *API) GetRunObject(ctx context.Context, request *proto.GetRunObjectRequest) (*proto.GetRunObjectResponse, error)

func (*API) GetSystemInfo

func (api *API) GetSystemInfo(context context.Context, request *proto.GetSystemInfoRequest) (*proto.GetSystemInfoResponse, error)

GetSystemInfo returns system information and health

func (*API) GetTaskRun

func (api *API) GetTaskRun(ctx context.Context, request *proto.GetTaskRunRequest) (*proto.GetTaskRunResponse, error)

func (*API) GetTaskRunLogs

func (api *API) GetTaskRunLogs(request *proto.GetTaskRunLogsRequest, stream proto.Gofer_GetTaskRunLogsServer) error

func (*API) GetToken

func (api *API) GetToken(ctx context.Context, request *proto.GetTokenRequest) (*proto.GetTokenResponse, error)

func (*API) GetTrigger

func (api *API) GetTrigger(ctx context.Context, request *proto.GetTriggerRequest) (*proto.GetTriggerResponse, error)

func (*API) GetTriggerInstallInstructions added in v0.3.0

func (api *API) GetTriggerInstallInstructions(ctx context.Context, request *proto.GetTriggerInstallInstructionsRequest) (*proto.GetTriggerInstallInstructionsResponse, error)

func (*API) InstallCommonTask added in v0.3.0

func (api *API) InstallCommonTask(ctx context.Context, request *proto.InstallCommonTaskRequest) (*proto.InstallCommonTaskResponse, error)

func (*API) InstallTrigger added in v0.3.0

func (api *API) InstallTrigger(ctx context.Context, request *proto.InstallTriggerRequest) (*proto.InstallTriggerResponse, error)

func (*API) ListCommonTasks added in v0.3.0

func (api *API) ListCommonTasks(ctx context.Context, request *proto.ListCommonTasksRequest) (*proto.ListCommonTasksResponse, error)

func (*API) ListEvents added in v0.1.0

func (api *API) ListEvents(request *proto.ListEventsRequest, stream proto.Gofer_ListEventsServer) error

func (*API) ListGlobalSecrets added in v0.3.0

func (api *API) ListGlobalSecrets(ctx context.Context, request *proto.ListGlobalSecretsRequest) (*proto.ListGlobalSecretsResponse, error)

func (*API) ListNamespaces

func (api *API) ListNamespaces(ctx context.Context, request *proto.ListNamespacesRequest) (*proto.ListNamespacesResponse, error)

func (*API) ListPipelineObjects added in v0.3.0

func (api *API) ListPipelineObjects(ctx context.Context, request *proto.ListPipelineObjectsRequest) (*proto.ListPipelineObjectsResponse, error)

func (*API) ListPipelineSecrets added in v0.3.0

func (api *API) ListPipelineSecrets(ctx context.Context, request *proto.ListPipelineSecretsRequest) (*proto.ListPipelineSecretsResponse, error)

func (*API) ListPipelines

func (api *API) ListPipelines(ctx context.Context, request *proto.ListPipelinesRequest) (*proto.ListPipelinesResponse, error)

func (*API) ListRunObjects added in v0.3.0

func (api *API) ListRunObjects(ctx context.Context, request *proto.ListRunObjectsRequest) (*proto.ListRunObjectsResponse, error)

func (*API) ListRuns

func (api *API) ListRuns(ctx context.Context, request *proto.ListRunsRequest) (*proto.ListRunsResponse, error)

func (*API) ListTaskRuns

func (api *API) ListTaskRuns(ctx context.Context, request *proto.ListTaskRunsRequest) (*proto.ListTaskRunsResponse, error)

func (*API) ListTokens added in v0.3.0

func (api *API) ListTokens(ctx context.Context, request *proto.ListTokensRequest) (*proto.ListTokensResponse, error)

func (*API) ListTriggers

func (api *API) ListTriggers(ctx context.Context, request *proto.ListTriggersRequest) (*proto.ListTriggersResponse, error)

func (*API) PutGlobalSecret added in v0.3.0

func (api *API) PutGlobalSecret(ctx context.Context, request *proto.PutGlobalSecretRequest) (*proto.PutGlobalSecretResponse, error)

func (*API) PutPipelineObject

func (api *API) PutPipelineObject(ctx context.Context, request *proto.PutPipelineObjectRequest) (*proto.PutPipelineObjectResponse, error)

func (*API) PutPipelineSecret added in v0.3.0

func (api *API) PutPipelineSecret(ctx context.Context, request *proto.PutPipelineSecretRequest) (*proto.PutPipelineSecretResponse, error)

func (*API) PutRunObject

func (api *API) PutRunObject(ctx context.Context, request *proto.PutRunObjectRequest) (*proto.PutRunObjectResponse, error)

func (*API) RepairOrphan

func (api *API) RepairOrphan(ctx context.Context, request *proto.RepairOrphanRequest) (*proto.RepairOrphanResponse, error)

func (*API) RetryRun

func (api *API) RetryRun(ctx context.Context, request *proto.RetryRunRequest) (*proto.RetryRunResponse, error)

func (*API) StartAPIService

func (api *API) StartAPIService()

StartAPIService starts the Gofer API service and blocks until a SIGINT or SIGTERM is received.

func (*API) StartRun

func (api *API) StartRun(ctx context.Context, request *proto.StartRunRequest) (*proto.StartRunResponse, error)

func (*API) ToggleEventIngress

func (api *API) ToggleEventIngress(ctx context.Context, request *proto.ToggleEventIngressRequest) (*proto.ToggleEventIngressResponse, error)

func (*API) UninstallCommonTask added in v0.3.0

func (api *API) UninstallCommonTask(ctx context.Context, request *proto.UninstallCommonTaskRequest) (*proto.UninstallCommonTaskResponse, error)

func (*API) UninstallTrigger added in v0.3.0

func (api *API) UninstallTrigger(ctx context.Context, request *proto.UninstallTriggerRequest) (*proto.UninstallTriggerResponse, error)

func (*API) UpdateNamespace

func (api *API) UpdateNamespace(ctx context.Context, request *proto.UpdateNamespaceRequest) (*proto.UpdateNamespaceResponse, error)

func (*API) UpdatePipeline added in v0.3.0

func (api *API) UpdatePipeline(ctx context.Context, request *proto.UpdatePipelineRequest) (*proto.UpdatePipelineResponse, error)

type CancelContext

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

type InterpolationKind added in v0.3.0

type InterpolationKind string
const (
	InterpolationKindUnknown        InterpolationKind = "UNKNOWN"
	InterpolationKindPipelineSecret InterpolationKind = "PIPELINE_SECRET"
	InterpolationKindGlobalSecret   InterpolationKind = "GLOBAL_SECRET"
	InterpolationKindPipelineObject InterpolationKind = "PIPELINE_OBJECT"
	InterpolationKindRunObject      InterpolationKind = "RUN_OBJECT"
)

type RunStateMachine added in v0.3.0

type RunStateMachine struct {
	API      *API
	Pipeline *models.Pipeline
	Run      *models.Run
	TaskRuns syncmap.Syncmap[string, models.TaskRun]
	StopRuns *atomic.Bool // Used to stop the progression of a run
}

Used to keep track of a run as it progresses through the necessary states.

Jump to

Keyboard shortcuts

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