types

package
v0.0.0-...-5d951de Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContainerStatusOff      = "off"
	ContainerStatusBuilding = "building"
	ContainerStatusStarting = "starting"
	ContainerStatusRunning  = "running"
	ContainerStatusStopping = "stopping"
	ContainerStatusError    = "error"
)
View Source
const (
	EventNameContainersChange      = "change"
	EventNameContainerStatusChange = "status_change"
	EventNameContainerStdout       = "stdout"
	EventNameContainerStderr       = "stderr"
	EventNameContainerDownload     = "download"
)
View Source
const (
	LogKindOut       = "out"
	LogKindErr       = "err"
	LogKindDownload  = "download"
	LogKindDownloads = "downloads"
	LogKindVertexOut = "vertex_out"
	LogKindVertexErr = "vertex_err"
)

Variables

View Source
var (
	ErrContainerNotFound     = errors.NotFoundf("container")
	ErrContainerStillRunning = errors.New("container still running")
	ErrDatabaseIDNotFound    = errors.NotFoundf("database id")
)
View Source
var ErrBufferEmpty = errors.New("the buffer is empty")
View Source
var ErrInvalidEnvVariableName = errors.NotValidf("environment variable name")
View Source
var ErrInvalidPort = errors.NotValidf("port")
View Source
var ErrTemplateNotFound = errors.NotFoundf("template")

Functions

This section is empty.

Types

type BuildImageOptions

type BuildImageOptions struct {
	Dir        string `json:"dir,omitempty"`
	Name       string `json:"name,omitempty"`
	Dockerfile string `json:"dockerfile,omitempty"`
}

type Capabilities

type Capabilities []Capability

type Capability

type Capability struct {
	ID          uuid.UUID `json:"id"           db:"id"           example:"7e63ced7-4f4e-4b79-95ca-62930866f7bc"`
	ContainerID uuid.UUID `json:"container_id" db:"container_id" example:"d1fb743c-f937-4f3d-95b9-1a8475464591"`
	Name        string    `json:"name"         db:"name"`
}

type Container

type Container struct {
	ID              uuid.UUID `json:"id"                     db:"id"                 example:"1cb8c970-395f-4810-8c9e-e4df35f456e1"`
	TemplateID      *string   `json:"template_id,omitempty"  db:"template_id"        example:"postgres"`
	UserID          uuid.UUID `json:"user_id"                db:"user_id"            example:"596ecff2-ca67-4194-947d-59e90920680f"`
	Image           string    `json:"image"                  db:"image"              example:"postgres"`
	ImageTag        string    `json:"image_tag,omitempty"    db:"image_tag"          example:"latest"`
	Status          string    `json:"status"                 db:"status"             example:"running"`
	LaunchOnStartup bool      `json:"launch_on_startup"      db:"launch_on_startup"  example:"true"`
	Name            string    `json:"name"                   db:"name"               example:"Postgres"`
	Description     *string   `json:"description"            db:"description"        example:"An SQL database."`
	Color           *string   `json:"color"                  db:"color"              example:"#336699"`
	Icon            *string   `json:"icon"                   db:"icon"               example:"simpleicons/postgres.svg"`
	Command         *string   `json:"command,omitempty"      db:"command"            example:"tunnel run"`

	Databases map[string]uuid.UUID `json:"databases,omitempty"`
	Update    *ContainerUpdate     `json:"update,omitempty"`
}

func (*Container) DockerContainerName

func (i *Container) DockerContainerName() string

func (*Container) DockerImageVertexName

func (i *Container) DockerImageVertexName() string

func (*Container) GetImageNameWithTag

func (i *Container) GetImageNameWithTag() string

func (*Container) IsBusy

func (i *Container) IsBusy() bool

func (*Container) IsRunning

func (i *Container) IsRunning() bool

type ContainerFilters

type ContainerFilters struct {
	Tags     *[]string `json:"tags,omitempty"`
	Features *[]string `json:"features,omitempty"`
}

type ContainerUpdate

type ContainerUpdate struct {
	CurrentVersion string `json:"current_version"`
	LatestVersion  string `json:"latest_version"`
}

type Containers

type Containers []Container

type CreateContainerOptions

type CreateContainerOptions struct {
	TemplateID *string `json:"template_id,omitempty"`
	Image      *string `json:"image,omitempty"`
	ImageTag   *string `json:"image_tag,omitempty"`
}

