v1alpha1

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is the version string for the types registered for xene.
	Version string = "v1alpha1"

	// RegistryPath contains the path of the registry key
	RegistryPath string = fmt.Sprintf("%s/registry", Version)

	// WorkflowKeyPrefix is the key prefix for all the workflow objects.
	WorkflowKeyPrefix string = fmt.Sprintf("%s/workflow", RegistryPath)

	// WorkflowStatusKeyPrefix is the key prefix for all the workflow status objects.
	WorkflowStatusKeyPrefix string = fmt.Sprintf("%s/status/workflow", RegistryPath)

	// PipelineStatusKeyPrefix is the key prefix for all the pipeline status objects.
	PipelineStatusKeyPrefix string = fmt.Sprintf("%s/status/pipeline", RegistryPath)

	// PipelineKeyPrefix is the key prefix for all the pipeline objects.
	PipelineKeyPrefix string = fmt.Sprintf("%s/pipeline", RegistryPath)

	// TriggerStatusKeyPrefix is the key prefix for all the trigger status objects.
	TriggerStatusKeyPrefix string = fmt.Sprintf("%s/status/trigger", RegistryPath)

	// TriggerKeyPrefix is the key prefix for all the trigger objects.
	TriggerKeyPrefix string = fmt.Sprintf("%s/trigger", RegistryPath)

	// WorkflowKind is the Kind when creating a Workflow
	WorkflowKind string = "Workflow"

	// WorkflowStatusKind is the kind corresponding to WorkflowStatus
	WorkflowStatusKind string = "WorkflowStatus"

	// AgentKeyPrefix is the key prefix for all the agent objects in xene.
	AgentKeyPrefix string = fmt.Sprintf("%s/agent", RegistryPath)

	// AgentKind is the kind when creating Agent object
	AgentKind string = "Agent"

	// SecretKeyPrefix is the key prefix for all the workflow objects.
	SecretKeyPrefix string = fmt.Sprintf("%s/secret", RegistryPath)

	// SecretKind is the kind when creating a secret object in xene.
	SecretKind string = "Secret"

	// DefaultTriggerType contains the name of the default trigger type.
	DefaultTriggerType TriggerType = "default"

	// CronTriggerType contains the name of the cron job trigger type.
	CronTriggerType TriggerType = "cron"

	// DockerExecutor is the name of the docker executor used by agent.
	DockerExecutor Executor = "docker"

	// ContainerExecutor is the name of the container executor used by agent.
	ContainerExecutor Executor = "container"

	// RegisteredExecutors contains a list of executors ContainerExecutor with xene.
	RegisteredExecutors []Executor = []Executor{ContainerExecutor}

	// RegisteredTriggerTypes contains a list of TriggerTypes allowed with xene.
	RegisteredTriggerTypes []TriggerType = []TriggerType{DefaultTriggerType, CronTriggerType}

	// RegistryItemWorkflow contains the workflow registry item name
	RegistryItemWorkflow RegistryItem = "workflow"

	// RegistryItemAgent contains the Agent registry item name
	RegistryItemAgent RegistryItem = "agent"

	// RegistryItemSecret contains the secret registry item name
	RegistryItemSecret RegistryItem = "secret"

	// RegistryItems contains a list of all the available registry items
	RegistryItems []RegistryItem = []RegistryItem{RegistryItemAgent, RegistryItemSecret, RegistryItemWorkflow}

	// StatusError contains the error status
	StatusError string = "Error"

	// StatusSuccess contains the success status
	StatusSuccess string = "Success"

	// StatusRunning contains the running  status
	StatusRunning string = "Running"

	// StatusNotExecuted contais the status when a component is not executed.
	StatusNotExecuted string = "NotExecuted"
)
View Source
var (
	// ErrInvalidDNSSubdomainName is error used when the name is not a valid
	// DNS Subdomain conforming to RFC 1123
	ErrInvalidDNSSubdomainName = errors.New("Name should be a valid DNS subdomain conforming to RFC 1123")
)
View Source
var NameRegex = regexp.MustCompile(`^[a-zA-Z0-9]+[a-zA-Z0-9-._]*[a-zA-Z0-9]+$`)

NameRegex is the regex for any ID/Name used by xene. Matches any DNS Subdomain Names

Functions

func GetWorkflowPrefixedName

func GetWorkflowPrefixedName(wf, name string) string

GetWorkflowPrefixedName returns the name prefixed with the workflow name.

func IsValidDNSSubdomainName

