pipeline

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: Apache-2.0 Imports: 3 Imported by: 12

Documentation

Overview

Package pipeline provides the defined pipeline types for Vela.

Usage:

import "github.com/go-vela/types/pipeline"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildWithContext

func BuildWithContext(c context.Context, b *Build) context.Context

BuildWithContext inserts the Build type to the context.

func ContainerWithContext

func ContainerWithContext(c context.Context, s *Container) context.Context

ContainerWithContext inserts the Container type to the context.

func SecretWithContext

func SecretWithContext(c context.Context, s *Secret) context.Context

SecretWithContext inserts the Secret type to the context.

func StageWithContext

func StageWithContext(c context.Context, s *Stage) context.Context

StageWithContext inserts the Stage type to the context.

Types

type Build

type Build struct {
	ID       string         `json:"id,omitempty"`
	Version  string         `json:"version,omitempty"`
	Metadata Metadata       `json:"metadata,omitempty"`
	Secrets  SecretSlice    `json:"secrets,omitempty"`
	Services ContainerSlice `json:"services,omitempty"`
	Stages   StageSlice     `json:"stages,omitempty"`
	Steps    ContainerSlice `json:"steps,omitempty"`
}

Build is the pipeline representation of a build for a pipeline.

func BuildFromContext

func BuildFromContext(c context.Context) *Build

BuildFromContext retrieves the Build type from the context.

func (*Build) Purge

func (b *Build) Purge(r *RuleData) *Build

Purge removes the steps, in every stage, that contain a ruleset that do not match the provided ruledata. If all steps from a stage are removed, then the entire stage is removed from the pipeline. If no stages are provided in the pipeline, then the function will remove the steps that have a ruleset that do not match the provided ruledata. If both stages and steps are provided, then an empty pipeline is returned.

type Container

type Container struct {
	ID          string            `json:"id,omitempty"`
	Commands    []string          `json:"commands,omitempty"`
	Detach      bool              `json:"detach,omitempty"`
	Directory   string            `json:"directory,omitempty"`
	Entrypoint  []string          `json:"entrypoint,omitempty"`
	Environment map[string]string `json:"environment,omitempty"`
	ExitCode    int               `json:"exit_code,omitempty"`
	Image       string            `json:"image,omitempty"`
	Name        string            `json:"name,omitempty"`
	Needs       []string          `json:"needs,omitempty"`
	Networks    []string          `json:"networks,omitempty"`
	Number      int               `json:"number,omitempty"`
	Ports       []string          `json:"ports,omitempty"`
	Privileged  bool              `json:"privileged,omitempty"`
	Pull        bool              `json:"pull,omitempty"`
	Ruleset     Ruleset           `json:"ruleset,omitempty"`
	Secrets     StepSecretSlice   `json:"secrets,omitempty"`
	Ulimits     UlimitSlice       `json:"ulimits,omitempty"`
	Volumes     VolumeSlice       `json:"volumes,omitempty"`
}

Container is the pipeline representation of a Container in a pipeline.

func ContainerFromContext

func ContainerFromContext(c context.Context) *Container

ContainerFromContext retrieves the container type from the context.

type ContainerSlice

type ContainerSlice []*Container

ContainerSlice is the pipeline representation of the Containers block for a pipeline.

func (*ContainerSlice) Purge

func (c *ContainerSlice) Purge(r *RuleData) *ContainerSlice

Purge removes the Containers that have a ruleset that do not match the provided ruledata.

type Metadata

type Metadata struct {
	Template bool `json:"template,omitempty"`
}

Metadata is the yaml representation of the metadata block for a pipeline.

type Port

type Port struct {
	Port     int    `json:"port,omitempty"`
	Host     int    `json:"host,omitempty"`
	Protocol string `json:"protocol,omitempty"`
}

Port is the pipeline representation of a port for a step in a pipeline.

type PortSlice

type PortSlice []*Port

PortSlice is the pipeline representation of the ports for a step in a pipeline.

type RuleData

type RuleData struct {
	Branch string
	Event  string
	Path   []string
	Repo   string
	Status string
	Tag    string
}

RuleData is the data to check our ruleset against for a step in a pipeline.

type Rules

type Rules struct {
	Branch Ruletype `json:"branch,omitempty"`
	Event  Ruletype `json:"event,omitempty"`
	Path   Ruletype `json:"path,omitempty"`
	Repo   Ruletype `json:"repo,omitempty"`
	Status Ruletype `json:"status,omitempty"`
	Tag    Ruletype `json:"tag,omitempty"`
}

