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 SourceData, env Environment, ...) (d Deployment, err error)
- func (a App) Promote(source Deployment, deployNumber DeploymentNumber, requestedBy domain.UserID) (d Deployment, err error)
- func (a App) Redeploy(source Deployment, deployNumber DeploymentNumber, requestedBy domain.UserID) (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 ArtifactManager
- type Backend
- type Config
- type Deployment
- type DeploymentCreated
- type DeploymentID
- type DeploymentLogger
- type DeploymentNumber
- type DeploymentStateChanged
- type DeploymentStatus
- type DeploymentsReader
- type DeploymentsWriter
- type EnvVars
- type Environment
- type EnvironmentsEnv
- type RunningOrPendingAppDeploymentsCount
- type Service
- type Services
- type ServicesEnv
- type Source
- type SourceData
- 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) 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 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 ( ErrNoValidSourceFound = errors.New("no_valid_source_found") ErrInvalidSourcePayload = errors.New("invalid_source_payload") SourceDataTypes = storage.NewDiscriminatedMapper(func(sd SourceData) string { return sd.Kind() }) )
var ( ErrNotInPendingState = apperr.New("not_in_pending_state") ErrNotInRunningState = apperr.New("not_in_running_state") )
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 SourceData, env Environment, 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, 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, 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 AppCleanupRequested struct { bus.Notification ID AppID Requested shared.Action[domain.UserID] }
func (AppCleanupRequested) Name_ ¶ added in v1.2.0
func (AppCleanupRequested) Name_() string
type AppCreated ¶
type AppCreated struct { bus.Notification ID AppID Name UniqueAppName Created shared.Action[domain.UserID] }
func (AppCreated) Name_ ¶ added in v1.2.0
func (AppCreated) Name_() string
type AppDeleted ¶
type AppDeleted struct { bus.Notification ID AppID }
func (AppDeleted) Name_ ¶ added in v1.2.0
func (AppDeleted) Name_() string
type AppEnvChanged ¶
type AppEnvChanged struct { bus.Notification ID AppID Env EnvironmentsEnv }
func (AppEnvChanged) Name_ ¶ added in v1.2.0
func (AppEnvChanged) Name_() string
type AppEnvRemoved ¶
type AppEnvRemoved struct { bus.Notification ID AppID }
func (AppEnvRemoved) Name_ ¶ added in v1.2.0
func (AppEnvRemoved) Name_() string
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 AppVCSConfigured struct { bus.Notification ID AppID Config VCSConfig }
func (AppVCSConfigured) Name_ ¶ added in v1.2.0
func (AppVCSConfigured) Name_() string
type AppVCSRemoved ¶
type AppVCSRemoved struct { bus.Notification ID AppID }
func (AppVCSRemoved) Name_ ¶ added in v1.2.0
func (AppVCSRemoved) Name_() string
type AppsReader ¶
type ArtifactManager ¶ added in v1.1.0
type ArtifactManager interface { // Prepare the build directory and logger for the given deployment. // Returns the build directory path and the logger to use for each of the deployment steps. // You MUST close the logger if no err has been returned. PrepareBuild(context.Context, Deployment) (string, DeploymentLogger, error) // Cleanup an application artefacts. Cleanup(context.Context, App) error // Returns the absolute path to a deployment log file. LogPath(context.Context, Deployment) string }
Manage all build artifacts.
type Backend ¶
type Backend interface { Run(context.Context, string, DeploymentLogger, Deployment) (Services, error) // Launch a deployment stored in the given path 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
func (Config) ProjectName ¶
Retrieve the name of the project wich is the combination of the appname and the environment targeted by this configuration.
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) Requested ¶ added in v1.1.0
func (d Deployment) Requested() shared.Action[domain.UserID]
func (Deployment) Source ¶ added in v1.1.0
func (d Deployment) Source() SourceData
type DeploymentCreated ¶
type DeploymentCreated struct { bus.Notification ID DeploymentID Config Config State State Source SourceData Requested shared.Action[domain.UserID] }
func (DeploymentCreated) Name_ ¶ added in v1.2.0
func (DeploymentCreated) Name_() string
type DeploymentID ¶
type DeploymentID struct {
// contains filtered or unexported fields
}
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 DeploymentLogger ¶ added in v1.1.0
type DeploymentLogger interface { io.WriteCloser Stepf(string, ...any) Warnf(string, ...any) Infof(string, ...any) Error(error) }
Specific logger interface use by deployment jobs to document the deployment process.
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 { bus.Notification ID DeploymentID State State }
func (DeploymentStateChanged) Name_ ¶ added in v1.2.0
func (DeploymentStateChanged) Name_() string
type DeploymentStatus ¶
type DeploymentStatus uint8
const ( DeploymentStatusPending DeploymentStatus = iota DeploymentStatusRunning DeploymentStatusFailed DeploymentStatusSucceeded )
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 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 Source ¶ added in v1.1.0
type Source interface { Prepare(App, any) (SourceData, error) // Prepare the given payload for the given application, doing any needed validation Fetch(context.Context, string, DeploymentLogger, Deployment) error // Retrieve deployment data and store them in the given path before passing in to a backend }
Represents a source which has initiated a deployment.
type SourceData ¶ added in v1.1.0
Contains stuff related to how the deployment has been triggered. The inner data depends on the Source which has been requested.
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. The default value represents a pending state.
func (State) Status ¶
func (s State) Status() DeploymentStatus
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 meaning.
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.