Documentation ¶
Index ¶
- func GlobalSecret(key string) string
- func PipelineObject(key string) string
- func PipelineSecret(key string) string
- func RunObject(key string) string
- type Pipeline
- type PipelineWrapper
- func (p *PipelineWrapper) Description(description string) *PipelineWrapper
- func (p *PipelineWrapper) Finish() error
- func (p *PipelineWrapper) Parallelism(parallelism int64) *PipelineWrapper
- func (p *PipelineWrapper) Proto() *proto.UserPipelineConfig
- func (p *PipelineWrapper) Tasks(tasks ...*TaskWrapper) *PipelineWrapper
- func (p *PipelineWrapper) Validate() error
- type RegistryAuth
- type RequiredParentStatus
- type Task
- type TaskWrapper
- func (t *TaskWrapper) Command(command ...string) *TaskWrapper
- func (t *TaskWrapper) DependsOn(taskID string, state RequiredParentStatus) *TaskWrapper
- func (t *TaskWrapper) DependsOnMany(dependsOn map[string]RequiredParentStatus) *TaskWrapper
- func (t *TaskWrapper) Description(description string) *TaskWrapper
- func (t *TaskWrapper) Entrypoint(entrypoint ...string) *TaskWrapper
- func (t *TaskWrapper) FromTaskProto(proto *proto.UserPipelineTaskConfig)
- func (t *TaskWrapper) InjectAPIToken(injectToken bool) *TaskWrapper
- func (t *TaskWrapper) Proto() *proto.UserPipelineTaskConfig
- func (t *TaskWrapper) RegistryAuth(user, pass string) *TaskWrapper
- func (t *TaskWrapper) Variable(key, value string) *TaskWrapper
- func (t *TaskWrapper) Variables(variables map[string]string) *TaskWrapper
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GlobalSecret ¶
Convenience function to insert global secret values.
func PipelineObject ¶
Convenience function to insert pipeline object values.
func PipelineSecret ¶
Convenience function to insert pipeline secret values.
Types ¶
type Pipeline ¶ added in v0.4.0
type Pipeline struct { ID string `json:"id"` // Unique Identifier for the pipeline. Name string `json:"name"` // Humanized name for the pipeline. Description string `json:"description"` // A short description for the pipeline. Parallelism int64 `json:"parallelism"` // How many runs are allowed to run at the same time. Tasks []*TaskWrapper `json:"tasks"` // The task set of the pipeline. AKA which containers should be run. }
A pipeline is a representation of a Gofer pipeline, the structure in which users represent what they want to run in Gofer.
type PipelineWrapper ¶ added in v0.4.0
type PipelineWrapper struct {
Pipeline
}
PipelineWrapper type simply exists so that we can make structs with fields like "id" and we can still add functions called "id()". This makes it not only easier to reason about when working with the struct, but when just writing pipelines as an end user.
func NewPipeline ¶
func NewPipeline(id, name string) *PipelineWrapper
Create a new pipeline.
- The ID must be between 3 and 32 characters long and only alphanumeric, underscores are the only allowed alphanumeric character. Ex. `simple_pipeline`
- The name is a human friendly name to represent the pipeline. Ex. `Simple Pipeline`
Example (Dag) ¶
taskOne := NewTask("task_one", "ghcr.io/clintjedwards/gofer/debug/wait:latest"). Description("This task has no dependencies so it will run immediately"). Variable("WAIT_DURATION", "20s") dependsOnOne := NewTask("depends_on_one", "ghcr.io/clintjedwards/gofer/debug/log:latest"). Description("This task depends on the first task to finish a successfull result."+ "This means that if the first task fails this task will not run."). Variable("LOGS_HEADER", "This string can be anything you want it to be"). DependsOn(taskOne.ID, RequiredParentStatusSuccess) dependsOnTwo := NewTask("depends_on_two", "docker.io/library/hello-world"). Description("This task depends on the second task, but will run after its finished regardless of the result."). DependsOn(dependsOnOne.ID, RequiredParentStatusAny) err := NewPipeline("dag_test_pipeline", "DAG Test Pipeline"). Description(`This pipeline shows off how you might use Gofer's DAG(Directed Acyclic Graph) system to chain together containers that depend on other container's end states. This is obviously very useful if you want to perform certain trees of actions depending on what happens in earlier containers.`). Parallelism(10). Tasks(taskOne, dependsOnOne, dependsOnTwo). Finish() if err != nil { panic(err) }
Output:
Example (Simple) ¶
err := NewPipeline("simple_test_pipeline", "Simple Test Pipeline"). Description("Simple Test Pipeline"). Tasks( NewTask("simple_task", "ubuntu:latest"). Description("This task simply prints our hello-world message and exits!"). Command("echo", `Hello from Gofer!`), ). Finish() if err != nil { panic(err) }
Output:
func (*PipelineWrapper) Description ¶ added in v0.4.0
func (p *PipelineWrapper) Description(description string) *PipelineWrapper
A description allows you to succinctly describe what your pipeline is used for.
func (*PipelineWrapper) Finish ¶ added in v0.4.0
func (p *PipelineWrapper) Finish() error
Call finish as the last method to the pipeline config. Finish validates and converts the pipeline to Protobuf so that it can be read in by other programs.
func (*PipelineWrapper) Parallelism ¶ added in v0.4.0
func (p *PipelineWrapper) Parallelism(parallelism int64) *PipelineWrapper
How many runs are allowed to happen at the same time. 0 means no-limit.
func (*PipelineWrapper) Proto ¶ added in v0.4.0
func (p *PipelineWrapper) Proto() *proto.UserPipelineConfig
func (*PipelineWrapper) Tasks ¶ added in v0.4.0
func (p *PipelineWrapper) Tasks(tasks ...*TaskWrapper) *PipelineWrapper
Tasks are containers that the pipeline runs.
func (*PipelineWrapper) Validate ¶ added in v0.4.0
func (p *PipelineWrapper) Validate() error
Checks pipeline for common pipeline mistakes and returns an error if found.
type RegistryAuth ¶
RegistryAuth represents docker repository authentication.
func (*RegistryAuth) FromProto ¶
func (ra *RegistryAuth) FromProto(proto *proto.RegistryAuth)
func (*RegistryAuth) Proto ¶ added in v0.4.0
func (ra *RegistryAuth) Proto() *proto.RegistryAuth
Returns the protobuf representation.
type RequiredParentStatus ¶
type RequiredParentStatus string
RequiredParentStatus is used to describe the state you would like the parent dependency to be in before the child is run.
const ( // Any means that no matter what the state of the parent is at end, the child will run. RequiredParentStatusAny RequiredParentStatus = "ANY" // Success requires that the parent pass with a SUCCESSFUL status before the child will run. RequiredParentStatusSuccess RequiredParentStatus = "SUCCESS" // Failure requires the parent fail in anyway before the child is run. RequiredParentStatusFailure RequiredParentStatus = "FAILURE" )
type Task ¶ added in v0.5.0
type Task struct { ID string `json:"id"` Description string `json:"description"` Image string `json:"image"` RegistryAuth *RegistryAuth `json:"registry_auth"` DependsOn map[string]RequiredParentStatus `json:"depends_on"` Variables map[string]string `json:"variables"` Entrypoint *[]string `json:"entrypoint"` Command *[]string `json:"command"` // Allows users to tell gofer to auto-create and inject API Token into task. If this setting is found, Gofer creates // an API key for the run (stored in the user's secret store) and then injects it for this run under the // environment variables "GOFER_API_TOKEN". This key is automatically cleaned up when Gofer attempts to clean up // the Run's objects. InjectAPIToken bool `json:"inject_api_token"` }
Task is a representation of a Gofer task. Tasks are simply containers that Pipeline users need to run.
type TaskWrapper ¶ added in v0.5.0
type TaskWrapper struct {
Task
}
TaskWrapper type simply exists so that we can make structs with fields like "id" and we can still add functions called "id()". This makes it not only easier to reason about when working with the struct, but when just writing pipelines as an end user.
func NewTask ¶ added in v0.5.0
func NewTask(id, image string) *TaskWrapper
Creates a new Gofer task. Tasks are simply containers you wish to run.
func (*TaskWrapper) Command ¶ added in v0.5.0
func (t *TaskWrapper) Command(command ...string) *TaskWrapper
Change the container's [command](https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact)
func (*TaskWrapper) DependsOn ¶ added in v0.5.0
func (t *TaskWrapper) DependsOn(taskID string, state RequiredParentStatus) *TaskWrapper
Add a single task dependency. This allows you to tie a task's execution to the result of another task.
func (*TaskWrapper) DependsOnMany ¶ added in v0.5.0
func (t *TaskWrapper) DependsOnMany(dependsOn map[string]RequiredParentStatus) *TaskWrapper
Add multiple task dependencies. This allows you to tie a task's execution to the result of several other tasks.
func (*TaskWrapper) Description ¶ added in v0.5.0
func (t *TaskWrapper) Description(description string) *TaskWrapper
Add a short description of the task's purpose.
func (*TaskWrapper) Entrypoint ¶ added in v0.5.0
func (t *TaskWrapper) Entrypoint(entrypoint ...string) *TaskWrapper
Change the container's [entrypoint](https://docs.docker.com/engine/reference/builder/#understand-how-cmd-and-entrypoint-interact
func (*TaskWrapper) FromTaskProto ¶ added in v0.5.0
func (t *TaskWrapper) FromTaskProto(proto *proto.UserPipelineTaskConfig)
func (*TaskWrapper) InjectAPIToken ¶ added in v0.5.0
func (t *TaskWrapper) InjectAPIToken(injectToken bool) *TaskWrapper
Gofer will auto-generate and inject a Gofer API token as `GOFER_API_TOKEN`. This allows you to easily have tasks communicate with Gofer by either embedding Gofer's CLI or just simply using the token to authenticate to the API.
This auto-generated token is stored in this pipeline's secret store and automatically cleaned up when the run objects get cleaned up.
func (*TaskWrapper) Proto ¶ added in v0.5.0
func (t *TaskWrapper) Proto() *proto.UserPipelineTaskConfig
func (*TaskWrapper) RegistryAuth ¶ added in v0.5.0
func (t *TaskWrapper) RegistryAuth(user, pass string) *TaskWrapper
Authentication details if your container repository requires them.
func (*TaskWrapper) Variable ¶ added in v0.5.0
func (t *TaskWrapper) Variable(key, value string) *TaskWrapper
Add a single variable. Variables are passed to your task as environment variables in a key value fashion. Variable values can also be pulled from other resources within Gofer. Making it easy to pass in things like secrets.
func (*TaskWrapper) Variables ¶ added in v0.5.0
func (t *TaskWrapper) Variables(variables map[string]string) *TaskWrapper
Add multiple variables. Variables are passed to your task as environment variables in a key value fashion. Variable values can also be pulled from other resources within Gofer like the secret store. Making it easy to pass in things like secrets.