entities

package
v0.0.0-...-a7ff5df Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 11 Imported by: 5

Documentation

Index

Constants

View Source
const (
	EnvNameRegExp    = `^[a-z0-9]+(-[a-z0-9]+)*$`
	EnvNameMaxLength = 16
)
View Source
const (
	DefaultClusterName = "default"
)

Variables

View Source
var (
	ErrElevenNotInstalled    = errors.New("ErrElevenNotInstalled")
	ErrUninstallExistingEnvs = errors.New("ErrUninstallExistingEnvs")
)

Functions

func BuildInitialLocalSSHCfgHostnameForEnv

func BuildInitialLocalSSHCfgHostnameForEnv(envName string) string

func BuildSlugForEnv

func BuildSlugForEnv(rawString string) string

func CheckDomainValidity

func CheckDomainValidity(domain string) error

func CheckEnvNameValidity

func CheckEnvNameValidity(envName string) error

func CheckPortValidity

func CheckPortValidity(port string, reservedPorts []string) error

Types

type CloudService

type CloudService interface {
	CreateElevenConfigStorage(stepper.Stepper) error
	RemoveElevenConfigStorage(stepper.Stepper) error

	LookupElevenConfig(stepper.Stepper) (*Config, error)
	SaveElevenConfig(stepper.Stepper, *Config) error

	CreateCluster(stepper.Stepper, *Config, *Cluster) error
	RemoveCluster(stepper.Stepper, *Config, *Cluster) error

	CheckInstanceTypeValidity(stepper.Stepper, string) error

	CreateEnv(stepper.Stepper, *Config, *Cluster, *Env) error
	RemoveEnv(stepper.Stepper, *Config, *Cluster, *Env) error

	OpenPort(stepper.Stepper, *Config, *Cluster, *Env, string) error
	ClosePort(stepper.Stepper, *Config, *Cluster, *Env, string) error
}

type CloudServiceBuilder

type CloudServiceBuilder interface {
	Build() (CloudService, error)
}

type Cluster

type Cluster struct {
	ID                  string          `json:"id"`
	Name                string          `json:"name"`
	DefaultInstanceType string          `json:"default_instance_type"`
	InfrastructureJSON  string          `json:"infrastructure_json"`
	Envs                map[string]*Env `json:"envs"`
	IsDefault           bool            `json:"is_default"`
	Status              ClusterStatus   `json:"status"`
	CreatedAtTimestamp  int64           `json:"created_at_timestamp"`
}

func NewCluster

func NewCluster(
	clusterName string,
	defaultInstanceType string,
	isDefaultCluster bool,
) *Cluster

func (*Cluster) GetNameSlug

func (c *Cluster) GetNameSlug() string

func (*Cluster) SetInfrastructureJSON

func (c *Cluster) SetInfrastructureJSON(infrastructure interface{}) error

type ClusterStatus

type ClusterStatus string
const (
	ClusterStatusCreating ClusterStatus = "creating"
	ClusterStatusCreated  ClusterStatus = "created"
	ClusterStatusRemoving ClusterStatus = "removing"
)

type Config

type Config struct {
	ID                 string              `json:"id"`
	Clusters           map[string]*Cluster `json:"clusters"`
	CreatedAtTimestamp int64               `json:"created_at_timestamp"`
}

func NewConfig

func NewConfig() *Config

func (*Config) ClusterExists

func (c *Config) ClusterExists(clusterName string) bool

func (*Config) CountEnvsInCluster

func (c *Config) CountEnvsInCluster(clusterName string) (int, error)

func (*Config) EnvExists

func (c *Config) EnvExists(clusterName, envName string) bool

func (*Config) GetCluster

func (c *Config) GetCluster(clusterName string) (*Cluster, error)

func (*Config) GetEnv

func (c *Config) GetEnv(clusterName, envName string) (*Env, error)

func (*Config) RemoveCluster

func (c *Config) RemoveCluster(clusterName string) error

func (*Config) RemoveEnv

func (c *Config) RemoveEnv(clusterName, envName string) error

func (*Config) SetCluster

func (c *Config) SetCluster(cluster *Cluster) error

func (*Config) SetEnv

func (c *Config) SetEnv(clusterName string, env *Env) error

type DomainReachabilityChecker

type DomainReachabilityChecker interface {
	Check(
		env *Env,
		domain string,
	) (reachable bool, redirToHTTPS bool, err error)
}

type Env

