types

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventNameInstancesChange = "change"

	EventNameInstanceStatusChange = "status_change"
	EventNameInstanceStdout       = "stdout"
	EventNameInstanceStderr       = "stderr"
)
View Source
const (
	InstanceStatusOff      = "off"
	InstanceStatusBuilding = "building"
	InstanceStatusStarting = "starting"
	InstanceStatusRunning  = "running"
	InstanceStatusStopping = "stopping"
	InstanceStatusError    = "error"
)
View Source
const (
	InstanceInstallMethodScript  = "script"
	InstanceInstallMethodRelease = "release"
	InstanceInstallMethodDocker  = "docker"
)
View Source
const (
	LogKindOut       = "out"
	LogKindErr       = "err"
	LogKindVertexOut = "vertex_out"
	LogKindVertexErr = "vertex_err"
)
View Source
const (
	PmNone   = "sources"
	PmAptGet = "apt-get"
	PmBrew   = "brew"
	PmNpm    = "npm"
	PmPacman = "pacman"
	PmSnap   = "snap"
)

Variables

View Source
var (
	ErrInstanceNotFound     = errors.New("instance not found")
	ErrInstanceStillRunning = errors.New("instance still running")
)
View Source
var (
	ErrServiceNotFound = errors.New("the service was not found")
)

Functions

This section is empty.

Types

type APIError added in v0.5.7

type APIError struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

func (APIError) Error added in v0.7.0

func (e APIError) Error() string

type About added in v0.5.0

type About struct {
	Version string `json:"version"`
	Commit  string `json:"commit"`
	Date    string `json:"date"`

	OS   string `json:"os"`
	Arch string `json:"arch"`
}

type BuildImageOptions added in v0.9.0

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

type Container added in v0.9.0

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

func NewContainer added in v0.9.0

func NewContainer(c dockertypes.Container) Container

type CreateContainerOptions added in v0.9.0

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

type CreateContainerResponse added in v0.9.0

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

type DatabaseEnvironment added in v0.6.0

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 added in v0.6.0

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 added in v0.4.0

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

	// 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 Dependencies added in v0.7.0

type Dependencies struct {
	LastUpdatesCheck *time.Time    `json:"last_updates_check"`
	Items            []*Dependency `json:"items"`
}

type Dependency

type Dependency struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Version string `json:"version"`

	Update  *DependencyUpdate `json:"update,omitempty"`
	Updater DependencyUpdater `json:"-"`
}

type DependencyUpdate added in v0.7.0

type DependencyUpdate struct {
	CurrentVersion string `json:"current_version"`
	LatestVersion  string `json:"latest_version"`
	NeedsRestart   bool   `json:"needs_restart,omitempty"`
}

type DependencyUpdater added in v0.7.0

type DependencyUpdater interface {
	// CheckForUpdate will check if the dependency has an update available. If
	// true, it returns the Dependency, or nil otherwise.
	CheckForUpdate() (*DependencyUpdate, error)

	// InstallUpdate will install the previously fetched update.
	InstallUpdate() error

	// GetCurrentVersion returns the current version of the dependency.
	GetCurrentVersion() string

	// GetPath returns the path of the dependency.
	GetPath() string
}

DependencyUpdater describes main vertex programs that Vertex needs to run, like Vertex, Vertex Services, Vertex Web UI...

type DockerAdapterPort added in v0.9.0

type DockerAdapterPort interface {
	ListContainers() ([]Container, error)
	DeleteContainer(id string) error
	CreateContainer(options CreateContainerOptions) (CreateContainerResponse, error)
	StartContainer(id string) error
	StopContainer(id string) error
	InfoContainer(id string) (InfoContainerResponse, error)
	LogsStdoutContainer(id string) (io.ReadCloser, error)
	LogsStderrContainer(id string) (io.ReadCloser, error)
	WaitContainer(id string, cond WaitContainerCondition) error
	InfoImage(id string) (InfoImageResponse, error)
	PullImage(options PullImageOptions) (io.ReadCloser, error)
	BuildImage(options BuildImageOptions) (dockertypes.ImageBuildResponse, error)
}