func IsValidDNSSubdomainName(name string) bool

IsValidDNSSubdomainName checks if the provided string is a valid DNS subdomain name

Types

type Agent

type Agent struct {
	// TypeMeta stores meta type information for the agent object.
	TypeMeta `json:",inline"`

	// Metadata contains metadata about the Agent object.
	Metadata Metadata `json:"metadata"`

	// Spec contains the spec of the agent.
	Spec AgentSpec `json:"spec"`
}

Agent is the type which contains agent object definition.

func (*Agent) DeepEquals

func (a *Agent) DeepEquals(ag *Agent) bool

DeepEquals checks if the object provided is equal to the agent object.

func (*Agent) Validate

func (a *Agent) Validate() error

Validate checks for any issues in the information about the agent in the type.

type AgentSpec

type AgentSpec struct {
	// Address contains the address of the agent.
	Address string `json:"address"`

	// Insecure specifies if the agent is running insecure mode,
	// in that case we don't need certifictes for communication.
	Insecure bool `json:"insecure"`

	// ClientKeySecret is the xene client key registry secret object name to use
	// for the GRPC client for agent.
	ClientKeySecret string `json:"clientKeySecret"`

	// ClientCertSecret is the xene registry secret which contains the client certificate.
	ClientCertSecret string `json:"clientCertSecret"`

	// RootCASecret corresponds to the root certificate authority xene secret.
	RootCASecret string `json:"rootCA"`

	// ServerName is the hostname of the server, this is used in case
	// of mTLS authentication between apiserver and the agent.
	ServerName string `json:"serverName"`

	// LogServerEnabled specifies if the log server is enabled for the agent.
	LogServerEnabled bool `json:"logServerEnabled"`

	// LogServerPort contains the port of the http log file handler run with
	// the agent.
	LogServerPort uint32 `json:"logServerPort"`
}

AgentSpec contains the spec of the workflow.

func (*AgentSpec) DeepEquals

func (a *AgentSpec) DeepEquals(az *AgentSpec) bool

DeepEquals checks if the two AgentSpec objects are equal or not

func (*AgentSpec) Validate

func (a *AgentSpec) Validate() error

Validate validates the specification provided for the agent..

type ContainerConfig

type ContainerConfig struct {
	// Image contains the image to use for the container.
	Image string `json:"image"`
}

ContainerConfig contains configuration corresponding to the container executor of a pipeline.

func (*ContainerConfig) DeepEqual

func (c *ContainerConfig) DeepEqual(cz *ContainerConfig) bool

DeepEqual checks if the two pipeline executor objects are equal or not.

type Executor

type Executor string

Executor is a type for representing an executor on the agent.

type KVPairStruct

type KVPairStruct struct {
	Key   string `json:"key" example:"registry/workflow/xxdfdihdfai=="`
	Value string `json:"value" example:"Workflow Document"`

	Version          uint64 `json:"version"`
	ExpiresAt        uint64 `json:"expiresAt"`
	DeletedOrExpired bool   `json:"deletedOrExpired"`
}

KVPairStruct is the representation of Key value pair in golang structure This is used when we serialize KeyValue to string.

type KVPairStructFunc

type KVPairStructFunc func(*KVPairStruct)

KVPairStructFunc is the function type of a function which takes KVPairStruct as an argument.

type KeyValuePairs

type KeyValuePairs map[string]Value

KeyValuePairs is a map of key=value pairs

type Metadata

type Metadata struct {
	ObjectMeta `json:",inline"`

	// UID is the unique ID associated with each managed resource.
	UID string `json:"uid,omitempty"`
}

Metadata corresponds to the metadata associated with the object.

func (*Metadata) Validate

func (m *Metadata) Validate() error

Validate validates the information present in metadata.

type ObjectMeta

type ObjectMeta struct {
	// Description for the type object.
	Description string `json:"description"`

	// Name is the name of the type object.
	Name string `json:"name"`
}

ObjectMeta contains metadata which is common to all of the objects in xene.

func (*ObjectMeta) DeepEquals

func (o *ObjectMeta) DeepEquals(oz *ObjectMeta) bool

DeepEquals checks if the two ObjectMeta objects are equal or not

func (*ObjectMeta) GetName

func (o *ObjectMeta) GetName() string

GetName return the name of the object

type PipelineExecutor

type PipelineExecutor struct {
	// Type contains the type of the pipeline executor
	Type string `json:"type"`

	ContainerConfig ContainerConfig `json:"containerConfig,omitempty"`
}

