Skip to main content

Apps

Struct Apps 

Source
pub struct Apps { /* private fields */ }
Expand description

Projects, environments, apps and their deployments, for every org.

Implementations§

Source§

impl Apps

Source

pub fn cancel_queued( &self, org: &OrgId, app: &str, id: u64, reason: &str, ) -> Result<bool>

Close a deployment that has not started as cancelled, with reason. Returns whether it was cancelled (false when it already started or finished).

Source§

impl Apps

Source

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.

Source

pub fn with_build(self, f: BuildFn) -> Apps

Use f instead of crate::build::run (tests).

Source

pub fn with_digest(self, f: DigestFn) -> Apps

Use f to find an image’s digest instead of skopeo inspect.

Source

pub fn with_timeout(self, t: Duration) -> Apps

Source

pub fn source_dir(&self, org: &OrgId, app: &str) -> PathBuf

Where an app’s git checkout lives.

Source

pub fn project_create( &self, org: &OrgId, name: &str, description: &str, environments: &[String], ) -> Result<Project>

Source

pub fn project_get(&self, org: &OrgId, name: &str) -> Result<Project>

Source

pub fn project_list(&self, org: &OrgId) -> Result<Vec<Project>>

Source

pub fn project_delete(&self, org: &OrgId, name: &str) -> Result<()>

Delete an empty project (its apps go first).

Source

pub fn environment_create( &self, org: &OrgId, project: &str, env: &str, ) -> Result<Project>

Source

pub fn environment_delete( &self, org: &OrgId, project: &str, env: &str, ) -> Result<Project>

Source

pub fn get(&self, org: &OrgId, name: &str) -> Result<App>

Source

pub fn list(&self, org: &OrgId) -> Result<Vec<App>>

Source

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.

Source

pub fn secrets(&self) -> &Arc<Secrets> ⓘ

The org’s secret store (backups read destination credentials and database passwords from it).

Source

pub fn client(&self) -> &Client

The incus client the apps run on.

Source

pub fn controller(&self) -> &Controller

The stack controller (events, definitions).

Source

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).

Source

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).

Source

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.

Source

pub fn env_get(&self, org: &OrgId, name: &str) -> Result<String>

Source

pub fn env_set(&self, org: &OrgId, name: &str, text: &str) -> Result<App>

Replace an app’s environment with .env text.

Source

pub fn webhook_secret( &self, org: &OrgId, name: &str, rotate: bool, ) -> Result<String>

The app’s webhook secret; with rotate, a new one first.

Source

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.

Source

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.

Source

pub fn deployment(&self, org: &OrgId, app: &str, id: u64) -> Result<Deployment>

Source

pub fn deployments(&self, org: &OrgId, app: &str) -> Result<Vec<Deployment>>

Newest first.

Source

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).

Source

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.

Source

pub fn wait( &self, org: &OrgId, app: &str, id: u64, timeout: Duration, ) -> Result<Deployment>

Wait until a deployment finishes, or timeout.

Source

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.

Source

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.

Source

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

Source

pub fn preview_get(&self, org: &OrgId, app: &str, n: u64) -> Result<Preview>

Source

pub fn preview_list(&self, org: &OrgId, app: &str) -> Result<Vec<Preview>>

An app’s previews, by pull request number.

Source

pub fn preview_deployment( &self, org: &OrgId, app: &str, n: u64, id: u64, ) -> Result<Deployment>

Source

pub fn preview_deployments( &self, org: &OrgId, app: &str, n: u64, ) -> Result<Vec<Deployment>>

Newest first.

Source

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).

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn start_preview_upkeep(&self)

Run Self::previews_upkeep every five minutes (the daemon).

Trait Implementations§

Source§

impl Clone for Apps

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Apps

§

impl !UnwindSafe for Apps

§

impl Freeze for Apps

§

impl Send for Apps

§

impl Sync for Apps

§

impl Unpin for Apps

§

impl UnsafeUnpin for Apps

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V