types

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContainerStatusOff      = "off"
	ContainerStatusBuilding = "building"
	ContainerStatusStarting = "starting"
	ContainerStatusRunning  = "running"
	ContainerStatusStopping = "stopping"
	ContainerStatusError    = "error"
)
View Source
const (
	LogKindOut       = "out"
	LogKindErr       = "err"
	LogKindDownload  = "download"
	LogKindDownloads = "downloads"
	LogKindVertexOut = "vertex_out"
	LogKindVertexErr = "vertex_err"
)
View Source
const (
	ErrCodeContainerUuidInvalid           router.ErrCode = "container_uuid_invalid"
	ErrCodeContainerUuidMissing           router.ErrCode = "container_uuid_missing"
	ErrCodeContainerNotFound              router.ErrCode = "container_not_found"
	ErrCodeContainerAlreadyRunning        router.ErrCode = "container_already_running"
	ErrCodeContainerStillRunning          router.ErrCode = "container_still_running"
	ErrCodeContainerNotRunning            router.ErrCode = "container_not_running"
	ErrCodeFailedToGetContainer           router.ErrCode = "failed_to_get_container"
	ErrCodeFailedToListContainers         router.ErrCode = "failed_to_list_containers"
	ErrCodeFailedToCreateContainer        router.ErrCode = "failed_to_create_container"
	ErrCodeFailedToStartContainer         router.ErrCode = "failed_to_start_container"
	ErrCodeFailedToStopContainer          router.ErrCode = "failed_to_stop_container"
	ErrCodeFailedToDeleteContainer        router.ErrCode = "failed_to_delete_container"
	ErrCodeFailedToGetContainerLogs       router.ErrCode = "failed_to_get_logs"
	ErrCodeFailedToUpdateServiceContainer router.ErrCode = "failed_to_update_service_container"
	ErrCodeFailedToGetVersions            router.ErrCode = "failed_to_get_versions"
	ErrCodeFailedToWaitContainer          router.ErrCode = "failed_to_wait_container"
	ErrCodeFailedToSetLaunchOnStartup     router.ErrCode = "failed_to_set_launch_on_startup"
	ErrCodeFailedToSetDisplayName         router.ErrCode = "failed_to_set_display_name"
	ErrCodeFailedToSetDatabase            router.ErrCode = "failed_to_set_database"
	ErrCodeFailedToSetVersion             router.ErrCode = "failed_to_set_version"
	ErrCodeFailedToSetTags                router.ErrCode = "failed_to_set_tags"
	ErrCodeFailedToSetEnv                 router.ErrCode = "failed_to_set_env"
	ErrCodeFailedToCheckForUpdates        router.ErrCode = "failed_to_check_for_updates"
	ErrCodeFailedToRecreateContainer      router.ErrCode = "failed_to_recreate_container"
	ErrCodeFailedToGetContainerInfo       router.ErrCode = "failed_to_get_container_info"
	ErrCodeFailedToGetImageInfo           router.ErrCode = "failed_to_get_image_info"
	ErrCodeFailedToPullImage              router.ErrCode = "failed_to_pull_image"
	ErrCodeFailedToBuildImage             router.ErrCode = "failed_to_build_image"
	ErrCodeFailedToDeleteMounts           router.ErrCode = "failed_to_delete_mounts"

	ErrCodeServiceIdMissing       router.ErrCode = "service_id_missing"
	ErrCodeServiceNotFound        router.ErrCode = "service_not_found"
	ErrCodeFailedToInstallService router.ErrCode = "failed_to_install_service"
)
View Source
const (
	EventNameContainersChange      = "change"
	EventNameContainerStatusChange = "status_change"
	EventNameContainerStdout       = "stdout"
	EventNameContainerStderr       = "stderr"
	EventNameContainerDownload     = "download"
)
View Source
const (
	ContainerInstallMethodDocker = "docker"
)

Variables

