Documentation ¶
Overview ¶
Package scribe provides the primary library / client functions, types, and methods for creating Scribe pipelines.
Index ¶
- Constants
- Variables
- func NewDefaultCollection(opts clients.CommonOpts) *pipeline.Collection
- func NewMultiCollection() *pipeline.Collection
- func RegisterClient(name string, initializer InitializerFunc)
- type GitConfig
- type InitializerFunc
- type MultiFunc
- type PipelineConfig
- type Scribe
- func (s *Scribe) Add(steps ...pipeline.Step)
- 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) Pipeline() int64
- func (s *Scribe) When(events ...pipeline.Event)
- type ScribeMulti
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 using the Drone client, which is used to generate a Drone config from a Scribe pipeline ClientDrone = "drone" // ClientDagger ClientDagger = "dagger" )
var ArgDefaults = map[string]func(context.Context) *exec.Cmd{ pipeline.ArgumentCommitRef.Key: func(ctx context.Context) *exec.Cmd { return exec.CommandContext(ctx, "git", "rev-parse", "HEAD") }, pipeline.ArgumentCommitSHA.Key: func(ctx context.Context) *exec.Cmd { return exec.CommandContext(ctx, "git", "rev-parse", "HEAD") }, pipeline.ArgumentRemoteURL.Key: func(ctx context.Context) *exec.Cmd { return exec.CommandContext(ctx, "git", "remote", "get-url", "origin") }, pipeline.ArgumentBranch.Key: func(ctx context.Context) *exec.Cmd { return exec.CommandContext(ctx, "git", "rev-parse", "--abbrev-ref", "HEAD") }, pipeline.ArgumentTagName.Key: func(ctx context.Context) *exec.Cmd { return exec.CommandContext(ctx, "git", "describe", "--tags") }, }
var ClientInitializers = map[string]InitializerFunc{ ClientCLI: cli.New, ClientDrone: drone.New, ClientDagger: dagger.New, }
The ClientInitializers define how different RunModes initialize the Scribe client
var ErrorCancelled = errors.New("cancelled")
var LocalModes = []string{"dagger"}
LocalClients define modes that are intended to run a pipeline "locally". These local clients will do things like filter the pipeline based on the selected event with the '-e' flag.
Functions ¶
func NewDefaultCollection ¶
func NewDefaultCollection(opts clients.CommonOpts) *pipeline.Collection
func NewMultiCollection ¶
func NewMultiCollection() *pipeline.Collection
func RegisterClient ¶
func RegisterClient(name string, initializer InitializerFunc)
Types ¶
type InitializerFunc ¶
type InitializerFunc func(clients.CommonOpts) (pipeline.Client, error)
type MultiFunc ¶
type MultiFunc func(*Scribe)
func MultiFuncWithLogging ¶
func MultiFuncWithLogging(logger logrus.FieldLogger, mf MultiFunc) MultiFunc
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 clients.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 clients.CommonOpts, collection *pipeline.Collection) *Scribe
NewClient creates a new Scribe client based on the commonopts. It does not check for a non-nil "Args" field.
func NewWithClient ¶
func NewWithClient(opts clients.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) Add ¶ added in v0.11.0
Add allows users to define steps. The order in which steps are ran is defined by what they provide / require. Some steps do not produce anything, like for example running a suite of tests for a pass/fail result.
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) When ¶
When allows users to define when this pipeline is executed, especially in the remote environment. Users can execute the pipeline as if it was triggered from the event by supplying the `-e` or `--event` argument. This function will overwrite any other events that were added to the pipeline.
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 clients.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 clients.CommonOpts, client pipeline.Client) *ScribeMulti
func (*ScribeMulti) Add ¶ added in v0.11.1
func (s *ScribeMulti) Add(pipelines ...pipeline.Pipeline)
Add adds new pipelines to the Scribe DAG to be processed by the Client.
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) PrintGraph ¶ added in v0.11.1
func (s *ScribeMulti) PrintGraph(msg string)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package args just holds the type definitions for pipeline / cmd arguments to avoid cyclic imports
|
Package args just holds the type definitions for pipeline / cmd arguments to avoid cyclic imports |
Package main contains the logic for the `scribe` CLI
|
Package main contains the logic for the `scribe` CLI |
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. |
demo
|
|
Package exec provides helper functions and Actions for executing shell commands.
|
Package exec provides helper functions and Actions for executing shell commands. |
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. |
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. |
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. |
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. |
Package stringutil contains general string utilities used throughout this project.
|
Package stringutil contains general string utilities used throughout this project. |
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. |