Provider System
Spuff uses a provider abstraction layer that enables support for multiple cloud providers. This document explains how the system works.
Overview
Architecture
The provider system follows the Registry Pattern, which enables:
Extensibility: Add new providers without modifying existing code
Dynamic discovery: List available providers at runtime
Uniform configuration: All providers use the same creation interface
Main Components
src/provider/mod.rs
Provider trait and core types
src/provider/registry.rs
ProviderFactory and ProviderRegistry
src/provider/config.rs
InstanceRequest, ImageSpec, ProviderTimeouts
src/provider/error.rs
ProviderError with specific types
src/provider/digitalocean.rs
Reference implementation
Provider Creation Flow
Core Types
InstanceRequest
Configuration for creating an instance (provider-agnostic):
ImageSpec
Provider-agnostic image specification:
ProviderInstance
Instance returned by the provider:
InstanceStatus
Possible instance states:
ProviderError
Structured errors with retry information:
Current Providers
DigitalOcean
Stable
digitalocean.rs
DIGITALOCEAN_TOKEN
Hetzner
Planned
-
HETZNER_TOKEN
AWS EC2
Planned
-
AWS_ACCESS_KEY_ID
Documentation
Creating a Provider - Complete step-by-step guide
Provider API Reference - Detailed documentation for each method
Testing Providers - Testing strategies with mocks
Contributing
Want to add support for a new provider? Follow these steps:
Open an issue to discuss the implementation
Read the Creating a Provider guide
Use the DigitalOcean implementation as reference
Ensure adequate test coverage
Update the documentation
Design Decisions
Consult the ADR to understand architectural decisions:
Last updated
Was this helpful?