Documentation ¶
Overview ¶
Package scribe provides the primary library / client functions, types, and methods for creating Scribe pipelines.
Index ¶
- Constants
- Variables
- func GetState(val string, log logrus.FieldLogger, args *plumbing.PipelineArgs) (*pipeline.State, error)
- func NewCLIClient(opts pipeline.CommonOpts) pipeline.Client
- func NewDefaultCollection(opts pipeline.CommonOpts) *pipeline.Collection
- func NewDockerClient(opts pipeline.CommonOpts) pipeline.Client
- func NewDroneClient(opts pipeline.CommonOpts) pipeline.Client
- func NewDroneStarlarkClient(opts pipeline.CommonOpts) pipeline.Client
- func NewMultiCollection() *pipeline.Collection
- func RegisterClient(name string, initializer InitializerFunc)
- type GitConfig
- type InitializerFunc
- type MultiFunc
- type MultiSubFunc
- type PipelineConfig
- type Scribe
- func (s *Scribe) Background(steps ...pipeline.Step)
- func (s *Scribe) Cache(action pipeline.Action, c pipeline.Cacher) pipeline.Action
- func (s *Scribe) Done()
- func (s *Scribe) Execute(ctx context.Context, collection *pipeline.Collection) error
- func (s *Scribe) Parallel(steps ...pipeline.Step)
- func (s *Scribe) Pipeline() int64
- func (s *Scribe) Run(steps ...pipeline.Step)
- func (s *Scribe) Sub(sf SubFunc)
- func (s *Scribe) When(events ...pipeline.Event)
- type ScribeMulti
- func (s *ScribeMulti) Done()
- func (s *ScribeMulti) Execute(ctx context.Context, collection *pipeline.Collection) error
- func (s *ScribeMulti) New(name string, mf MultiFunc) pipeline.Pipeline
- func (s *ScribeMulti) Parallel(steps ...pipeline.Pipeline)
- func (s *ScribeMulti) Run(steps ...pipeline.Pipeline)
- func (s *ScribeMulti) Sub(sf MultiSubFunc)
- type SubFunc
Constants ¶
const DefaultPipelineID int64 = 1
Variables ¶
var ( // ClientCLI is set when a pipeline is ran from the Scribe CLI, typically for local development, but can also be set when running Scribe within a third-party service like CircleCI or Drone ClientCLI string = "cli" // ClientDrone is set when a pipeline is ran in Drone mode, which is used to generate a Drone config from a Scribe pipeline ClientDrone = "drone" ClientDroneStarlark = "drone-starlark" // RunModeDocker runs the pipeline using the Docker CLI for each step ClientDocker = "docker" )
var ClientInitializers = map[string]InitializerFunc{ ClientCLI: NewCLIClient, ClientDrone: NewDroneClient, ClientDroneStarlark: NewDroneStarlarkClient, ClientDocker: NewDockerClient, }
The ClientInitializers define how different RunModes initialize the Scribe client
var ErrorCancelled = errors.New("cancelled")
Functions ¶
func GetState ¶
func GetState(val string, log logrus.FieldLogger, args *plumbing.PipelineArgs) (*pipeline.State, error)
func NewCLIClient ¶
func NewCLIClient(opts pipeline.CommonOpts) pipeline.Client
func NewDefaultCollection ¶
func NewDefaultCollection(opts pipeline.CommonOpts) *pipeline.Collection
func NewDockerClient ¶
func NewDockerClient(opts pipeline.CommonOpts) pipeline.Client
func NewDroneClient ¶
func NewDroneClient(opts pipeline.CommonOpts) pipeline.Client
func NewDroneStarlarkClient ¶
func NewDroneStarlarkClient(opts pipeline.CommonOpts) pipeline.Client
func NewMultiCollection ¶
func NewMultiCollection() *pipeline.Collection
func RegisterClient ¶
func RegisterClient(name string, initializer InitializerFunc)
Types ¶
type InitializerFunc ¶
type InitializerFunc func(pipeline.CommonOpts) pipeline.Client
type MultiFunc ¶
type MultiFunc func(*Scribe)
func MultiFuncWithLogging ¶
func MultiFuncWithLogging(logger logrus.FieldLogger, mf MultiFunc) MultiFunc
type MultiSubFunc ¶
type MultiSubFunc func(*ScribeMulti)
type PipelineConfig ¶
type PipelineConfig struct{}
Config defines the typical options that are provided in a pipeline. These options can be provided many ways, and often depend on the execution environment. They are retrieved at pipeline-time.
type Scribe ¶
type Scribe struct { Client pipeline.Client Collection *pipeline.Collection // Opts are the options that are provided to the pipeline from outside sources. This includes mostly command-line arguments and environment variables Opts pipeline.CommonOpts Log logrus.FieldLogger Version string // contains filtered or unexported fields }
Scribe is the client that is used in every pipeline to declare the steps that make up a pipeline. The Scribe type is not thread safe. Running any of the functions from this type concurrently may have unexpected results.
func New ¶
New creates a new Scribe client which is used to create pipeline a single pipeline with many steps. This function will panic if the arguments in os.Args do not match what's expected. This function, and the type it returns, are only ran inside of a Scribe pipeline, and so it is okay to treat this like it is the entrypoint of a command. Watching for signals, parsing command line arguments, and panics are all things that are OK in this function. New is used when creating a single pipeline. In order to create multiple pipelines, use the NewMulti function.
func NewClient ¶
func NewClient(c pipeline.CommonOpts, collection *pipeline.Collection) *Scribe
NewClient creates a new Scribe client based on the commonopts (mostly the mode). It does not check for a non-nil "Args" field.
func NewWithClient ¶
func NewWithClient(opts pipeline.CommonOpts, client pipeline.Client) *Scribe
NewWithClient creates a new Scribe object with a specific client implementation. This function is intended to be used in very specific environments, like in tests.
func (*Scribe) Background ¶
Background allows users to define steps that run in the background. In some environments this is referred to as a "Service" or "Background service". In many scenarios, users would like to simply use a docker image with the default command. In order to accomplish that, simply provide a step without an action.
func (*Scribe) Execute ¶
Execute is the equivalent of Done, but returns an error. Done should be preferred in Scribe pipelines as it includes sub-process handling and logging.
func (*Scribe) Parallel ¶
Parallel will run the listed steps at the same time. This function blocks the pipeline execution until all of the steps have completed.
func (*Scribe) Run ¶
Run allows users to define steps that are ran sequentially. For example, the second step will not run until the first step has completed. This function blocks the pipeline execution until all of the steps provided (step) have completed sequentially.
func (*Scribe) Sub ¶
Sub creates a sub-pipeline. The sub-pipeline is equivalent to creating a new coroutine made of multiple steps. This sub-pipeline will run concurrently with the rest of the pipeline at the time of definition. Under the hood, the Scribe client creates a new Scribe object with a clean Collection, then calles the SubFunc (sf) with the new Scribe object. The collection is then populated by the SubFunc, and then appended to the existing collection.
type ScribeMulti ¶
type ScribeMulti struct { Client pipeline.Client Collection *pipeline.Collection // Opts are the options that are provided to the pipeline from outside sources. This includes mostly command-line arguments and environment variables Opts pipeline.CommonOpts Log logrus.FieldLogger Version string // contains filtered or unexported fields }
func NewMulti ¶
func NewMulti() *ScribeMulti
NewMulti is the equivalent of `scribe.New`, but for building a pipeline made of multiple pipelines. Pipelines can behave in the same way that a step does. They can be ran in parallel using the Parallel function, or ran in a series using the Run function. To add new pipelines to execution, use the `(*scribe.ScribeMulti).New(...)` function.
func NewMultiWithClient ¶
func NewMultiWithClient(opts pipeline.CommonOpts, client pipeline.Client) *ScribeMulti
func (*ScribeMulti) Done ¶
func (s *ScribeMulti) Done()
func (*ScribeMulti) Execute ¶
func (s *ScribeMulti) Execute(ctx context.Context, collection *pipeline.Collection) error
Execute is the equivalent of Done, but returns an error. Done should be preferred in Scribe pipelines as it includes sub-process handling and logging.
func (*ScribeMulti) New ¶
func (s *ScribeMulti) New(name string, mf MultiFunc) pipeline.Pipeline
New creates a new Pipeline step that executes the provided MultiFunc onto a new `*Scribe` type, creating a DAG. Because this function returns a pipeline.Step[T], it can be used with the normal Scribe functions like `Run` and `Parallel`.
func (*ScribeMulti) Parallel ¶
func (s *ScribeMulti) Parallel(steps ...pipeline.Pipeline)
func (*ScribeMulti) Run ¶
func (s *ScribeMulti) Run(steps ...pipeline.Pipeline)
func (*ScribeMulti) Sub ¶
func (s *ScribeMulti) Sub(sf MultiSubFunc)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
docker
Package docker contains docker images and metadata for the suite of scribe docker images and utilities
|
Package docker contains docker images and metadata for the suite of scribe docker images and utilities |
demo
|
|
Package docker contains actions and steps for working with Docker images and Docker containers.
|
Package docker contains actions and steps for working with Docker images and Docker containers. |
Package exec provides helper functions and Actions for executing shell commands.
|
Package exec provides helper functions and Actions for executing shell commands. |
Package plumbing contains the internal scribe command utilities.
|
Package plumbing contains the internal scribe command utilities. |
cmd
Package main contains the logic for the `scribe` CLI Package main contains the CLI logic for the `scribe` command The scribe command's main responsibility is to run a pipeline.
|
Package main contains the logic for the `scribe` CLI Package main contains the CLI logic for the `scribe` command The scribe command's main responsibility is to run a pipeline. |
cmdutil
Package cmdutil provides utility functions and types for working with the 'scribe' CLI.
|
Package cmdutil provides utility functions and types for working with the 'scribe' CLI. |
pipeline
Package pipeline contains the meta types and interfaces that define a Scribe pipeline.
|
Package pipeline contains the meta types and interfaces that define a Scribe pipeline. |
pipeline/clients/drone
Package drone contians the drone client implementation for generating a Drone pipeline config.
|
Package drone contians the drone client implementation for generating a Drone pipeline config. |
pipelineutil
Package pipelineutil defines utilities for working with Pipelines and is separated as it may also import packages that import pipeline.
|
Package pipelineutil defines utilities for working with Pipelines and is separated as it may also import packages that import pipeline. |
plog
Package plog (or plumbig log) provides a logging initializer and utility functions for working with a logging library.
|
Package plog (or plumbig log) provides a logging initializer and utility functions for working with a logging library. |
stringutil
Package stringutil contains general string utilities used throughout this project.
|
Package stringutil contains general string utilities used throughout this project. |
syncutil
Package syncutil provides utilities for working with asynchronous tasks and provides wrappers around the "sync" package.
|
Package syncutil provides utilities for working with asynchronous tasks and provides wrappers around the "sync" package. |