v1

package
v0.0.0-...-3b05df2 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultNamespace = "default"
	AllNamespace     = ""
)
View Source
const (
	KindBox      = "Box"
	KindWorkflow = "Workflow"
	KindSecret   = "Secret"
)
View Source
const (
	StatusEnable  = "enable"
	StatusDisable = "disable"
)
View Source
const DockerConfigJSONKey = ".dockerconfigjson"
View Source
const LabelStatus = "ink.io/status"

Variables

View Source
var ErrCanceled = errors.New("canceled")

Functions

func GetValueFromMap

func GetValueFromMap(obj map[string]any, fromPath ...string) (any, bool)

func SetValueToMap

func SetValueToMap(obj map[string]any, toVal any, toPath ...string)

Types

type Box

type Box struct {
	Metadata `yaml:",inline"`

	Resources []BoxResource     `json:"resources" yaml:"resources"`
	Settings  map[string]string `json:"settings,omitempty" yaml:"settings,omitempty"`
	Status    BoxStatus         `json:"status,omitempty" yaml:"status,omitempty"`
}

Box defines a collection of stage executions.

func (*Box) GetSelectors

func (b *Box) GetSelectors(kind string, settings map[string]string) (names []string, selectors []*selector.Selector)

func (*Box) Validate

func (b *Box) Validate(workflows []*Workflow) error

type BoxResource

type BoxResource struct {
	Kind          string             `json:"kind" yaml:"kind"`
	Name          string             `json:"name,omitempty" yaml:"name,omitempty"`
	Selector      *selector.Selector `json:"selector,omitempty" yaml:"selector,omitempty"`
	LabelSelector *selector.Selector `json:"labelSelector,omitempty" yaml:"labelSelector,omitempty"`
}

type BoxStatus

type BoxStatus struct {
	Builds int64 `json:"builds"`
}

type Build

type Build struct {
	ID       uint64            `json:"id" yaml:"id"`
	BoxID    uint64            `json:"boxID" yaml:"boxID"`
	Number   uint64            `json:"number" yaml:"number"`
	Phase    Phase             `json:"phase" yaml:"phase"`
	Title    string            `json:"title" yaml:"title"`
	Message  string            `json:"message,omitempty" yaml:"message,omitempty"`
	Settings map[string]string `json:"settings,omitempty" yaml:"settings,omitempty"`
	Started  int64             `json:"started,omitempty" yaml:"started,omitempty"`
	Stopped  int64             `json:"stopped,omitempty" yaml:"stopped,omitempty"`

	Stages []*Stage `json:"stages,omitempty" yaml:"stages,omitempty"`
}

func (*Build) CompleteSettings

func (b *Build) CompleteSettings(box *Box) map[string]string

type BytesSize

type BytesSize int64

BytesSize stores a human-readable size in bytes, kibibytes, mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB").

func (BytesSize) String

func (b BytesSize) String() string

String returns a human-readable size in bytes, kibibytes, mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB").

func (*BytesSize) UnmarshalYAML

func (b *BytesSize) UnmarshalYAML(unmarshal func(any) error) error

UnmarshalYAML implements yaml unmarshalling.

type Data

type Data struct {
	Box      *Box      `json:"box,omitempty"`
	Build    *Build    `json:"build,omitempty"`
	Workflow *Workflow `json:"workflow,omitempty"`
	Status   *Stage    `json:"status,omitempty"`
	Secrets  []*Secret `json:"secrets,omitempty"`
}

type DockerAuth

type DockerAuth struct {
	Auth     string `json:"auth" yaml:"auth"`
	Username string `json:"username,omitempty" yaml:"username,omitempty"`
	Password string `json:"password,omitempty" yaml:"password,omitempty"`
}

func (*DockerAuth) Decrypt

func (da *DockerAuth) Decrypt() error

func (*DockerAuth) Encrypt

func (da *DockerAuth) Encrypt()

