Documentation
¶
Index ¶
- type CloudManager
- func (m *CloudManager) CreateInstance(config ServiceConfig) (*ServiceInstance, error)
- func (m *CloudManager) CreateTraefikBundle(acmeEmail string) (string, error)
- func (m *CloudManager) DeleteInstance(id string) error
- func (m *CloudManager) GetInstance(id string) (*ServiceInstance, bool)
- func (m *CloudManager) GetInstanceLogs(id string, tailLines int) (string, error)
- func (m *CloudManager) ListInstances() []*ServiceInstance
- func (m *CloudManager) RecreateWithDomain(id string, domain *DomainConfig) (*ServiceInstance, error)
- func (m *CloudManager) RefreshInstanceStatus(id string) error
- func (m *CloudManager) RestartInstance(id string) error
- func (m *CloudManager) StartInstance(id string) error
- func (m *CloudManager) StopInstance(id string) error
- type DomainConfig
- type ServiceConfig
- type ServiceInstance
- type ServiceType
- type VolumeMount
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloudManager ¶
type CloudManager struct {
// contains filtered or unexported fields
}
Managing the docker service instances
func NewCloudDBManager ¶
func NewCloudDBManager() (*CloudManager, error)
func (*CloudManager) CreateInstance ¶
func (m *CloudManager) CreateInstance(config ServiceConfig) (*ServiceInstance, error)
Creating a new service instance based on the provided configuration The service is created with default values if not provided After creating the instance, it will be started and exposed to a public port on your machine
func (*CloudManager) CreateTraefikBundle ¶
func (m *CloudManager) CreateTraefikBundle(acmeEmail string) (string, error)
CreateTraefikBundle — programmatically run Traefik with ACME on your network Equivalent to the docker-compose in the docs; keeps ops inside Go if desired.
func (*CloudManager) DeleteInstance ¶
func (m *CloudManager) DeleteInstance(id string) error
Deleting a service instance be careful when using this in production
func (*CloudManager) GetInstance ¶
func (m *CloudManager) GetInstance(id string) (*ServiceInstance, bool)
Get an service instance from its ID
func (*CloudManager) GetInstanceLogs ¶ added in v0.2.0
func (m *CloudManager) GetInstanceLogs(id string, tailLines int) (string, error)
GetInstanceLogs fetches the last N lines of logs from a container
func (*CloudManager) ListInstances ¶
func (m *CloudManager) ListInstances() []*ServiceInstance
This returns all service instances
func (*CloudManager) RecreateWithDomain ¶
func (m *CloudManager) RecreateWithDomain(id string, domain *DomainConfig) (*ServiceInstance, error)
RecreateWithDomain — convenience to switch/add domain (labels are immutable)
func (*CloudManager) RefreshInstanceStatus ¶ added in v0.2.0
func (m *CloudManager) RefreshInstanceStatus(id string) error
RefreshInstanceStatus syncs instance status from Docker
func (*CloudManager) RestartInstance ¶ added in v0.2.0
func (m *CloudManager) RestartInstance(id string) error
RestartInstance restarts a running or stopped instance
func (*CloudManager) StartInstance ¶ added in v0.2.0
func (m *CloudManager) StartInstance(id string) error
StartInstance starts a stopped instance
func (*CloudManager) StopInstance ¶ added in v0.2.0
func (m *CloudManager) StopInstance(id string) error
StopInstance stops a running instance without deleting it
type DomainConfig ¶
type DomainConfig struct {
Domain string `json:"domain" yaml:"domain"` // e.g. donidb.com
CertResolver string `json:"cert_resolver,omitempty" yaml:"cert_resolver,omitempty"` // default "letsencrypt"
EntryPoint string `json:"entrypoint,omitempty" yaml:"entrypoint,omitempty"` // default "websecure" (443)
AllowedCIDRs []string `json:"allowed_cidrs,omitempty" yaml:"allowed_cidrs,omitempty"` // optional IP allow-list
}
type ServiceConfig ¶
type ServiceConfig struct {
Type ServiceType `json:"type,omitempty" yaml:"type,omitempty"`
Name string `json:"name" yaml:"name"`
Username string `json:"username,omitempty" yaml:"username,omitempty"`
Password string `json:"password,omitempty" yaml:"password,omitempty"`
DatabaseName string `json:"database_name,omitempty" yaml:"database_name,omitempty"`
Version string `json:"version,omitempty" yaml:"version,omitempty"`
UsLatestVersion bool `json:"use_latest_version,omitempty" yaml:"use_latest_version,omitempty"`
Variables map[string]string `json:"variables,omitempty" yaml:"variables,omitempty"`
ExposedPorts []string `json:"exposed_ports,omitempty" yaml:"exposed_ports,omitempty"`
Volumes []VolumeMount `json:"volumes,omitempty" yaml:"volumes,omitempty"`
Domain *DomainConfig `json:"domain,omitempty" yaml:"domain,omitempty"`
}
The necessary config for a docker service creation
type ServiceInstance ¶
type ServiceInstance struct {
ID string `json:"id"`
Name string `json:"name"`
Type ServiceType `json:"type"`
ContainerID string `json:"container_id"`
Port int `json:"port"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
DatabaseName string `json:"database_name,omitempty"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
ExternalPort int `json:"external_port"`
Domain string `json:"domain,omitempty"`
VolumeNames []string `json:"volume_names,omitempty"`
}
Represents a docker service instance
type ServiceType ¶
type ServiceType string
Represents a docker service name
const ( PostgreSQL ServiceType = "postgresql" MySQL ServiceType = "mysql" MongoDB ServiceType = "mongodb" Redis ServiceType = "redis" MariaDB ServiceType = "mariadb" )
type VolumeMount ¶
type VolumeMount struct {
Name string `json:"name" yaml:"name"` // docker volume name
ContainerPath string `json:"container_path" yaml:"container_path"` // e.g. /var/lib/postgresql/data
ReadOnly bool `json:"read_only,omitempty" yaml:"read_only,omitempty"`
Driver string `json:"driver,omitempty" yaml:"driver,omitempty"` // "local" etc.
DriverOpts map[string]string `json:"driver_opts,omitempty" yaml:"driver_opts,omitempty"`
}