PipelineExecutor is a type which contains configuration for the executor of of the pipeline.

func (*PipelineExecutor) DeepEqual

func (p *PipelineExecutor) DeepEqual(pz *PipelineExecutor) bool

DeepEqual checks if the two pipeline executor objects are equal or not.

type PipelineRunStatus

type PipelineRunStatus struct {
	Name string `json:"name"`

	RunID string `json:"runID"`

	Status string `json:"status"`

	Agent string `json:"agent"`

	// StartTime is the start time of the pipeline run.
	StartTime int64 `json:"startTime"`

	// EndTime is the time of the pipeline end.
	EndTime int64 `json:"endTime"`

	Tasks map[string]*TaskRunStatus `json:"tasks"`
}

PipelineRunStatus contains the status of a pipeline run.

func GetDummyPipelineRunStatus

func GetDummyPipelineRunStatus(p *PipelineSpecWithName) PipelineRunStatus

GetDummyPipelineRunStatus returns a dummy pipeline run status

func NewPipelineRunStatus

func NewPipelineRunStatus() PipelineRunStatus

NewPipelineRunStatus returns a new instance of PipelineRunStatus object.

type PipelineSpec

type PipelineSpec struct {
	// trigger contains the Trigger for the configured pipeline.
	Trigger *TriggerSpec `json:"-"`

	// Dag contains the dag corresponding to tasks in a pipeline.
	Dag *dag.AcyclicGraph `json:"-"`

	// TriggerName contains the name of the trigger to use for the pipeline.
	TriggerName string `json:"trigger"`

	// Description contains description about the pipeline.
	Description string `json:"description"`

	// Executor describes executor for the pipeline.
	// Should be one of the preconfigured list of available executors.
	Executor PipelineExecutor `json:"executor"`

	// RootTask contains the root task for the pipeline.
	RootTask dag.Vertex `json:"-"`

	// Tasks contains the list of the tasks in the pipeline.
	Tasks map[string]*TaskSpec `json:"tasks"`

	// Envs contains the environment variable for the pipeline.
	Envs map[string]string `json:"envs"`
}

PipelineSpec contains the spec of a pipeline associated with the workflow.

func (*PipelineSpec) DeepEqual

func (p *PipelineSpec) DeepEqual(pz *PipelineSpec) bool

DeepEqual checks if the two pipeline objects are equal or not.

func (*PipelineSpec) Resolve

func (p *PipelineSpec) Resolve(pipelineName string) error

Resolve resolves the specification provided for the pipeline.

func (*PipelineSpec) Validate

func (p *PipelineSpec) Validate(name string) error

Validate validates the specification provided for the pipeline.

type PipelineSpecWithName

type PipelineSpecWithName struct {
	PipelineSpec `json:",inline"`

	// Name contains the name of the pipeline.
	Name string `json:"name"`

	// Workflow contains the workflow that the pipeline is a part of.
	Workflow string `json:"workflow"`
}

PipelineSpecWithName contains the spec of a pipeline associated with the workflow along with the name stored.

type PipelineStatus

type PipelineStatus struct {
	// Executor is the name of the agent which ran this pipeline
	Executor string `json:"executor"`

	// PreviousExecutors contains a list of agents previously in use for the
	// provided pipelines
	PreviousExecutors []string `json:"previousExecutors"`

	// Status contains the status information of the pipeline.
	Status string `json:"status"`
}

PipelineStatus contains the status of the pipeline in context

func (*PipelineStatus) GetAllExecutors

func (p *PipelineStatus) GetAllExecutors() []string

GetAllExecutors returns all the executors that were associated with pipeline

type RegistryItem

type RegistryItem string

RegistryItem is the type of registry item in xene.

type Secret

type Secret struct {
	// TypeMeta stores meta type information for the agent object.
	TypeMeta `json:",inline"`

	// Metadata contains metadata about the Agent object.
	Metadata Metadata `json:"metadata"`

	// Spec contains the spec of the agent.
	Spec SecretSpec `json:"spec"`
}

Secret is the type which contains xene secret object definition.

func (*Secret) AddContent

func (s *Secret) AddContent(data []byte)

AddContent adds the provided data to the secret content after base64 encoding it to a string.

func (*Secret) GetContent

func (s *Secret) GetContent() ([]byte, error)

GetContent adds the provided data to the secret content after base64 encoding it to a string.

func (*Secret) Validate