type DockerAuths

type DockerAuths struct {
	Auths map[string]DockerAuth `json:"auths" yaml:"auths"`
}

func (*DockerAuths) Match

func (das *DockerAuths) Match(image string) string

type EmptyDirVolume

type EmptyDirVolume struct {
	Medium    StorageMedium `json:"medium,omitempty"`
	SizeLimit BytesSize     `json:"sizeLimit,omitempty"`
}

type EnvVar

type EnvVar struct {
	// Name of the environment variable.
	Name string `json:"name" yaml:"name"`

	// Description only used to describe the env
	Description string `json:"description,omitempty" yaml:"description,omitempty"`

	// Variable references $(VAR_NAME) are expanded
	// using the previously defined environment variables in the container and
	// any service environment variables. If a variable cannot be resolved,
	// the reference in the input string will be unchanged. Double $$ are reduced
	// to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e.
	// "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)".
	// Escaped references will never be expanded, regardless of whether the variable exists or not.
	// Defaults to "".
	Value string `json:"value,omitempty" yaml:"value,omitempty"`

	// Source for the environment variable's value. Cannot be used if the value is not empty.
	ValueFrom *EnvVarSource `json:"valueFrom,omitempty" yaml:"valueFrom,omitempty"`
}

EnvVar represents an environment variable present in a Flow.

type EnvVarSource

type EnvVarSource struct {
	SecretKeyRef *SecretKeySelector `json:"secretKeyRef,omitempty"`
}

EnvVarSource represents a source for the value of an EnvVar.

type Flow

type Flow struct {
	Name            string         `json:"name" yaml:"name"`
	Image           string         `json:"image,omitempty" yaml:"image,omitempty"`
	ImagePullPolicy PullPolicy     `json:"imagePullPolicy,omitempty" yaml:"imagePullPolicy,omitempty"`
	Privileged      bool           `json:"privileged,omitempty" yaml:"privileged,omitempty"`
	WorkingDir      string         `json:"workingDir,omitempty" yaml:"workingDir,omitempty"`
	Env             []EnvVar       `json:"env,omitempty" yaml:"env,omitempty"`
	Entrypoint      []string       `json:"entrypoint,omitempty" yaml:"entrypoint,omitempty"`
	Shell           []string       `json:"shell,omitempty" yaml:"shell,omitempty"`
	Command         []string       `json:"command,omitempty" yaml:"command,omitempty"`
	Args            []string       `json:"args,omitempty" yaml:"args,omitempty"`
	VolumeMounts    []VolumeMount  `json:"volumeMounts,omitempty" yaml:"volumeMounts,omitempty"`
	Devices         []VolumeDevice `json:"devices,omitempty" yaml:"devices,omitempty"`
	DNS             []string       `json:"dns,omitempty" yaml:"dns,omitempty"`
	DNSSearch       []string       `json:"dnsSearch,omitempty" yaml:"dnsSearch,omitempty"`
	ExtraHosts      []string       `json:"extraHosts,omitempty" yaml:"extraHosts,omitempty"`
}

type HostPathVolume

type HostPathVolume struct {
	Path string `json:"path"`
}

type ListOption

type ListOption struct {
	Pagination    Pagination
	LabelSelector string
}

func (*ListOption) Labels

func (o *ListOption) Labels() map[string]string

func (*ListOption) SetLabels

func (o *ListOption) SetLabels(labels map[string]string)

func (*ListOption) ToValues

func (o *ListOption) ToValues() url.Values

type Metadata