func (*CreateContainerOptions) FillDefaults

func (o *CreateContainerOptions) FillDefaults()

type CreateContainerResponse

type CreateContainerResponse struct {
	ID       string   `json:"id,omitempty"`
	Warnings []string `json:"warnings,omitempty"`
}

type CreateDockerContainerOptions

type CreateDockerContainerOptions struct {
	ImageName     string            `json:"image_name,omitempty"`
	ContainerName string            `json:"container_name,omitempty"`
	ExposedPorts  nat.PortSet       `json:"exposed_ports,omitempty"`
	PortBindings  nat.PortMap       `json:"port_bindings,omitempty"`
	Binds         []string          `json:"binds,omitempty"`
	Mounts        []mount.Mount     `json:"mounts,omitempty"`
	Env           []string          `json:"env,omitempty"`
	CapAdd        []string          `json:"cap_add,omitempty"`
	Sysctls       map[string]string `json:"sysctls,omitempty"`
	Cmd           []string          `json:"cmd,omitempty"`
}

type CreateVolumeOptions

type CreateVolumeOptions struct {
	Name string `json:"name,omitempty"`
}

type DatabaseEnvironment

type DatabaseEnvironment struct {
	// DisplayName is a readable name for the user.
	DisplayName string `yaml:"display_name" json:"display_name"`

	// The database Types. Can be redis, postgres...
	Types []string `yaml:"types" json:"types"`

	// The database environment names.
	Names DatabaseEnvironmentNames `yaml:"names" json:"names"`
}

type DatabaseEnvironmentNames

type DatabaseEnvironmentNames struct {
	Host     string `yaml:"host" json:"host"`
	Port     string `yaml:"port" json:"port"`
	Username string `yaml:"username" json:"username"`
	Password string `yaml:"password" json:"password"`
	Database string `yaml:"database" json:"database"`
}

type DatabaseFeature

type DatabaseFeature struct {
	// The database Type. Can be redis, postgres...
	Type string `yaml:"type" json:"type" example:"postgres"`

	// The database Category. Can be 'sql', 'redis'...
	Category string `yaml:"category" json:"category" example:"sql"`

	// The database Port. Must be the name
	// of an environment variable.
	Port string `yaml:"port" json:"port" example:"5432"`

	// The Username to connect to the database. Must be the name
	// of an environment variable.
	Username *string `yaml:"username" json:"username" example:"postgres"`

	// The Password to connect to the database. Must be the name
	// of an environment variable.
	Password *string `yaml:"password" json:"password" example:"postgres"`

	// The DefaultDatabase to connect to the database. Must be the name
	// of an environment variable.
	DefaultDatabase *string `yaml:"default-database" json:"database_default" example:"postgres"`
}

type DockerContainer

type DockerContainer struct {
	ID      string   `json:"id,omitempty"`
	ImageID string   `json:"image_id,omitempty"`
	Names   []string `json:"names,omitempty"`
	Mounts  []Mount  `json:"mounts,omitempty"`
	State   string   `json:"state,omitempty"`
}

func NewDockerContainer

func NewDockerContainer(c dockertypes.Container) DockerContainer

type DownloadProgress

type DownloadProgress struct {
	ID      string `json:"id"`
	Status  string `json:"status"`
	Current int64  `json:"current,omitempty"`
	Total   int64  `json:"total,omitempty"`
}

type DownloadProgressGroup

type DownloadProgressGroup []*DownloadProgress

type EnvVariable

type EnvVariable struct {
	ID          uuid.UUID       `json:"id"                    db:"id"            example:"7e63ced7-4f4e-4b79-95ca-62930866f7bc"`
	ContainerID uuid.UUID       `json:"container_id"          db:"container_id"  example:"d1fb743c-f937-4f3d-95b9-1a8475464591"`
	Type        EnvVariableType `json:"type"                  db:"type"          enum:"port"`
	Name        string          `json:"name"                  db:"name"          example:"DB_PORT"`
	DisplayName string          `json:"display_name"          db:"display_name"  example:"Database Port"`
	Value       string          `json:"value"                 db:"value"         example:"5400"`
	Default     *string         `json:"default,omitempty"     db:"default_value" example:"5432"`
	Description *string         `json:"description,omitempty" db:"description"   example:"The server database port"`
	Secret      bool            `json:"secret"                db:"secret"        example:"true"`
}

func (*EnvVariable) Validate

func (v *EnvVariable) Validate() error

