feat: Add package pinning command (pin/unpin)#967
feat: Add package pinning command (pin/unpin)#967AshokThangavel wants to merge 3 commits intointersystems:mainfrom
pin/unpin)#967Conversation
This feature introduces package pinning functionality to enhance module stability and integrity within ZPM. **Key Changes:** * **New Commands:** Implemented `pin <module>` to lock a module's version and `unpin <module>` to unlock it. * **Integrity Check:** Added codebase-level checks to block `install`, `update`, `reinstall`, and `uninstall` when a module is pinned. * **Storage:** Created `%IPM.Storage.PinnedModule` for persistent storage of pinned module status. * **Visibility:** Updated `list` command to display the `-Pinned` status next to the version, and added the `list -p` modifier to view only pinned modules. **Impact:** Prevents accidental version changes for critical installed packages.
pin/unpin) to ZPMpin/unpin)
|
As per discussion #968 1. Dependency Protection StrategyThe
2. Implementation DetailsA. Implicit Protection Logic (Default)When a module is implicitly protected (Module B is protected by Pinned Module A), the core IPM modification commands ( B. Unpinning LogicThe protection on a dependency (Module B) will only be lifted when the last pinned module that relies on it (Module A) is unpinned. |
|
After discussion we're deciding not to add this feature - it's a bit confusing with respect to lock files / installation from them, and there are some odd interactions there. (We're revisiting some of the other older PRs too, I promise!) |
Feature: Package Pinning (
pin/unpin) ImplementationThis Pull Request introduces package pinning functionality. This feature allows users to lock an installed module's version, preventing accidental or automatic upgrades, downgrades, or removal until explicitly unpinned.
1. Overview
This feature enhances IPM's stability and dependency management by implementing a mechanism to lock installed modules. This ensures production or critical modules remain fixed at a specific version, protecting them from core IPM modification commands.
The implementation relies on a new persistent storage class to track pinned modules.
2. New Commands:
pinandunpin2.1.
pinCommandMarks a specific, installed module as pinned to prevent future modification operations.
Usage Examples:
2.2.
unpinCommandRemoves the pinned status from an installed module, allowing future ZPM operations (install, reinstall,uninstall, update) to proceed normally.
Usage Examples:
3. Architectural and Visibility Changes
3.1. Storage Mechanism
A new independent storage class,
%IPM.Storage.PinnedModule, was created to manage the list of all modules marked as pinned, their version, and their current status.3.2. Visibility and Discovery
listcommand: The status-Pinnedis appended to the version number for easy identification (e.g.,web-fslog 1.0.0-Pinned).list -pmodifier: A new modifier,-p(or--pinned), was implemented. This allows users to quickly list and audit only the modules that are currently pinned.4. Operational Blocking (Integrity Check)
The pinning status is checked at the codebase level within the execution logic for all modification commands. If a module is pinned, the command is blocked and a specific error is returned.
installERROR! The module web-fslog is pinned unable to installreinstallERROR! The module web-fslog is pinned unable to reinstalluninstallERROR! The module web-fslog is pinned unable to uninstallupdateERROR! The module web-fslog is pinned unable to updateVerification Trace for Blocking
The following sequence confirms the blocking mechanism when a module is pinned:
Verification Trace for Unlocking
The following sequence confirms that the
unpincommand correctly restores the ability to modify the package:5. Unit Testing Results
Integration and unit tests were created to validate the entire lifecycle of the pin feature and its interaction with core ZPM commands. All 20 assertions passed.
web-fslog).installcommand on the pinned module (AssertStatusNotOK).reinstallcommand on the pinned module (AssertStatusNotOK).uninstallcommand on the pinned module (AssertStatusNotOK).updatecommand on the pinned module (AssertStatusNotOK).unpincommand on a module that was already unpinned (AssertStatusNotOK).Resolves #968