pub struct Apps { /* private fields */ }Expand description
Projects, environments, apps and their deployments, for every org.
Implementations§
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_digest(self, f: DigestFn) -> Apps
pub fn with_digest(self, f: DigestFn) -> Apps
Use f to find an image’s digest 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 project_create( &self, org: &OrgId, name: &str, description: &str, environments: &[String], ) -> Result<Project>
pub fn project_get(&self, org: &OrgId, name: &str) -> Result<Project>
pub fn project_list(&self, org: &OrgId) -> Result<Vec<Project>>
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).
pub fn environment_create( &self, org: &OrgId, project: &str, env: &str, ) -> Result<Project>
pub fn environment_delete( &self, org: &OrgId, project: &str, env: &str, ) -> Result<Project>
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
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).