type EnvVariableFilters

type EnvVariableFilters struct {
	ContainerID *uuid.UUID `json:"container_id,omitempty" db:"container_id" example:"d1fb743c-f937-4f3d-95b9-1a8475464591"`
}

type EnvVariableType

type EnvVariableType string
const (
	EnvVariableTypeString EnvVariableType = "string"
	EnvVariableTypePort   EnvVariableType = "port"
)

type EventContainerCreated

type EventContainerCreated struct{}

type EventContainerDeleted

type EventContainerDeleted struct{ ContainerID uuid.UUID }

type EventContainerLog

type EventContainerLog struct {
	ContainerID uuid.UUID
	Kind        string
	Message     LogLineMessage
}

type EventContainerStatusChange

type EventContainerStatusChange struct {
	ContainerID uuid.UUID
	Container   Container
	Name        string
	Status      string
}

type EventContainersChange

type EventContainersChange struct{}

type EventContainersLoaded

type EventContainersLoaded struct{ Count int }

type Features

type Features struct {
	// The database feature describes the database made available
	// by this template.
	Databases *[]DatabaseFeature `yaml:"databases" json:"databases"`
}

type InfoContainerResponse

type InfoContainerResponse struct {
	ID           string   `json:"id,omitempty"`
	Name         string   `json:"name,omitempty"`
	Platform     string   `json:"platform,omitempty"`
	Image        string   `json:"image,omitempty"`
	PortBindings []string `json:"port_bindings,omitempty"`
}

type InfoImageResponse

type InfoImageResponse struct {
	ID           string   `json:"id,omitempty"`
	Architecture string   `json:"architecture,omitempty"`
	OS           string   `json:"os,omitempty"`
	Size         int64    `json:"size,omitempty"`
	Tags         []string `json:"tags,omitempty"`
}

type LogLine

type LogLine struct {
	Id      int            `json:"id"`
	Kind    string         `json:"kind"`
	Message LogLineMessage `json:"message"`
}

type LogLineMessage

type LogLineMessage interface {
	String() string
}

type LogLineMessageDownload

type LogLineMessageDownload struct {
	*DownloadProgress
}

func NewLogLineMessageDownload

func NewLogLineMessageDownload(p *DownloadProgress) *LogLineMessageDownload

func (*LogLineMessageDownload) MarshalJSON

func (m *LogLineMessageDownload) MarshalJSON() ([]byte, error)

func (*LogLineMessageDownload) String

func (m *LogLineMessageDownload) String() string

type LogLineMessageDownloads

type LogLineMessageDownloads struct {
	*DownloadProgressGroup
}

func NewLogLineMessageDownloads

func NewLogLineMessageDownloads(p *DownloadProgress) *LogLineMessageDownloads

func (*LogLineMessageDownloads) MarshalJSON

func (m *LogLineMessageDownloads) MarshalJSON() ([]byte, error)

func (*LogLineMessageDownloads) Merge

func (m *LogLineMessageDownloads) Merge(progress *DownloadProgress)

func (*LogLineMessageDownloads) String

func (m *LogLineMessageDownloads) String() string

type LogLineMessageString

type LogLineMessageString struct {
	Value string `json:"value"`
}

func NewLogLineMessageString

func NewLogLineMessageString(s string) *LogLineMessageString

func (*LogLineMessageString) String

func (m *LogLineMessageString) String() string

type Mount

type Mount struct {
	Source      string `json:"source,omitempty"`
	Destination string `json:"destination,omitempty"`
}

func NewMount

func NewMount(m dockertypes.MountPoint) Mount

func NewMounts

func NewMounts(m []dockertypes.MountPoint) []Mount

type Port

type Port struct {
	ID          uuid.UUID `json:"id"           db:"id"            example:"7e63ced7-4f4e-4b79-95ca-62930866f7bc"`
	ContainerID uuid.UUID `json:"container_id" db:"container_id"  example:"d1fb743c-f937-4f3d-95b9-1a8475464591"`
	In          string    `json:"in"           db:"internal_port" example:"5432"` // Port in the container
	Out         string    `json:"out"          db:"external_port" example:"5432"` // Port exposed
}

func (*Port) Validate

func (p *Port) Validate() error

type PortFilters

type PortFilters struct {
	ContainerID *uuid.UUID `json:"container_id,omitempty" db:"container_id"  example:"d1fb743c-f937-4f3d-95b9-1a8475464591"`
}

