Documentation
¶
Index ¶
- Variables
- type App
- func (a *App) Delete(deployments RunningOrPendingAppDeploymentsCount) error
- func (a *App) HasEnvironmentVariables(vars EnvironmentsEnv)
- func (a App) ID() AppID
- func (a App) NewDeployment(deployNumber DeploymentNumber, meta Meta, env Environment, ...) (d Deployment, err error)
- func (a App) Path(relativeTo ...string) string
- func (a App) Promote(source Deployment, deployNumber DeploymentNumber, tmpl DeploymentDirTemplate, ...) (d Deployment, err error)
- func (a App) Redeploy(source Deployment, deployNumber DeploymentNumber, tmpl DeploymentDirTemplate, ...) (d Deployment, err error)
- func (a *App) RemoveEnvironmentVariables()
- func (a *App) RemoveVersionControl()
- func (a *App) RequestCleanup(requestedBy domain.UserID)
- func (a *App) UseVersionControl(config VCSConfig)
- func (a App) VCS() monad.Maybe[VCSConfig]
- type AppCleanupRequested
- type AppCreated
- type AppDeleted
- type AppEnvChanged
- type AppEnvRemoved
- type AppID
- type AppName
- type AppVCSConfigured
- type AppVCSRemoved
- type AppsReader
- type AppsWriter
- type Backend
- type Config
- type Deployment
- func (d Deployment) Config() Config
- func (d *Deployment) HasEnded(services Services, deploymentErr error) error
- func (d *Deployment) HasStarted() error
- func (d Deployment) ID() DeploymentID
- func (d Deployment) LogPath(relativeTo ...string) string
- func (d Deployment) Path(relativeTo ...string) string
- func (d Deployment) Trigger() Meta
- type DeploymentCreated
- type DeploymentDirTemplate
- type DeploymentID
- type DeploymentNumber
- type DeploymentStateChanged
- type DeploymentStatus
- type DeploymentTemplateData
- type DeploymentsReader
- type DeploymentsWriter
- type EnvVars
- type Environment
- type EnvironmentsEnv
- type Kind
- type Meta
- type RunningOrPendingAppDeploymentsCount
- type Service
- type Services
- type ServicesEnv
- type State
- func (s State) ErrCode() monad.Maybe[string]
- func (s State) Failed(err error) (State, error)
- func (s State) FinishedAt() monad.Maybe[time.Time]
- func (s State) LogFile() string
- func (s State) Services() monad.Maybe[Services]
- func (s State) Started() (State, error)
- func (s State) StartedAt() monad.Maybe[time.Time]
- func (s State) Status() DeploymentStatus
- func (s State) Succeeded(services Services) (State, error)
- type Trigger
- type UniqueAppName
- type Url
- type VCSConfig
Constants ¶
This section is empty.
Variables ¶
var ( ErrAppNameAlreadyTaken = apperr.New("app_name_already_taken") ErrVCSNotConfigured = apperr.New("vcs_not_configured") ErrAppCleanupNeeded = apperr.New("app_cleanup_needed") ErrAppCleanupRequested = apperr.New("app_cleanup_requested") ErrAppHasRunningOrPendingDeployments = apperr.New("app_has_running_or_pending_deployments") )
var ( ErrCouldNotPromoteProductionDeployment = apperr.New("could_not_promote_production_deployment") ErrInvalidSourceDeployment = apperr.New("invalid_source_deployment") )
var ( ErrNotInPendingState = apperr.New("not_in_pending_state") ErrNotInRunningState = apperr.New("not_in_running_state") )
var ( ErrNoValidTriggerFound = apperr.New("no_valid_trigger_found") ErrInvalidTriggerPayload = apperr.New("invalid_trigger_payload") ErrTriggerFetchFailed = apperr.New("trigger_fetch_failed") )
var (
ErrInvalidAppName = apperr.New("invalid_app_name")
)
var (
ErrInvalidEnvironmentName = apperr.New("invalid_environment_name")
)
var ErrInvalidUrl = apperr.New("invalid_url")
Functions ¶
This section is empty.
Types ¶
type App ¶
func NewApp ¶
func NewApp(name UniqueAppName, createdBy domain.UserID) (app App)
Instantiates a new App.
func (*App) Delete ¶
func (a *App) Delete(deployments RunningOrPendingAppDeploymentsCount) error
Delete the application. This will only succeed if there are no running or pending deployments and a cleanup request has been made.
func (*App) HasEnvironmentVariables ¶
func (a *App) HasEnvironmentVariables(vars EnvironmentsEnv)
Store environement variables per env and per services for this application.
func (App) NewDeployment ¶
func (a App) NewDeployment( deployNumber DeploymentNumber, meta Meta, env Environment, tmpl DeploymentDirTemplate, requestedBy domain.UserID, ) (d Deployment, err error)
Creates a new deployment for this app. This method acts as a factory for the deployment entity to make sure a new deployment can be created for an app.
func (App) Promote ¶
func (a App) Promote( source Deployment, deployNumber DeploymentNumber, tmpl DeploymentDirTemplate, requestedBy domain.UserID, ) (d Deployment, err error)
Promote the given deployment to the production environment
func (App) Redeploy ¶
func (a App) Redeploy( source Deployment, deployNumber DeploymentNumber, tmpl DeploymentDirTemplate, requestedBy domain.UserID, ) (d Deployment, err error)
Redeploy the given deployment.
func (*App) RemoveEnvironmentVariables ¶
func (a *App) RemoveEnvironmentVariables()
Removes all environment variables for this application.
func (*App) RemoveVersionControl ¶
func (a *App) RemoveVersionControl()
Removes the version control configuration from the app.
func (*App) RequestCleanup ¶
Request backend cleaning for this application. This marks the application for deletion.
func (*App) UseVersionControl ¶
Sets an app version control configuration.
type AppCleanupRequested ¶
type AppCreated ¶
type AppDeleted ¶
type AppDeleted struct {
ID AppID
}
type AppEnvChanged ¶
type AppEnvChanged struct {
ID AppID
Env EnvironmentsEnv
}
type AppEnvRemoved ¶
type AppEnvRemoved struct {
ID AppID
}
type AppName ¶
type AppName string
func AppNameFrom ¶
Creates an AppName from a given raw value and returns any error if the value is not a valid AppName.
type AppVCSConfigured ¶
type AppVCSRemoved ¶
type AppVCSRemoved struct {
ID AppID
}
type AppsReader ¶
type Backend ¶
type Backend interface {
Run(context.Context, Deployment) (Services, error) // Launch a deployment through the backend and return services that has been deployed
Cleanup(context.Context, App) error // Cleanup an application, which means removing every possible stuff related to it
}
Backend service used to run an application services.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Holds data related to the configuration of the final application. It should have everything needed to resolve service and image name and is the primarly used structure during the deployment configuration process by the backend.
func NewConfig ¶
func NewConfig(app App, environment Environment) Config
Builds a new config from the given application.
func (Config) AppName ¶
func (c Config) AppName() UniqueAppName
func (Config) Environment ¶
func (c Config) Environment() Environment
func (Config) EnvironmentVariablesFor ¶
Retrieve environment variables associated with the given service name. FIXME: If I want to follow my mantra, it should returns a readonly map
type Deployment ¶
func DeploymentFrom ¶
func DeploymentFrom(scanner storage.Scanner) (d Deployment, err error)
func (Deployment) Config ¶
func (d Deployment) Config() Config
func (*Deployment) HasEnded ¶
func (d *Deployment) HasEnded(services Services, deploymentErr error) error
Mark the deployment has ended with availables services or with an error if any. The internal status of the deployment will be updated accordingly.
func (*Deployment) HasStarted ¶
func (d *Deployment) HasStarted() error
Mark a deployment has started.
func (Deployment) ID ¶
func (d Deployment) ID() DeploymentID
func (Deployment) LogPath ¶
func (d Deployment) LogPath(relativeTo ...string) string
Retrieve the path where the log for this deployment is stored relative to the given directories.
func (Deployment) Path ¶
func (d Deployment) Path(relativeTo ...string) string
Retrieve the deployment path relative to the given directories.
func (Deployment) Trigger ¶
func (d Deployment) Trigger() Meta
type DeploymentCreated ¶
type DeploymentDirTemplate ¶
type DeploymentDirTemplate interface {
Execute(DeploymentTemplateData) string
}
Since the build directory is a template, materialize it with this tiny interface. Making it a template enables the user to configure how the deployment directory should be built.
type DeploymentID ¶
type DeploymentID struct {
// contains filtered or unexported fields
}
The deployment unique identifier is a composite key based on the app id and the deployment number.
func DeploymentIDFrom ¶
func DeploymentIDFrom(app AppID, number DeploymentNumber) DeploymentID
Construct a deployment id from an app and a deployment number
func (DeploymentID) AppID ¶
func (i DeploymentID) AppID() AppID
func (DeploymentID) DeploymentNumber ¶
func (i DeploymentID) DeploymentNumber() DeploymentNumber
type DeploymentNumber ¶
type DeploymentNumber int
The deployment unique identifier is a composite key based on the app id and the deployment number.
type DeploymentStateChanged ¶
type DeploymentStateChanged struct {
ID DeploymentID
State State
}
type DeploymentStatus ¶
type DeploymentStatus uint8
const ( DeploymentStatusPending DeploymentStatus = iota DeploymentStatusRunning DeploymentStatusFailed DeploymentStatusSucceeded )
type DeploymentTemplateData ¶
type DeploymentTemplateData struct {
Number DeploymentNumber
Environment Environment
}
Template data used to build a deployment path.
type DeploymentsReader ¶
type DeploymentsReader interface {
GetByID(context.Context, DeploymentID) (Deployment, error)
GetNextDeploymentNumber(context.Context, AppID) (DeploymentNumber, error)
GetRunningDeployments(context.Context) ([]Deployment, error)
GetRunningOrPendingDeploymentsCount(context.Context, AppID) (RunningOrPendingAppDeploymentsCount, error)
}
type DeploymentsWriter ¶
type DeploymentsWriter interface {
Write(context.Context, ...*Deployment) error
}
type Environment ¶
type Environment string
const ( // The production environment has a special meaning when determining the application domain. Production Environment = "production" // Staging environment Staging Environment = "staging" )
func EnvironmentFrom ¶
func EnvironmentFrom(value string) (Environment, error)
Creates a new environment value object from a raw value.
func (Environment) IsProduction ¶
func (e Environment) IsProduction() bool
Returns true if the given environment represents the production one.
type EnvironmentsEnv ¶
type EnvironmentsEnv map[Environment]ServicesEnv // Environment variables per deployment environment
func EnvironmentsEnvFrom ¶
Builds the map of environment variables per env and per service from a raw value.
func (EnvironmentsEnv) Equals ¶
func (e EnvironmentsEnv) Equals(other EnvironmentsEnv) bool
func (*EnvironmentsEnv) Scan ¶
func (e *EnvironmentsEnv) Scan(value any) error
type Kind ¶
type Kind string
Specific type to represents a trigger kind to add helper methods on it.
const KindGit Kind = "git"
Represents a trigger which will fetch source code from Git. It is defined here because it has special meanings (see below).
type Meta ¶
type Meta struct {
// contains filtered or unexported fields
}
Contains stuff related to how the deployment has been triggered. The inner data depends on the Trigger which has been requested, this is why I use primitive types here.
type RunningOrPendingAppDeploymentsCount ¶
type RunningOrPendingAppDeploymentsCount uint
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Hold data related to services deployed and runned upon a deployment success.
func (Service) MarshalJSON ¶
func (Service) QualifiedName ¶
func (*Service) UnmarshalJSON ¶
type Services ¶
type Services []Service
Custom types to hold Service array which implements the Scanner and Valuer interface to store it as a json string in the database (no need to create another table for it).
func (Services) Internal ¶
Append a new service (not exposed to the outside world) to the current services array.
type ServicesEnv ¶
func (*ServicesEnv) Scan ¶
func (e *ServicesEnv) Scan(value any) error
type State ¶
type State struct {
// contains filtered or unexported fields
}
Holds together information related to the current deployment state. With a value object, it is easier to validate consistency between all those related properties.
func (State) Status ¶
func (s State) Status() DeploymentStatus
type Trigger ¶
type Trigger interface {
Prepare(App, any) (Meta, error) // Prepare the given payload for the given application, doing any needed validation
Fetch(context.Context, Deployment) error // Retrieve deployment data before passing in to a backend
}
Represents a trigger which has initiated a deployment.
type UniqueAppName ¶
type UniqueAppName AppName // Represents the unique name of an app and will be used as a subdomain.
type Url ¶
type Url struct {
// contains filtered or unexported fields
}
Url struct which embed an url.URL struct and provides additional methods and meanings.
func (Url) MarshalJSON ¶
func (*Url) UnmarshalJSON ¶
type VCSConfig ¶
type VCSConfig struct {
// contains filtered or unexported fields
}
Holds the vcs configuration of an application.
func NewVCSConfig ¶
Instantiates a new version control config object.
func (VCSConfig) Authenticated ¶
If this repository needs authentication, use the provided token.