type Env struct {
	ID                       string          `json:"id"`
	Name                     string          `json:"name"`
	LocalSSHConfigHostname   string          `json:"local_ssh_config_hostname"`
	InfrastructureJSON       string          `json:"infrastructure_json"`
	InstanceType             string          `json:"instance_type"`
	InstancePublicIPAddress  string          `json:"instance_public_ip_address"`
	SSHHostKeys              []EnvSSHHostKey `json:"ssh_host_keys"`
	SSHKeyPairPEMContent     string          `json:"ssh_key_pair_pem_content"`
	Repositories             []EnvRepository `json:"repositories"`
	Runtimes                 EnvRuntimes     `json:"runtimes"`
	ServedPorts              EnvServedPorts  `json:"served_ports"`
	Status                   EnvStatus       `json:"status"`
	AdditionalPropertiesJSON string          `json:"additional_properties_json"`
	CreatedAtTimestamp       int64           `json:"created_at_timestamp"`
}

func NewEnv

func NewEnv(
	envName string,
	localSSHCfgDupHostCt int,
	instanceType string,
	repositories []EnvRepository,
	runtimes EnvRuntimes,
) *Env

func (*Env) AddServedPortBinding

func (e *Env) AddServedPortBinding(
	servedPort EnvServedPort,
	binding string,
	redirectToHTTPS bool,
)

func (*Env) DoesServedPortBindingExist

func (e *Env) DoesServedPortBindingExist(targetBinding string) bool

func (*Env) DoesServedPortExist

func (e *Env) DoesServedPortExist(servedPort EnvServedPort) bool

func (*Env) GetNameSlug

func (e *Env) GetNameSlug() string

func (*Env) GetSSHKeyPairName

func (e *Env) GetSSHKeyPairName() string

func (*Env) RemoveServedPort

func (e *Env) RemoveServedPort(servedPort EnvServedPort)

func (*Env) RemoveServedPortBinding

func (e *Env) RemoveServedPortBinding(servedPort EnvServedPort, targetBinding string)

func (*Env) SetAdditionalPropertiesJSON

func (e *Env) SetAdditionalPropertiesJSON(additionalProps interface{}) error

func (*Env) SetInfrastructureJSON

func (e *Env) SetInfrastructureJSON(infrastructure interface{}) error

type EnvRepository

type EnvRepository struct {
	Name          string              `json:"name"`
	Owner         string              `json:"owner"`
	ExplicitOwner bool                `json:"explicit_owner"`
	GitURL        EnvRepositoryGitURL `json:"git_url"`
	GitHTTPURL    EnvRepositoryGitURL `json:"git_http_url"`
}

type EnvRepositoryGitURL

type EnvRepositoryGitURL string

type EnvRuntimes

type EnvRuntimes map[string]string

func ParseEnvRuntimes

func ParseEnvRuntimes(runtimes []string) (EnvRuntimes, error)

type EnvSSHHostKey

type EnvSSHHostKey struct {
	Algorithm   string `json:"algorithm"`
	Fingerprint string `json:"fingerprint"`
}

func ParseSSHHostKeysForEnv

func ParseSSHHostKeysForEnv(hostKeysContent string) ([]EnvSSHHostKey, error)

type EnvServedPort

type EnvServedPort string

type EnvServedPortBinding

type EnvServedPortBinding struct {
	Value           string                   `json:"value"`
	Type            EnvServedPortBindingType `json:"type"`
	RedirectToHTTPS bool                     `json:"redirect_to_https"`
}

type EnvServedPortBindingType

type EnvServedPortBindingType string
const (
	EnvServedPortBindingTypePort   EnvServedPortBindingType = "port"
	EnvServedPortBindingTypeDomain EnvServedPortBindingType = "domain"
)

type EnvServedPorts

type EnvServedPorts map[EnvServedPort][]EnvServedPortBinding

type EnvStatus

type EnvStatus string
const (
	EnvStatusCreating EnvStatus = "creating"
	EnvStatusCreated  EnvStatus = "created"
	EnvStatusRemoving EnvStatus = "removing"
)

type ErrCloudflareSSLFull

type ErrCloudflareSSLFull struct {
	Domain string
}

func (ErrCloudflareSSLFull) Error

func (ErrCloudflareSSLFull) Error() string

type ErrClusterAlreadyExists

type ErrClusterAlreadyExists struct {
	ClusterName string
}

func (ErrClusterAlreadyExists) Error

func (e ErrClusterAlreadyExists) Error() string

type ErrClusterNotExists

type ErrClusterNotExists struct {
	ClusterName string
}

func (ErrClusterNotExists) Error

func (e ErrClusterNotExists) Error() string

type ErrEditCreatingEnv

type ErrEditCreatingEnv struct {
	EnvName string
}

