alien_core/deployment/compute.rs
1//! Compute backend configuration (Horizon container orchestration).
2
3use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6/// Configuration for a single Horizon cluster.
7///
8/// Contains the cluster ID and management token needed to interact with
9/// the Horizon control plane API for container operations.
10#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
11#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
12#[serde(rename_all = "camelCase")]
13pub struct HorizonClusterConfig {
14 /// Cluster ID (deterministic: workspace/project/deployment/resourceid)
15 pub cluster_id: String,
16
17 /// Management token for API access (hm_...)
18 /// Used by alien-deployment controllers to create/update containers
19 pub management_token: String,
20 // Note: Machine token (hj_...) is NOT in DeploymentConfig
21 // It's added to environmentVariables snapshot as a built-in secret variable
22 // and synced to vault (Parameter Store/Secret Manager/Key Vault)
23}
24
25/// Horizon configuration for container orchestration.
26///
27/// Contains all the information needed for Alien to interact with Horizon
28/// clusters during deployment. Each ContainerCluster resource gets its own
29/// entry in the clusters map.
30#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
31#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
32#[serde(rename_all = "camelCase")]
33pub struct HorizonConfig {
34 /// Horizon API base URL (e.g., "https://horizon.alien.dev")
35 pub url: String,
36
37 /// Base URL for downloading the horizond binary, without arch suffix.
38 ///
39 /// Each cloud controller appends `/linux-{arch}/horizond` to construct the
40 /// final download URL used in VM startup scripts.
41 ///
42 /// Production example: "https://releases.alien.dev/horizond/v0.3.0"
43 /// Dev example (ngrok): "https://abc123.ngrok.io"
44 pub horizond_download_base_url: String,
45
46 /// ETag of the horizond binary fetched from the releases server -- used as a
47 /// change-detection signal only. nginx auto-generates ETags from mtime+size,
48 /// so every `cargo zigbuild` changes this value and triggers a rolling update.
49 ///
50 /// Optional: when absent (releases server unreachable), change detection
51 /// falls back to URL-only (sufficient for versioned production releases).
52 #[serde(default, skip_serializing_if = "Option::is_none")]
53 pub horizond_binary_hash: Option<String>,
54
55 /// Cluster configurations (one per ContainerCluster resource)
56 /// Key: ContainerCluster resource ID from stack
57 /// Value: Cluster ID and management token for that cluster
58 pub clusters: HashMap<String, HorizonClusterConfig>,
59}
60
61/// Compute backend for Container and Function resources.
62///
63/// Determines how compute workloads are orchestrated on cloud platforms.
64/// When None, the platform default is used (Horizon for cloud platforms).
65#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
66#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
67#[serde(tag = "type", rename_all = "camelCase")]
68pub enum ComputeBackend {
69 /// VMs with Horizon orchestration (default for cloud platforms)
70 Horizon(HorizonConfig),
71 // Future backends:
72 // /// Deploy to existing Kubernetes cluster (EKS/GKE/AKS)
73 // Kubernetes(KubernetesCredentials),
74 // /// AWS ECS Fargate (serverless containers)
75 // EcsFargate,
76}