types

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 3 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"
)
View Source
const (
	URLKindClient = "client"
)

Variables

View Source
var (
	ErrServiceNotFound = errors.New("the service was not found")
)

Functions

This section is empty.

Types

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 Dependency

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

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

	// GetID returns the ID of the dependency that can be used to
	// identify it from the client.
	GetID() string
}

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

type EnvDefinition added in v0.3.0

type EnvDefinition 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 EnvVariables

type EnvVariables map[string]string

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

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

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 Instance

type Instance struct {
	Service
	InstanceMetadata

	UUID         uuid.UUID    `json:"uuid"`
	Status       string       `json:"status"`
	EnvVariables EnvVariables `json:"env"`

	Update *InstanceUpdate `json:"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) IsDockerized added in v0.1.1

func (i *Instance) IsDockerized() bool

func (*Instance) IsRunning

func (i *Instance) IsRunning() bool

type InstanceLogsRepository added in v0.1.1

type InstanceLogsRepository 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 InstanceMetadata

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

type InstanceRepository

type InstanceRepository interface {
	Get(uuid uuid.UUID) (*Instance, error)
	GetAll() 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

	SaveMetadata(i *Instance) error
	LoadMetadata(i *Instance) error

	SaveEnv(i *Instance, variables map[string]string) error
	LoadEnv(i *Instance) error

	ReadService(instancePath string) (Service, error)

	Reload(func(uuid uuid.UUID))
}

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 Package

type Package struct {
	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 PackageRepository

type PackageRepository interface {
	Get(id string) (Package, error)
	GetPath(id string) string
}

type RunnerRepository added in v0.1.1

type RunnerRepository interface {
	Delete(instance *Instance) error
	Start(instance *Instance, onLog func(msg string), onErr func(msg string), setStatus func(status string)) 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 {
	// 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"`

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

	// EnvDefinitions defines all parameterizable environment variables.
	EnvDefinitions []EnvDefinition `yaml:"environment,omitempty" json:"environment,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"`
}

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

type ServiceMethodDocker struct {
	// Image is the Docker image to run.
	Image *string `yaml:"image,omitempty" json:"image,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"`
}

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 ServiceRepository

type ServiceRepository 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)

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

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

	// 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 Update

type Update struct {
	ID             string `json:"id"`
	Name           string `json:"name"`
	CurrentVersion string `json:"current_version"`
	LatestVersion  string `json:"latest_version"`
	NeedsRestart   bool   `json:"needs_restart"`
}

type Updates

type Updates struct {
	LastChecked *time.Time `json:"last_checked"`
	Items       []Update   `json:"items"`
}

Jump to

Keyboard shortcuts

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