Skip to content

Commit

Permalink
Add upgrade options
Browse files Browse the repository at this point in the history
  • Loading branch information
luc-blaeser committed Jan 5, 2024
1 parent c498e12 commit 5bb8771
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ic-utils/src/interfaces/management_canister/builders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,15 @@ impl<'agent, 'canister: 'agent> AsyncCall<(Principal,)>
}
}

#[derive(Debug, Copy, Clone, CandidType, Deserialize, Eq, PartialEq)]
/// Upgrade options.
pub struct UpgradeOptions {
/// Skip pre-upgrade hook. Only for exceptional cases, see the IC documentation. Not useful for Motoko.
pub skip_pre_upgrade: Option<bool>,
/// Enhanced orthogonal persistence for Motoko. Not used by other CDKs.
pub keep_main_memory: Option<bool>,
}

/// The install mode of the canister to install. If a canister is already installed,
/// using [InstallMode::Install] will be an error. [InstallMode::Reinstall] overwrites
/// the module, and [InstallMode::Upgrade] performs an Upgrade step.
Expand All @@ -377,9 +386,9 @@ pub enum InstallMode {
/// Overwrite the canister with this module.
#[serde(rename = "reinstall")]
Reinstall,
/// Upgrade the canister with this module.
/// Upgrade the canister with this module and some options.
#[serde(rename = "upgrade")]
Upgrade,
Upgrade(Option<UpgradeOptions>),
}

/// A prepared call to `install_code`.
Expand All @@ -404,7 +413,7 @@ impl FromStr for InstallMode {
match s {
"install" => Ok(InstallMode::Install),
"reinstall" => Ok(InstallMode::Reinstall),
"upgrade" => Ok(InstallMode::Upgrade),
"upgrade" => Ok(InstallMode::Upgrade(None)),
&_ => Err(format!("Invalid install mode: {}", s)),
}
}
Expand Down

0 comments on commit 5bb8771

Please sign in to comment.