นโยบายที่จัดรูปป้ายกำกับ: ระดับการสนับสนุนต่อสภาพแวดล้อม และคำตัดสินที่อ่านระดับนั้น
ปลั๊กอิน
- สาม
รายการ ที่ บทบาท label-transformซึ่งจัด รูป ป้าย กำกับ บน โหนด ของ บิลด์: นโยบาย Rego ที่ อ่าน สภาพ แวดล้อม ของ Release และ ปลั๊กอิน ติด แท็ก สอง ตัว ที่ คอมไพล์ รวม ไว้ ใน CLI คือ label-injectorและselector-tagger - หนึ่ง
รายการ ที่ บทบาท ir-verdictคือนโยบาย Rego เหนือ กราฟ บิลด์ ที่ หยุด บิลด์ สำหรับ production ซึ่ง มี โหนด ที่ ไม่มี ระดับ การ สนับสนุน
Releases สองstaging และ production และcheck.sh สร้าง
สิ่งที่ตัวอย่างนี้บิลด์
| อินสแตนซ์ | Component ของ | สิ่ง |
|---|---|---|
db | core/datastore/mariadb | ฐาน |
cache | core/datastore/redis | แคช |
web | core/devtool/adminer | UI ดูแลdb |
ทั้งdist/compose/docker-compose.yaml Aggregate และ Releases ทั้ง
การแนบทั้งสี่
การ.aggrega-config.yaml ของplugins.governance ดัง
| ปลั๊กอิน | บทบาท | สิ่ง | |
|---|---|---|---|
| 1 | governance/rego:0.9.0 พร้อม policies/support-tier.rego | label-transform | ops.example.com/environment บนops.example.com/support-tier บน |
| 2 | governance/label-injector:0.9.0 | label-transform | ops.example.com/owner บนbackup.example.com/schedule บนdatastore |
| 3 | governance/selector-tagger:0.9.0 | label-transform | tag จากpolicies/tags.yaml |
| 4 | governance/rego:0.9.0 พร้อม policies/production-support.rego | ir-verdict | ไม่มี: หยุด |
0.9.0 คือaggrega build --release release-production.yaml --auto-pull --detail แสดง
[… omitted: the line counting what the pull resolved, and the rows for the Components, the Recipes, the Feature and the FeatureRecipes, each read from the registry] in-binary Plugin governance/label-injector ← governance/label-injector:0.9.0 in-binary Plugin governance/label-injector:0.9.0 ← .aggrega-config.yaml.plugins.governance in-binary Plugin governance/rego ← governance/rego:0.9.0 in-binary Plugin governance/rego:0.9.0 ← .aggrega-config.yaml.plugins.governance in-binary Plugin governance/selector-tagger ← governance/selector-tagger:0.9.0 in-binary Plugin governance/selector-tagger:0.9.0 ← .aggrega-config.yaml.plugins.governance[… omitted: the rows for this workspace's Aggregate and Manifest, the pull's summary, a lint notice about core/secret-value, and the build's summary]การ
สิ่งที่นโยบาย label-transform อ่าน
นโยบายlabel-transform อ่านinput.graph.nodes โดย
component— Component ที่โหนด สร้าง อินสแตนซ์ เช่น core/datastore/mariadbresolved_version— เวอร์ชันที่ Component หา ค่า ได้ labels— ป้ายกำกับ ที่ โหนด มี เมื่อ นโยบาย รัน: ป้าย กำกับ ของ Component เอง และ ป้าย กำกับ ที่ การ แปลง ก่อน หน้า เขียน values— ค่าที่อินสแตนซ์ ของ โหนด ประกาศ ใน Aggregate ไม่มี เมื่อ ไม่ ได้ ประกาศ ที่ นี่ มี เพียง dbที่ประกาศ คือ database: appdb
นโยบายinput.compilation_context คือ release_name และ environment นั่น
นโยบายir-verdict อ่านinput.graph.spec.nodes กฎir-verdict ไม่มี compilation_context คำops.example.com/environment บน
หาก
aggrega build --release release-production.yaml --dry-run --policy-input payloadsเขียนpayloads/ หนึ่งlabel-transform.1.rego.json, label-transform.2.label-injector.json, label-transform.3.selector-tagger.json — ควบคู่
นโยบาย Rego
policies/support-tier.rego รวบรวมlabels หนึ่ง
env := input.compilation_context.environment
labels contains {"node": id, "key": "ops.example.com/environment", "value": env} if { some id, _ in input.graph.nodes}
labels contains {"node": id, "key": "ops.example.com/support-tier", "value": data.support_tiers[env]} if { some id, node in input.graph.nodes node.labels["component.aggrega.ai/category"] in data.supported_categories}การdata ของ
settings: # The categories whose components get a support tier. supported_categories: [datastore, devtool] # The tier each environment gives them. support_tiers: production: on-call staging: office-hoursสิ่งที่ปลั๊กอินในตัวแต่ละตัวเขียน
label-injector นำmatch ของset ของmatch ที่rules ดังsources ที่ops.example.com/owner: shop-team และdb และ cache ซึ่งdatastore ได้ backup.example.com/schedule: nightly ส่วน web อยู่devtool และ
selector-tagger เขียนtag เสมอ ค่าsources โหนดdefault และdefault โหนดtag policies/tags.yaml แมป
core/datastore/mariadb: orderscore/datastore/redis: sessionsและ default ของuntagged ดังweb จึงuntagged
ทั้ง
ทั้งlabel-transform เท่านั้น เมื่อir-verdict ตัวselector-tagger ที่
[E0085] ir-verdict: plugin "governance/selector-tagger:0.9.0": call "verdict_ir": wasm: plugin "selector-tagger" does not declare export "verdict_ir" in describe(): wasm: plugin rejected by the sandboxร่างตัวอย่าง
คุณ
เขียน
aggrega draft --example policy-label-transformจาก
cd policy-label-transformบิลด์
aggrega build --release release-staging.yaml --auto-pullaggrega build --release release-production.yaml --auto-pullแค็ตตาล็อกhub.aggrega.ai ซึ่ง.aggrega-config.yaml ระบุ เมื่อ--catalog จะ--auto-pull เติม
กับผู้ช่วย AI
ผู้
ใช้เครื่องมือของ Aggrega เท่านั้น และไม่สร้างโฟลเดอร์เอง หากโฟลเดอร์พื้นที่ทำงานยังไม่มีโฟลเดอร์ `policy-label-transform` เรียกเครื่องมือ `draft` หนึ่งครั้งโดยตั้ง `example` เป็น `policy-label-transform` และไม่ระบุ `dir`: เครื่องมือจะเขียนตัวอย่างลงในโฟลเดอร์ `policy-label-transform` ใหม่ จากนั้นเรียกเครื่องมือ `build` หนึ่งครั้งต่อ Release แต่ละรายการ ตามลำดับนี้ — `release-staging.yaml` และ `release-production.yaml` — โดยทุกครั้งตั้ง `workspace_root` เป็น `policy-label-transform` ตั้ง `release` เป็นไฟล์นั้น ตั้ง `auto_pull` เป็น true และตั้ง `write` เป็น true แจ้งฉันว่าแต่ละบิลด์เขียนไฟล์ใดบ้าง ไฟล์เหล่านั้นอยู่ใต้ `policy-label-transform/dist/`ป้ายกำกับที่แต่ละโหนดได้ในท้ายที่สุด
--ir-graph พิมพ์aggrega build --release release-production.yaml --auto-pull --ir-graph แล้ว web อ่าน
"web": { "labels": { "component.aggrega.ai/type": "server", "component.aggrega.ai/category": "devtool", "component.aggrega.ai/upstream-licensing": "osi-approved", "ops.example.com/environment": "production", "ops.example.com/support-tier": "on-call", "ops.example.com/owner": "shop-team", "tag": "untagged" }, [… omitted: the node's Component, its version, where it is placed, its catalog metadata, the file it was declared in, and its connection to db]}ป้ายcheck.sh อ่าน
labels the attachments wrote, release-staging.yaml: db ops.example.com/environment: staging ops.example.com/support-tier: office-hours ops.example.com/owner: shop-team backup.example.com/schedule: nightly tag: orders cache ops.example.com/environment: staging ops.example.com/support-tier: office-hours ops.example.com/owner: shop-team backup.example.com/schedule: nightly tag: sessions web ops.example.com/environment: staging ops.example.com/support-tier: office-hours ops.example.com/owner: shop-team tag: untagged
labels the attachments wrote, release-production.yaml: db ops.example.com/environment: production ops.example.com/support-tier: on-call ops.example.com/owner: shop-team backup.example.com/schedule: nightly tag: orders cache ops.example.com/environment: production ops.example.com/support-tier: on-call ops.example.com/owner: shop-team backup.example.com/schedule: nightly tag: sessions web ops.example.com/environment: production ops.example.com/support-tier: on-call ops.example.com/owner: shop-team tag: untaggedมี
เมื่อaggrega inspect release-production.yaml --ir-graph พิมพ์ops.example.com/environment หรือ ops.example.com/support-tier และtag: untagged บน
การแปลงเปลี่ยนป้ายกำกับและไม่เปลี่ยนอะไรอื่น
การlabel-transform ระบุE0069 และ
การrelease-production.yaml สองdist/compose/docker-compose.yaml จึงcheck.sh เปรียบ
คำตัดสิน และบิลด์ที่คำตัดสินหยุด
policies/production-support.rego แนบir-verdict หลัง
deny contains msg if { some id, node in input.graph.spec.nodes node.labels["ops.example.com/environment"] == "production" not node.labels["ops.example.com/support-tier"] msg := sprintf("%v is built for production and carries no ops.example.com/support-tier label", [id])}Releases ทั้งsupported_categories เขียน[datastore] ใน .aggrega-config.yaml web จะaggrega build --release release-production.yaml --auto-pull หยุด:
[… omitted: the pull's lines, which carry the refusal below once more, and a lint notice about core/secret-value][POLICY_ERROR E0005] policy plugin "rego" rejected the build: web is built for production and carries no ops.example.com/support-tier label caused by: policy violationบิลด์1 และdist/ release-staging.yaml ยังstaging และcheck.sh สร้าง
คำ
สิ่งที่ไฟล์ล็อกบันทึก
ไฟล์release-production.lock มีmutators: — ปลั๊กอิน บทบาท การplugins::
plugins: - uri: governance/label-injector [… omitted: the artifact digest, which depends on the aggrega binary that built it, recorded twice] referenced_from: - governance/label-injector:0.9.0 - uri: governance/rego [… omitted: the artifact digest, recorded twice] referenced_from: - governance/rego:0.9.0 - uri: governance/selector-tagger [… omitted: the artifact digest, recorded twice] referenced_from: - governance/selector-tagger:0.9.0การverdict_inputs: โดย
verdict_inputs: - plugin: governance/rego:0.9.0 role: ir-verdict sources: - digest: sha256:5e01fc76f791ef00eba02f02ffb383437c87531f3927ee4a91cec9bf9c6e8cd8 path: production-support.regoการ.aggrega-config.yaml — ไฟล์mutators: [] และ plugins: [] และverdict_inputs: การ
การตรวจสอบทุกบิลด์
การaggrega draft --example เขียน
./check.shcheck.sh ทำการ
release-production.yamlในสำเนา ของ พื้นที่ ทำงาน นี้ ที่ ไม่มี การ แนบ ด้าน การ กำกับ ดูแล เป็น ฐาน อ้างอิง release-staging.yamlและrelease-production.yamlที่นี่ ซึ่ง แต่ละ รายการ ต้อง สำเร็จ พร้อม ป้าย กำกับ ที่ ระบุ ข้าง ต้น บน แต่ละ โหนด โดย โครงสร้าง ไฟล์ ของ production ตรง กับ ของ ฐาน อ้างอิง ทุก ไบต์ release-production.yamlในสำเนา ที่ นโยบาย ครอบคลุม เฉพาะ หมวด หมู่ datastoreซึ่งต้อง หยุด ด้วย E0005และประโยค ข้าง ต้น และ ไม่มี การ ปฏิเสธ อื่น อยู่ ข้าง กัน
พิมพ์
RELEASE GOVERNANCE EXIT EXPECTED VERDICT----------------------------------------------------------------------------------------------------release-production.yaml none 0 reference OKrelease-staging.yaml as attached 0 pass OK: the expected labelsrelease-production.yaml as attached 0 pass OK: the expected labels; byte-identical to the build with nonerelease-production.yaml narrowed 1 halt OK: E0005, the expected sentence[… omitted: the two label listings shown above]check: every build ended as expected.สำเนา.aggrega-config.yaml ของ./build-release.sh หาAGGREGA_BIN กำหนด-- ส่งdist/ อยู่
ตำแหน่งที่คอมไพเลอร์ไม่ตีความ
คอมไพเลอร์on-call อยู่office-hours หรือdevtool ต้อง
ไฟล์
aggregate.yaml— ฐานข้อมูล แคช และ UI สำหรับ การ ดูแล ที่ เชื่อม โยง กับ ฐาน ข้อมูล ไม่มี ป้าย กำกับ manifest.yaml— ผูกชนิด ของ ส่วน ประกอบ แต่ละ ชนิด และ Feature ข้อมูล ลับ เข้า กับ Recipe ของ Docker Compose ใช้ ร่วม กัน โดย Releases ทั้ง สอง release-staging.yaml,release-production.yaml— สองสภาพ แวดล้อม .aggrega-config.yaml— รีจิสทรีเริ่ม ต้น และ การ แนบ ด้าน การ กำกับ ดูแล ทั้ง สี่ policies/support-tier.rego— นโยบาย label-transformpolicies/production-support.rego— คำตัดสิน policies/tags.yaml— แมปจาก ส่วน ประกอบ ไป ยัง แท็ก ของ ตัว ติด แท็ก ตาม ตัว คัด เลือก build-release.sh— บิลด์ Release หนึ่งรายการ พร้อม พิมพ์ คำ สั่ง aggrega buildที่เทียบ เท่า ออก มา check.sh— ทำการบิลด์ สี่ รอบ และ ตรวจ สอบ ผล ของ แต่ละ รอบ