phylax

package
v0.0.0-...-d3e8332 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildJob

func BuildJob(reqBytes []byte, natsInfo map[string]string)

BuildJob adds an Informer to watch a BuildJob on the user cluster

func BuildStart

func BuildStart(reqBytes []byte, natsInfo map[string]string)

BuildStart persists a WorkflowDefinition Build in the database

func GetBuild

func GetBuild(reqBytes []byte, msg *nats.Msg, natsInfo map[string]string)

GetBuild will return the Build from MongoDB with the information tying it to a WorkflowDefinition

func GetBuildsForUser

func GetBuildsForUser(reqBytes []byte, msg *nats.Msg, natsInfo map[string]string)

GetBuildsForUser will return all Builds from MongoDB with information tying them to WorkflowDefinitions

func GetResources

func GetResources(reqBytes []byte, msg *nats.Msg, natsInfo map[string]string)

GetResources ...

func GetRunner

func GetRunner(reqBytes []byte, msg *nats.Msg, natsInfo map[string]string)

GetRunner will return the Runner from MongoDB with the information tying it to a WorkflowDefinition

func GetRunnersForUser

func GetRunnersForUser(reqBytes []byte, msg *nats.Msg, natsInfo map[string]string)

GetRunnersForUser will return all Runners from MongoDB with information tying them to WorkflowDefinitions

func InitMongoDB

func InitMongoDB(name, address string) error

InitMongoDB will initialize the connection to the database

func PleoDelete

func PleoDelete(reqBytes []byte, natsInfo map[string]string)

PleoDelete ...

func PleoRun

func PleoRun(reqBytes []byte, natsInfo map[string]string)

PleoRun will store a new Runner in the database when a run is started

func UpdateRunner

func UpdateRunner(reqBytes []byte, natsInfo map[string]string)

UpdateRunner is used to add the TCPPort NodePort to the Runner after it is created

func WorkflowDefinitionCreate

func WorkflowDefinitionCreate(msg *stan.Msg)

WorkflowDefinitionCreate logs when a WorkflowDefinition is created

Types

type Build

type Build struct {
	Condition         BuildConditionType `bson:"condition" json:"condition"`
	MonitoredResource `bson:",inline"`
	RunAfterBuild     bool `json:"run"`
	// RunID should only be populated if RunAfterBuild is true
	RunID string `bson:"runid" json:"runid"`
}

Build represents a request to build the necessary Docker image(s) for a WorkflowDefinition

func NewBuild

func NewBuild(request Request) (build *Build, err error)

NewBuild accepts a Request and uses it to populate a Build. The Condition field is set to BuildPending.

func (Build) GetCollection

func (b Build) GetCollection() string

GetCollection returns the MongoDB collection in which Builds should be stored.

func (Build) GetID

func (b Build) GetID() string

GetID ...

func (Build) GetOwner

func (b Build) GetOwner() string

GetOwner ...

type BuildConditionType

type BuildConditionType string

BuildConditionType is a string that represents the state of a Build.

const (
	// BuildComplete means the build has completed successfully.
	BuildComplete BuildConditionType = "Complete"
	// BuildFailed means the build has failed.
	BuildFailed BuildConditionType = "Failed"
	// BuildPending means the build is still in progress.
	BuildPending BuildConditionType = "Pending"
)

These are valid conditions of a build.

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB struct is a wrapper around the CRUD adapter for Phylax related types.

func (DB) Delete

func (d DB) Delete(document common.CacaoBase) error

Delete ...

func (DB) GetBuild

func (d DB) GetBuild(ID, owner string) (*Build, error)

GetBuild ...

func (DB) GetBuildsForUser

func (d DB) GetBuildsForUser(owner string) (builds []Build, err error)

GetBuildsForUser ...

func (DB) GetRunner

func (d DB) GetRunner(ID, owner string) (*Runner, error)

GetRunner ...

func (DB) GetRunnersForUser

func (d DB) GetRunnersForUser(owner string) (runners []Runner, err error)

GetRunnersForUser ...

func (DB) Save

func (d DB) Save(document common.CacaoBase) error

Save ...

type MonitoredResource

type MonitoredResource struct {
	ID                   string         `bson:"_id" json:"id"`
	Owner                string         `bson:"owner" json:"owner"`
	StartDate            time.Time      `bson:"startdate" json:"startdate"`
	EndDate              time.Time      `bson:"enddate" json:"enddate"`
	WorkflowDefinitionID string         `bson:"workflowdefinitionid" json:"workflowdefinitionid"`
	ResourceName         string         `bson:"resourcename" json:"resourcename"`
	Cluster              common.Cluster `json:"cluster"`
	Namespace            string         `bson:"namespace" json:"namespace"`
}

MonitoredResource comprises the fields that are common among resources that Phylax monitors (e.g. Runners, Builds)

func (*MonitoredResource) Populate

func (m *MonitoredResource) Populate(request Request) error

Populate accepts a phylax.Request and uses it to populate the fields of a MonitoredResource

type Request

type Request struct {
	common.BasicRequest
	RunAfterBuild      bool               `json:"run"`
	TCPPorts           []core.ServicePort `json:"tcp_ports,omitempty"`
	HTTPPorts          []core.ServicePort `json:"http_ports,omitempty"`
	Namespace          string             `json:"namespace,omitempty"`
	AuthDisabled       bool               `json:"auth_disabled,omitempty"`
	WorkflowDefinition struct {
		Name       string             `json:"name,omitempty"`
		Type       string             `bson:"type" json:"type,omitempty" yaml:"type"`
		TCPPorts   []core.ServicePort `json:"tcp_ports,omitempty"`
		Repository common.Repository  `json:"repository"`
	} `json:"data,omitempty"`
}

Request is a struct containing the necessary fields for all Phylax operations coming from the API

type Runner

type Runner struct {
	MonitoredResource `bson:",inline"`
	TCPPorts          []core.ServicePort `bson:"tcp_ports" json:"tcp_ports"`
	HTTPPorts         []core.ServicePort `bson:"http_ports" json:"http_ports"`
	AuthDisabled      bool               `bson:"auth_disabled" json:"auth_disabled"`
}

Runner contains the necessary information to link objects in K8s to the WorkflowDefinition they originate from

func NewRunner

func NewRunner(request Request) (runner *Runner, err error)

NewRunner populates a Runner from a phylax.Request and returns a pointer to it and an error if anything goes wrong

func (Runner) GetCollection

func (r Runner) GetCollection() string

GetCollection returns the MongoDB collection in which Runners should be stored.

func (Runner) GetID

func (r Runner) GetID() string

GetID ...

func (Runner) GetOwner

func (r Runner) GetOwner() string

GetOwner ...

func (*Runner) GetRedacted

func (r *Runner) GetRedacted() Runner

GetRedacted will return a new Runner with the cluster config removed

Jump to

Keyboard shortcuts

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