type EnvVariables

type EnvVariables map[string]string

type EventAdapterPort added in v0.5.6

type EventAdapterPort interface {
	AddListener(l Listener)
	RemoveListener(l Listener)
	Send(e interface{})
}

type EventInstanceLog added in v0.1.1

type EventInstanceLog struct {
	InstanceUUID uuid.UUID
	Kind         string
	Message      string
}

type EventInstanceStatusChange added in v0.1.1

type EventInstanceStatusChange struct {
	InstanceUUID uuid.UUID
	Status       string
}

type EventInstancesChange added in v0.1.1

type EventInstancesChange struct{}

type Features added in v0.4.0

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

type Hardware added in v0.7.0

type Hardware struct {
	// Dockerized is true if the application is running inside a Docker container.
	Dockerized bool `json:"dockerized"`

	// Host is the host information.
	Host Host `json:"host"`
}

type Host added in v0.7.0

type Host struct {
	// OS is the operating system name.
	// Example: "linux"
	OS string `json:"os"`

	// Arch is the hardware architecture.
	// Example: "arm64"
	Arch string `json:"arch"`

	// Platform is the platform name.
	// Example: "arch"
	Platform string `json:"platform"`

	// Version is the platform version.
	// Example: "13.5.2"
	Version string `json:"version"`

	// Name is the hostname.
	// Example: "my-host"
	Name string `json:"name"`
}

type InfoContainerResponse added in v0.9.0

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

type InfoImageResponse added in v0.9.0

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 Instance

type Instance struct {
	InstanceSettings

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

	Update        *InstanceUpdate `json:"update,omitempty"`
	ServiceUpdate ServiceUpdate   `json:"service_update,omitempty"`
}

func NewInstance added in v0.1.1

func NewInstance(id uuid.UUID, service Service) Instance

func (*Instance) DockerContainerName

func (i *Instance) DockerContainerName() string

func (*Instance) DockerImageName

func (i *Instance) DockerImageName() string

func (*Instance) HasFeature added in v0.6.0

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

func (*Instance) HasOneOfFeatures added in v0.6.0

func (i *Instance) HasOneOfFeatures(featureTypes []string) bool

func (*Instance) IsDockerized added in v0.1.1

func (i *Instance) IsDockerized() bool

func (*Instance) IsRunning

func (i *Instance) IsRunning() bool

func (*Instance) LaunchOnStartup added in v0.6.0

func (i *Instance) LaunchOnStartup() bool

func (*Instance) ResetDefaultEnv added in v0.6.0

func (i *Instance) ResetDefaultEnv()

type InstanceAdapterPort added in v0.5.6

type InstanceAdapterPort interface {
	Get(uuid uuid.UUID) (*Instance, error)
	GetAll() map[uuid.UUID]*Instance
	Search(query InstanceQuery) map[uuid.UUID]*Instance
	GetPath(uuid uuid.UUID) string
	Delete(uuid uuid.UUID) error
	Exists(uuid uuid.UUID) bool
	Set(uuid uuid.UUID, instance Instance) error

	SaveSettings(i *Instance) error
	LoadSettings(i *Instance) error

	SaveEnv(i *Instance) error
	LoadEnv(i *Instance) error

	SaveService(i *Instance) error
	LoadService(instancePath string) (Service, error)
	LoadServiceRaw(instancePath string) (interface{}, error)

	Reload(func(uuid uuid.UUID))
}

type InstanceLogsAdapterPort added in v0.5.6

type InstanceLogsAdapterPort interface {
	Open(uuid uuid.UUID) error
	Close(uuid uuid.UUID) error
	Push(uuid uuid.UUID, line LogLine)

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

	CloseAll() error
}

type InstanceQuery added in v0.6.0

type InstanceQuery struct {
	Features []string `json:"features,omitempty"`
}

type InstanceSettings added in v0.4.5

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

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

	// DisplayName is a custom name for the instance.
	DisplayName *string `json:"display_name,omitempty"`

	// Database describes the databases used by the instance.
	// The key is the database ID, and the value is the database instance UUID.
	Databases map[string]uuid.UUID `json:"databases,omitempty"`
}