func (ErrEditCreatingEnv) Error

func (ErrEditCreatingEnv) Error() string

type ErrEditRemovingEnv

type ErrEditRemovingEnv struct {
	EnvName string
}

func (ErrEditRemovingEnv) Error

func (ErrEditRemovingEnv) Error() string

type ErrEnvCloudInitError

type ErrEnvCloudInitError struct {
	Logs         string
	ErrorMessage string
}

func (ErrEnvCloudInitError) Error

func (ErrEnvCloudInitError) Error() string

type ErrEnvDuplicatedRepositories

type ErrEnvDuplicatedRepositories struct {
	RepoOwner string
	RepoName  string
}

func (ErrEnvDuplicatedRepositories) Error

type ErrEnvDuplicatedRuntimes

type ErrEnvDuplicatedRuntimes struct {
	Runtime string
}

func (ErrEnvDuplicatedRuntimes) Error

type ErrEnvInvalidRuntime

type ErrEnvInvalidRuntime struct {
	Runtime string
}

func (ErrEnvInvalidRuntime) Error

func (ErrEnvInvalidRuntime) Error() string

type ErrEnvInvalidRuntimeVersion

type ErrEnvInvalidRuntimeVersion struct {
	Runtime                string
	RuntimeVersion         string
	RuntimeVersionExamples []string
}

func (ErrEnvInvalidRuntimeVersion) Error

type ErrEnvNotExists

type ErrEnvNotExists struct {
	ClusterName string
	EnvName     string
}

func (ErrEnvNotExists) Error

func (ErrEnvNotExists) Error() string

type ErrEnvRepositoryNotFound

type ErrEnvRepositoryNotFound struct {
	RepoOwner string
	RepoName  string
}

func (ErrEnvRepositoryNotFound) Error

type ErrInitRemovingEnv

type ErrInitRemovingEnv struct {
	EnvName string
}

func (ErrInitRemovingEnv) Error

func (ErrInitRemovingEnv) Error() string

type ErrInvalidDomain

type ErrInvalidDomain struct {
	Domain string
}

func (ErrInvalidDomain) Error

func (ErrInvalidDomain) Error() string

type ErrInvalidEnvName

type ErrInvalidEnvName struct {
	EnvName          string
	EnvNameRegExp    string
	EnvNameMaxLength int
}

func (ErrInvalidEnvName) Error

func (ErrInvalidEnvName) Error() string

type ErrInvalidPort

type ErrInvalidPort struct {
	InvalidPort string
}

func (ErrInvalidPort) Error

func (ErrInvalidPort) Error() string

type ErrLetsEncryptTimedOut

type ErrLetsEncryptTimedOut struct {
	Domain        string
	ReturnedError error
}

func (ErrLetsEncryptTimedOut) Error

type ErrProxyForceHTTPS

type ErrProxyForceHTTPS struct {
	Domain string
}

func (ErrProxyForceHTTPS) Error

func (ErrProxyForceHTTPS) Error() string

type ErrReservedPort

type ErrReservedPort struct {
	ReservedPort string
}

func (ErrReservedPort) Error

func (ErrReservedPort) Error() string

type ErrServeCreatingEnv

type ErrServeCreatingEnv struct {
	EnvName string
}

func (ErrServeCreatingEnv) Error

func (ErrServeCreatingEnv) Error() string

type ErrServeRemovingEnv

type ErrServeRemovingEnv struct {
	EnvName string
}

func (ErrServeRemovingEnv) Error

func (ErrServeRemovingEnv) Error() string

type ErrUnresolvableDomain

type ErrUnresolvableDomain struct {
	Domain       string
	EnvIPAddress string
}

func (ErrUnresolvableDomain) Error

func (ErrUnresolvableDomain) Error() string

type ErrUnserveCreatingEnv

type ErrUnserveCreatingEnv struct {
	EnvName string
}

func (ErrUnserveCreatingEnv) Error

func (ErrUnserveCreatingEnv) Error() string

type ErrUnserveRemovingEnv

type ErrUnserveRemovingEnv struct {
	EnvName string
}

func (ErrUnserveRemovingEnv) Error

func (ErrUnserveRemovingEnv) Error() string

type ErrUpdateInstanceTypeCreatingEnv

type ErrUpdateInstanceTypeCreatingEnv struct {
	EnvName string
}

func (ErrUpdateInstanceTypeCreatingEnv) Error

type HookRunner

type HookRunner interface {
	Run(
		cloudService CloudService,
		config *Config,
		cluster *Cluster,
		env *Env,
	) error
}

Jump to

Keyboard shortcuts

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