core

package
v0.2.1-0...-9c16218 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeEphemeral  = "EPHEMERAL"
	TypePersistent = "PERSISTENT"
)

Variables

View Source
var (
	// ErrNotAuthenticated is returned when authentication is required but not supplied.
	ErrNotAuthenticated = errors.New("not authenticated")
)

Functions

func OptBuiltAt

func OptBuiltAt(t time.Time) func(*Core) error

OptBuiltAt sets the time the core was built at to t.

func OptCompilerOverride

func OptCompilerOverride(s string) func(*Core) error

OptCompilerOverride overrides the compiler. This is not normally required, but can be useful during testing to ensure predictable build info.

func OptGitCommit

func OptGitCommit(gitCommit string) func(*Core) error

OptGitCommit sets the git commit to s.

func OptGitTreeState

func OptGitTreeState(gitTreeState string) func(*Core) error

OptGitTreeState sets the git tree state to s.

func OptGitVersion

func OptGitVersion(gitVersion semver.Version) func(*Core) error

OptGitVersion sets the core version to v.

func OptGoVersionOverride

func OptGoVersionOverride(s string) func(*Core) error

OptGoVersionOverride overrides the Go version. This is not normally required, but can be useful during testing to ensure predictable build info.

func OptPlatformOverride

func OptPlatformOverride(s string) func(*Core) error

OptPlatformOverride overrides the platform. This is not normally required, but can be useful during testing to ensure predictable build info.

Types

type AuthMetadata

type AuthMetadata struct {
	Issuer                                    string   `json:"issuer"`
	AuthorizationEndpoint                     string   `json:"authorization_endpoint"`
	TokenEndpoint                             string   `json:"token_endpoint"`
	JWKSURI                                   string   `json:"jwks_uri"`
	RegistrationEndpoint                      string   `json:"registration_endpoint"`
	ScopesSupported                           []string `json:"scopes_supported"`
	ResponseTypesSupported                    []string `json:"response_types_supported"`
	ResponseModesSupported                    []string `json:"response_modes_supported"`
	GrantTypesSupported                       []string `json:"grant_types_supported"`
	TokenEndpointAuthMethodsSupported         []string `json:"token_endpoint_auth_methods_supported"`
	RevocationEndpoint                        string   `json:"revocation_endpoint"`
	RevocationEndpointAuthMethodsSupported    []string `json:"revocation_endpoint_auth_methods_supported"`
	IntrospectionEndpoint                     string   `json:"introspection_endpoint"`
	IntrospectionEndpointAuthMethodsSupported []string `json:"introspection_endpoint_auth_methods_supported"`
	CodeChallengeMethodsSupported             []string `json:"code_challenge_methods_supported"`
}

AuthMetadata contains metadata as defined in the OAuth 2.0 Authorization Server Metadata proposed standard (RFC 8414).

type BuildInfo

type BuildInfo struct {
	GitVersion   *semver.Version
	GitCommit    *string
	GitTreeState *string
	BuiltAt      *time.Time
	GoVersion    string
	Compiler     string
	Platform     string
}

BuildInfo contains build information about the core.

type Core

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

Core represents core business logic.

func New

func New(p Persister, f IOFetcher, s Scheduler, options ...func(*Core) error) (*Core, error)

New creates a new core.

func (*Core) CreateWorkflow

func (c *Core) CreateWorkflow(ctx context.Context, s WorkflowSpec) (Workflow, error)

CreateWorkflow creates a new workflow. If an ID is provided in w, it is ignored and replaced with a unique identifier in the returned workflow.

func (*Core) DeleteWorkflow

func (c *Core) DeleteWorkflow(ctx context.Context, id string) (Workflow, error)

DeleteWorkflow deletes a workflow by ID. If the supplied ID is not valid, or there there is not a workflow with a matching ID in the database, an error is returned.

func (*Core) GetBuildInfo

func (c *Core) GetBuildInfo(ctx context.Context) (BuildInfo, error)

GetBuildInfo returns build information about the core.

