alien_core/import/context.rs
1use crate::{ManagementConfig, Platform, ResourceEntry, Stack, StackSettings};
2use indexmap::IndexMap;
3
4/// Context passed to generator-side import emitters.
5#[derive(Debug, Clone, Copy)]
6pub struct EmitContext<'a> {
7 /// The source stack being rendered.
8 pub stack: &'a Stack,
9 /// The stack resource entry currently being emitted.
10 pub resource: &'a ResourceEntry,
11 /// Stable resource id for the current entry.
12 pub resource_id: &'a str,
13 /// Target platform for this emission pass.
14 pub platform: Platform,
15 /// User-selected stack settings for the setup artifact.
16 pub stack_settings: &'a StackSettings,
17 /// Stable names precomputed by the outer generator.
18 pub names: &'a IndexMap<String, String>,
19}
20
21impl<'a> EmitContext<'a> {
22 /// Returns the precomputed format-specific name for a resource id.
23 pub fn name_for(&self, resource_id: &str) -> Option<&'a str> {
24 self.names.get(resource_id).map(String::as_str)
25 }
26}
27
28/// Context passed to manager- or agent-side importers.
29#[derive(Debug, Clone, Copy)]
30pub struct ImportContext<'a> {
31 /// Resource id currently being imported.
32 pub resource_id: &'a str,
33 /// Target platform for this imported resource.
34 pub platform: Platform,
35 /// Region or location reported by the setup artifact.
36 pub region: &'a str,
37 /// Stack settings supplied by the setup artifact.
38 pub stack_settings: &'a StackSettings,
39 /// Platform-derived management configuration, when this setup created a
40 /// cross-account/cross-tenant management identity.
41 pub management_config: Option<&'a ManagementConfig>,
42 /// Original resource entry from the active stack.
43 pub resource: &'a ResourceEntry,
44}