type Metadata struct {
	Kind      string            `json:"kind" yaml:"kind"`
	Name      string            `json:"name" yaml:"name"`
	Namespace string            `json:"namespace" yaml:"namespace"`
	Labels    map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`

	ID       uint64     `json:"id,omitempty" yaml:"id,omitempty"`
	Creation time.Time  `json:"creation,omitempty" yaml:"creation,omitempty"`
	Deletion *time.Time `json:"deletion,omitempty" yaml:"deletion,omitempty"`
}

func GetMetadata

func GetMetadata(object Object) Metadata

func NewMetadata

func NewMetadata(namespace, name string) Metadata

func (*Metadata) GetCreationTimestamp

func (m *Metadata) GetCreationTimestamp() time.Time

func (*Metadata) GetDeletionTimestamp

func (m *Metadata) GetDeletionTimestamp() *time.Time

func (*Metadata) GetKind

func (m *Metadata) GetKind() string

func (*Metadata) GetLabels

func (m *Metadata) GetLabels() map[string]string

func (*Metadata) GetName

func (m *Metadata) GetName() string

func (*Metadata) GetNamespace

func (m *Metadata) GetNamespace() string

func (*Metadata) SetCreationTimestamp

func (m *Metadata) SetCreationTimestamp(timestamp time.Time)

func (*Metadata) SetDeletionTimestamp

func (m *Metadata) SetDeletionTimestamp(timestamp *time.Time)

func (*Metadata) SetKind

func (m *Metadata) SetKind(kind string)

func (*Metadata) SetLabels

func (m *Metadata) SetLabels(labels map[string]string)

func (*Metadata) SetName

func (m *Metadata) SetName(name string)

func (*Metadata) SetNamespace

func (m *Metadata) SetNamespace(namespace string)

func (*Metadata) String

func (m *Metadata) String() string

type Object

type Object interface {
	GetNamespace() string
	SetNamespace(namespace string)
	GetKind() string
	SetKind(kind string)
	GetName() string
	SetName(name string)
	GetLabels() map[string]string
	SetLabels(labels map[string]string)

	GetCreationTimestamp() time.Time
	SetCreationTimestamp(timestamp time.Time)
	GetDeletionTimestamp() *time.Time
	SetDeletionTimestamp(timestamp *time.Time)
}

type Pagination

type Pagination struct {
	Page  int   `json:"page" desc:"page number"`
	Size  int   `json:"size" desc:"page size"`
	Total int64 `json:"total" desc:"total number"`
}

func GetPagination

func GetPagination(r *http.Request) *Pagination

func (*Pagination) List

func (o *Pagination) List(list any) map[string]any

func (*Pagination) Scope

func (o *Pagination) Scope(db *gorm.DB) *gorm.DB

func (*Pagination) SetTotal

func (o *Pagination) SetTotal(total int64) *Pagination

func (*Pagination) ToValues

func (o *Pagination) ToValues() url.Values

type Phase

type Phase string
const (
	PhaseUnknown Phase = "Unknown"
	// PhaseWaiting used for dependencies,
	// the status description that waits for the dependency to finish executing.
	PhaseWaiting   Phase = "Waiting"
	PhasePending   Phase = "Pending"
	PhaseRunning   Phase = "Running"
	PhaseSucceeded Phase = "Succeeded"
	PhaseFailed    Phase = "Failed"
	PhaseCanceled  Phase = "Canceled"
	PhaseSkipped   Phase = "Skipped"
)

func ToPhase

func ToPhase(s string) Phase

func (Phase) IsDone

func (s Phase) IsDone() bool

func (Phase) IsFailed

func (s Phase) IsFailed() bool

func (Phase) IsSucceeded

func (s Phase) IsSucceeded() bool

func (Phase) String

func (s Phase) String() string

type Platform

type Platform struct {
	OS   string `json:"os,omitempty" yaml:"os,omitempty"`
	Arch string `json:"arch,omitempty" yaml:"arch,omitempty"`
}

Platform defines the target platform.

type PullPolicy

type PullPolicy string
const (
	// PullAlways means that kubelet always attempts to pull the latest image.
	// Flow will fail If the pull fails.
	PullAlways PullPolicy = "Always"
	// PullNever means that kubelet never pulls an image, but only uses a local image.
	// Flow will fail if the image isn't present.
	PullNever PullPolicy = "Never"
	// PullIfNotPresent means that kubelet pulls if the image isn't present on disk.
	// Flow will fail if the image isn't present and the pull fails.
	PullIfNotPresent PullPolicy = "IfNotPresent"
)

func (PullPolicy) String

func (s PullPolicy) String() string

type Secret

type Secret struct {
	Metadata `yaml:",inline"`

	Data        map[string]string `json:"data,omitempty" yaml:"data,omitempty"`
	EncryptData map[string]string `json:"encryptData,omitempty" yaml:"encryptData,omitempty"`
}

func (*Secret) Decrypt

func (s *Secret) Decrypt() error

func (*Secret) Encrypt

func (s *Secret) Encrypt()

type SecretKeySelector

type SecretKeySelector struct {
	// The name of the secret in the same namespace to select from.
	Name string `json:"name" yaml:"name"`
	// The key of the secret to select from.  Must be a valid secret key.
	Key string `json:"key" yaml:"key"`
}

SecretKeySelector selects a key of a Secret.

func (*SecretKeySelector) Find

func (s *SecretKeySelector) Find(secrets []*Secret) (key string, data string)

type Stage

type Stage struct {
	ID      uint64 `json:"id" yaml:"id"`
	BoxID   uint64 `json:"boxID" yaml:"boxID"`
	BuildID uint64 `json:"buildID" yaml:"buildID"`
	Number  uint64 `json:"number" yaml:"number"`
	Phase   Phase  `json:"phase" yaml:"phase"`
	Name    string `json:"name" yaml:"name"`
	Limit   int    `json:"limit" yaml:"limit"`
	Started int64  `json:"started,omitempty" yaml:"started,omitempty"`
	Stopped int64  `json:"stopped,omitempty" yaml:"stopped,omitempty"`
	Error   string `json:"error,omitempty" yaml:"error,omitempty"`

	WorkerName string   `json:"workerName,omitempty" yaml:"workerName,omitempty"`
	Worker     Worker   `json:"worker,omitempty" yaml:"worker,omitempty"`
	DependsOn  []string `json:"dependsOn,omitempty" yaml:"dependsOn,omitempty"`

	Steps []*Step `json:"steps,omitempty" yaml:"steps,omitempty"`
}

type Step

type Step struct {
	ID       uint64 `json:"id" yaml:"id"`
	StageID  uint64 `json:"stageID" yaml:"stageID"`
	Number   uint64 `json:"number" yaml:"number"`
	Phase    Phase  `json:"phase" yaml:"phase"`
	Name     string `json:"name" yaml:"name"`
	Started  int64  `json:"started,omitempty" yaml:"started,omitempty"`
	Stopped  int64  `json:"stopped,omitempty" yaml:"stopped,omitempty"`
	ExitCode int    `json:"exitCode,omitempty" yaml:"exitCode,omitempty"`
	Error    string `json:"error,omitempty" yaml:"error,omitempty"`
}

type StorageMedium

type StorageMedium string

StorageMedium defines ways that storage can be allocated to a volume.

const (
	StorageMediumDefault StorageMedium = ""       // use whatever the default is for the node, assume anything we don't explicitly handle is this
	StorageMediumMemory  StorageMedium = "memory" // use memory (e.g. tmpfs on linux)
)

type UnstructuredObject

type UnstructuredObject struct {
	Object map[string]any
}

func (*UnstructuredObject) GetCreationTimestamp

func (o *UnstructuredObject) GetCreationTimestamp() time.Time

func (*UnstructuredObject) GetDeletionTimestamp

func (o *UnstructuredObject) GetDeletionTimestamp() *time.Time

func (*UnstructuredObject) GetKind

func (o *UnstructuredObject) GetKind() string

func (*UnstructuredObject) GetLabels

func (o *UnstructuredObject) GetLabels() map[string]string

func (*UnstructuredObject) GetName

func (o *UnstructuredObject) GetName() string

func (*UnstructuredObject) GetNamespace

func (o *UnstructuredObject) GetNamespace() string

func (*UnstructuredObject) MarshalJSON

func (o *UnstructuredObject) MarshalJSON() ([]byte, error)

func (*UnstructuredObject) MarshalYAML

func (o *UnstructuredObject) MarshalYAML() ([]byte, error)

func (*UnstructuredObject) SetCreationTimestamp

func (o *UnstructuredObject) SetCreationTimestamp(timestamp time.Time)

func (*UnstructuredObject) SetDeletionTimestamp

func (o *UnstructuredObject) SetDeletionTimestamp(timestamp *time.Time)

func (*UnstructuredObject) SetKind

func (o *UnstructuredObject) SetKind(kind string)

func (*UnstructuredObject) SetLabels

func (o *UnstructuredObject) SetLabels(labels map[string]string)

func (*UnstructuredObject) SetName

func (o *UnstructuredObject) SetName(name string)

func (*UnstructuredObject) SetNamespace

func (o *UnstructuredObject) SetNamespace(namespace string)

func (*UnstructuredObject) ToObject

func (o *UnstructuredObject) ToObject(v Object) error

func (*UnstructuredObject) UnmarshalJSON

func (o *UnstructuredObject) UnmarshalJSON(data []byte) error

func (*UnstructuredObject) UnmarshalYAML

func (o *UnstructuredObject) UnmarshalYAML(value *yaml.Node) error

type Volume

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

	HostPath *HostPathVolume `json:"hostPath,omitempty" `
	EmptyDir *EmptyDirVolume `json:"emptyDir,omitempty" `
}

type VolumeDevice

type VolumeDevice struct {
	Name string `json:"name" yaml:"name"`
	Path string `json:"path" yaml:"path"`
}

type VolumeMount

type VolumeMount struct {
	// This must match the Name of a Volume.
	Name string `json:"name"`
	// Path within the container at which the volume should be mounted.  Must
	// not contain ':'.
	Path string `json:"path"`
}

VolumeMount describes a mounting of a Volume within a container.

type Worker

type Worker struct {
	Kind     WorkerKind        `json:"kind,omitempty" yaml:"kind,omitempty"`
	Labels   map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"`
	Platform *Platform         `json:"platform,omitempty" yaml:"platform,omitempty"`
}

