เมทริกซ์การขยายเทมเพลต
เอกสารอ้างอิงการขยายเทมเพลต — เมทริกซ์ฉบับสมบูรณ์
Aggrega DSL รองรับtext/template ของ Go (โดย
1. ทรีลำดับเวลาของไปป์ไลน์ (เมื่อข้อมูลกลายเป็นรูปธรรม)
การ
Resolution — resolver and syntax validator ├── .parameters → Interpolated into the Aggregate's text; the merged map │ then stays readable to path templates only ├── .values → schema-validated against the Component's pillar schema, concrete ├── .infra → Release-merged into target components/features, concrete └── Catalog entities → Resolved (extends merged, pillar schemas composed, usesSchema extracted)
Topology construction ├── .context.instance_id → Node identity, written as a name (e.g., "data-layer-zdmain-db") └── .context.labels → From Catalog + label-transform mutations
Graph finalization ├── .context.annotations.release → Cascaded from boundary hierarchy ├── .context.annotations.catalog → From Component metadata.annotations ├── .context.annotations.aggregate → Cascaded from subsystem hierarchy └── feature_values_mapping → 5-Tier Onion Model normalized
Rendering begins. Provides evaluation — locals preamble, then provides ├── .context.rendered_name → Asked of each node's provider before the preamble; present only where │ that provider derives a name for the node's output ├── .locals (per node) → Block resolved in author order; an entry reads earlier siblings └── .provides (all nodes) → Self-contained templates evaluated (any order), reading .locals
Inject hydration — self-inject resolution └── component.inject → value: literals expanded, from: own provides resolved
Inject hydration — uses-inject resolution └── uses[].inject → from: target provides resolved
Inject mapping — injectMapping interception └── .context.inject → Fully populated pipe, intercepted by FeatureRecipe injectMappings
Base rendering └── Full template context → Everything available
The plugin pipeline — post-render mutation └── Full template context + .steps → Inter-step pipeline outputs available2. เมทริกซ์การขยายเทมเพลต
ทุก
| # | Location | เอนทิตี | ประเมิน | การ |
|---|---|---|---|---|
| 1 | {{ .parameters.X }} ใน | Aggregate | การ | .parameters เท่านั้น ข้อมูล |
| 2 | {{ .parameters.X }} ใน | Release | ไม่ | ไม่มี สตริง{{ .parameters.X }} ภายinfra: ในparameters: ไปparameters: แบบ$import: รวม |
| 3 | เทมเพลต directory / subDirectory | แนว | การ | .capability, .boundary_name, .parameters.X, .manifest.recipe_name, .parent_boundary.* และ .component_id (เฉพาะ subDirectory: — เทมเพลต directory: ปฏิเสธ |
| 4 | สตริง value: ของ inject ของ Component | ส่วน | การ | .values, .infra, .context.instance_id, .context.labels, .context.annotations.* (ทั้ง 3 กลุ่ม), .metadata.* (release_name, release_version, environment, aggregate_name) ต้อง.context.inject (วน.context.uses (ใช้ uses[].inject สำหรับvalue: '{{"{{"}} .metadata.release_name }}' — เพื่อ.parameters |
| 5 | สตริงsource (สตริงsource: ที่ | Recipe / FeatureRecipe | การ | สองversion, chart, ref และ module_subdir ของaggrega pull หา.values, .infra, .locals และoptional, capitalizedWords, index) และ.context รายการ .locals ที่.locals ใน.context.instance_id, .values, .infra, .locals (บล็อก.attachment_name เพิ่ม.context.instance_id ของ.context.rendered_name ซึ่ง.boundary.* และ.context.inject, .context.uses, .provides (ข้อlocals ของ |
| 6 | เทมเพลต provides ของ Recipe | Recipe | การ | .context.instance_id, .context.rendered_name (ชื่อ.values, .infra, .locals (บล็อก.context.inject, .context.uses (ข้าม.context.annotations.*, .context.labels, .context.metadata, .metadata.* (ผูก.attachment_name (ไม่มี.locals.<key> ที่ |
| 7 | valuesMapping ของ Recipe (แบบ$import: ของ$import: ของ | Recipe | การ | บริบท.values, .infra, .context.* (instance_id, rendered_name, labels, annotations, inject, uses), .locals, .provides, .features, .metadata การ.context.rendered_name ที่$import: จะ |
| 8 | injectMapping ของ FeatureRecipe | FeatureRecipe | การ | บริบท.values, .infra, .context.* (รวม.context.inject — ท่อ.context.uses) .context.used_by ว่าง.context.render_facts ไม่มี: การ.context.rendered_name คือexecutionScope ของ FeatureRecipe จะ.context.* ของ.features.<attachment>.provides กับ .locals ใน.boundary ซึ่ง |
| 9 | valuesMapping ของ FeatureRecipe (รวมworkload: และ artifacts: ใน | FeatureRecipe | การ | บริบท.attachment_name, .inject (รายการ inject: ของinject:), .context.render_facts — สิ่ง.context.used_by — ส่วนreadsCallerRenderFacts: true แต่ละ.context.uses มี.render_facts เมื่อ FeatureRecipe ตั้ง readsTargetRenderFacts: true .context.instance_id และ .context.rendered_name คือlocals: และ provides: ของ FeatureRecipe ด้วย — และ.context.rendered_name ที่.source คือ source: ที่ |
| 10 | บล็อก with: ของ | Recipe / FeatureRecipe | ไปป์ไลน์ | บริบท.steps (เอาต์พุต.context.used_by ว่าง.context.uses ที่.context.render_facts ซึ่ง |
| 11 | เนื้อหา workload: ของ Recipe (ทุก$import:) | Recipe | การ | บริบทreplicas, containers.<name>.image, containers.<name>.variables.<KEY>, containers.<name>.ports.<port>, services.<name>.ports.<port>, volumes.<name>.*, health.* — เป็น |
หมายเหตุsource (#5) ใช้provides ร่วม.context.inject และ .context.uses การ.context.inject และsource ของlocals ของ.provides ทั้งprovides เอง.locals กฎsource ของ FeatureRecipe ในlocals ของ
หมายเหตุreplicas: {{ .infra.replicas | default 1 }} ที่LOG_LEVEL: "{{ .values.log_level }}" ภายใน containers.app.variables ที่
ค่าreplicas: {{ .infra.replicas | default 1 }} ข้างreplicas” เข้าreplicas เป็น 0” — default ทำงานinfra.replicas: 0 อย่าง| default 1 จะreplicas: {{ optional .infra "replicas" 1 }} — optional ตรวจ1 เมื่อsprig-functions.md สำหรับ
3. การอ้างอิงที่ต้องห้ามและเหตุผล
| Location | การ | เหตุผล |
|---|---|---|
value: ของ inject ของ Component (#4) | .context.inject | ท่อ inject กำลังvalue: ของ self-inject อ่าน |
value: ของ inject ของ Component (#4) | .context.uses | การuses[].inject เทมเพลต value: ของ self-inject ของ |
provides ของ Recipe (#6) | .context.inject | เทมเพลต provides ถูก.values, .infra, .locals, .context.instance_id, .context.rendered_name) ท่อ inject จะ |
provides ของ Recipe (#6) | .attachment_name | รอบ provides ของ Recipe พื้น |
source (#5) | .provides | พื้นlocals ของprovides: อ่าน .locals ได้ เทมเพลต |
locals ของ Recipe (ส่วน | .provides | Locals หา.values / .infra โดยตรง — แล้วprovides จึง |
locals ของ Recipe (ส่วน | .context.rendered_name | locals ของ Recipe ใช้source ของ Recipe นั้น (#5) และsource เป็น.context.instance_id เป็น.context กำหนดprovides หรือ |
provides ของ Recipe (#6) | .context.uses | .context.uses อ้าง |
locals, provides, source ของ FeatureRecipe (#5) และ | .context.rendered_name | บน.context.instance_id ไว้.context กำหนด |
source (#5) | .context.inject | การ.context.inject ท่อ |
source (#5) | .context.uses | การ |
| พารามิเตอร์ (ทุก | พื้น | การ{{ .parameters.X }} ใน YAML ที่.parameters.X โดยตรง |
4. เส้นทางการหาค่า self-inject
การinject: ระดับ
- สตริง
value:ที่เป็น หากค่า ตาม ตัว อักษร: ค่า มี นิพจน์ เทมเพลต ของ Go คอมไพเลอร์ จะ ประเมิน ค่า นิพจน์ เหล่า นั้น ด้วย บริบท จาก แถว #4 ของ เมทริกซ์ ( .values,.infra,.context.instance_id,.metadata.*เป็นต้น) ที่เขียน แบบ หลีก อักขระ ตาม ที่ แถว #4 แสดง สตริง ธรรมดา ผ่าน ไป โดย ไม่ เปลี่ยนแปลง - การ
อ้างอิง from:: คอมไพเลอร์ค้นหา คีย์ ใน แมป providesของโหนด เอง ซึ่ง หา ค่า เสร็จ แล้ว ณ เวลา นั้น หาก ไม่มี คีย์ คอมไพเลอร์ จะ หยุด การ บิลด์ ด้วย ข้อ ผิด พลาด invalid-inject-key (คีย์ การ แทรก ไม่ ถูก ต้อง) - การ
ตรวจ ก่อนการ ชน กัน: ผสาน เข้า กับ ท่อ .context.injectคอมไพเลอร์ตรวจ สอบ ว่า ไม่มี คีย์ ใด ชน กับ คีย์ uses-inject ที่ ครึ่ง หลัง ของ ไฮเดรชัน ของ inject หา ค่า การ ชน กัน จะ หยุด การ บิลด์ ด้วย ข้อ ผิด พลาด duplicate-delivery-key (คีย์ การ ส่ง มอบ ซ้ำ)
สตริง.context.inject.env, .context.inject.file, .context.inject.arg (และinjectMapping) รัน ท่อ