func (*Core) GetWorkflow

func (c *Core) GetWorkflow(ctx context.Context, id string) (Workflow, error)

GetWorkflow retrieves a workflow by ID. If the supplied ID is not valid, or there there is not a workflow with a matching ID in the database, an error is returned.

func (*Core) Viewer

func (c *Core) Viewer(ctx context.Context) (User, error)

Viewer returns the user associated with ctx.

type IOFetcher

type IOFetcher interface {
	JobOutputFetcher
}

IOFetcher is the interface where IO data is retrieved.

type Job

type Job struct {
	ID         string              `bson:"_id,omitempty"`
	CreatedAt  time.Time           `bson:"createdAt"`
	StartedAt  *time.Time          `bson:"startedAt,omitempty"`
	FinishedAt *time.Time          `bson:"finishedAt,omitempty"`
	WorkflowID string              `bson:"workflowID"`
	Name       string              `bson:"name"`
	Image      string              `bson:"image"`
	Command    []string            `bson:"command"`
	Status     string              `bson:"status"`
	ExitCode   *int                `bson:"exitCode,omitempty"`
	Requires   []string            `bson:"requires"`
	Volumes    []VolumeRequirement `bson:"volumes"`
	// contains filtered or unexported fields
}

Job contains information about an indivisual job.

func (Job) CreatedBy

func (j Job) CreatedBy(ctx context.Context) (User, error)

CreatedBy retrieves the user that created job j.

func (Job) GetOutput

func (j Job) GetOutput() (string, error)

GetOutput retrieves the output of the job.

func (Job) RequiredJobsPage

func (j Job) RequiredJobsPage(ctx context.Context, pa PageArgs) (JobsPage, error)

RequiredJobsPage retrieves a page of jobs required by job j.

type JobOutputFetcher

type JobOutputFetcher interface {
	GetJobOutput(string) (string, error)
}

JobOutputFetcher is the interface to fetch job output.

type JobPersister

type JobPersister interface {
	CreateJob(context.Context, Job) (Job, error)
	DeleteJobsByWorkflowID(context.Context, string) error
	GetJobs(context.Context, PageArgs) (JobsPage, error)
	GetJobsByWorkflowID(context.Context, PageArgs, string) (JobsPage, error)
	GetJobsByID(context.Context, PageArgs, string, []string) (JobsPage, error)
}

JobPersister is the interface by which jobs are persisted.

type JobsPage

type JobsPage struct {
	Jobs       []Job    // Slice of results.
	PageInfo   PageInfo // Information to aid in pagination.
	TotalCount int      // Identifies the total count of items in the connection.
}

JobsPage represents a page of jobs resulting from a query, and associated metadata.

type PageArgs

type PageArgs struct {
	After  *string // Select elements in the list that come after the specified cursor.
	Before *string // Select elements in the list that come before the specified cursor.
	First  *int    // Select the first n elements from the list.
	Last   *int    // Select the last n elements from the list.
}

PageArgs contains criteria to select a page of results.

type PageInfo

type PageInfo struct {
	StartCursor     *string // When paginating backwards, the cursor to continue.
	EndCursor       *string // When paginating forwards, the cursor to continue.
	HasNextPage     bool    // When paginating forwards, are there more items?
	HasPreviousPage bool    // When paginating backwards, are there more items?
}

PageInfo contains information to aid in pagination.

type Persister

type Persister interface {
	WorkflowPersister
	JobPersister
	VolumePersister
}

Persister is the interface by which all data is persisted.

type Scheduler

type Scheduler interface {
	AddWorkflow(context.Context, Workflow, []Job, map[string]Volume) error
}

Scheduler is the interface by which all workflows are scheduled.

type User

type User struct {
	ID    string `bson:"_id,omitempty"` // Unique user ID.
	Login string `bson:"login"`         // The username used to login.
	// contains filtered or unexported fields
}

User represents a user.

func (User) JobsPage

func (u User) JobsPage(ctx context.Context, pa PageArgs) (JobsPage, error)

