By script
This document explains the differences between the interactive and non-interactive canister management scripts, their use cases, and the prerequisites required to run them.
Prerequisites
1. Install Required Tools:
2. Set Up a Toolkit Hotkey
Both scripts require your DFX identity principal to be configured as a hotkey in the Toolkit UI for authentication.
Steps:
- Open the Toolkit UI.
- Navigate to Settings > Hotkeys.
- Add your principal as a hotkey:
- Get your DFX principal using:
dfx identity get-principal
- Get your DFX principal using:
- Save the changes.
Script Comparison: Interactive vs Non-Interactive
1. Interactive Script
Path: scripts/manage-canister-interactive.sh
The interactive script provides a step-by-step workflow for managing canisters. It guides you through:
- Operation Selection: Choose between installing, reinstalling, or upgrading a canister.
- Input Collection: Prompts you for the root canister ID, target canister ID, WASM module path, and optional Candid arguments.
- Input Persistence: Remembers your inputs from previous runs and offers them as defaults.
Use Case:
Ideal for developers who want a simple and user-friendly interface for managing canisters during development or testing.
Benefits:
- No prior configuration required.
- Input persistence reduces repetitive tasks.
- Guides users through each step with validation and confirmations.
2. Non-Interactive Script
Path: scripts/upgrade_canister.sh
The non-interactive script is designed for automation and can be tailored for specific use cases. Unlike the interactive script, it does not prompt for inputs and requires modification of the script itself.
How It Works:
- You define the root canister ID, target canister ID, WASM module path, and optional Candid arguments directly in the script.
- It executes the operation (install, reinstall, or upgrade) without user input.
Use Case:
Perfect for CI/CD pipelines or automated workflows where you need consistent, repeatable, and unattended operations.
Benefits:
- Fully automated once configured.
- Ideal for integrating with CI/CD pipelines.
- Reduces manual errors in repetitive tasks.
Summary of Differences
Feature | Interactive Script | Non-Interactive Script |
---|---|---|
Input Collection | Prompts the user interactively | Hardcoded in the script |
Use Case | Development/testing environments | CI/CD pipelines, automation |
Input Persistence | Saves previous inputs for reuse | Not applicable |
User Confirmation | Requires confirmation before running | No user interaction required |
Execution | Guided and manual | Automated and repeatable |
Choosing the Right Script
- Use the interactive script if you’re managing canisters manually and need flexibility during development or testing.
- Use the non-interactive script if you want to automate canister management in CI/CD pipelines or other workflows.