Rules is the pipeline representation of the ruletypes from a ruleset block for a step in a pipeline.

func (*Rules) Empty

func (r *Rules) Empty() bool

Empty returns true if the provided ruletypes are empty.

func (*Rules) Match

func (r *Rules) Match(from *RuleData, op string) bool

Match returns true for the or operator when one of the ruletypes from the rules match the provided ruledata. Match returns true for the and operator when all of the ruletypes from the rules match the provided ruledata. For both operators, when none of the ruletypes from the rules match the provided ruledata, the function returns false.

type Ruleset

type Ruleset struct {
	If       Rules  `json:"if,omitempty"`
	Unless   Rules  `json:"unless,omitempty"`
	Operator string `json:"operator,omitempty"`
	Continue bool   `json:"continue,omitempty"`
}

Ruleset is the pipeline representation of a ruleset block for a step in a pipeline.

func (*Ruleset) Match

func (r *Ruleset) Match(from *RuleData) bool

Match returns true when the provided ruledata matches the if rules and does not match any of the unless rules. When the provided if rules are empty, the function returns true. When both the provided if and unless rules are empty, the function also returns true.

type Ruletype

type Ruletype []string

Ruletype is the pipeline representation of an element for a ruleset block for a step in a pipeline.

func (*Ruletype) MatchAnd

func (r *Ruletype) MatchAnd(data string) bool

MatchAnd returns true when the provided ruletype matches the provided ruledata. When the provided ruletype is empty, the function returns true.

func (*Ruletype) MatchOr

func (r *Ruletype) MatchOr(data string) bool

MatchOr returns true when the provided ruletype matches the provided ruledata. When the provided ruletype is empty, the function returns false.

type Secret

type Secret struct {
	Name   string `json:"name,omitempty"`
	Value  string `json:"value,omitempty"`
	Key    string `json:"key,omitempty"`
	Engine string `json:"engine,omitempty"`
	Type   string `json:"type,omitempty"`
}

Secret is the pipeline representation of a secret from the secrets block for a pipeline.

func SecretFromContext

func SecretFromContext(c context.Context) *Secret

SecretFromContext retrieves the Secret type from the context.

type SecretSlice

type SecretSlice []*Secret

SecretSlice is the pipeline representation of the secrets block for a pipeline.

type Stage

type Stage struct {
	Name  string         `json:"name,omitempty"`
	Needs []string       `json:"needs,omitempty"`
	Steps ContainerSlice `json:"steps,omitempty"`
}

Stage is the pipeline representation of a stage in a pipeline.

func StageFromContext

func StageFromContext(c context.Context) *Stage

StageFromContext retrieves the Stage type from the context.

type StageSlice

type StageSlice []*Stage

StageSlice is the pipeline representation of the stages block for a pipeline.

func (*StageSlice) Purge

func (s *StageSlice) Purge(r *RuleData) *StageSlice

Purge removes the steps, from the stages, that have a ruleset that do not match the provided ruledata. If all steps from a stage are removed, then the entire stage is removed from the pipeline.

type StepSecret

type StepSecret struct {
	Source string `json:"source,omitempty"`
	Target string `json:"target,omitempty"`
}

StepSecret is the pipeline representation of a secret from a secrets block for a step in a pipeline.

type StepSecretSlice

type StepSecretSlice []*StepSecret

StepSecretSlice is the pipeline representation of the secrets block for a step in a pipeline.

type Ulimit

type Ulimit struct {
	Name string `json:"name,omitempty"`
	Soft int64  `json:"soft,omitempty"`
	Hard int64  `json:"hard,omitempty"`
}

Ulimit is the pipeline representation of a ulimit from the ulimits block for a step in a pipeline.

type UlimitSlice

type UlimitSlice []*Ulimit

UlimitSlice is the pipeline representation of the ulimits block for a step in a pipeline.

type Volume

type Volume struct {
	Source      string `json:"source,omitempty"`
	Destination string `json:"destination,omitempty"`
	AccessMode  string `json:"access_mode,omitempty"`
}

Volume is the pipeline representation of a volume from a volumes block for a step in a pipeline.

type VolumeSlice

type VolumeSlice []*Volume

VolumeSlice is the pipeline representation of the volumes block for a step in a pipeline.

Jump to

Keyboard shortcuts

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