Skip to content

Commit f586065

Browse files
committed
refactor(wit): Remove app-init-no-cleanup-error
1 parent e13588b commit f586065

3 files changed

Lines changed: 10 additions & 21 deletions

File tree

workflow/deployer-workflow/impl-flyio/src/lib.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ use generated::{
2323
},
2424
workflow::{
2525
types::{AppCleanupFailed, AppInitModifyError},
26-
workflow::{
27-
self as workflow_import, AppInitError, AppInitNoCleanupError, ObeliskConfig,
28-
},
26+
workflow::{self as workflow_import, AppInitError, ObeliskConfig},
2927
},
3028
},
3129
};
@@ -174,7 +172,7 @@ fn app_modify_without_cleanup(
174172
Ok(get_secret_keys(config))
175173
}
176174

177-
fn cleanup(app_name: &str, modify_error: Option<AppInitModifyError>) -> AppInitError {
175+
fn cleanup(app_name: &str, modify_error: AppInitModifyError) -> AppInitError {
178176
// Delete the app with force.
179177
match activity_fly_http::apps::delete(app_name, true) {
180178
Ok(()) => AppInitError::CleanupOk,
@@ -203,9 +201,8 @@ impl Guest for Component {
203201
fn app_modify_no_cleanup_on_error(
204202
app_name: String,
205203
config: ObeliskConfig,
206-
) -> Result<Vec<String>, AppInitNoCleanupError> {
204+
) -> Result<Vec<String>, AppInitModifyError> {
207205
app_modify_without_cleanup(&app_name, config)
208-
.map_err(AppInitNoCleanupError::AppInitModifyError)
209206
}
210207

211208
fn app_init(
@@ -217,10 +214,7 @@ impl Guest for Component {
217214
app_create(&org_slug, &app_name)?;
218215
// Launch a child workflow by using import
219216
let required_secrets = workflow_import::app_modify_no_cleanup_on_error(&app_name, &config)
220-
.map_err(|err| match err {
221-
AppInitNoCleanupError::AppInitModifyError(err) => cleanup(&app_name, Some(err)),
222-
AppInitNoCleanupError::ExecutionFailed => cleanup(&app_name, None),
223-
})?;
217+
.map_err(|err| cleanup(&app_name, err))?;
224218
// Sleep until all requested secrets are stored in the app.
225219
let required_secrets: HashSet<_> = required_secrets.into_iter().collect();
226220
while !required_secrets.is_empty() {

workflow/deployer-workflow/wit/obelisk-flyio_workflow@1.0.0-beta/types.wit

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,17 @@ interface types {
4646
volume-write-error(string),
4747
/// Error running `obelisk server verify -i`
4848
verify-error(string),
49+
/// Trap (panic) during execution
50+
execution-failed,
4951
}
5052

5153
record app-cleanup-failed {
52-
/// The associated value contains the reason of failure, if available.
53-
/// If the payload is missing a trap in child workflow occurred.
54-
modify-error: option<app-init-modify-error>,
54+
/// Reason of the original failure.
55+
modify-error: app-init-modify-error,
5556
/// Reason why cleanup failed.
5657
cleanup-error: string,
5758
}
5859

59-
variant app-init-no-cleanup-error {
60-
app-init-modify-error(app-init-modify-error),
61-
execution-failed,
62-
}
63-
6460
variant app-init-error {
6561
app-name-conflict,
6662
app-create-error(string),

workflow/deployer-workflow/wit/obelisk-flyio_workflow@1.0.0-beta/workflow.wit

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package obelisk-flyio:workflow@1.0.0-beta;
22

33
interface workflow {
4-
use types.{obelisk-config, app-init-no-cleanup-error, app-init-error};
4+
use types.{obelisk-config, app-init-modify-error, app-init-error};
55

66
/// Allocate an IP address.
77
/// Create a volume.
@@ -13,8 +13,7 @@ interface workflow {
1313
app-modify-no-cleanup-on-error: func(
1414
app-name: string,
1515
config: obelisk-config,
16-
) -> result<list<string>, app-init-no-cleanup-error>;
17-
16+
) -> result<list<string>, app-init-modify-error>;
1817

1918
/// Chcek whether the app_name exists. If it does, return app-name-conflict.
2019
/// Create a fly app.

0 commit comments

Comments
 (0)