Nested Hierarchy Credentials
Organize credentials in deeply nested hierarchies for complex multi-tenant or multi-region setups.
Use case: Managing credentials across multiple countries, tenants, environments, and service providers.
Hierarchy Structure
Section titled “Hierarchy Structure”partition "EU" { environment "production" { tags = ["eu", "prod", "gdpr"]
provider "stripe" { country "DE" { api_key = sensitive("pk_live_de_xxx") api_secret = sensitive("sk_live_de_xxx") webhook_secret = sensitive("whsec_de_xxx") }
country "FR" { api_key = sensitive("pk_live_fr_xxx") api_secret = sensitive("sk_live_fr_xxx") webhook_secret = sensitive("whsec_fr_xxx") }
country "SE" { api_key = sensitive("pk_live_se_xxx") api_secret = sensitive("sk_live_se_xxx") webhook_secret = sensitive("whsec_se_xxx") } }
provider "database" { country "DE" { host = "db-de.eu.prod.internal" port = 5432 username = "app_de" password = sensitive("de_prod_secret") }
country "FR" { host = "db-fr.eu.prod.internal" port = 5432 username = "app_fr" password = sensitive("fr_prod_secret") } } }}Accessing Nested Nodes
Section titled “Accessing Nested Nodes”use Cline\Huckle\Facades\Huckle;
// Full path access$deStripe = Huckle::get('EU.production.stripe.DE');$frDb = Huckle::get('EU.production.database.FR');
// Access fields$apiKey = $deStripe->api_key->reveal(); // 'pk_live_de_xxx'$host = $frDb->host; // 'db-fr.eu.prod.internal'Filtering by Country
Section titled “Filtering by Country”# List all nodes for Germanyphp artisan huckle:lint --table --country=DE
# List Stripe nodes for Sweden in productionphp artisan huckle:lint --table --provider=stripe --country=SE --environment=productionContext-Based Export
Section titled “Context-Based Export”use Cline\Huckle\Facades\Huckle;
// Export all German production configsHuckle::exportContextToEnv([ 'partition' => 'EU', 'environment' => 'production', 'country' => 'DE',]);
// Export all Stripe configs across EUHuckle::exportContextToEnv([ 'partition' => 'EU', 'provider' => 'stripe',]);Multi-Region Setup
Section titled “Multi-Region Setup”# US regionpartition "US" { environment "production" { provider "stripe" { country "US" { api_key = sensitive("pk_live_us_xxx") } } }}
# EU regionpartition "EU" { environment "production" { provider "stripe" { country "DE" { api_key = sensitive("pk_live_de_xxx") } country "FR" { api_key = sensitive("pk_live_fr_xxx") } } }}
# APAC regionpartition "APAC" { environment "production" { provider "stripe" { country "JP" { api_key = sensitive("pk_live_jp_xxx") } country "AU" { api_key = sensitive("pk_live_au_xxx") } } }}Dynamic Country Selection
Section titled “Dynamic Country Selection”use Cline\Huckle\Facades\Huckle;
class PaymentService{ public function getStripeKey(string $region, string $country): string { $node = Huckle::get("{$region}.production.stripe.{$country}");
return $node->api_key->reveal(); }}
// Usage$service = new PaymentService();$key = $service->getStripeKey('EU', 'DE'); // German Stripe key$key = $service->getStripeKey('US', 'US'); // US Stripe keyComparing Countries
Section titled “Comparing Countries”# Compare German and French configsphp artisan huckle:diff EU.production.stripe.DE EU.production.stripe.FR