config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: GPL-3.0 Imports: 9 Imported by: 7

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func GlobalSecret

func GlobalSecret(key string) string

func PipelineObject

func PipelineObject(key string) string

func PipelineSecret

func PipelineSecret(key string) string

func RunObject

func RunObject(key string) string

Types

type CommonTaskConfig

type CommonTaskConfig struct {
	Kind        TaskKind                        `json:"kind"`
	Name        string                          `json:"name"`
	Label       string                          `json:"label"`
	Description string                          `json:"description"`
	DependsOn   map[string]RequiredParentStatus `json:"depends_on"`
	Settings    map[string]string               `json:"settings"`
}

func NewCommonTask

func NewCommonTask(name, label string) *CommonTaskConfig

func (*CommonTaskConfig) ToProto

func (t *CommonTaskConfig) ToProto() *proto.CommonTaskConfig

func (*CommonTaskConfig) WithDependsOnMany

func (t *CommonTaskConfig) WithDependsOnMany(dependsOn map[string]RequiredParentStatus) *CommonTaskConfig

func (*CommonTaskConfig) WithDependsOnOne

func (t *CommonTaskConfig) WithDependsOnOne(taskID string, state RequiredParentStatus) *CommonTaskConfig

func (*CommonTaskConfig) WithDescription

func (t *CommonTaskConfig) WithDescription(description string) *CommonTaskConfig

func (*CommonTaskConfig) WithSetting

func (t *CommonTaskConfig) WithSetting(key, value string) *CommonTaskConfig

func (*CommonTaskConfig) WithSettings

func (t *CommonTaskConfig) WithSettings(settings map[string]string) *CommonTaskConfig

type CustomTaskConfig

type CustomTaskConfig struct {
	Kind         TaskKind                        `json:"kind"`
	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"`
}

func NewCustomTask

func NewCustomTask(id, image string) *CustomTaskConfig

func (*CustomTaskConfig) FromCustomTaskProto

func (t *CustomTaskConfig) FromCustomTaskProto(proto *proto.CustomTaskConfig)

func (*CustomTaskConfig) ToProto

func (t *CustomTaskConfig) ToProto() *proto.CustomTaskConfig

func (*CustomTaskConfig) WithCommand

func (t *CustomTaskConfig) WithCommand(command ...string) *CustomTaskConfig

func (*CustomTaskConfig) WithDependsOnMany

func (t *CustomTaskConfig) WithDependsOnMany(dependsOn map[string]RequiredParentStatus) *CustomTaskConfig

func (*CustomTaskConfig) WithDependsOnOne

func (t *CustomTaskConfig) WithDependsOnOne(taskID string, state RequiredParentStatus) *CustomTaskConfig

func (*CustomTaskConfig) WithDescription

func (t *CustomTaskConfig) WithDescription(description string) *CustomTaskConfig

func (*CustomTaskConfig) WithEntrypoint

func (t *CustomTaskConfig) WithEntrypoint(entrypoint ...string) *CustomTaskConfig

func (*CustomTaskConfig) WithRegistryAuth

func (t *CustomTaskConfig) WithRegistryAuth(user, pass string) *CustomTaskConfig

func (*CustomTaskConfig) WithVariable

func (t *CustomTaskConfig) WithVariable(key, value string) *CustomTaskConfig

func (*CustomTaskConfig) WithVariables

func (t *CustomTaskConfig) WithVariables(variables map[string]string) *CustomTaskConfig

type PipelineConfig

type PipelineConfig struct {
	ID          string                  `json:"id"`
	Name        string                  `json:"name"`
	Description string                  `json:"description"`
	Parallelism int64                   `json:"parallelism"`
	Tasks       []TaskConfig            `json:"tasks"`
	Triggers    []PipelineTriggerConfig `json:"triggers"`
}

func NewPipeline

func NewPipeline(id, name string) *PipelineConfig
Example (Dag)
taskOne := NewCustomTask("task_one", "ghcr.io/clintjedwards/gofer/debug/wait:latest").
	WithDescription("This task has no dependencies so it will run immediately").
	WithVariable("WAIT_DURATION", "20s")

