Environment Management
Organize nodes by environment (development, staging, production) and switch contexts dynamically.
Use case: Managing the same services across multiple environments with environment-specific configurations.
Environment Structure
Section titled “Environment Structure”partition "database" { environment "development" { provider "main" { host = "localhost" port = 5432 username = "dev_user" password = sensitive("dev_password") } }
environment "staging" { provider "main" { host = "staging-db.internal" port = 5432 username = "staging_user" password = sensitive("staging_password") } }
environment "production" { provider "main" { host = "prod-db.internal" port = 5432 username = "prod_user" password = sensitive("prod_password") } }}Filtering by Environment
Section titled “Filtering by Environment”# List nodes in productionphp artisan huckle:list --environment=production
# List nodes in multiple environmentsphp artisan huckle:list --environment=staging --environment=productionuse Cline\Huckle\Facades\Huckle;
// Get all nodes for an environment$prodNodes = Huckle::forEnvironment('production');
// Export all production configsHuckle::exportContextToEnv([ 'environment' => 'production',]);Dynamic Environment Switching
Section titled “Dynamic Environment Switching”use Cline\Huckle\Facades\Huckle;
class DatabaseService{ public function getConfig(): array { $env = app()->environment(); $node = Huckle::get("database.{$env}.main");
return [ 'host' => $node->host, 'port' => $node->port, 'username' => $node->username, 'password' => $node->password->reveal(), ]; }}Comparing Environments
Section titled “Comparing Environments”# Compare production and stagingphp artisan huckle:diff production staging
# Output shows differences in:# - Node values# - Missing nodes# - Extra nodesEnvironment-Specific Tags
Section titled “Environment-Specific Tags”partition "api" { environment "production" { tags = ["prod", "critical", "monitored"]
provider "main" { # ... } }
environment "development" { tags = ["dev", "local"]
provider "main" { # ... } }}Filter by environment AND tag:
php artisan huckle:list --environment=production --tag=critical