type WorkerKind

type WorkerKind string
const (
	WorkerKindHost       WorkerKind = "host"
	WorkerKindDocker     WorkerKind = "docker"
	WorkerKindKubernetes WorkerKind = "kubernetes"
	WorkerKindSSH        WorkerKind = "ssh"
)

func (WorkerKind) String

func (s WorkerKind) String() string

type Workflow

type Workflow struct {
	Metadata `yaml:",inline"`

	Spec WorkflowSpec `json:"spec" yaml:"spec"`
}

func (*Workflow) Worker

func (w *Workflow) Worker() *Worker

type WorkflowSpec

type WorkflowSpec struct {
	Steps            []Flow             `json:"steps" yaml:"steps"`
	WorkingDir       string             `json:"workingDir,omitempty" yaml:"workingDir,omitempty"`
	Concurrency      int                `json:"concurrency,omitempty" yaml:"concurrency,omitempty"`
	Volumes          []Volume           `json:"volumes,omitempty" yaml:"volumes,omitempty"`
	DependsOn        []string           `json:"dependsOn,omitempty" yaml:"dependsOn,omitempty"`
	ImagePullSecrets []string           `json:"imagePullSecrets,omitempty" yaml:"imagePullSecrets,omitempty"`
	Worker           *Worker            `json:"worker,omitempty" yaml:"worker,omitempty"`
	When             *selector.Selector `json:"when,omitempty" yaml:"when,omitempty"`
}

Jump to

Keyboard shortcuts

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