dependsOnOne := NewCustomTask("depends_on_one", "ghcr.io/clintjedwards/gofer/debug/log:latest").
	WithDescription("This task depends on the first task to finish with a successfull result."+
		"This means that if the first task fails this task will not run.").
	WithVariable("LOGS_HEADER", "This string can be anything you want it to be").
	WithDependsOnOne(taskOne.ID, RequiredParentStatusSuccess)

dependsOnTwo := NewCustomTask("depends_on_two", "docker.io/library/hello-world").
	WithDescription("This task depends on the second task, but will run after its finished regardless of the result.").
	WithDependsOnOne(dependsOnOne.ID, RequiredParentStatusAny)

err := NewPipeline("dag_test_pipeline", "DAG Test Pipeline").
	WithDescription(`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.`).
	WithParallelism(10).
	WithTasks(taskOne, dependsOnOne, dependsOnTwo).
	Finish()
if err != nil {
	panic(err)
}
Output:

Example (Simple)
err := NewPipeline("simple_test_pipeline", "Simple Test Pipeline").
	WithDescription("Simple Test Pipeline").
	WithTasks(
		NewCustomTask("simple_task", "ubuntu:latest").
			WithDescription("This task simply prints our hello-world message and exits!").
			WithCommand("echo", `Hello from Gofer!`),
	).
	Finish()
if err != nil {
	panic(err)
}
Output:

func (*PipelineConfig) Finish

func (p *PipelineConfig) Finish() error

Call finish as the last method to the pipeline config

func (*PipelineConfig) ToProto

func (p *PipelineConfig) ToProto() *proto.PipelineConfig

func (*PipelineConfig) Validate

func (p *PipelineConfig) Validate() error

func (*PipelineConfig) WithDescription

func (p *PipelineConfig) WithDescription(description string) *PipelineConfig

func (*PipelineConfig) WithParallelism

func (p *PipelineConfig) WithParallelism(parallelism int64) *PipelineConfig

func (*PipelineConfig) WithTasks

func (p *PipelineConfig) WithTasks(tasks ...TaskConfig) *PipelineConfig

func (*PipelineConfig) WithTriggers

func (p *PipelineConfig) WithTriggers(triggers ...PipelineTriggerConfig) *PipelineConfig

type PipelineTriggerConfig

type PipelineTriggerConfig struct {
	Name     string            `json:"name"`
	Label    string            `json:"label"`
	Settings map[string]string `json:"settings"`
}

func NewTrigger

func NewTrigger(name, label string) *PipelineTriggerConfig

func (*PipelineTriggerConfig) FromProto

func (p *PipelineTriggerConfig) FromProto(proto *proto.PipelineTriggerConfig)

func (*PipelineTriggerConfig) ToProto

func (*PipelineTriggerConfig) WithSetting

func (p *PipelineTriggerConfig) WithSetting(key, value string) *PipelineTriggerConfig

func (*PipelineTriggerConfig) WithSettings

func (p *PipelineTriggerConfig) WithSettings(settings map[string]string) *PipelineTriggerConfig

type RegistryAuth

type RegistryAuth struct {
	User string `json:"user"`
	Pass string `json:"pass"`
}

func (*RegistryAuth) FromProto

func (ra *RegistryAuth) FromProto(proto *proto.RegistryAuth)

func (*RegistryAuth) ToProto

func (ra *RegistryAuth) ToProto() *proto.RegistryAuth

type RequiredParentStatus

type RequiredParentStatus string
const (
	RequiredParentStatusAny     RequiredParentStatus = "ANY"
	RequiredParentStatusSuccess RequiredParentStatus = "SUCCESS"
	RequiredParentStatusFailure RequiredParentStatus = "FAILURE"
)

func (RequiredParentStatus) ToString

func (status RequiredParentStatus) ToString() string

type TaskConfig

type TaskConfig interface {
	// contains filtered or unexported methods
}

type TaskKind

type TaskKind string
const (
	TaskKindUnknown TaskKind = "UNKNOWN"
	TaskKindCommon  TaskKind = "COMMON"
	TaskKindCustom  TaskKind = "CUSTOM"
)

Jump to

Keyboard shortcuts

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