#!/usr/bin/env herodo
// Pre-flight check: Ensure Kubernetes cluster is accessible
try {
    if !run("kubectl cluster-info").execute().success {
        print("SKIPPED: Kubernetes cluster is not accessible");
        exit(0);
    }
} catch(e) {
    print("SKIPPED: Kubernetes cluster is not accessible: " + e);
    exit(0);
}


let k = kubernetes();

print("Creating namespace 'development' for developer machines...");
let ns = k.namespace("development");

//all properties
let dev = ns.development_machine("mydev")
    .namespace("development")
    .image("ubuntu:24.04")
    .env("ENV", "production")                           // Single env var
    // .env_from_configmap("app-config")                  // ConfigMap env vars
    // .env_from_secret("app-secrets")                    // Secret env vars
    .label("app", "myapp")                             // Labels
    .port(8080)                                        // Expose ports
    .cpu(1000, 20000)                                   // Request, limit in millicores
    .memory(1024, 8000)                                // Request, limit in MB
    // .readiness_http("/health", 8080)                   // HTTP readiness probe
    // .liveness_http("/health", 8080)                    // HTTP liveness probe
    //     .initial_delay(10)
    //     .period(5)
    //     .failure_threshold(3)
    // .readiness_tcp(3306)                               // TCP readiness probe
    // .liveness_tcp(3306)                                // TCP liveness probe
    // .restart("always")                                 // Restart policy
    .deploy();                                        // Auto-enables SSH!

print(dev);

// let dev1 = ns.development_machine("mydev")
// let ssh_key = dev1.get_ssh_key();
// println("SSH Key: " + ssh_key);

// // Get pod details
// print("\n📋 Development Machine Details:");
// print("   - Name: " + dev1.get_name());
// print("   - Namespace: " + dev1.get_namespace());
// print("   - Image: " + dev1.get_image());
// print("   - CPU: " + dev1.get_cpu());
// print("   - Memory: " + dev1.get_memory());
