Documentation ¶
Overview ¶
Package pipeline : execution modelling The pipeline package offers mappings from JointJS Diagrams into golang for the purposes of designing a simplified overview of what a kubernetes deployment might look like.
Index ¶
- Constants
- func Sanitize(str string, sep string) string
- type Command
- func (command *Command) AddEnvVar(key, value string)
- func (command *Command) Execute(directory string, subdir string, filename string, event string, ...) int
- func (command *Command) ExecuteForever(cmd *exec.Cmd, done chan error) int
- func (command *Command) ExecuteWithTimeout(cmd *exec.Cmd, done chan error) int
- func (command *Command) GenerateRandomString() string
- func (command *Command) GetContainer(asTag bool) string
- type Container
- type GitRepo
- type Link
- type LinkInterface
- type Matcher
- type PathLink
- type Pipeline
- func (pipeline *Pipeline) AddEnv(command *Command)
- func (pipeline *Pipeline) CommandFromContainerName(kubernetesGroup string, image string) *Command
- func (pipeline *Pipeline) ContainerFromCommandID(commandID string) *Container
- func (pipeline *Pipeline) ContainerFromServiceName(serviceName string) *Container
- func (pipeline *Pipeline) GetCommand(id string) *Command
- func (pipeline *Pipeline) GetConnection(source *Command, dest *Command) *LinkInterface
- func (pipeline *Pipeline) GetEndIds() []string
- func (pipeline *Pipeline) GetLink(id string) *LinkInterface
- func (pipeline *Pipeline) GetLinksFrom(command *Command) []*LinkInterface
- func (pipeline *Pipeline) GetLinksTo(command *Command) []*LinkInterface
- func (pipeline *Pipeline) GetNext(after *Command) []*Command
- func (pipeline *Pipeline) GetNextID(after *Command) []string
- func (pipeline *Pipeline) GetParent(command *Command) *Container
- func (pipeline *Pipeline) GetPathSources(source *Command) []string
- func (pipeline *Pipeline) GetPrev(before *Command) []*Command
- func (pipeline *Pipeline) GetPreviousID(before *Command) []string
- func (pipeline *Pipeline) GetStart() []*Command
- func (pipeline *Pipeline) GetStartIds() []string
- func (pipeline *Pipeline) IsConvergence(command *Command) bool
- func (pipeline *Pipeline) Unique(matchers []Matcher) []Matcher
- func (pipeline *Pipeline) WatchItems() []Matcher
- type PortLink
- type Source
Constants ¶
const TIMEOUT = 15
TIMEOUT : The maximum number of minutes a command can execute for if not forever
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Command ¶
type Command struct { // ID is the jointJS element ID ID string `json:"id"` // Parent is the jointJS ID of a parent container Parent string `json:"parent"` // The command container name Name string `json:"name"` // The executable binary name to trigger when events are recieved Command string `json:"command"` // Should the command automatically be started AutoStart bool `json:"autostart"` // Arguments to give to the command Args string `json:"args"` // The version of the container Version string `json:"version"` // The programming language the container is executing Language string `json:"element"` // Does this container have a script to execute Script bool `json:"script"` // The content of the script - will be base64 encoded for transmission safety ScriptContent string `json:"scriptcontent"` // Is this a custom container or is it a pre-fabricated container from an upstream source Custom bool `json:"custom"` // The user defined timeout in minutes - if >15 will be rounded down to 15 Timeout int `json:"timeout"` // (Re)Use an existing container UseExisting bool `json:"existing"` // Expose this port as a service port ExposePort int `json:"exposeport"` // Is the service port a UDP port IsUDP bool `json:"isudp"` // The required CPU of the container (default 500m cpu) CPU string `json:"cpu"` // The required memory of the container (default 256Mi) Memory string `json:"memory"` // The time this command was started in unix nano StartTime int64 `json:"starttime"` // The time this command ended in unix nano EndTime int64 `json:"endtime"` // Environment variables to set directly on the command Environment []string `json:"environment"` // Details about any Git repository configured for the command GitRepo *GitRepo `json:"gitrepo"` // The image string to build the docker container from and load into kubernetes Image string // The computed tag to upload the container docker image as Tag string // Standard output buffer Stdout bytes.Buffer // Standard error buffer Stderr bytes.Buffer // The commands process ID whilst executing ProcessID int // A computed set of process arguments including any files ProcessArgs []string // A computed file separator FileSeperator string }
Command : Define the structure of a command taken from JointJS and executed by Syphon
func NewCommand ¶
NewCommand : Create a new command instance
func (*Command) AddEnvVar ¶
AddEnvVar : Add a value to the environment variables key, value will be converted to KEY=value
func (*Command) Execute ¶
func (command *Command) Execute(directory string, subdir string, filename string, event string, libraryDir string) int
Execute : Execute the current command inside the container
This is the main workhorse function for the application, taking all User configured and temporary variables, mapping them into the environment and process arguments then executing the command, terminating as necesssary after the configured timeout, and capturing the output for later storage and retrieval
func (*Command) ExecuteForever ¶
ExecuteForever : Executes the given command in a "forever" loop
Note: This command does not copy any logs - presuming they will grow exponentially large over time. Check STDERR/STDOUT on the pod for the logs garnered by it.
func (*Command) ExecuteWithTimeout ¶
ExecuteWithTimeout : Runs the given command with a timeout
By default, this timeout is set to 15 minutes and this value is used if 0 is provided. Longer timeouts can be set or set to -1 to run forever.
func (*Command) GenerateRandomString ¶
GenerateRandomString : Generates a random string of 12 characters for use in temporary filenames
func (*Command) GetContainer ¶
GetContainer : Gets a container build string.
if asTag is True, returns a modified form of the container string for uploading to the primary source
type Container ¶
type Container struct { // The JointJS ID of this container element ID string // The name of the container element Name string // How many pods to build Scale int32 // A list of all child IDs this container manages Children []string // The type of container SetType string // The containers state (Building, Ready, Destroying) State string // The number of pods last seen LastCount int // The pipeline this container belongs to Pipeline *Pipeline // Environment settings for the all pods under this set Environment []string }
Container :_Overall structure of a set container
func NewContainer ¶
NewContainer : Construct a new container instance
func (*Container) GetChildren ¶
GetChildren ; Get the set of child command containers of this container
type GitRepo ¶
type GitRepo struct { // The repository URL RepoURL string `json:"repo"` // The branch or commit to checkout on to Branch string `json:"branch"` // The Username to checkout with Username string `json:"username"` // The password or token to use for checkout Password string `json:"password"` // A script to act as the entrypoint inside the container Entrypoint string `json:"entrypoint"` // contains filtered or unexported fields }
GitRepo : Handle git operations for the pipeline
type Link ¶
type Link struct { // JointJS ID of the current link ID string // Type of link being drawn Type string // JointJS Source element ID of the link Source string // JointJS Destination element ID of the link Target string }
Link : Common structure between element link types
type LinkInterface ¶
type LinkInterface interface { // GetType : Get the type of link GetType() string // GetLink : Get the common link details GetLink() Link }
LinkInterface : Common methods to read data from a link type
func NewLink ¶
func NewLink(cell map[string]interface{}) LinkInterface
NewLink : Create a new Link object
type PathLink ¶
type PathLink struct { // Common Link details Link // The path this link will listen against // If link type is Path, this is mutually exclusive with Pattern Path string // Regex pattern to match when reading paths // ignored if link type is socket Pattern string // If link type is path sets up inotify watchers for the path Watch bool }
PathLink : Socket / Path connections
func NewPathLink ¶
NewPathLink : Convert a map[string]interface into a PathLink type
type Pipeline ¶
type Pipeline struct { // The name of the pipeline as specified by the user Name string // DNS name is a DNS formatted identifier of the pipeline DNSName string // The Fully qualified domain name of the pipeline Fqdn string // How the pipeline is represented in storeage BucketName string // A list of container group objects Containers map[string]*Container // Commands which become docker containers in their own right Commands map[string]*Command // Links between the commands Links map[string]*LinkInterface // A set of source objects Sources map[string]*Source // Tiyo config object Config *config.Config // Global environment settings Environment []string // Global pipeline credentials (encrypted) Credentials map[string]string }
Pipeline : The principle interface for mapping JointJS to Kubernetes
func GetPipeline ¶
GetPipeline : Load a pipeline by name from the bolt store and return a new pipeline
func (*Pipeline) CommandFromContainerName ¶
CommandFromContainerName : Get a command id from its final image name
func (*Pipeline) ContainerFromCommandID ¶
ContainerFromCommandID : Get a container from a command id
func (*Pipeline) ContainerFromServiceName ¶
ContainerFromServiceName : Get a container for a given kubernetes service
func (*Pipeline) GetCommand ¶
GetCommand : Gets the command at a given ID returns nil if not found
func (*Pipeline) GetConnection ¶
func (pipeline *Pipeline) GetConnection(source *Command, dest *Command) *LinkInterface
GetConnection : Get the link between two instances
func (*Pipeline) GetEndIds ¶
GetEndIds : Get all command ids at the end of the pipeline
return []string
func (*Pipeline) GetLink ¶
func (pipeline *Pipeline) GetLink(id string) *LinkInterface
GetLink : Get the link at a given ID returns nil if not found
func (*Pipeline) GetLinksFrom ¶
func (pipeline *Pipeline) GetLinksFrom(command *Command) []*LinkInterface
GetLinksFrom : Get all links leading from a given command Return slice of type *LinkInterface
func (*Pipeline) GetLinksTo ¶
func (pipeline *Pipeline) GetLinksTo(command *Command) []*LinkInterface
GetLinksTo : Get all links feeding into a given command returns a slice of type *LinkInterface
func (*Pipeline) GetNext ¶
GetNext : Get the next command[s] following the present command return []*Command
func (*Pipeline) GetNextID ¶
GetNextID : Get all IDs of commands following the present command
return []string slice of IDs
func (*Pipeline) GetParent ¶
GetParent : Gets the parent (if any) of the current command element returns nil if not found
func (*Pipeline) GetPathSources ¶
GetPathSources : get a list of commands which feed the current command
func (*Pipeline) GetPreviousID ¶
GetPreviousID : Get the previous ID[s] return []string
func (*Pipeline) GetStart ¶
GetStart : Gets all starting point commands
Starting commands are commands which either have no links leading into them, or their links have a source whose type is not a Command struct.
Starting commands will generally pick up directly off the event queue or require special case handling to initiate flow through the system
return []*Command
func (*Pipeline) GetStartIds ¶
GetStartIds : Gets a list of all IDs which have no inputs from other Command elements return slice of type string
func (*Pipeline) IsConvergence ¶
IsConvergence : Is this path a convergence point
A convergence point is where multiple paths come together into a single command. Such points are often bottlenecks for data-flow, or offer services such as API or storage Under normal flow, a convergence point only runs a single instance and may cause the pipeline to wait for feed paths to complete before continuing.
func (*Pipeline) WatchItems ¶
WatchItems : Gets a list of directories/files to watch for events. Does not create.
If path is empty, takes the name of the upstream command
type PortLink ¶
type PortLink struct { Link // Source port for connections SourcePort int // Destination port on the service DestPort int // Address to connect to Address string }
PortLink : TCP / UDP connections between elements
func NewPortLink ¶
NewPortLink : Create a new PortLink object