func (s *Secret) Validate() error

Validate validates the integrity of the Secret object.

type SecretSpec

type SecretSpec struct {
	// Type contains the type of secret we are storing.
	Type string `json:"type"`

	// Content contains the base64 string representation of the secret
	// content.
	Content string `json:"content"`

	// Restricted returns if the secret is restricted or not.
	Restricted bool `json:"restricted"`
}

SecretSpec contains the spec of the secret.

func (*SecretSpec) Validate

func (s *SecretSpec) Validate() error

Validate validates the integrity of the Secret object.

type StepRunStatus

type StepRunStatus struct {
	Status string `json:"status"`

	Time time.Duration `json:"time"`

	LogFile string `json:"logFile"`
}

StepRunStatus contains the status of an individual step run.

type TaskRunStatus

type TaskRunStatus struct {
	Status string `json:"status"`

	// Dependencies is a list of task names which this particular
	// task depends on.
	Dependencies []string `json:"dependencies"`

	Steps map[string]*StepRunStatus `json:"steps"`
}

TaskRunStatus contains the status of a task run.

type TaskSpec

type TaskSpec struct {

	// Description contains the description of the task
	Description string `json:"description"`

	// DependsOn contains a list of tasks this task depends on.
	// This is used to build the dag for the pipeline.
	DependsOn []*TaskSpec `json:"-"`

	// Dependencies is a list of task names which this particular
	// task depends on. It is used to resolve the DependsOn variable in
	// the struct.
	Dependencies []string `json:"dependencies"`

	// WorkingDirectory for the task.
	WorkingDirectory string `json:"workingDir"`

	// Step contains a list of steps to go through for the task.
	// These are executed linear.
	Steps []TaskStepSpec `json:"steps"`
	// contains filtered or unexported fields
}

TaskSpec contains the spec corresponding to a single task in a pipeline.

func (*TaskSpec) DeepEqual

func (t *TaskSpec) DeepEqual(tz *TaskSpec) bool

DeepEqual checks if the two TaskSpec objects are equal or not.

func (*TaskSpec) Hashcode

func (t *TaskSpec) Hashcode() string

Hashcode returns a string representation of the task, which is uniquely defined by its name.

func (*TaskSpec) Name

func (t *TaskSpec) Name() string

Name returns the name of the task.

func (*TaskSpec) Resolve

func (t *TaskSpec) Resolve(name string)

Resolve resolves the task specification.

type TaskStepSpec

type TaskStepSpec struct {
	// Name contains the name of the Step
	Name string `json:"name"`

	// Description contains the description of the step, this is
	// optional.
	Description string `json:"description"`

	// Type contains the type of the Step we are exeucting.
	Type string `json:"type"`

	// Cmd defines the command to execute for a step, when the
	// type of step is shell.
	Cmd string `json:"cmd"`
}

TaskStepSpec contains the specification of an individual TaskStep

func (*TaskStepSpec) DeepEqual

func (t *TaskStepSpec) DeepEqual(tz *TaskStepSpec) bool

DeepEqual checks if the two TaskSteppec objects are equal or not.

type TriggerSpec

type TriggerSpec struct {
	// Type contains the type of the trigger we are using
	// Default type for the trigger means that the type of the trigger
	// is webhook. For webhook triggers a WebhookURL is saved onto the
	// PipelineStatus which can be then used to trigger the pipeline.
	Type string `json:"type"`

	// CronConfig contains the configuration for Cron trigger type.
	CronConfig string `json:"cronConfig,omitempty"`
}

TriggerSpec contains spec of a trigger for xene workflow.

func (*TriggerSpec) DeepEqual

func (t *TriggerSpec) DeepEqual(tz *TriggerSpec) bool

DeepEqual checks if the two Trigger objects are equal or not.

func (*TriggerSpec) Validate

func (t *TriggerSpec) Validate(name string) error

Validate validates the specification provided for the a trigger.

type TriggerSpecWithName

type TriggerSpecWithName struct {
	TriggerSpec `json:",inline"`

	// Name contains the name of the trigger.
	Name string `json:"name"`

	// Workflow contains the workflow that the trigger is a part of.
	Workflow string `json:"workflow"`

	// Pipelines contains a list of pipelines configured for the trigger.
	Pipelines []string `json:"pipelines"`
}

TriggerSpecWithName contains the spec of a trigger associated with the pipeline along with the name stored.

func (*TriggerSpecWithName) AddPipeline

