provisioning/.provisioning/extensions/providers/digitalocean/hooks/validate-credentials.nu
2025-09-22 23:11:41 +01:00

34 lines
840 B
Plaintext
Executable File

#!/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
}