api

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: GPL-3.0 Imports: 49 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>
	ExtensionContainerIDFmt = "extension_%s"     // extension_<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")

	// ErrNoValidConfiguration is returned there is no pipeline configuration that is avaiable for use.
	ErrNoValidConfiguration = errors.New("api: there was no valid, live pipeline configuration found")

	// ErrExtensionNotFound is returned when a pipeline configuration contains a extension that was not registered with the API.
	ErrExtensionNotFound = errors.New("api: extension 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 extensions.

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) AttachToTaskRun added in v0.6.0

func (api *API) AttachToTaskRun(stream proto.Gofer_AttachToTaskRunServer) error

func (*API) BootstrapToken

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) CreatePipelineExtensionSubscription added in v0.5.0

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) DeletePipelineConfig added in v0.5.0

func (api *API) DeletePipelineConfig(ctx context.Context, request *proto.DeletePipelineConfigRequest) (
	*proto.DeletePipelineConfigResponse, error,
)

func (*API) DeletePipelineExtensionSubscription added in v0.5.0

func (api *API) DeletePipelineExtensionSubscription(ctx context.Context, request *proto.DeletePipelineExtensionSubscriptionRequest) (
	*proto.DeletePipelineExtensionSubscriptionResponse, 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) DeployPipeline added in v0.5.0

func (api *API) DeployPipeline(ctx context.Context, request *proto.DeployPipelineRequest) (*proto.DeployPipelineResponse, error)

func (*API) DisableExtension added in v0.5.0

func (api *API) DisableExtension(ctx context.Context, request *proto.DisableExtensionRequest) (*proto.DisableExtensionResponse, error)

func (*API) DisablePipeline

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

func (*API) DisablePipelineExtensionSubscription added in v0.5.0

func (api *API) DisablePipelineExtensionSubscription(ctx context.Context, request *proto.DisablePipelineExtensionSubscriptionRequest) (
	*proto.DisablePipelineExtensionSubscriptionResponse, error,
)

func (*API) DisableToken added in v0.3.0

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

func (*API) EnableExtension added in v0.5.0

func (api *API) EnableExtension(ctx context.Context, request *proto.EnableExtensionRequest) (*proto.EnableExtensionResponse, error)

func (*API) EnablePipeline

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

func (*API) EnablePipelineExtensionSubscription added in v0.5.0

func (api *API) EnablePipelineExtensionSubscription(ctx context.Context, request *proto.EnablePipelineExtensionSubscriptionRequest) (
	*proto.EnablePipelineExtensionSubscriptionResponse, error,
)

func (*API) EnableToken added in v0.3.0

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

func (*API) GetDeployment added in v0.5.0

func (api *API) GetDeployment(ctx context.Context, request *proto.GetDeploymentRequest) (*proto.GetDeploymentResponse, error)

func (*API) GetEvent added in v0.1.0

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

func (*API) GetExtension added in v0.5.0

func (api *API) GetExtension(_ context.Context, request *proto.GetExtensionRequest) (*proto.GetExtensionResponse, 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(_ 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) GetPipelineConfig added in v0.5.0

func (api *API) GetPipelineConfig(ctx context.Context, request *proto.GetPipelineConfigRequest) (
	*proto.GetPipelineConfigResponse, error,
)

func (*API) GetPipelineExtensionSubscription added in v0.5.0

func (api *API) GetPipelineExtensionSubscription(ctx context.Context, request *proto.GetPipelineExtensionSubscriptionRequest) (
	*proto.GetPipelineExtensionSubscriptionResponse, 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

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(_ context.Context, request *proto.GetTokenRequest) (*proto.GetTokenResponse, error)

func (*API) InstallExtension added in v0.5.0

func (api *API) InstallExtension(ctx context.Context, request *proto.InstallExtensionRequest) (*proto.InstallExtensionResponse, error)

func (*API) ListDeployments added in v0.5.0

func (api *API) ListDeployments(ctx context.Context, request *proto.ListDeploymentsRequest) (*proto.ListDeploymentsResponse, error)

func (*API) ListEvents added in v0.1.0

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

func (*API) ListExtensions added in v0.5.0

func (*API) ListGlobalSecrets added in v0.3.0

func (*API) ListNamespaces

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

func (*API) ListPipelineConfigs added in v0.5.0

func (api *API) ListPipelineConfigs(ctx context.Context, request *proto.ListPipelineConfigsRequest) (
	*proto.ListPipelineConfigsResponse, error,
)

func (*API) ListPipelineExtensionSubscriptions added in v0.5.0

func (api *API) ListPipelineExtensionSubscriptions(ctx context.Context, request *proto.ListPipelineExtensionSubscriptionsRequest) (
	*proto.ListPipelineExtensionSubscriptionsResponse, 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) 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) RegisterPipelineConfig added in v0.5.0

func (api *API) RegisterPipelineConfig(ctx context.Context, request *proto.RegisterPipelineConfigRequest) (*proto.RegisterPipelineConfigResponse, 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) RunExtensionInstaller added in v0.6.0

func (api *API) RunExtensionInstaller(stream proto.Gofer_RunExtensionInstallerServer) error

func (*API) RunPipelineConfigurator added in v0.6.0

func (api *API) RunPipelineConfigurator(stream proto.Gofer_RunPipelineConfiguratorServer) 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) UninstallExtension added in v0.5.0

func (api *API) UninstallExtension(ctx context.Context, request *proto.UninstallExtensionRequest) (*proto.UninstallExtensionResponse, error)

func (*API) UpdateNamespace

func (api *API) UpdateNamespace(ctx context.Context, request *proto.UpdateNamespaceRequest) (*proto.UpdateNamespaceResponse, 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.PipelineMetadata
	Config   *models.PipelineConfig
	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