flow

package
v0.0.0-...-e7db92f Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package flow : API subsystem for flow app

Package flow : This is the main executor for the pipeline sub-system Flow takes the pipeline object, iterates over it and builds the elements contained within it. It also contains handlers for handing status information back to assemble front end, and for delivering commands into the syphon executors via API calls.

Flow can be triggered in single pipeline mode by specifying the pipeline as a command line parameter (-p), and/or in update mode which will cause any containers in the pipeline to be rebuilt - useful for updating Tiyo inside any containers active in the pipeline.

Index

Constants

View Source
const MAXQUEUE = 100000

MAXQUEUE defines how many events should be written into the queue every n seconds

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {

	// The flow API can hold multiple pipelines but only one copy
	// of each individual pipeline.
	// If multiple copies of the same pipeline are required, multiple
	// flow instances need to be executed although this will lead to
	// issues with the current queue implementation
	Instances map[string]Flow
	// contains filtered or unexported fields
}

API Structure for the flow api

func NewAPI

func NewAPI() *API

NewAPI Create a new Flow API object

func (*API) Destroy

func (api *API) Destroy(c *gin.Context)

Destroy : Destroy all infrastructure related to the current pipeline

func (*API) Execute

func (api *API) Execute(c *gin.Context)

Execute : [Re]Create all infrastructure associated with the current pipeline

func (*API) Register

func (api *API) Register(c *gin.Context)

Register : Endpoint for Syphon executors to register their current status

When the status parameter is sent and is set to ready, if a command is available on the queue, this is sent back to syphon.

If syphon registers busy, no command should be sent back.

func (*API) Serve

func (api *API) Serve(config *config.Config)

Serve the API over HTTP

Flow api offers integrations for the Syphon application to communicate and for assemble to trigger the application deployments.

func (*API) Start

func (api *API) Start(c *gin.Context)

Start : Allow events to be picked up from the queue and new events to be added

func (*API) Status

func (api *API) Status(c *gin.Context)

Status : Get the status of the executing pipeline

func (*API) Stop

func (api *API) Stop(c *gin.Context)

Stop : Stop events being retrieved from the queue and new events being added

type DecryptBody

type DecryptBody struct {
	Value string `json:"value"`
	Token string `json:"token"`
}

type Flow

type Flow struct {

	// The real name (non-formatted) of the pipeline used by Flow
	Name string

	// The config system used by flow
	Config *config.Config

	// The pipeline executed by this instance of flow
	Pipeline *pipeline.Pipeline

	// The docker engine
	Docker *docker.Docker

	// Kubernetes engine
	Kubernetes *kube.Kubernetes

	// Flags expected for execution of Flow
	Flags *flag.FlagSet

	// The queue system for managing event handoff from assemble to syphon
	Queue *Queue

	// Is the pipeline being executed
	IsExecuting bool

	// The API subsystem
	API *API
	// contains filtered or unexported fields
}

Flow : Main structure of the Flow subsystem

func NewFlow

func NewFlow() *Flow

NewFlow : Construct a new Flow object

func (*Flow) Cleanup

func (flow *Flow) Cleanup(path string, owd string, err error) error

Cleanup : Delete any redundant files left over from building the container

func (*Flow) CopyTiyoBinary

func (flow *Flow) CopyTiyoBinary() error

CopyTiyoBinary : Tiyo embeds itself into the containers it build to run in Syphon mode.

func (*Flow) Create

func (flow *Flow) Create(instance *pipeline.Command) error

Create : Creates a new docker container image if one is not already found in the library

func (*Flow) Decrypt

func (flow *Flow) Decrypt(what string) (string, error)

Decrypt : Sends a string back to assemble for decryption

func (*Flow) Destroy

func (flow *Flow) Destroy()

Destroy : Destroys any infrastructure relating to this flow

func (*Flow) Execute

func (flow *Flow) Execute()

Execute : Triggers the current flow building all components

func (*Flow) Find

func (flow *Flow) Find(name string, config *config.Config) *Flow

Find : Find a pipeline by name and return a new Flow object with the pipeline embedded

func (*Flow) Init

func (flow *Flow) Init()

Init : Parse the command line and any environment variables for configuring Flow

func (*Flow) LoadPipeline

func (flow *Flow) LoadPipeline(pipelineName string) bool

LoadPipeline : Loads a pipeline from a given name returning false if the pipeline fails to load

func (*Flow) Run

func (flow *Flow) Run() int

Run : Run Flow

func (*Flow) Setup

func (flow *Flow) Setup(pipelineName string) bool

Setup : Sets up the flow ready for execution

func (*Flow) Start

func (flow *Flow) Start()

Start : Starts the flow queue

func (*Flow) Stop

func (flow *Flow) Stop()

Stop : Stop the flow queue from executing - does not stop the build

func (*Flow) WriteConfig

func (flow *Flow) WriteConfig() error

WriteConfig : Create a basic config for Syphon to communicate with the current flow

func (*Flow) WriteDockerfile

func (flow *Flow) WriteDockerfile(instance *pipeline.Command) error

WriteDockerfile ; Writes the template dockerfile ready for building the container

type Queue

type Queue struct {

	// The queue bucket to write to
	QueueBucket string

	// The files bucket to write to
	FilesBucket string

	// A bucket to store pod information in
	PodBucket string

	// A bucket to store non-filesystem events in
	EventsBucket string

	// The pipeline bucket to assign against
	PipelineBucket string

	// Configuration for the queue
	Config *config.Config

	// The pipeline used by the queue
	Pipeline *pipeline.Pipeline

	// HTTP client
	Client *http.Client

	// Is the queue stopped or not
	Stopped bool
}

Queue : Defines the structure of the queue item

func NewQueue

func NewQueue(config *config.Config, pipeline *pipeline.Pipeline, bucket string) *Queue

NewQueue : Create a new queue instance

func (*Queue) GetQueueItem

func (queue *Queue) GetQueueItem(container string, pod string) (int, *api.QueueItem)

GetQueueItem : Get a command to execute

func (*Queue) Register

func (queue *Queue) Register(request map[string]interface{}) *api.Result

Register : Registers a container into the queue executors

func (*Queue) Start

func (queue *Queue) Start()

Start : starts the current queue as a background process

func (*Queue) Stop

func (queue *Queue) Stop()

Stop : stops the current queue

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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