View Source
var (
	ErrContainerNotFound     = errors.New("container not found")
	ErrContainerStillRunning = errors.New("container still running")
	ErrDatabaseIDNotFound    = errors.New("database id not found")
)
View Source
var ErrBufferEmpty = errors.New("the buffer is empty")
View Source
var (
	ErrServiceNotFound = errors.New("the service was not found")
)

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 Container

type Container struct {
	ContainerSettings

	Service Service               `json:"service"`
	UUID    uuid.UUID             `json:"uuid"`
	Status  string                `json:"status"`
	Env     ContainerEnvVariables `json:"environment,omitempty"`

	Update        *ContainerUpdate `json:"update,omitempty"`
	ServiceUpdate ServiceUpdate    `json:"service_update,omitempty"`

	CacheVersions []string `json:"cache_versions,omitempty"`
}

func NewContainer

func NewContainer(id uuid.UUID, service Service) Container

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) GetVersion

func (i *Container) GetVersion() string

func (*Container) HasFeature

func (i *Container) HasFeature(featureType string) bool

func (*Container) HasFeatureIn

func (i *Container) HasFeatureIn(featureTypes []string) bool

func (*Container) HasTag

func (i *Container) HasTag(tag string) bool

func (*Container) HasTagIn

func (i *Container) HasTagIn(tags []string) bool

func (*Container) IsBusy

func (i *Container) IsBusy() bool

func (*Container) IsRunning

func (i *Container) IsRunning() bool

func (*Container) LaunchOnStartup

func (i *Container) LaunchOnStartup() bool

func (*Container) ResetDefaultEnv

func (i *Container) ResetDefaultEnv()

type ContainerEnvVariables

type ContainerEnvVariables map[string]string

type ContainerSearchQuery

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

type ContainerSettings

type ContainerSettings struct {
	// Method indicates how the container is installed.
	// It can be by script, release or docker.
	InstallMethod *string `json:"install_method,omitempty" yaml:"install_method,omitempty"`

	// LaunchOnStartup indicates if the container needs to start automatically when Vertex starts.
	// The default value is true.
	LaunchOnStartup *bool `json:"launch_on_startup,omitempty" yaml:"launch_on_startup,omitempty"`

	// DisplayName is a custom name for the container.
	DisplayName string `json:"display_name" yaml:"display_name"`

	// Databases describe the databases used by the container.
	// The key is the database ID, and the value is the database container UUID.
	Databases map[string]uuid.UUID `json:"databases,omitempty" yaml:"databases,omitempty"`

	// Version is the version of the program.
	Version *string `json:"version,omitempty" yaml:"version,omitempty"`

	// Tags are the tags assigned to the container.
	Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`
}

type ContainerUpdate

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

type CreateContainerOptions

type CreateContainerOptions 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"`
	Env           []string          `json:"env,omitempty"`
	CapAdd        []string          `json:"cap_add,omitempty"`
	Sysctls       map[string]string `json:"sysctls,omitempty"`
	Cmd           []string          `json:"cmd,omitempty"`
}

type CreateContainerResponse

type CreateContainerResponse struct {
	ID       string   `json:"id,omitempty"`
	Warnings []string `json:"warnings,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"`

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

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

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

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

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

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"`
}

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 EventContainerCreated

type EventContainerCreated struct{}

type EventContainerDeleted

type EventContainerDeleted struct {
	ContainerUUID uuid.UUID
	ServiceID     string
}

type EventContainerLoaded

type EventContainerLoaded struct {
	Container *Container
}

type EventContainerLog

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

type EventContainerStatusChange

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

type EventContainersChange

type EventContainersChange struct{}

type EventContainersLoaded

type EventContainersLoaded struct {
	Count int
}

type EventContainersStopped

type EventContainersStopped struct{}

type Features

