#!/usr/bin/env nu # Pre-server-create hook for DigitalOcean # Validates credentials and prerequisites def main [context: string] { let ctx = ($context | from json) print "🔍 Validating DigitalOcean credentials..." # Check if API token is set if ($env.DO_API_TOKEN? | is-empty) { print "❌ DO_API_TOKEN environment variable not set" exit 1 } # Check if doctl is installed if (which doctl | length) == 0 { print "❌ doctl CLI not found. Install from: https://github.com/digitalocean/doctl" exit 1 } print "✅ DigitalOcean credentials and tools validated" # Output validation results { provider: "digitalocean" validation: "passed" checks: { api_token: true doctl_installed: true } } | to json }