Skip to content

Commit

Permalink
feat(rust): remove spaces when resetting desktop app
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianbenavides committed Nov 7, 2023
1 parent b71af61 commit a0b0de4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions implementations/rust/ockam/ockam_app_lib/src/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use ockam_api::cli_state::{
};
use ockam_api::cloud::enroll::auth0::UserInfo;
use ockam_api::cloud::project::Project;
use ockam_api::cloud::space::Spaces;
use ockam_api::cloud::{AuthorityNode, Controller};
use ockam_api::nodes::models::portal::OutletStatus;
use ockam_api::nodes::models::transport::{CreateTransportJson, TransportMode, TransportType};
Expand Down Expand Up @@ -269,6 +270,7 @@ impl AppState {
}

async fn reset_state(&self) -> miette::Result<()> {
self.reset_orchestrator().await?;
let mut state = self.state.write().await;
match state.reset().await {
Ok(s) => {
Expand All @@ -280,6 +282,17 @@ impl AppState {
Ok(())
}

async fn reset_orchestrator(&self) -> miette::Result<()> {
let ctx = self.context();
let controller = self.controller().await?;
for space in self.state().await.spaces.list()? {
controller
.delete_space(&ctx, space.config().id.clone())
.await?;
}
Ok(())
}

/// Recreate a new NodeManagerWorker instance, which will restart the necessary
/// child workers as described in its Worker trait implementation.
pub async fn reset_node_manager(&self) -> miette::Result<()> {
Expand Down

0 comments on commit a0b0de4

Please sign in to comment.