क्रेडेंशियल डिलीवरी — `secretKeyRef` शुरू से अंत तक
एक अकेला PostgreSQL डेटाबेस जिसका पासवर्ड क्रेडेंशियल सबसिस्टम प्रदान करता है, प्रति प्रोवाइडर दिखाया गया। core/datastore/postgres पर वही password स्लॉट दोनों में से किसी भी क्रेडेंशियल परिवार को स्वीकार करता है; डेवलपर जो परिवार अटैच करता है, वही तय करता है कि पासवर्ड कैसे पहुँचाया जाता है, और डेटाबेस Recipe स्लॉट को उस तरह पढ़ता है जिस तरह उसका प्रोवाइडर समर्थन करता है।
उदाहरण ड्राफ़्ट करें
आप यह उदाहरण नीचे दिए कमांड से बिल्ड कर सकते हैं, या अपने AI असिस्टेंट से इसे अपने लिए बिल्ड करवा सकते हैं।
उदाहरण को उसी के नाम वाले एक नए फ़ोल्डर में लिखें:
aggrega draft --example credential-secretkeyrefफिर यह आगे चलाने के लिए कमांड प्रिंट करता है। पहला कमांड नए फ़ोल्डर में ले जाता है:
cd credential-secretkeyrefबिल्ड करें
इस उदाहरण में तीन रिलीज़ हैं। हर रन में एक बिल्ड करें:
aggrega build --release release-helm.yaml --auto-pullaggrega build --release release-compose.yaml --auto-pullaggrega build --release release-negative.yaml --auto-pull # expected to fail (see below)हर रिलीज़ अपनी कैटलॉग एंटिटी इस वर्कस्पेस की .aggrega-config.yaml के ज़रिए, उस हब रजिस्ट्री से रिज़ॉल्व करती है जिसे वह डिफ़ॉल्ट के रूप में नामित करती है, इसलिए किसी --catalog फ़्लैग की ज़रूरत नहीं होती, और --auto-pull बिल्ड के दौरान वह लॉकफ़ाइल लिखता है जो किसी नए क्लोन में नहीं होती।
AI असिस्टेंट के साथ
Aggrega के टूल के साथ सेट अप किया गया AI असिस्टेंट भी यही कर सकता है: यह प्रॉम्प्ट उसमें पेस्ट करें।
केवल Aggrega टूल का उपयोग करें, और स्वयं कोई फ़ोल्डर न बनाएं। यदि Workspace फ़ोल्डर में अभी कोई `credential-secretkeyref` फ़ोल्डर नहीं है, तो `draft` टूल को एक बार कॉल करें, `example` को `credential-secretkeyref` पर सेट करके और बिना `dir` के: यह उदाहरण को एक नए `credential-secretkeyref` फ़ोल्डर में लिखता है। फिर हर Release के लिए `build` टूल को एक बार कॉल करें, इस क्रम में — `release-helm.yaml`, `release-compose.yaml` — हर बार `workspace_root` को `credential-secretkeyref` पर, `release` को उस फ़ाइल पर, `auto_pull` को true पर और `write` को true पर सेट करके। फिर `build` टूल को इसी तरह कॉल करें, `release` को `release-negative.yaml` पर सेट करके: इसका अस्वीकार होना अपेक्षित है, इसलिए मुझे वह अस्वीकृति पढ़कर सुनाएं। मुझे बताएं कि हर बिल्ड ने कौन-सी फ़ाइलें लिखीं; वे `credential-secretkeyref/dist/` के अंतर्गत हैं।Helm — एक रेफ़रेंस योग्य Secret + secretKeyRef
aggregate-helm.yaml core/referenced-secret को password स्लॉट से अटैच करता है। Manifest उसे k8s-secret-from-parameter से मैप करता है, जो एक Kubernetes Secret को मूर्त रूप देता है और Secret की पहचान को provides {name, key} के रूप में प्रकाशित करता है। postgres helm Recipe containers.attachments के ज़रिए स्लॉट का रेफ़रेंस देता है, जिसे संश्लेषक एक env secretKeyRef के रूप में रेंडर करता है।
aggrega build --release release-helm.yaml --auto-pullजनरेट किया गया Secret (dist/helm/helm/db--password--db-secret-db-password.yaml) और डेटाबेस का secretKeyRef (dist/helm/helm/db-statefulset.yaml) एक ही रिसोर्स का नाम लेते हैं, क्योंकि दोनों .features.password.provides.name पढ़ते हैं — न कोई पुनः-व्युत्पत्ति है और न ही कोई परिपाटी जिस पर दोनों पक्षों को सहमत होना पड़े:
[… omitted: the apiVersion and the Secret kind]metadata: name: db-password [… omitted: the labels and annotations every rendered document carries]stringData: POSTGRES_PASSWORD: "dev-pw-change-me"
# db-statefulset.yaml (container env)- name: POSTGRES_PASSWORD valueFrom: secretKeyRef: name: db-password # == the Secret's metadata.name key: POSTGRES_PASSWORD # == the Secret's data keyCompose — एक inject-मान क्रेडेंशियल
aggregate-compose.yaml core/secret-value अटैच करता है। Compose में कोई Secret-रिसोर्स / secretKeyRef प्रिमिटिव नहीं है, इसलिए Manifest क्रेडेंशियल को dotenv-secret से मैप करता है, जो मान को inject पाइप पर उस कुंजी के अंतर्गत पहुँचाता है जिसका नाम अटैचमेंट values.key में देता है, यहाँ POSTGRES_PASSWORD, और postgres compose Recipe उसे उसी कुंजी के अंतर्गत पढ़ता है।
aggrega build --release release-compose.yaml --auto-pull# dist/compose/compose/docker-compose.yaml → POSTGRES_PASSWORD: dev-pw-change-meनकारात्मक — रेफ़रेंस से अस्वीकार किया गया एक गैर-रेफ़रेंस-योग्य भराव
aggregate-negative.yaml inject-मान वाले core/secret-value को password स्लॉट से अटैच करता है, फिर helm पर बिल्ड करता है, जहाँ postgres Recipe containers.attachments (एक secretKeyRef) के ज़रिए स्लॉट का रेफ़रेंस देता है। किसी secretKeyRef को इंगित करने के लिए एक Secret रिसोर्स चाहिए, लेकिन inject-मान क्रेडेंशियल ऐसा कोई रिसोर्स प्रकाशित नहीं करता — इसलिए बिल्ड मुखर रूप से रुक जाता है:
aggrega build --release release-negative.yaml --auto-pull# [… omitted: the pull's lines, which carry the same halt, and two lint notices]# [CATALOG_ERROR E0212] instance db# rendering node "db"# [… omitted: the cause, "workload attachment slot is not referenceable", naming the Recipe and its path in your catalog, then one line each for the "name" and the "key" the slot's provides does not expose]इस रिलीज़ के विफल होने की अपेक्षा है — रुकना ही सबक है। बिल्ड सफलता रिपोर्ट करने के बजाय 1 के साथ बाहर निकलता है, इसलिए गार्डरेल पाठक को भी दिखता है और उसे चलाने वाली किसी भी स्क्रिप्ट को भी।
दो सुधार हैं। एक रेफ़रेंस योग्य क्रेडेंशियल (core/referenced-secret) अटैच करें, जैसा aggregate-helm.yaml में है; या core/secret-value अटैचमेंट को बनाए रखें और Manifest में उसे k8s-secret-from-value से मैप करें, जो core/secret-value का Helm रियलाइज़ेशन है और मान को अपने द्वारा उत्सर्जित एक Secret में लिखता है तथा उस Secret का नाम और कुंजी प्रकाशित करता है, ताकि रेफ़रेंस के पास इंगित करने के लिए एक रिसोर्स हो। env-secret से बाइंड होने पर, inject-मान क्रेडेंशियल इसके बजाय inject पाइप के ज़रिए कंटेनर तक पहुँचता है, कभी भी containers.attachments रेफ़रेंस के ज़रिए नहीं।