types

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContainerStatusOff      = "off"
	ContainerStatusBuilding = "building"
	ContainerStatusStarting = "starting"
	ContainerStatusRunning  = "running"
	ContainerStatusStopping = "stopping"
	ContainerStatusError    = "error"
)
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"
	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"

	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 (
	LogKindOut       = "out"
	LogKindErr       = "err"
	LogKindDownload  = "download"
	LogKindDownloads = "downloads"
	LogKindVertexOut = "vertex_out"
	LogKindVertexErr = "vertex_err"
)
View Source
const (
	ContainerInstallMethodDocker = "docker"
)

Variables

View Source
var (
	ErrContainerNotFound     = errors.New("container not found")
	ErrContainerStillRunning = errors.New("container still running")
)
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 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 ContainerAdapterPort

type ContainerAdapterPort interface {
	Create(uuid uuid.UUID) error
	Delete(uuid uuid.UUID) error

	GetAll() ([]uuid.UUID, error)
}

type ContainerEnvAdapterPort

type ContainerEnvAdapterPort interface {
	Save(uuid uuid.UUID, env ContainerEnvVariables) error
	Load(uuid uuid.UUID) (ContainerEnvVariables, error)
}

type ContainerEnvVariables

type ContainerEnvVariables map[string]string

type ContainerLogsAdapterPort

type ContainerLogsAdapterPort interface {
	Register(uuid uuid.UUID) error
	Unregister(uuid uuid.UUID) error
	UnregisterAll() error

	Push(uuid uuid.UUID, line LogLine)
	Pop(uuid uuid.UUID) (LogLine, error)

	// LoadBuffer will load the latest logs kept in memory.
	LoadBuffer(uuid uuid.UUID) ([]LogLine, error)
}

type ContainerRunnerAdapterPort

type ContainerRunnerAdapterPort interface {
	Delete(inst *Container) error
	Start(inst *Container, setStatus func(status string)) (stdout io.ReadCloser, stderr io.ReadCloser, err error)
	Stop(inst *Container) error
	Info(inst Container) (map[string]any, error)
	WaitCondition(inst *Container, cond types.WaitContainerCondition) error

	CheckForUpdates(inst *Container) error
	HasUpdateAvailable(inst Container) (bool, error)
	GetAllVersions(inst Container) ([]string, error)
}

type ContainerSearchQuery

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

type ContainerServiceAdapterPort

type ContainerServiceAdapterPort interface {
	Save(uuid uuid.UUID, service Service) error
	Load(uuid uuid.UUID) (Service, error)
	LoadRaw(uuid uuid.UUID) (interface{}, error)
}

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 describes 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 ContainerSettingsAdapterPort

type ContainerSettingsAdapterPort interface {
	Save(uuid uuid.UUID, settings ContainerSettings) error
	Load(uuid uuid.UUID) (ContainerSettings, error)
}

type ContainerUpdate

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

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

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 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 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 ServiceAdapterPort

type ServiceAdapterPort interface {
	// Get a service with its id. Returns ErrServiceNotFound if
	// the service was not found.
	Get(id string) (Service, error)

	GetScript(id string) ([]byte, error)

	// GetRaw gets a service by id, without any processing.
	// Returns ErrServiceNotFound if the service was not found.
	GetRaw(id string) (interface{}, error)

	// GetAll gets all available services.
	GetAll() []Service

	// Reload the adapter
	Reload() 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

type ServiceVersioning

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

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 to specify a route to change the home path.
	HomeRoute *string `yaml:"home,omitempty" json:"home,omitempty"`

	// PingRoute allows to specify 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 = 1
)

Jump to

Keyboard shortcuts

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