provisioning/docs/src/development/providers/provider-distribution-guide.md

2 lines
18 KiB
Markdown
Raw Normal View History

# Provider Distribution Guide\n\n**Strategic Guide for Provider Management and Distribution**\n\nThis guide explains the two complementary approaches for managing providers in the provisioning system and when to use each.\n\n---\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Module-Loader Approach](#module-loader-approach)\n- [Provider Packs Approach](#provider-packs-approach)\n- [Comparison Matrix](#comparison-matrix)\n- [Recommended Hybrid Workflow](#recommended-hybrid-workflow)\n- [Command Reference](#command-reference)\n- [Real-World Scenarios](#real-world-scenarios)\n- [Best Practices](#best-practices)\n\n---\n\n## Overview\n\nThe provisioning system supports **two complementary approaches** for provider management:\n\n1. **Module-Loader**: Symlink-based local development with dynamic discovery\n2. **Provider Packs**: Versioned, distributable artifacts for production\n\nBoth approaches work seamlessly together and serve different phases of the development lifecycle.\n\n---\n\n## Module-Loader Approach\n\n### Purpose\n\nFast, local development with direct access to provider source code.\n\n### How It Works\n\n```{$detected_lang}\n# Install provider for infrastructure (creates symlinks)\nprovisioning providers install upcloud wuji\n\n# Internal Process:\n# 1. Discovers provider in extensions/providers/upcloud/\n# 2. Creates symlink: workspace/infra/wuji/.nickel-modules/upcloud_prov -> extensions/providers/upcloud/nickel/\n# 3. Updates workspace/infra/wuji/manifest.toml with local path dependency\n# 4. Updates workspace/infra/wuji/providers.manifest.yaml\n```\n\n### Key Features\n\n✅ **Instant Changes**: Edit code in `extensions/providers/`, immediately available in infrastructure\n✅ **Auto-Discovery**: Automatically finds all providers in extensions/\n✅ **Simple Commands**: `providers install/remove/list/validate`\n✅ **Easy Debugging**: Direct access to source code\n✅ **No Packaging**: Skip build/package step during development\n\n### Best Use Cases\n\n- 🔧 **Active Development**: Writing new provider features\n- 🧪 **Testing**: Rapid iteration and testing cycles\n- 🏠 **Local Infrastructure**: Single machine or small team\n- 📝 **Debugging**: Need to modify and test provider code\n- 🎓 **Learning**: Understanding how providers work\n\n### Example Workflow\n\n```{$detected_lang}\n# 1. List available providers\nprovisioning providers list\n\n# 2. Install provider for infrastructure\nprovisioning providers install upcloud wuji\n\n# 3. Verify installation\nprovisioning providers validate wuji\n\n# 4. Edit provider code\nvim extensions/providers/upcloud/nickel/server_upcloud.ncl\n\n# 5. Test changes immediately (no repackaging!)\ncd workspace/infra/wuji\nnickel export main.ncl\n\n# 6. Remove when done\nprovisioning providers remove upcloud wuji\n```\n\n### File Structure\n\n```{$detected_lang}\nextensions/providers/upcloud/\n├── nickel/\n│ ├── manifest.toml\n│ ├── server_upcloud.ncl\n│ └── network_upcloud.ncl\n└── README.md\n\nworkspace/infra/wuji/\n├── .nickel-modules/\n│ └── upcloud_prov -> ../../../../extensions/providers/upcloud/nickel/ # Symlink\n├── manifest.toml # Updated with local path dependency\n├── providers.manifest.yaml # Tracks installed providers\n└── schemas/\n └── servers.ncl\n```\n\n---\n\n## Provider Packs Approach\n\n### Purpose\n\nCreate versioned, distributable artifacts for production deployments and team collaboration.\n\n### How It Works\n\n```{$detected_lang}\n# Package providers into distributable artifacts\nexport PROVISIONING=/Users/Akasha/project-provisioning/provisioning\n./provisioning/core/cli/pack providers\n\n# Internal Process:\n# 1. Enters each provider's nickel/ directory\n# 2. Runs: nickel export . --format json (generates JSON for distribution)\n# 3. Creates: upcloud_prov_0.0.1.tar\n# 4. Generates metadata: distribution/registry/upcloud_prov.json\n```\n\n### Key Features\n\n✅ **Versioned Artifacts**: Immutable, reproducible packages\n✅ **Portable**: Share a