Documentation ¶
Overview ¶
Package flow provides the primary library / client functions, types, and methods for creating Flow pipelines.
Index ¶
- Constants
- Variables
- func NewDefaultCollection(opts clients.CommonOpts) *pipeline.Collection
- func NewMultiCollection() *pipeline.Collection
- func RegisterClient(name string, initializer InitializerFunc)
- type Flow
- func (s *Flow) Add(steps ...pipeline.Step)
- func (s *Flow) Background(steps ...pipeline.Step)
- func (s *Flow) Cache(action pipeline.Action, c pipeline.Cacher) pipeline.Action
- func (s *Flow) Done()
- func (s *Flow) Execute(ctx context.Context, collection *pipeline.Collection) error
- func (s *Flow) Pipeline() int64
- func (s *Flow) When(events ...pipeline.Event)
- type FlowMulti
- func (s *FlowMulti) Add(pipelines ...pipeline.Pipeline)
- func (s *FlowMulti) AddPipelines(pipelines ...Pipeline)
- func (s *FlowMulti) Done()
- func (s *FlowMulti) Execute(ctx context.Context, collection *pipeline.Collection) error
- func (s *FlowMulti) New(name string, mf MultiFunc) pipeline.Pipeline
- func (s *FlowMulti) PrintGraph(msg string)
- type GitConfig
- type InitializerFunc
- type MultiFunc
- type Pipeline
- type PipelineConfig
Constants ¶
const DefaultPipelineID int64 = 1
Variables ¶
var ( ClientCLI string = "cli" ClientDrone = "drone" ClientDagger = "dagger" ClientGraphviz = "graphviz" )
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, ClientGraphviz: graphviz.New, }
The ClientInitializers define how different RunModes initialize the Flow 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 Flow ¶
type Flow 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 }
Flow is the client that is used in every pipeline to declare the steps that make up a pipeline. The Flow type is not thread safe. Running any of the functions from this type concurrently may have unexpected results.
func New ¶
New creates a new Flow 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 Flow 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(ctx context.Context, c clients.CommonOpts, collection *pipeline.Collection) *Flow
NewClient creates a new Flow 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) *Flow
NewWithClient creates a new Flow object with a specific client implementation. This function is intended to be used in very specific environments, like in tests.
func (*Flow) Add ¶
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 (*Flow) 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 (*Flow) Execute ¶
Execute is the equivalent of Done, but returns an error. Done should be preferred in Flow pipelines as it includes sub-process handling and logging.
func (*Flow) 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 FlowMulti ¶
type FlowMulti 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() *FlowMulti
NewMulti is the equivalent of `Flow.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 `(*flow.FlowMulti).New(...)` function.
func NewMultiWithClient ¶
func NewMultiWithClient(opts clients.CommonOpts, client pipeline.Client) *FlowMulti
func (*FlowMulti) AddPipelines ¶
AddPipelines adds a list of pipelines into the DAG. The order in which they are defined or added is not important; the order in which they run depends on what they require and what they provide. This function can be ran multiple times; every new item added with 'AddPipelines' will be appended to the dag.
func (*FlowMulti) Execute ¶
Execute is the equivalent of Done, but returns an error. Done should be preferred in Flow pipelines as it includes sub-process handling and logging.
func (*FlowMulti) New ¶
New creates a new Pipeline step that executes the provided MultiFunc onto a new `*Flow` type, creating a DAG. Because this function returns a pipeline.Step[T], it can be used with the normal Flow functions like `Run` and `Parallel`.
func (*FlowMulti) PrintGraph ¶
type InitializerFunc ¶
type MultiFunc ¶
type MultiFunc func(*Flow)
func MultiFuncWithLogging ¶
func MultiFuncWithLogging(logger logrus.FieldLogger, mf MultiFunc) MultiFunc
type Pipeline ¶
type Pipeline struct { Name string Requires []state.Argument Steps []pipeline.Step Provides []state.Argument When []pipeline.Event }
Pipeline is a more user-friendly, declarative representation of a Pipeline in the 'pipeline' package. This is only used when defining a pipeline in a declarative manner using the 'AddPipelines' function.
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.
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 `flow` CLI
|
Package main contains the logic for the `flow` CLI |
Package cmdutil provides utility functions and types for working with the 'flow' CLI.
|
Package cmdutil provides utility functions and types for working with the 'flow' 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 Flow pipeline.
|
Package pipeline contains the meta types and interfaces that define a Flow 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. |