Skip to main content

alien_core/deployment/
config.rs

1//! Deployment configuration and OTLP observability settings.
2
3use crate::{ExternalBindings, ManagementConfig, StackSettings};
4use bon::Builder;
5use serde::{Deserialize, Serialize};
6use std::collections::HashMap;
7
8use super::{
9    is_false, ComputeBackend, DeletionPolicy, DomainMetadata, EnvironmentVariableType,
10    EnvironmentVariablesSnapshot,
11};
12
13/// Deployment configuration
14///
15/// Configuration for how to perform the deployment.
16/// A signed release and the chain that verifies it, carried to enforcers.
17#[derive(Debug, Clone, PartialEq, Eq)]
18pub struct ReleaseStatements {
19    /// The `release/v2` statement for this deployment's platform.
20    pub release: crate::SignedStatement,
21    /// The project's signer list chain, oldest first.
22    pub signer_lists: Vec<crate::SignedStatement>,
23}
24
25/// Note: Credentials (ClientConfig) are passed separately to step() function.
26#[derive(Debug, Clone, Serialize, Deserialize, Builder)]
27#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
28#[serde(rename_all = "camelCase")]
29pub struct DeploymentConfig {
30    /// This invocation is an explicit setup run using the installer's credentials.
31    /// Not serialized: a release or stored configuration cannot request an identity refresh.
32    #[serde(skip)]
33    #[cfg_attr(feature = "openapi", schema(ignore))]
34    #[builder(default)]
35    pub setup_run: bool,
36    /// Identifies this setup run, set together with `setup_run`. Every setup run gets a new
37    /// one, so a controller can tell a result recorded earlier in this run from one recorded in
38    /// an earlier run.
39    #[serde(skip)]
40    #[cfg_attr(feature = "openapi", schema(ignore))]
41    pub setup_run_id: Option<String>,
42    /// The target release's signed statement and the signer list chain, for
43    /// controllers that hand them to the deployment's enforcers unchanged.
44    /// Set by the deployment runner from the release being deployed; not
45    /// serialized, so stored configuration can't supply them.
46    #[serde(skip)]
47    #[cfg_attr(feature = "openapi", schema(ignore))]
48    pub release_statements: Option<ReleaseStatements>,
49    /// A protected deployment's newest signed `config/v1`, which controllers hand to the
50    /// enforcers with the release. The enforcers verify it against the install's own trust and
51    /// refuse one older than what they accepted, so it is carried as received.
52    #[serde(default, skip_serializing_if = "Option::is_none")]
53    pub signed_config: Option<crate::SignedStatement>,
54    /// Site registry (`host[/path]`) every Kubernetes workload image is pulled from.
55    /// Set by the Operator from the installation's `global.imageRegistry`; never part of a
56    /// release, so a release cannot redirect where an installation pulls from.
57    #[serde(skip)]
58    #[cfg_attr(feature = "openapi", schema(ignore))]
59    pub image_registry: Option<String>,
60    /// Names of the installation's image pull Secrets (the chart's `runtime.imagePullSecrets`).
61    /// Set by the Operator; listed on every workload pod so a private mirror can be pulled from.
62    #[serde(skip)]
63    #[cfg_attr(feature = "openapi", schema(ignore))]
64    #[builder(default)]
65    pub image_pull_secrets: Vec<String>,
66    /// Human-readable deployment name for cloud console metadata.
67    ///
68    /// This is separate from the physical resource prefix in StackState. It is
69    /// used only for display text such as IAM role descriptions, service
70    /// account descriptions, and custom role titles.
71    #[serde(default, skip_serializing_if = "Option::is_none")]
72    pub deployment_name: Option<String>,
73    /// User-customizable deployment settings (network, deployment model, approvals).
74    /// Provided by customer via CloudFormation, Terraform, CLI, or Helm.
75    #[serde(default)]
76    pub stack_settings: StackSettings,
77    /// Platform service account/role that will manage the infrastructure remotely.
78    /// Derived from Manager's ServiceAccount, not user-specified.
79    #[serde(skip_serializing_if = "Option::is_none")]
80    pub management_config: Option<ManagementConfig>,
81    /// Registered installation identity for target federation setup.
82    /// Callers derive this from registration, separately from display metadata.
83    #[serde(default, skip_serializing_if = "Option::is_none")]
84    pub gcp_federation_scope: Option<crate::GcpFederationScope>,
85    /// Environment variables snapshot
86    pub environment_variables: EnvironmentVariablesSnapshot,
87    /// Deployer-provided stack input values, keyed by input id. A resource
88    /// gated with `.enabled(input)` and a Live lifecycle follows these
89    /// values; a missing key falls back to the input's declared boolean
90    /// default. Suppliers must not place secret-kind input values here:
91    /// this map serializes and debug-prints unredacted.
92    #[serde(default, skip_serializing_if = "HashMap::is_empty")]
93    #[builder(default)]
94    pub input_values: HashMap<String, serde_json::Value>,
95    /// Values the manager holds for this deployment instead of the sender.
96    /// For each slot the sender gives the kind and a keyed digest, never the
97    /// value. The manager loads the value from its own store, refuses to run
98    /// when a digest differs, and merges the value into `environment_variables`
99    /// or `input_values` before the deployment steps.
100    #[serde(default, skip_serializing_if = "Vec::is_empty")]
101    #[builder(default)]
102    pub value_slots: Vec<ValueSlotRef>,
103    /// IDs of applicable secret inputs stored for this exact deployment target.
104    /// Trusted presence metadata only: never values, gate answers, or authority.
105    /// Absent on legacy targets; an explicit empty list means no stored secrets.
106    #[serde(default, skip_serializing_if = "Option::is_none")]
107    #[cfg_attr(feature = "openapi", schema(nullable = false))]
108    pub stored_secret_input_ids: Option<Vec<String>>,
109    /// Allow frozen resource changes during updates
110    /// When true, skips the frozen resources compatibility check.
111    /// This requires running with elevated cloud credentials.
112    #[serde(default, skip_serializing_if = "is_false")]
113    pub allow_frozen_changes: bool,
114    /// Compute backend for Container and Worker resources.
115    /// When None, the platform default is used for cloud platforms.
116    /// Contains cluster IDs and management tokens for container orchestration.
117    /// Worker runtime credentials are provided through cloud identity and vault-backed secrets.
118    #[serde(skip_serializing_if = "Option::is_none")]
119    pub compute_backend: Option<ComputeBackend>,
120    /// External bindings for pre-existing services.
121    /// Required for Kubernetes platform (all infrastructure resources).
122    /// Optional for cloud platforms (override specific resources).
123    #[serde(default)]
124    pub external_bindings: ExternalBindings,
125    /// Cloud platform that owns imported base infrastructure for a Kubernetes
126    /// runtime deployment.
127    #[serde(default, skip_serializing_if = "Option::is_none")]
128    pub base_platform: Option<crate::Platform>,
129    /// DNS-style label domain used for Kubernetes resource ownership labels.
130    ///
131    /// Defaults to `alien.dev` when absent. Whitelabeled Operator builds set this
132    /// so generated workloads and optional log collectors share the same label
133    /// namespace.
134    #[serde(default, skip_serializing_if = "Option::is_none")]
135    pub label_domain: Option<String>,
136    /// Kubernetes label selector that narrows which raw resources the observe
137    /// pass reports (e.g. `app.kubernetes.io/part-of=my-app`). `None` observes
138    /// everything in the namespace. Ignored by cloud observers.
139    #[serde(default, skip_serializing_if = "Option::is_none")]
140    pub observe_label_selector: Option<String>,
141    /// When true the observe pass reports raw resources across every namespace
142    /// (cluster scope); otherwise it stays within the operator's own namespace.
143    /// The label selector, if any, still filters within whichever scope applies.
144    /// Ignored by cloud observers.
145    #[serde(default)]
146    #[builder(default)]
147    pub observe_all_namespaces: bool,
148    /// Public endpoint URLs for exposed resources (optional override).
149    ///
150    /// Use this only when a caller already knows the public URL. Managed public
151    /// endpoint flows should prefer `domain_metadata` plus controller-reported
152    /// load balancer outputs so DNS, certificate renewal, and route readiness
153    /// stay tied to the resource state.
154    ///
155    /// If not set, platforms determine public endpoint URLs from other sources:
156    /// - Managed DNS/TLS flows: `domain_metadata` FQDN or load balancer DNS
157    /// - Local: `http://localhost:{allocated_port}`
158    /// - Custom or disabled exposure: no public endpoint URL unless a controller reports one
159    ///
160    /// Outer key: resource ID. Inner key: endpoint name. Value: public URL.
161    #[serde(skip_serializing_if = "Option::is_none")]
162    pub public_endpoints: Option<HashMap<String, HashMap<String, String>>>,
163    /// Domain metadata for auto-managed public resources.
164    ///
165    /// Contains generated hostnames, DNS record state, certificate material,
166    /// and renewal markers for platforms that use managed public endpoints.
167    /// Kubernetes uses this only when its exposure mode is `generated`; BYO and
168    /// disabled Kubernetes exposure do not receive managed domain metadata.
169    #[serde(skip_serializing_if = "Option::is_none")]
170    pub domain_metadata: Option<DomainMetadata>,
171    /// OTLP observability configuration for log export (optional).
172    ///
173    /// When set, worker runtimes export captured application logs through this
174    /// endpoint. Container orchestrators may use it for their node-level log
175    /// collectors, but app container configs must not receive the auth header.
176    #[serde(skip_serializing_if = "Option::is_none")]
177    pub monitoring: Option<OtlpConfig>,
178    /// Manager base URL (e.g., "https://manager.alien.dev").
179    ///
180    /// The manager IS the container registry — its `/v2/` endpoint serves as
181    /// the OCI Distribution API. Controllers derive the proxy host from this
182    /// to configure pull auth (RegistryCredentials, imagePullSecrets).
183    ///
184    /// When None (e.g., `alien dev`), controllers use image URIs as-is.
185    #[serde(default, skip_serializing_if = "Option::is_none")]
186    pub manager_url: Option<String>,
187    /// Exact audience for bounded runtime identity exchange. When present,
188    /// runtimes must use identity exchange and cannot fall back to stored tokens.
189    /// Absence preserves the legacy mode for installs awaiting migration.
190    #[serde(default, skip_serializing_if = "Option::is_none")]
191    pub runtime_identity_audience: Option<String>,
192    /// Deployment token for pull authentication with the manager's registry.
193    ///
194    /// Used by controllers to configure registry credentials so cloud platforms
195    /// and K8s can pull images from the manager's `/v2/` endpoint.
196    #[serde(default, skip_serializing_if = "Option::is_none")]
197    pub deployment_token: Option<String>,
198    /// Native image registry host+prefix for platforms that require it.
199    ///
200    /// Lambda (ECR) and Cloud Run (GAR) require native registry URIs. Other
201    /// runtimes, including Azure Container Apps, pull through the manager's
202    /// registry proxy.
203    ///
204    /// Derived by the manager from the artifact registry binding:
205    /// - ECR: `{account_id}.dkr.ecr.{region}.amazonaws.com/{repository_prefix}`
206    /// - GAR: `{region}-docker.pkg.dev/{project_id}/{repository_name}`
207    #[serde(default, skip_serializing_if = "Option::is_none")]
208    pub native_image_host: Option<String>,
209    /// Operator requests to replace a replica's persistent volume with a new
210    /// volume made from a snapshot. A container controller performs each
211    /// request once, identified by its `request_id`, and reports it in
212    /// `ContainerOutputs.volumes`. Only a volume that a controller reports in
213    /// `ContainerOutputs.volumes` can be the target of a request.
214    #[serde(default, skip_serializing_if = "Vec::is_empty")]
215    #[builder(default)]
216    pub volume_restores: Vec<VolumeRestoreRequest>,
217    /// How the deletion this run performs treats data. Under `Erase`, controllers also
218    /// delete what they would otherwise keep after the resource is gone, such as a
219    /// container's final volume snapshots.
220    /// Not serialized: deletion sets it from the policy persisted in runtime metadata,
221    /// so a stored configuration cannot request an erase.
222    #[serde(skip)]
223    #[cfg_attr(feature = "openapi", schema(ignore))]
224    #[builder(default)]
225    pub deletion_policy: DeletionPolicy,
226}
227
228/// A value the manager holds, named by slot, with the digest the sender expects.
229///
230/// The slot is `env:NAME` for an environment variable, `input:ID` for a stack
231/// input, or `cenv.<container>.<NAME>` for a dynamic container's variable. An
232/// input's stored value is the JSON text of the input value.
233#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
234#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
235#[serde(rename_all = "camelCase")]
236pub struct ValueSlotRef {
237    /// `env:NAME`, `input:ID` or `cenv.<container>.<NAME>`.
238    pub slot: String,
239    /// Whether the value is a secret. The manager checks it against the stored kind.
240    pub kind: EnvironmentVariableType,
241    /// Keyed digest of the value, as lowercase hex.
242    pub digest: String,
243    /// Variable name, repeated for display. The slot decides the name.
244    #[serde(default, skip_serializing_if = "Option::is_none")]
245    pub env_name: Option<String>,
246    /// Target resource patterns for an environment variable. `None` means all resources.
247    #[serde(default, skip_serializing_if = "Option::is_none")]
248    pub targets: Option<Vec<String>>,
249}
250
251/// Replace one replica's persistent volume with a new volume made from a snapshot.
252///
253/// The controller stops the replica, snapshots the volume it is about to
254/// replace (so the restore can be undone), creates the new volume in the same
255/// zone, starts the replica on it, and deletes the replaced volume.
256#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
257#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
258#[serde(rename_all = "camelCase")]
259pub struct VolumeRestoreRequest {
260    /// Unique ID of this request. A controller performs each request once.
261    pub request_id: String,
262    /// ID of the container resource that owns the volume
263    pub resource_id: String,
264    /// Replica ordinal whose volume is replaced
265    pub ordinal: u32,
266    /// Cloud ID of the snapshot to restore: an EBS snapshot ID, a Compute
267    /// Engine snapshot name, or an Azure snapshot resource ID
268    pub snapshot_id: String,
269}
270
271/// Resource-attribute key marking OTLP telemetry as Alien system-component
272/// output (infrastructure daemons and internal runtimes) rather than user
273/// workload. Log consumers — the CLI log viewer and the dashboard — hide
274/// telemetry carrying this attribute by default. The value is the string
275/// `"true"`.
276///
277/// System components set this on their own telemetry's resource attributes so
278/// consumers can filter generically, without enumerating component names.
279pub const ALIEN_SYSTEM_RESOURCE_ATTRIBUTE: &str = "alien.system";
280
281/// Prefix that marks one captured output line of a Worker as Alien system output.
282///
283/// The worker runtime strips it from the line and records
284/// [`ALIEN_SYSTEM_RESOURCE_ATTRIBUTE`] on the exported record. Alien components that run as a
285/// Worker's application write it at the start of every line they print. Like the attribute, it
286/// only hides a line by default; it grants nothing.
287pub const ALIEN_SYSTEM_LOG_LINE_PREFIX: &str = "\u{1e}ALIEN_SYSTEM\u{1f}";
288
289/// OTLP log export configuration for a deployment.
290///
291/// When set, injected compute runtimes export captured application logs
292/// through the given endpoint via OTLP/HTTP; which resources are injected
293/// is platform-dependent. Workers read auth headers from a runtime-only
294/// secret. Runtime-less Containers and Daemons receive standard OTEL auth
295/// variables only at the final hosting boundary: Local passes them directly
296/// to the process and Kubernetes projects them from a per-workload Secret.
297#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
298#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
299#[serde(rename_all = "camelCase")]
300pub struct OtlpConfig {
301    /// Full OTLP logs endpoint URL.
302    /// Example: "https://<manager-host>/v1/logs"
303    pub logs_endpoint: String,
304    /// Auth header value in "key=value,..." format.
305    /// Example: "authorization=Bearer <write-token>"
306    pub logs_auth_header: String,
307    /// Full OTLP metrics endpoint URL (optional).
308    /// When set, the worker runtime exports its own VM/container orchestration metrics here.
309    /// Example: "https://api.axiom.co/v1/metrics"
310    #[serde(skip_serializing_if = "Option::is_none")]
311    pub metrics_endpoint: Option<String>,
312    /// Auth header value for the metrics endpoint in "key=value,..." format (optional).
313    ///
314    /// When absent, `logs_auth_header` is reused for metrics -- suitable when the same
315    /// credential covers both signals. When present (e.g. Axiom with separate datasets),
316    /// this value is used exclusively for metrics.
317    ///
318    /// Example: "authorization=Bearer <token>,x-axiom-dataset=<metrics-dataset>"
319    #[serde(skip_serializing_if = "Option::is_none")]
320    pub metrics_auth_header: Option<String>,
321    /// Resource attributes attached to every OTLP signal emitted for this deployment.
322    ///
323    /// Platform managers use this for stable identity such as `alien.workspace_id`,
324    /// `alien.project_id`, `alien.deployment_group_id`, and `alien.deployment_id`.
325    /// Runtime-specific resource attributes such as `service.name` remain owned by
326    /// the runtime/exporter.
327    #[serde(default, skip_serializing_if = "HashMap::is_empty")]
328    pub resource_attributes: HashMap<String, String>,
329}
330
331#[cfg(test)]
332mod input_values_tests {
333    use super::*;
334
335    /// Older actors serialize configs without the field; it must deserialize
336    /// to an empty map, and an empty map must not serialize at all.
337    #[test]
338    fn input_values_default_to_empty_and_stay_off_the_wire() {
339        let json = serde_json::json!({
340            "stackSettings": serde_json::to_value(crate::StackSettings::default()).unwrap(),
341            "environmentVariables": {
342                "variables": [],
343                "hash": "hash",
344                "createdAt": "2026-01-01T00:00:00Z",
345            },
346            "externalBindings": {},
347        });
348        let config: DeploymentConfig =
349            serde_json::from_value(json).expect("old shape deserializes");
350        assert!(config.input_values.is_empty());
351        assert!(config.stored_secret_input_ids.is_none());
352
353        let round = serde_json::to_value(&config).expect("serializes");
354        assert!(round.get("storedSecretInputIds").is_none());
355        assert!(
356            round.get("inputValues").is_none(),
357            "empty map must not serialize"
358        );
359    }
360    #[test]
361    fn stored_secret_presence_roundtrips_without_values_or_gate_answers() {
362        let mut config = DeploymentConfig::builder()
363            .stack_settings(StackSettings::default())
364            .environment_variables(EnvironmentVariablesSnapshot {
365                variables: vec![],
366                hash: String::new(),
367                created_at: String::new(),
368            })
369            .allow_frozen_changes(false)
370            .external_bindings(ExternalBindings::default())
371            .build();
372        assert!(config.stored_secret_input_ids.is_none());
373        config.stored_secret_input_ids = Some(Vec::new());
374        let empty = serde_json::to_value(&config).unwrap();
375        assert_eq!(empty["storedSecretInputIds"], serde_json::json!([]));
376        assert_eq!(
377            serde_json::from_value::<DeploymentConfig>(empty)
378                .unwrap()
379                .stored_secret_input_ids,
380            Some(Vec::new())
381        );
382        config.stored_secret_input_ids =
383            Some(vec!["apiKey".to_string(), "enableFeature".to_string()]);
384        let wire = serde_json::to_value(&config).unwrap();
385        assert_eq!(
386            wire["storedSecretInputIds"],
387            serde_json::json!(["apiKey", "enableFeature"])
388        );
389        assert!(wire.get("inputValues").is_none());
390        let decoded: DeploymentConfig = serde_json::from_value(wire.clone()).unwrap();
391        assert_eq!(
392            decoded.stored_secret_input_ids,
393            config.stored_secret_input_ids
394        );
395        assert_eq!(serde_json::to_value(decoded.clone()).unwrap(), wire);
396        assert!(decoded.input_values.is_empty());
397        for default in [false, true] {
398            let input: crate::StackInputDefinition = serde_json::from_value(serde_json::json!({
399                "id": "enableFeature", "kind": "boolean", "providedBy": ["deployer"],
400                "required": false, "label": "Enable feature", "description": "", "default": crate::StackInputDefaultValue::Boolean(default)
401            }))
402            .unwrap();
403            assert_eq!(
404                crate::gate_resolves_true(
405                    &[input],
406                    "enableFeature",
407                    &decoded.input_values,
408                    "worker",
409                    crate::Platform::Aws
410                )
411                .unwrap(),
412                default
413            );
414        }
415        assert!(crate::gate_resolves_true(
416            &[],
417            "enableFeature",
418            &decoded.input_values,
419            "worker",
420            crate::Platform::Aws
421        )
422        .is_err());
423    }
424
425    fn deployment_config_with_cluster(
426        cluster_image: Option<serde_json::Value>,
427    ) -> serde_json::Value {
428        let config = DeploymentConfig::builder()
429            .stack_settings(StackSettings::default())
430            .environment_variables(EnvironmentVariablesSnapshot {
431                variables: vec![],
432                hash: String::new(),
433                created_at: String::new(),
434            })
435            .allow_frozen_changes(false)
436            .external_bindings(ExternalBindings::default())
437            .compute_backend(crate::ComputeBackend::Horizon(crate::HorizonConfig {
438                url: "https://horizon.example.com".to_string(),
439                horizon_machine_image: None,
440                clusters: HashMap::from([(
441                    "compute".to_string(),
442                    crate::HorizonClusterConfig {
443                        machine_url: None,
444                        cluster_id: "cluster-1".to_string(),
445                        management_token: "hm_test".to_string(),
446                        runtime_identity: None,
447                        horizon_machine_image: cluster_image
448                            .map(|image| serde_json::from_value(image).unwrap()),
449                    },
450                )]),
451            }))
452            .build();
453        serde_json::to_value(&config).unwrap()
454    }
455
456    fn machine_image(version: &str) -> serde_json::Value {
457        serde_json::json!({
458            "channel": "stable",
459            "machineImageVersion": version,
460            "horizondVersion": version,
461            "gitSha": "abc123",
462            "createdAt": "2026-01-01T00:00:00Z",
463            "baseImage": { "name": "linux", "version": "1" },
464            "horizondArtifacts": {}
465        })
466    }
467
468    /// A deployment config written before clusters could carry a machine image, as managers
469    /// receive and store it, reads back with no cluster image.
470    #[test]
471    fn deployment_config_without_cluster_machine_image_reads_as_before() {
472        let wire = deployment_config_with_cluster(None);
473        let cluster = &wire["computeBackend"]["clusters"]["compute"];
474        assert_eq!(
475            cluster,
476            &serde_json::json!({ "clusterId": "cluster-1", "managementToken": "hm_test" })
477        );
478
479        let config: DeploymentConfig = serde_json::from_value(wire).unwrap();
480        let Some(crate::ComputeBackend::Horizon(horizon)) = config.compute_backend else {
481            panic!("the Horizon backend reads back");
482        };
483        assert_eq!(horizon.clusters["compute"].horizon_machine_image, None);
484    }
485
486    /// The types on the path from the deployment config to a cluster as they were before the
487    /// cluster machine image existed: none of them rejects unknown fields.
488    #[derive(Debug, Deserialize)]
489    #[serde(rename_all = "camelCase")]
490    struct PreviousDeploymentConfig {
491        compute_backend: Option<PreviousComputeBackend>,
492    }
493
494    #[derive(Debug, Deserialize)]
495    #[serde(tag = "type", rename_all = "camelCase")]
496    enum PreviousComputeBackend {
497        Horizon(PreviousHorizonConfig),
498    }
499
500    #[derive(Debug, Deserialize)]
501    #[serde(rename_all = "camelCase")]
502    struct PreviousHorizonConfig {
503        clusters: HashMap<String, PreviousHorizonClusterConfig>,
504    }
505
506    #[derive(Debug, Deserialize, PartialEq)]
507    #[serde(rename_all = "camelCase")]
508    struct PreviousHorizonClusterConfig {
509        cluster_id: String,
510        management_token: String,
511    }
512
513    /// A manager built before the field reads a deployment config that sets it and ignores it.
514    #[test]
515    fn deployment_config_with_cluster_machine_image_reads_in_older_readers() {
516        let wire = deployment_config_with_cluster(Some(machine_image("1")));
517        assert!(wire["computeBackend"]["clusters"]["compute"]["horizonMachineImage"].is_object());
518
519        let previous: PreviousDeploymentConfig = serde_json::from_value(wire.clone())
520            .expect("an older reader must accept a cluster that carries its own image");
521        let Some(PreviousComputeBackend::Horizon(horizon)) = previous.compute_backend else {
522            panic!("the Horizon backend reads back");
523        };
524        assert_eq!(
525            horizon.clusters["compute"],
526            PreviousHorizonClusterConfig {
527                cluster_id: "cluster-1".to_string(),
528                management_token: "hm_test".to_string(),
529            }
530        );
531
532        let current: DeploymentConfig = serde_json::from_value(wire).unwrap();
533        let Some(crate::ComputeBackend::Horizon(horizon)) = current.compute_backend else {
534            panic!("the Horizon backend reads back");
535        };
536        assert_eq!(
537            horizon
538                .machine_image_for("compute")
539                .map(|image| image.machine_image_version.as_str()),
540            Some("1")
541        );
542    }
543}
544
545impl DeploymentConfig {
546    /// The reference a workload image is pulled from: the release's reference, moved to the
547    /// installation's site registry when one is configured.
548    pub fn workload_image(&self, image: &str) -> String {
549        match self.image_registry.as_deref().filter(|r| !r.is_empty()) {
550            Some(registry) => crate::image_rewrite::rewrite_to_site_registry(image, registry),
551            None => image.to_string(),
552        }
553    }
554}