type InstanceUpdate added in v0.4.0

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

type Listener added in v0.1.1

type Listener interface {
	OnEvent(e interface{})
	GetUUID() uuid.UUID
}

type LogLine

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

type Mount added in v0.9.0

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

func NewMount added in v0.9.0

func NewMount(m dockertypes.MountPoint) Mount

func NewMounts added in v0.9.0

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

type Package

type Package struct {
	ID             string            `json:"-"`
	Name           string            `json:"name"`
	Description    string            `json:"description"`
	Homepage       string            `json:"homepage"`
	License        string            `json:"license"`
	Check          string            `json:"check"`
	InstallPackage map[string]string `json:"install"`
	Installed      *bool             `json:"installed,omitempty"`
}

type PackageAdapterPort added in v0.5.6

type PackageAdapterPort interface {
	GetByID(id string) (Package, error)
	GetPath(id string) string

	// Reload the adapter
	Reload() error
}

type ProxyAdapterPort added in v0.5.6

type ProxyAdapterPort interface {
	GetRedirects() ProxyRedirects
	GetRedirectByHost(host string) *ProxyRedirect
	AddRedirect(id uuid.UUID, redirect ProxyRedirect) error
	RemoveRedirect(id uuid.UUID) error
}

type ProxyRedirect added in v0.5.0

type ProxyRedirect struct {
	Source string `json:"source"`
	Target string `json:"target"`
}

type ProxyRedirects added in v0.5.0

type ProxyRedirects map[uuid.UUID]ProxyRedirect

type PublicKey added in v0.8.0

type PublicKey struct {
	Type              string `json:"type"`
	FingerprintSHA256 string `json:"fingerprint_sha_256"`
}

type PullImageOptions added in v0.9.0

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

type RunnerAdapterPort added in v0.5.6

type RunnerAdapterPort interface {
	Delete(instance *Instance) error
	Start(instance *Instance, setStatus func(status string)) (stdout io.ReadCloser, stderr io.ReadCloser, err error)
	Stop(instance *Instance) error
	Info(instance Instance) (map[string]any, error)

	CheckForUpdates(instance *Instance) error
	HasUpdateAvailable(instance Instance) (bool, error)
}

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 added in v0.6.0

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

type ServiceAdapterPort added in v0.5.6

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 added in v0.3.0

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

type ServiceDependency added in v0.3.0

type ServiceDependency struct{}

type ServiceEnv added in v0.6.0

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 added in v0.1.1

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

type ServiceMethodRelease added in v0.2.0

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

type ServiceMethodScript added in v0.1.1

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 added in v0.1.1

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 added in v0.6.0

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

type ServiceV1 added in v0.6.0

type ServiceV1 Service

type ServiceVersioning added in v0.6.0

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

type Settings added in v0.5.3

type Settings struct {
	Notifications *SettingsNotifications `json:"notifications,omitempty"`
}

type SettingsAdapterPort added in v0.5.6

type SettingsAdapterPort interface {
	GetSettings() Settings

	GetNotificationsWebhook() *string
	SetNotificationsWebhook(webhook *string) error
}

type SettingsNotifications added in v0.5.3

type SettingsNotifications struct {
	Webhook *string `json:"webhook,omitempty"`
}

type TempListener added in v0.1.1

type TempListener struct {
	// contains filtered or unexported fields
}

func NewTempListener added in v0.1.1

func NewTempListener(onEvent func(e interface{})) TempListener

func (TempListener) GetUUID added in v0.1.1

func (t TempListener) GetUUID() uuid.UUID

func (TempListener) OnEvent added in v0.1.1

func (t TempListener) OnEvent(e interface{})

type URL added in v0.1.1

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 added in v0.6.0

type Version int
const (
	MaxSupportedVersion Version = 1
)

type WaitContainerCondition added in v0.9.0

type WaitContainerCondition container.WaitCondition

Jump to

Keyboard shortcuts

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