type Features struct {
	// The database feature describes the database made available
	// by this service.
	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 PullImageOptions

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

type Service

type Service struct {
	ServiceVersioning `yaml:",inline"`

	// ID is the identifier of the service. It must be unique.
	ID string `yaml:"id" json:"id"`

	// Name is the displayed name of the service.
	Name string `yaml:"name" json:"name"`

	// Repository is the url of the repository, if it is an external repository.
	Repository *string `yaml:"repository,omitempty" json:"repository,omitempty"`

	// Description describes the service in a few words.
	Description string `yaml:"description" json:"description"`

	// Color is the main color of the service.
	Color *string `yaml:"color,omitempty" json:"color,omitempty"`

	// Icon is the icon link of the service, located in ./live/services/icons/.
	Icon *string `yaml:"icon,omitempty" json:"icon,omitempty"`

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

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

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

	// URLs defines all service urls.
	URLs []URL `yaml:"urls,omitempty" json:"urls,omitempty"`

	// Methods defines different methods to install the service.
	Methods ServiceMethods `yaml:"methods" json:"methods"`
}

func (*Service) UnmarshalYAML

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

type ServiceClone

type ServiceClone struct {
	Repository string `yaml:"repository" json:"repository"`
}

type ServiceDependency

type ServiceDependency struct{}

type ServiceEnv

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

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

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

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

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

	// Description describes this variable to the user.
	Description string `yaml:"description" json:"description"`
}

type ServiceMethodDocker

type ServiceMethodDocker struct {
	// Image is the Docker image to run.
	Image *string `yaml:"image,omitempty" json:"image,omitempty"`

	// Clone describes the repository to clone if some files are needed to run the script.
	Clone *ServiceClone `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"`

	// 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.
	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"`

	// Environment is a map containing docker environment variable as a key, and
	// its corresponding service environment name as a value.
	Environment *map[string]string `yaml:"environment,omitempty" json:"environment,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 ServiceMethodRelease

type ServiceMethodRelease struct {
	// Dependencies lists all dependencies needed before running the service.
	Dependencies *map[string]ServiceDependency `yaml:"dependencies,omitempty" json:"dependencies,omitempty"`
}

type ServiceMethodScript

type ServiceMethodScript struct {
	// Filename is the name of the file to run to start the service.
	Filename string `yaml:"file" json:"file"`

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

	// Dependencies lists all dependencies needed before running the service.
	Dependencies *map[string]ServiceDependency `yaml:"dependencies,omitempty" json:"dependencies,omitempty"`
}

type ServiceMethods

type ServiceMethods struct {
	// Script is a method to launch the service with a shell script.
	Script *ServiceMethodScript `yaml:"script,omitempty" json:"script,omitempty"`

	// Release is a method to download and launch the service with
	// precompiled binaries from GitHub.
	Release *ServiceMethodRelease `yaml:"release,omitempty" json:"release,omitempty"`

	// Docker is a method to run the service with Docker.
	Docker *ServiceMethodDocker `yaml:"docker,omitempty" json:"docker,omitempty"`
}

type ServiceUpdate

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

type ServiceV1

type ServiceV1 Service

func (*ServiceV1) Upgrade added in v0.16.0

func (s *ServiceV1) Upgrade() *ServiceV2

Upgrade ServiceV1 to ServiceV2. Ports are now a map from port:ENV_NAME instead of port:port.

type ServiceV2 added in v0.16.0

type ServiceV2 Service

func (*ServiceV2) Upgrade added in v0.16.0

func (s *ServiceV2) Upgrade() *Service

type ServiceVersioning

type ServiceVersioning struct {
	// Version of the service format used.
	Version Version `yaml:"version" json:"version"`
}

type SetDatabasesOptions

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

type URL

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

	// 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"`

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

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

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

type Version

type Version int
const (
	MaxSupportedVersion Version = 2
)

type Volume

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

type WaitContainerCondition

type WaitContainerCondition container.WaitCondition

Jump to

Keyboard shortcuts

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