pub struct Apps { /* private fields */ }Expand description
Projects, environments, apps and their deployments, for every org.
Implementations§
Source§impl Apps
impl Apps
Sourcepub fn compose_owner(&self, org: &OrgId, stack: &str) -> Option<ComposeOwner>
pub fn compose_owner(&self, org: &OrgId, stack: &str) -> Option<ComposeOwner>
The project environment a deployed compose stack belongs to.
Sourcepub fn managed_by(&self, org: &OrgId, stack: &str) -> Option<&'static str>
pub fn managed_by(&self, org: &OrgId, stack: &str) -> Option<&'static str>
What owns a stack besides its file: the apps of a project
environment (<project>-<env>, and a pull request’s
<project>-<env>-pr-<n>), or the org’s ingress tunnel.
Sourcepub fn default_owner(
&self,
org: &OrgId,
stack: &str,
) -> Result<(String, String, bool)>
pub fn default_owner( &self, org: &OrgId, stack: &str, ) -> Result<(String, String, bool)>
Where a stack with no owner goes: the project of its name (its
production environment, else its first), or a new project named
after it with a production environment. (project, env, create).
Sourcepub fn compose_attach(
&self,
org: &OrgId,
project: &str,
env: &str,
stack: &str,
create_project: bool,
) -> Result<ComposeOwner>
pub fn compose_attach( &self, org: &OrgId, project: &str, env: &str, stack: &str, create_project: bool, ) -> Result<ComposeOwner>
Make stack belong to project/env; with create_project, a
project that does not exist is made, with that one environment, in
the same write. A stack keeps the owner it has: attaching it
elsewhere is refused. Nothing is deployed.
Sourcepub fn compose_detach(&self, org: &OrgId, stack: &str) -> Result<()>
pub fn compose_detach(&self, org: &OrgId, stack: &str) -> Result<()>
Forget which environment stack belongs to (it was removed).
Nothing to do for a stack with no owner.
Sourcepub fn adopt_compose_stacks(
&self,
stacks: &[(OrgId, String)],
) -> Vec<Result<String>> ⓘ
pub fn adopt_compose_stacks( &self, stacks: &[(OrgId, String)], ) -> Vec<Result<String>> ⓘ
Give every stack in stacks with no owner one (Apps::default_owner),
creating its project when needed. Skipped: owned stacks, the ingress
tunnel, and stacks the apps run (environments and previews). Nothing
is deployed; running it again changes nothing. One line per stack
adopted, or why it was not.
Sourcepub fn dns_scope(&self, org: &OrgId, stack: &str) -> Option<DnsScope>
pub fn dns_scope(&self, org: &OrgId, stack: &str) -> Option<DnsScope>
The environment a stack’s services are also named in, and which of them are: what the controller’s hosts files follow.
Sourcepub fn scope_fn(&self) -> DnsScopeFn
pub fn scope_fn(&self) -> DnsScopeFn
Apps::dns_scope for crate::stack::Controller::set_dns_scope.
It holds the apps weakly: the controller outliving them answers none.
Sourcepub fn environment_compose(
&self,
org: &OrgId,
project: &str,
env: &str,
) -> EnvCompose
pub fn environment_compose( &self, org: &OrgId, project: &str, env: &str, ) -> EnvCompose
An environment’s compose stacks and the names they lost.
Sourcepub fn compose_check(
&self,
org: &OrgId,
project: &str,
env: &str,
stack: &str,
services: &[String],
) -> Result<()>
pub fn compose_check( &self, org: &OrgId, project: &str, env: &str, stack: &str, services: &[String], ) -> Result<()>
Before compose stack stack is deployed into project/env with
services: refuse a stack the apps run, and a service name the
environment already gives an app or another stack’s service. Names
the stack holds already (deployed before) are its own.
Source§impl Apps
impl Apps
Sourcepub fn on_secret_changed(&self, f: SecretHook)
pub fn on_secret_changed(&self, f: SecretHook)
Tell f about each secret that gets a new value outside secret_set
(once; later calls are ignored).
Source§impl Apps
impl Apps
Sourcepub fn new(
state: &Path,
client: Client,
ctl: Controller,
secrets: Arc<Secrets>,
) -> Apps
pub fn new( state: &Path, client: Client, ctl: Controller, secrets: Arc<Secrets>, ) -> Apps
Open the app store under state. Deployments a stopped daemon left
unfinished are marked failed.
Sourcepub fn with_build(self, f: BuildFn) -> Apps
pub fn with_build(self, f: BuildFn) -> Apps
Use f instead of crate::build::run (tests).
Sourcepub fn with_probe(self, f: ImageProbe) -> Apps
pub fn with_probe(self, f: ImageProbe) -> Apps
Use f to ask registries about images instead of skopeo inspect.
pub fn with_timeout(self, t: Duration) -> Apps
Sourcepub fn source_dir(&self, org: &OrgId, app: &str) -> PathBuf
pub fn source_dir(&self, org: &OrgId, app: &str) -> PathBuf
Where an app’s git checkout lives.
pub fn get(&self, org: &OrgId, name: &str) -> Result<App>
pub fn list(&self, org: &OrgId) -> Result<Vec<App>>
Sourcepub fn create(&self, org: &OrgId, spec: AppSpec) -> Result<(App, String)>
pub fn create(&self, org: &OrgId, spec: AppSpec) -> Result<(App, String)>
Create an app (not deployed yet) and its webhook secret. Returns the app and that secret.
Sourcepub fn secrets(&self) -> &Arc<Secrets> ⓘ
pub fn secrets(&self) -> &Arc<Secrets> ⓘ
The org’s secret store (backups read destination credentials and database passwords from it).
Sourcepub fn controller(&self) -> &Controller
pub fn controller(&self) -> &Controller
The stack controller (events, definitions).
Sourcepub fn wait_converged(&self, org: &OrgId, name: &str) -> Result<(bool, String)>
pub fn wait_converged(&self, org: &OrgId, name: &str) -> Result<(bool, String)>
Wait (up to the deploy timeout) for an app’s service to converge at
its current revision: (converged, why not).
Sourcepub fn check_spec(&self, org: &OrgId, spec: &AppSpec) -> Result<()>
pub fn check_spec(&self, org: &OrgId, spec: &AppSpec) -> Result<()>
What create and update check about the secrets a spec names,
for callers that check without writing (app_apply with
dry_run).
Sourcepub fn update(&self, org: &OrgId, name: &str, patch: &Value) -> Result<App>
pub fn update(&self, org: &OrgId, name: &str, patch: &Value) -> Result<App>
Change an app’s settings with a JSON merge patch (null clears a
setting). Name, project and environment are fixed. Takes effect at
the next deploy.
pub fn env_get(&self, org: &OrgId, name: &str) -> Result<String>
Sourcepub fn env_set(&self, org: &OrgId, name: &str, text: &str) -> Result<App>
pub fn env_set(&self, org: &OrgId, name: &str, text: &str) -> Result<App>
Replace an app’s environment with .env text.
Sourcepub fn webhook_secret(
&self,
org: &OrgId,
name: &str,
rotate: bool,
) -> Result<String>
pub fn webhook_secret( &self, org: &OrgId, name: &str, rotate: bool, ) -> Result<String>
The app’s webhook secret; with rotate, a new one first.
Sourcepub fn deploy_key(&self, org: &OrgId, name: &str) -> Result<String>
pub fn deploy_key(&self, org: &OrgId, name: &str) -> Result<String>
A new ed25519 deploy key for a git app over SSH: stored as the org
secret app.<app>.deploy-key, made the app’s credential, and its
public half returned to paste into the repository’s deploy keys.
Sourcepub fn delete(&self, org: &OrgId, name: &str) -> Result<()>
pub fn delete(&self, org: &OrgId, name: &str) -> Result<()>
Delete an app: its service leaves the stack (the stack goes when it was the last), then its records, checkout and the secrets isb made for it. Named volumes are kept.
pub fn deployment(&self, org: &OrgId, app: &str, id: u64) -> Result<Deployment>
Sourcepub fn deployments(&self, org: &OrgId, app: &str) -> Result<Vec<Deployment>>
pub fn deployments(&self, org: &OrgId, app: &str) -> Result<Vec<Deployment>>
Newest first.
Sourcepub fn log(
&self,
org: &OrgId,
app: &str,
id: u64,
offset: u64,
) -> Result<(String, u64, bool)>
pub fn log( &self, org: &OrgId, app: &str, id: u64, offset: u64, ) -> Result<(String, u64, bool)>
A deployment’s log from byte offset: (text, next offset, finished).
Sourcepub fn log_and_record(
&self,
org: &OrgId,
app: &str,
id: u64,
offset: u64,
) -> Result<(String, u64, Deployment)>
pub fn log_and_record( &self, org: &OrgId, app: &str, id: u64, offset: u64, ) -> Result<(String, u64, Deployment)>
Apps::log with the deployment record read just before the log,
so a client follows the text and the status in one call: a record
that says finished means the text holds every line.
Sourcepub fn wait(
&self,
org: &OrgId,
app: &str,
id: u64,
timeout: Duration,
) -> Result<Deployment>
pub fn wait( &self, org: &OrgId, app: &str, id: u64, timeout: Duration, ) -> Result<Deployment>
Wait until a deployment finishes, or timeout.
Sourcepub fn deploy(
&self,
org: &OrgId,
name: &str,
trigger: Trigger,
by: &str,
requested: Option<String>,
) -> Result<Deployment>
pub fn deploy( &self, org: &OrgId, name: &str, trigger: Trigger, by: &str, requested: Option<String>, ) -> Result<Deployment>
Queue a deploy of the app’s current settings.
Sourcepub fn rollback(
&self,
org: &OrgId,
name: &str,
to: Option<u64>,
trigger: Trigger,
by: &str,
) -> Result<Deployment>
pub fn rollback( &self, org: &OrgId, name: &str, to: Option<u64>, trigger: Trigger, by: &str, ) -> Result<Deployment>
Queue a rollback to deployment to (default: the one before the
current): its image and settings, without building.
Sourcepub fn webhook(
&self,
org: &str,
app: &str,
header: &dyn Fn(&str) -> Option<String>,
token: Option<&str>,
body: &[u8],
) -> (u16, Value)
pub fn webhook( &self, org: &str, app: &str, header: &dyn Fn(&str) -> Option<String>, token: Option<&str>, body: &[u8], ) -> (u16, Value)
Answer POST /api/v1/webhooks/<org>/<app>: (status, body). Nothing
happens without a valid signature or token; an unknown org or app
answers as a bad signature does, so the endpoint maps nothing.
Source§impl Apps
impl Apps
Sourcepub fn check_image(
&self,
before: Option<&AppSpec>,
spec: &AppSpec,
) -> Result<Option<String>>
pub fn check_image( &self, before: Option<&AppSpec>, spec: &AppSpec, ) -> Result<Option<String>>
Check the remote image spec names (an image source, or a
database’s) before it is saved: Err when its registry does not
have it, a warning when that could not be confirmed. With before
(an update), an image that did not change is not asked about again.
Source§impl Apps
impl Apps
pub fn preview_get(&self, org: &OrgId, app: &str, n: u64) -> Result<Preview>
Sourcepub fn preview_list(&self, org: &OrgId, app: &str) -> Result<Vec<Preview>>
pub fn preview_list(&self, org: &OrgId, app: &str) -> Result<Vec<Preview>>
An app’s previews, by pull request number.
pub fn preview_deployment( &self, org: &OrgId, app: &str, n: u64, id: u64, ) -> Result<Deployment>
Sourcepub fn preview_deployments(
&self,
org: &OrgId,
app: &str,
n: u64,
) -> Result<Vec<Deployment>>
pub fn preview_deployments( &self, org: &OrgId, app: &str, n: u64, ) -> Result<Vec<Deployment>>
Newest first.
Sourcepub fn preview_log(
&self,
org: &OrgId,
app: &str,
n: u64,
id: u64,
offset: u64,
) -> Result<(String, u64, bool)>
pub fn preview_log( &self, org: &OrgId, app: &str, n: u64, id: u64, offset: u64, ) -> Result<(String, u64, bool)>
A preview deployment’s log from byte offset: (text, next offset, finished).
Sourcepub fn preview_wait(
&self,
org: &OrgId,
app: &str,
n: u64,
id: u64,
timeout: Duration,
) -> Result<Deployment>
pub fn preview_wait( &self, org: &OrgId, app: &str, n: u64, id: u64, timeout: Duration, ) -> Result<Deployment>
Wait until a preview deployment finishes, or timeout.
Sourcepub fn preview_json(&self, org: &OrgId, p: &Preview) -> Value
pub fn preview_json(&self, org: &OrgId, p: &Preview) -> Value
A preview as the tools show it: the record, plus its last deployment’s status.
Sourcepub fn preview_request(
&self,
org: &OrgId,
name: &str,
provider: Provider,
pr: &PullRequest,
trigger: Trigger,
by: &str,
requested: String,
) -> Result<Requested>
pub fn preview_request( &self, org: &OrgId, name: &str, provider: Provider, pr: &PullRequest, trigger: Trigger, by: &str, requested: String, ) -> Result<Requested>
Create or update the preview of pr and queue a deploy of it.
Sourcepub fn preview_redeploy(
&self,
org: &OrgId,
name: &str,
n: u64,
trigger: Trigger,
by: &str,
) -> Result<Deployment>
pub fn preview_redeploy( &self, org: &OrgId, name: &str, n: u64, trigger: Trigger, by: &str, ) -> Result<Deployment>
Build and deploy a preview’s head again.
Sourcepub fn preview_remove(
&self,
org: &OrgId,
name: &str,
n: u64,
why: &str,
wait: bool,
) -> Result<()>
pub fn preview_remove( &self, org: &OrgId, name: &str, n: u64, why: &str, wait: bool, ) -> Result<()>
Remove a preview: its service (and the stack with its last), its
volumes, its build cache, its images and its records. With wait,
returns when done; else in the background.
Sourcepub fn previews_upkeep(&self)
pub fn previews_upkeep(&self)
One pass of upkeep: finish removals that failed or were interrupted,
and remove previews idle past their app’s ttl.
Sourcepub fn start_preview_upkeep(&self)
pub fn start_preview_upkeep(&self)
Run Self::previews_upkeep every five minutes (the daemon).
Source§impl Apps
impl Apps
pub fn project_create( &self, org: &OrgId, name: &str, description: &str, environments: &[String], ) -> Result<Project>
pub fn project_get(&self, org: &OrgId, name: &str) -> Result<Project>
Sourcepub fn project_list(&self, org: &OrgId) -> Result<Vec<Project>>
pub fn project_list(&self, org: &OrgId) -> Result<Vec<Project>>
The org’s projects. Compose stacks that are gone are left out.
Sourcepub fn contents(
&self,
org: &OrgId,
project: &str,
env: Option<&str>,
) -> Result<(Vec<String>, Vec<String>)>
pub fn contents( &self, org: &OrgId, project: &str, env: Option<&str>, ) -> Result<(Vec<String>, Vec<String>)>
What runs in a project, or in one of its environments: its apps and its live compose stacks, by name.
Sourcepub fn project_delete(&self, org: &OrgId, name: &str) -> Result<()>
pub fn project_delete(&self, org: &OrgId, name: &str) -> Result<()>
Delete an empty project (its apps go first).