JobsPage retrieves a page of jobs created by user u.

func (User) VolumesPage

func (u User) VolumesPage(ctx context.Context, pa PageArgs) (VolumesPage, error)

VolumesPage retrieves a page of volumes created by user u.

func (User) WorkflowsPage

func (u User) WorkflowsPage(ctx context.Context, pa PageArgs) (WorkflowsPage, error)

WorkflowsPage retrieves a page of workflows created by user u.

type Volume

type Volume struct {
	ID         string     `bson:"_id,omitempty"`
	CreatedAt  time.Time  `bson:"createdAt"`
	WorkflowID string     `bson:"workflowID"`
	Name       string     `bson:"name"`
	Type       VolumeType `bson:"type"`
	// contains filtered or unexported fields
}

Volume describes a storage volume.

type VolumePersister

type VolumePersister interface {
	CreateVolume(context.Context, Volume) (Volume, error)
	DeleteVolumesByWorkflowID(context.Context, string) error
	GetVolumes(context.Context, PageArgs) (VolumesPage, error)
	GetVolumesByWorkflowID(context.Context, PageArgs, string) (VolumesPage, error)
}

VolumePersister is the interface by which workflows are persisted.

type VolumeRequirement

type VolumeRequirement struct {
	VolumeID string `bson:"volumeID"`
	Name     string `bson:"name"`
	Location string `bson:"location"`
}

VolumeRequirement describes a required volume.

type VolumeType

type VolumeType string

func (VolumeType) String

func (v VolumeType) String() string

func (VolumeType) Valid

func (v VolumeType) Valid() bool

Valid ensures that a volume type

type VolumesPage

type VolumesPage struct {
	Volumes    []Volume // Slice of results.
	PageInfo   PageInfo // Information to aid in pagination.
	TotalCount int      // Identifies the total count of items in the connection.
}

VolumesPage represents a page of Volumes resulting from a query, and associated metadata.

type Workflow

type Workflow struct {
	ID         string     `bson:"_id,omitempty"`
	CreatedAt  time.Time  `bson:"createdAt"`
	StartedAt  *time.Time `bson:"startedAt,omitempty"`
	FinishedAt *time.Time `bson:"finishedAt,omitempty"`
	Name       string     `bson:"name"`
	Status     string     `bson:"status"`
	// contains filtered or unexported fields
}

Workflow represents a workflow.

func (Workflow) CreatedBy

func (w Workflow) CreatedBy(ctx context.Context) (User, error)

CreatedBy retrieves the user that created workflow w.

func (Workflow) JobsPage

func (w Workflow) JobsPage(ctx context.Context, pa PageArgs) (JobsPage, error)

JobsPage retrieves a page of jobs related to workflow w.

func (Workflow) VolumesPage

func (w Workflow) VolumesPage(ctx context.Context, pa PageArgs) (VolumesPage, error)

VolumesPage retrieves a page of volumes related to workflow w.

type WorkflowPersister

type WorkflowPersister interface {
	CreateWorkflow(context.Context, Workflow) (Workflow, error)
	DeleteWorkflow(context.Context, string) (Workflow, error)
	GetWorkflow(context.Context, string) (Workflow, error)
	GetWorkflows(context.Context, PageArgs) (WorkflowsPage, error)
}

WorkflowPersister is the interface by which workflows are persisted.

type WorkflowSpec

type WorkflowSpec struct {
	Name    string        `bson:"name"`
	Jobs    []jobSpec     `bson:"jobs"`
	Volumes *[]volumeSpec `bson:"volumes"`
}

WorkflowSpec represents a workflow specification.

type WorkflowsPage

type WorkflowsPage struct {
	Workflows  []Workflow // Slice of results.
	PageInfo   PageInfo   // Information to aid in pagination.
	TotalCount int        // Identifies the total count of items in the connection.
}

WorkflowsPage represents a page of workflows resulting from a query, and associated metadata.

Jump to

Keyboard shortcuts

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