type Ports

type Ports []Port

type PullImageOptions

type PullImageOptions struct {
	Image string `json:"image,omitempty"`
}

type SetDatabasesOptions

type SetDatabasesOptions struct {
	// The database name to connect to the database. Must be the name
	// of an environment variable.
	DatabaseName *string
}

type Sysctl

type Sysctl struct {
	ID          uuid.UUID `json:"id"           db:"id"           example:"7e63ced7-4f4e-4b79-95ca-62930866f7bc"`
	ContainerID uuid.UUID `json:"container_id" db:"container_id" example:"d1fb743c-f937-4f3d-95b9-1a8475464591"`
	Name        string    `json:"name"         db:"name"`
	Value       string    `json:"value"        db:"value"`
}

type Sysctls

type Sysctls []Sysctl

type Tag

type Tag struct {
	ID     uuid.UUID `json:"id"      db:"id"      example:"12"`
	UserID uuid.UUID `json:"user_id" db:"user_id" example:"d1fb743c-f937-4f3d-95b9-1a8475464591"`
	Name   string    `json:"name"    db:"name"    example:"Vertex SQL"`
}

type Tags

type Tags []Tag

type Template

type Template struct {
	TemplateVersioning `yaml:",inline"`

	// ID is the identifier of the template. It must be unique.
	ID string `yaml:"id" json:"id" example:"vertex-auth"`

	// Name is the displayed name of the template.
	Name string `yaml:"name" json:"name" example:"Vertex Auth"`

	// Repository is the url of the repository, if it is an external repository.
	Repository *string `yaml:"repository,omitempty" json:"repository,omitempty" example:"https://github.com/vertex-center/vertex"`

	// Description describes the template in a few words.
	Description string `yaml:"description" json:"description" example:"The authentication backend of Vertex."`

	// Color is the main color of the template.
	Color *string `yaml:"color,omitempty" json:"color,omitempty" example:"#f38ba8"`

	// Icon is the icon link of the template, located in ./live/templates/icons/.
	Icon *string `yaml:"icon,omitempty" json:"icon,omitempty" example:"vertex.svg"`

	// Features describes some features of the template to help Vertex.
	Features *Features `yaml:"features,omitempty" json:"features,omitempty"`

	// Env defines all parameterizable environment variables.
	Env []TemplateEnv `yaml:"environment,omitempty" json:"environment,omitempty"`

	// Databases defines all databases used by the template.
	Databases map[string]DatabaseEnvironment `yaml:"databases,omitempty" json:"databases,omitempty"`

	// Ports defines all ports that should be exposed by the container.
	Ports []TemplatePort `yaml:"ports,omitempty" json:"ports,omitempty"`

	// URLs defines all template urls.
	// Deprecated: URLs are deleted in version 3.
	URLs []URL `yaml:"urls,omitempty" json:"urls,omitempty"`

	// Methods define different methods to install the template.
	Methods TemplateMethods `yaml:"methods" json:"methods"`
}

func (*Template) UnmarshalYAML

func (s *Template) UnmarshalYAML(unmarshal func(interface{}) error) error

type TemplateClone

type TemplateClone struct {
	Repository string `yaml:"repository" json:"repository" example:"https://github.com/vertex-center/vertex"`
}

type TemplateDependency

type TemplateDependency struct{}

type TemplateEnv

type TemplateEnv struct {
	// Type is the environment variable type.
	// It can be: port, string, url.
	Type string `yaml:"type" json:"type" example:"port"`

	// Name is the environment variable name that will be used by the template.
	Name string `yaml:"name" json:"name" example:"PORT"`

	// DisplayName is a readable name for the user.
	DisplayName string `yaml:"display_name" json:"display_name" example:"Server Port"`

	// Secret is true if the value should not be read.
	Secret *bool `yaml:"secret,omitempty" json:"secret,omitempty" example:"false"`

	// Default defines a default value.
	Default string `yaml:"default,omitempty" json:"default,omitempty" example:"8080"`

	// Description describes this variable to the user.
	Description string `yaml:"description" json:"description" example:"The port where the server will listen."`
}

type TemplateMethodDocker

