parser

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2016 License: Apache-2.0 Imports: 7 Imported by: 45

Documentation

Index

Constants

View Source
const (
	DefaultCloner = "plugins/drone-git"   // Default clone plugin.
	DefaultCacher = "plugins/drone-cache" // Default cache plugin.
	DefaultMatch  = "plugins/*"           // Default plugin whitelist.
)

Variables

View Source
var (
	ErrImageMissing   = errors.New("Yaml must specify an image for every step")
	ErrImageWhitelist = errors.New("Yaml must specify am image from the white-list")
)

Functions

func Cache

func Cache(n Node, dir string) error

Cache transforms the Docker Node to mount a volume to the host machines local cache.

func Debug

func Debug(n Node, debug bool) error

Debug transforms plugin Nodes to set the DEBUG environment variable when starting plugins.

func DefaultNotifyFilter

func DefaultNotifyFilter(n Node) error

func Escalate

func Escalate(n Node) error

Escalate escalates a Docker Node to run in privileged mode if the plugin is whitelisted.

func HttpProxy

func HttpProxy(n Node) error

HttpProxy injects the HTTP_PROXY and HTTPS_PROXY environment variables into the container.

func ImageMatch

func ImageMatch(n Node, patterns []string) error

ImageMatch checks the image name against a whitelist.

func ImageName

func ImageName(n Node) error

ImageName expands to a fully qualified image name. If no image name is found, a default is used when possible, else ErrImageMissing is returned.

func ImagePull

func ImagePull(n Node, pull bool) error

func Mount

func Mount(n Node, from, to string) error

func Sanitize

func Sanitize(n Node) error

Sanitize sanitizes a Docker Node by removing any potentially harmful configuration options.

func StorageDriver

func StorageDriver(n Node, storageDriver string) error

Types

type DockerNode

type DockerNode struct {
	NodeType

	Image          string
	Pull           bool
	Privileged     bool
	Environment    []string
	Entrypoint     []string
	Command        []string
	Commands       []string
	Volumes        []string
	Devices        []string
	ExtraHosts     []string
	Net            string
	DNS            []string
	AuthConfig     yaml.AuthConfig
	Memory         int64
	CPUSetCPUs     string
	OomKillDisable bool
	Vargs          map[string]interface{}
}

DockerNode represents a Docker container that should be launched as part of the build process.

type FilterNode

type FilterNode struct {
	NodeType

	Repo        string
	Branch      []string
	Event       []string
	Success     string
	Failure     string
	Change      string
	Matrix      map[string]string
	Environment []string

	Node Node // Node to execution if conditions met
}

FilterNode represents a conditional step used to filter nodes. If conditions are met the child node is executed.

type ListNode

type ListNode struct {
	NodeType
	Nodes []Node // nodes executed in lexical order.
}

ListNode holds a sequence of nodes.

type Node

type Node interface {
	Type() NodeType
}

type NodeType

type NodeType uint

NodeType identifies the type of a parse tree node.

const (
	NodeList NodeType = 1 << iota
	NodeFilter
	NodeBuild
	NodeCache
	NodeClone
	NodeDeploy
	NodeCompose
	NodeNotify
	NodePublish
)

func (NodeType) Type

func (t NodeType) Type() NodeType

Type returns itself and provides an easy default implementation for embedding in a Node. Embedded in all non-trivial Nodes.

type RuleFunc

type RuleFunc func(Node) error

RuleFunc defines a function used to validate or modify the yaml during the parsing process.

func CacheFunc

func CacheFunc(dir string) RuleFunc

func DebugFunc

func DebugFunc(debug bool) RuleFunc

func ImageMatchFunc

func ImageMatchFunc(patterns []string) RuleFunc

func ImagePullFunc

func ImagePullFunc(pull bool) RuleFunc

func MountFunc

func MountFunc(from, to string) RuleFunc

func SanitizeFunc

func SanitizeFunc(trusted bool) RuleFunc

func StorageDriverFunc

func StorageDriverFunc(storageDriver string) RuleFunc

type Tree

type Tree struct {
	Root *ListNode
	// contains filtered or unexported fields
}

Tree is the representation of a parsed build configuraiton Yaml file.

func Load

func Load(conf *yaml.Config, rules []RuleFunc) (*Tree, error)

Load loads the Yaml build definition structure and returns an execution Tree.

func Parse

func Parse(raw string, rules []RuleFunc) (*Tree, error)

Parse parses the Yaml build definition file and returns an execution Tree.

Jump to

Keyboard shortcuts

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