Public release release-09ca780bd67a
Source commit: 09ca780bd67a00467e78139cf38466b8201b66ca Public tree identity: sha256:2f744c260b5fc2cf074ad9129f97f87f03714902e5b9fe174128afdc342ec2d0
This commit is contained in:
commit
eb1077f380
221 changed files with 81144 additions and 0 deletions
35
crates/clusterflux-cli/src/confirm.rs
Normal file
35
crates/clusterflux-cli/src/confirm.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use serde_json::{json, Value};
|
||||
|
||||
use crate::errors::cli_error_summary_for_category;
|
||||
|
||||
pub(crate) fn confirmation_required_report(
|
||||
command: &str,
|
||||
operation: &str,
|
||||
target: Value,
|
||||
confirm_command: String,
|
||||
) -> Value {
|
||||
let message = format!("{command} requires --yes before {operation}");
|
||||
let next_actions = json!([
|
||||
confirm_command,
|
||||
"review the command target before confirming",
|
||||
"rerun with --json to inspect the safe failure"
|
||||
]);
|
||||
let mut machine_error = cli_error_summary_for_category("policy", &message);
|
||||
if let Some(object) = machine_error.as_object_mut() {
|
||||
object.insert("confirmation_required".to_owned(), json!(true));
|
||||
object.insert("next_actions".to_owned(), next_actions.clone());
|
||||
}
|
||||
json!({
|
||||
"command": command,
|
||||
"status": "confirmation_required",
|
||||
"operation": operation,
|
||||
"target": target,
|
||||
"requires_confirmation": true,
|
||||
"confirmation_required": true,
|
||||
"explicit_user_action_required": true,
|
||||
"coordinator_request_sent": false,
|
||||
"safe_failure": true,
|
||||
"next_actions": next_actions,
|
||||
"machine_error": machine_error,
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue