Skip to content

Commit

Permalink
fix: Update CanisterInstallMode signature (#527)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamspofford-dfinity authored Nov 4, 2024
1 parent 9a65c41 commit 4e628a8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-12]
os: [ubuntu-latest, macos-13-large]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
36 changes: 33 additions & 3 deletions src/ic-cdk/src/api/management_canister/main/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ pub enum CanisterInstallMode {
Reinstall,
/// Upgrade an existing canister.
#[serde(rename = "upgrade")]
Upgrade(Option<SkipPreUpgrade>),
Upgrade(Option<UpgradeFlags>),
}

/// If set to true, the pre_upgrade step will be skipped during the canister upgrade
/// Flags for canister installation with [`CanisterInstallMode::Upgrade`].
#[derive(
CandidType,
Serialize,
Expand All @@ -209,7 +209,37 @@ pub enum CanisterInstallMode {
Copy,
Default,
)]
pub struct SkipPreUpgrade(pub Option<bool>);
pub struct UpgradeFlags {
/// If set to `true`, the `pre_upgrade` step will be skipped during the canister upgrade
pub skip_pre_upgrade: Option<bool>,
/// If set to `Keep`, the WASM heap memory will be preserved instead of cleared.
pub wasm_memory_persistence: Option<WasmPersistenceMode>,
}

/// WASM memory persistence setting for [`UpgradeFlags`].
#[derive(
CandidType,
Serialize,
Deserialize,
Debug,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
Clone,
Copy,
Default,
)]
pub enum WasmPersistenceMode {
/// Preserve heap memory (only officially supported by Motoko)
#[serde(rename = "keep")]
Keep,
/// Clear heap memory
#[serde(rename = "replace")]
#[default]
Replace,
}

/// WASM module.
pub type WasmModule = Vec<u8>;
Expand Down

0 comments on commit 4e628a8

Please sign in to comment.