pipeline

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

The package pipeline contains the bounded context that is pipeline. Each requirement (create, delete, get, trigger, update) is separated into different files, you will notice this across the project. We do this so it is easy to find all the related files for a requirement.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPipelineNotFound for pipeline.
	ErrPipelineNotFound = errors.New("pipeline not found")

	// ErrInvalidPipelineName for pipeline.
	ErrInvalidPipelineName = errors.New("invalid pipeline name")

	// ErrMissingJobs for pipeline.
	ErrMissingJobs = errors.New("missing jobs")

	// ErrInvalidJobName for pipeline.
	ErrInvalidJobName = errors.New("invalid job name")

	// ErrMissingSteps for pipeline.
	ErrMissingSteps = errors.New("missing steps")

	// ErrInvalidID for pipeline.
	ErrInvalidID = errors.New("invalid id")
)

Module for fx.

Functions

func IsInvalidArgument

func IsInvalidArgument(err error) bool

IsInvalidArgument for pipeline.

func IsNotFound added in v0.6.0

func IsNotFound(err error) bool

IsNotFound for pipeline.

Types

type Command added in v0.11.0

type Command interface {
	// Exec a command and output the result or error.
	Exec(ctx context.Context, cmd string) (string, error)
}

Command runs a specific command.

func NewCommand added in v0.11.0

func NewCommand() Command

NewCommand for pipeline.

type ID added in v0.7.0

type ID string

ID for service.

A common pattern in DDD is to make sure we have defined types and allow us to extend what we mean by an id.

func (ID) Valid added in v0.7.0

func (i ID) Valid() error

Valid or error if ID is not the correct length.

type InMemoryRepository

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

InMemoryRepository for pipeline.

The mux is to make sure we don't accidentally corrupt. The cache and enc are there to make sure we don't maintain pointers in memory.

func (*InMemoryRepository) Create

func (r *InMemoryRepository) Create(p *Pipeline) (*Pipeline, error)

Create a pipeline and set the identifier.

func (*InMemoryRepository) Delete added in v0.9.0

func (r *InMemoryRepository) Delete(id ID) (*Pipeline, error)

Delete a pipeline.

func (*InMemoryRepository) Get added in v0.6.0

func (r *InMemoryRepository) Get(id ID) (*Pipeline, error)

Get a pipeline.

func (*InMemoryRepository) Update added in v0.8.0

func (r *InMemoryRepository) Update(id ID, p *Pipeline) (*Pipeline, error)

Update a pipeline.

type Job

type Job struct {
	Name  string
	Steps []string
}

Job of the pipeline.

Each job just has a list of commands that will run on the host. A good job definition would have some sort of workflow definition to allow different patterns. An example can be found at https://circleci.com/docs/workflows/

func (*Job) Valid

func (j *Job) Valid() error

Valid job or error if name is blank or empty steps.

type OSCommand added in v0.11.0

type OSCommand struct{}

OSCommand uses os/exec.

func (*OSCommand) Exec added in v0.11.0

func (r *OSCommand) Exec(ctx context.Context, cmd string) (string, error)

Exec using os/exec.

type Pipeline

type Pipeline struct {
	Name string
	ID   ID
	Jobs []*Job
}

Pipeline to be executed.

A pipeline has a list of jobs.

func (*Pipeline) Valid

func (p *Pipeline) Valid() error

Valid pipeline or error if name is blank, empty jobs or invalid jobs.

type Repository

type Repository interface {
	// Get a pipeline.
	Get(id ID) (*Pipeline, error)

	// Create a pipeline.
	Create(p *Pipeline) (*Pipeline, error)

	// Update a pipeline.
	Update(id ID, p *Pipeline) (*Pipeline, error)

	// Delete a pipeline.
	Delete(id ID) (*Pipeline, error)
}

Repository for pipeline.

func NewRepository

func NewRepository(enc *gob.Encoder) Repository

NewRepository for pipeline.

type Service

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

Service coordinates all the pipeline activities.

This is entry point and the type to be used when interacting with this package.

func NewService

func NewService(repo Repository, cmd Command) *Service

NewService for pipeline.

func (*Service) Create

func (s *Service) Create(p *Pipeline) (*Pipeline, error)

Create a new pipeline.

func (*Service) Delete added in v0.9.0

func (s *Service) Delete(id ID) (*Pipeline, error)

Update an existing pipeline.

func (*Service) Get added in v0.6.0

func (s *Service) Get(id ID) (*Pipeline, error)

Get pipeline by id.

func (*Service) Trigger added in v0.11.0

func (s *Service) Trigger(ctx context.Context, id ID) (*Pipeline, error)

Update an existing pipeline.

This assumes that we will just run each job and each step serially. The first error we exit.

func (*Service) Update added in v0.8.0

func (s *Service) Update(id ID, p *Pipeline) (*Pipeline, error)

Update an existing pipeline.

Jump to

Keyboard shortcuts

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