func (t *TriggerSpecWithName) AddPipeline(name string)

AddPipeline adds the pipeline with the provided name to the trigger pipeline list.

func (*TriggerSpecWithName) RemovePipeline

func (t *TriggerSpecWithName) RemovePipeline(name string)

RemovePipeline removes the pipeline with the provided name to the trigger pipeline list.

type TriggerType

type TriggerType string

TriggerType is the type to specify the type of trigger.

type TypeMeta

type TypeMeta struct {
	// Kind is the kind of resource the object will represent.
	// For example this can be - Workflow
	Kind string `json:"kind"`

	// ApiVersion is the version this specification corresponds to.
	APIVersion string `json:"apiVersion"`
}

TypeMeta describe the type details for a particular object understood by xene. It is same as that what kubernetes uses for type specification of the object.

func (*TypeMeta) DeepEquals

func (t *TypeMeta) DeepEquals(tz *TypeMeta) bool

DeepEquals checks if the two TypeMeta objects are equal or not

func (*TypeMeta) Validate

func (t *TypeMeta) Validate(reqKind string) error

Validate checks for the information in TypeMeta

type Value

type Value struct {
	// Data is data represented by the value.
	Data []byte

	// Version is the revision of the modified key.
	Version uint64

	// ExpiresAt is the time at which key will expire.
	ExpiresAt uint64

	// DeletedOrExpired checks if the key associated with the value is deleted
	// or expired.
	DeletedOrExpired bool
}

Value is an abstraction of the data stored in the kvstore as well as the mod revision of that data.

type Workflow

type Workflow struct {
	// TypeMeta stores meta type information for the workflow object.
	TypeMeta `json:",inline"`

	// Metadata contains metadata about the Workflow object.
	Metadata Metadata `json:"metadata"`

	// Spec contains the spec of the workflow
	Spec WorkflowSpec `json:"spec"`
}

Workflow is the type which contains workflow object definition.

func (*Workflow) CheckTriggerRequired

func (w *Workflow) CheckTriggerRequired(name string) bool

CheckTriggerRequired checks if the provided trigger name is associated with a pipeline or not.

func (*Workflow) GetTriggerAsssociatedPipelines

func (w *Workflow) GetTriggerAsssociatedPipelines(trigger string) []string

GetTriggerAsssociatedPipelines returns a list of pipelines associated with the provided triggername.

func (*Workflow) GetValidTriggers

func (w *Workflow) GetValidTriggers() map[string]struct{}

GetValidTriggers returns a list of valid triggers

func (*Workflow) RemoveNonLinkedTriggers

func (w *Workflow) RemoveNonLinkedTriggers()

RemoveNonLinkedTriggers removes all the triggers which don't have a pipeline associated with them.

func (*Workflow) Resolve

func (w *Workflow) Resolve() error

Resolve resolves the workflow object by acting upon different relations in the spec.

func (*Workflow) Validate

func (w *Workflow) Validate() error

Validate checks for any issues in the information about the workflow in the type.

type WorkflowSpec

type WorkflowSpec struct {
	// Triggers contains a list of trigger.
	Triggers map[string]*TriggerSpec `json:"triggers"`

	// Pipelines contains a list of pipeline configured with workflow.
	Pipelines map[string]*PipelineSpec `json:"pipelines"`
}

WorkflowSpec contains the spec of the workflow.

func (*WorkflowSpec) Validate

func (w *WorkflowSpec) Validate() error

Validate validates the specification provided for the workflow.

type WorkflowStatus

type WorkflowStatus struct {
	// TypeMeta stores meta type information for the WorkflowStatus object.
	TypeMeta `json:",inline"`

	// Metadata contains metadata about the WorkflowStatus object.
	Metadata Metadata `json:"metadata"`

	// WorkflowSpec contains the workflow spec currently being executed
	// by xene.
	WorkflowSpec string `json:"workflowSpec"`

	// Pipelines contains the status of all the pipelines.
	Pipelines map[string]*PipelineStatus `json:"pipelines"`
}

WorkflowStatus contains the status corresponding to a defined workflow.

func NewWorkflowStatus

func NewWorkflowStatus(wf *Workflow) (WorkflowStatus, error)

NewWorkflowStatus returns a new WorkflowStatus object using the workflow specification provided.

func (*WorkflowStatus) Validate

func (w *WorkflowStatus) Validate() error

Validate checks for any issues in the information about the workflow status in the type.

Jump to

Keyboard shortcuts

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