| 745 | } |
| 746 | |
| 747 | fn save_lifecycle(dir: &Path, lifecycle: &ManagedLifecycle) -> CliResult<()> { |
| 748 | validate_run_id(&lifecycle.run_id)?; |
| 749 | fs::create_dir_all(dir)?; |
| 750 | let path = lifecycle_path(dir, &lifecycle.run_id); |
| 751 | let data = serde_json::to_vec_pretty(lifecycle) |
| 752 | .map_err(|e| CliError::Internal(anyhow!("failed to serialize managed lifecycle: {}", e)))?; |
| 753 | let tmp = path.with_extension("json.tmp"); |
| 754 | fs::write(&tmp, data)?; |
| 755 | fs::rename(&tmp, &path)?; |
| 756 | Ok(()) |
| 757 | } |
| 758 | |
| 759 | fn remove_lifecycle(dir: &Path, run_id: &str) -> CliResult<()> { |
| 760 | validate_run_id(run_id)?; |