type TemplateMethodDocker struct {
	// Image is the Docker image to run.
	Image *string `yaml:"image,omitempty" json:"image,omitempty" example:"ghcr.io/vertex-center/vertex"`

	// Clone describes the repository to clone if some files are needed to run the script.
	Clone *TemplateClone `yaml:"clone,omitempty" json:"clone,omitempty"`

	// Dockerfile is the name of the Dockerfile if the repository is cloned.
	Dockerfile *string `yaml:"dockerfile,omitempty" json:"dockerfile,omitempty" example:"Dockerfile"`

	// Ports is a map containing docker port as a key, and output port as a value.
	// The output port is automatically adjusted with PORT environment variables.
	// Deprecated: Use the root Ports variable instead.
	Ports *map[string]string `yaml:"ports,omitempty" json:"ports,omitempty"`

	// Volumes is a map containing output folder as a key, and input folder from Docker
	// as a string value.
	Volumes *map[string]string `yaml:"volumes,omitempty" json:"volumes,omitempty"`

	// Capabilities is an array containing all additional Docker capabilities.
	Capabilities *[]string `yaml:"capabilities,omitempty" json:"capabilities,omitempty"`

	// Sysctls allows to modify kernel parameters.
	Sysctls *map[string]string `yaml:"sysctls,omitempty" json:"sysctls,omitempty"`

	// Cmd is the command to run in the container.
	Cmd *string `yaml:"command,omitempty" json:"command,omitempty"`
}

type TemplateMethods

type TemplateMethods struct {
	// Docker is a method to run the template with Docker.
	Docker *TemplateMethodDocker `yaml:"docker,omitempty" json:"docker,omitempty"`
}

type TemplatePort

type TemplatePort struct {
	// Name is the name displayed to the used describing this port.
	Name string `yaml:"name" json:"name" example:"Server Port"`

	// Port is the port where this port is supposed to be.
	Port string `yaml:"port" json:"port" example:"3000"`
}

type TemplateUpdate

type TemplateUpdate struct {
	Available bool `json:"available"`
}

type TemplateV1

type TemplateV1 Template

func (*TemplateV1) Upgrade

func (s *TemplateV1) Upgrade() *TemplateV2

Upgrade TemplateV1 to TemplateV2. Ports are now a map from port:ENV_NAME instead of port:port.

type TemplateV2

type TemplateV2 Template

func (*TemplateV2) Upgrade

func (s *TemplateV2) Upgrade() *TemplateV3

Upgrade TemplateV2 to TemplateV3. Ports are now an array in the root of the template.

type TemplateV3

type TemplateV3 Template

func (*TemplateV3) Upgrade

func (s *TemplateV3) Upgrade() *Template

type TemplateVersioning

type TemplateVersioning struct {
	// Version of the template format used.
	Version Version `yaml:"version" json:"version" example:"3"`
}

type URL deprecated

type URL struct {
	// Name is the name displayed to the used describing this URL.
	Name string `yaml:"name" json:"name" example:"Vertex Client"`

	// Port is the port where this url is supposed to be.
	// Note that this port is mapped to the default value of an environment definition if possible,
	// but the port here doesn't change with the environment.
	Port string `yaml:"port" json:"port" example:"3000"`

	// HomeRoute allows specifying a route to change the home path.
	HomeRoute *string `yaml:"home,omitempty" json:"home,omitempty" example:"/home"`

	// PingRoute allows specifying a route to change the ping path.
	PingRoute *string `yaml:"ping,omitempty" json:"ping,omitempty" example:"/ping"`

	// Kind is the type of url.
	// It can be: client, server.
	Kind string `yaml:"kind" json:"kind" enum:"client,server"`
}

Deprecated: Deleted in version 3.

type Version

type Version int
const MaxSupportedVersion Version = 3

type Volume

type Volume struct {
	ID          uuid.UUID  `json:"id"           db:"id"             example:"7e63ced7-4f4e-4b79-95ca-62930866f7bc"`
	ContainerID uuid.UUID  `json:"container_id" db:"container_id"   example:"d1fb743c-f937-4f3d-95b9-1a8475464591"`
	Type        VolumeType `json:"type"         db:"type"           example:"bind"` // bind or volume
	In          string     `json:"in"           db:"internal_path"`                 // Path in the container
	Out         string     `json:"out"          db:"external_path"`                 // Path on the host
}

type VolumeType

type VolumeType string
const (
	VolumeTypeBind   VolumeType = "bind"
	VolumeTypeVolume VolumeType = "volume"
)

type Volumes

type Volumes []Volume

type WaitContainerCondition

type WaitContainerCondition container.WaitCondition

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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