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 compose_owner(&self, org: &OrgId, stack: &str) -> Option<ComposeOwner>

The project environment a deployed compose stack belongs to.

Source

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.

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn environment_compose( &self, org: &OrgId, project: &str, env: &str, ) -> EnvCompose

An environment’s compose stacks and the names they lost.

Source

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

Source

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

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

The secret name got a new value: when it is a database app’s password (db.<app>.password), store the URL secret and the database’s urls again with it. Returns the secrets whose value moved.

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_probe(self, f: ImageProbe) -> Apps

Use f to ask registries about images 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 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 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

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

Source§

impl Apps

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

The org’s projects. Compose stacks that are gone are left out.

Source

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.

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>

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