aggrega pin
aggrega pin <entity-path> 會在 Recipe 或 FeatureRecipe 旁的 entity.lock 中,為實體從自身文件之外讀取的每個輸入記錄內容固定項目。這是實體作者的步驟:在實體被使用或發布之前執行它,並提交它所寫的鎖定檔。
aggrega pin catalog/recipe/helm/server/1.0.0/recipe.yaml記錄的內容
實體可以依賴其自身文件之外的位元組,鎖定檔會為每一項各持有一個固定項目:
- 你完整寫出座標的遠端
source:— 其kind、url、chart、module_subdir、version或ref中都沒有範本。此步驟會擷取它,並記錄它解析到的版本(對 git 來源而言,是其ref所指名的 commit),以及所擷取內容的內容摘要。 artifacts項目以$import匯入的檔案。 此步驟會依該檔案在你工作區中的現況計算其摘要。source:所指名、位於實體旁的目錄或檔案中的每個檔案。 不會擷取任何東西:此步驟會為該來源貢獻給實體發布內容的每個檔案計算摘要(即它所指名的目錄之下、實體的忽略規則保留的每個檔案,或那一個檔案),並依其相對於實體的路徑記錄。位於 Recipe 旁但該來源未貢獻的檔案(例如 README)不會被固定。寫成範本的來源,例如./charts/{{ .values.flavour }},要等 Release 填入後才會指名其目錄,因此它會貢獻實體目錄中規則保留的每個檔案,而這些檔案各自都會被固定。建置會在其提供者讀取來源之前,將該來源與這些固定項目比較,因此自固定之後有檔案被新增、變更或移除,都會中止建置,見 A local source no longer matches the pins recorded beside its Recipe(本機來源不再與其 Recipe 旁所記錄的固定項目相符)。- 對於是目錄的
source:,還有忽略規則本身。 此步驟會記錄由哪個外掛程式提供該實體的能力,以及它所組成的確切規則,如下一節所述。
它不會記錄的有:來源座標由範本填入的遠端來源,這種來源要等 Release 填入後才會指名成品,並由 aggrega pull 在每個 Release 的鎖定檔中固定;以及內嵌的 artifacts 項目或取自 ArtifactLibrary 的項目。此檔案本身在 實體鎖定檔結構描述 中逐欄位說明。
不需要 Release。 完整寫出的來源,對於將來會使用該實體的每個 Release 都指名同一個成品,因此解析它不需要 Release 提供任何東西。這正是讓作者能在完全沒有 Release 的工作區中固定實體的原因。
實體檔案絕不會被寫入。 此步驟推導出的內容放在實體旁;你所輸入的內容維持原樣。在輸入未變時重新執行,會讓鎖定檔保持位元組完全相同,而不再讀取任何鎖定檔會記錄之內容的實體,其鎖定檔會被移除。Component、Feature 或任何其他不讀取此類輸入的種類,會被回報為沒有東西可固定,且其旁的任何東西都不會被動到。
隨實體發布的檔案
source: 指名其旁一個目錄(例如同位置的 chart、模組)的 Recipe 或 FeatureRecipe,在發布時會攜帶該目錄的檔案。並非其中每個檔案都屬於該處:版本控制目錄、相依性快取、編輯器留下的檔案。哪些檔案屬於該處,由忽略規則決定,語法與 .gitignore 使用的相同,而且由你控制。 它們來自兩個地方:
- 為該實體的能力進行渲染的外掛程式,會宣告其自身生態系從不發布的內容。chart 外掛程式會排除版本控制目錄(
.git/、.hg/、.svn/、.bzr/)以及 chart 的templates/之下的隱藏檔,並遵循 chart 自己的.helmignore:走訪來源時只要遇到一個,其各行就會被當作持有它之目錄的進一步規則來讀取。Terraform 外掛程式會排除版本控制目錄與.terraform/工作目錄(不包含相依性鎖定檔,它本來就該隨模組一起發布),並以同樣方式遵循.terraformignore。未宣告任何內容的外掛程式則保留所有檔案。 - 你自己的
.aggregaignore,位於實體文件旁的一個檔案,語法相同。它的各行在外掛程式的規則以及外掛程式所指名的每個忽略檔之後才套用,因此對於你指名的任何路徑,你擁有最後決定權:像.venv/這樣的一行會排除外掛程式一無所知的目錄,像!.git/這樣的一行會把外掛程式排除的目錄找回來。該檔案本身絕不會隨之發布;它的規則則會,放在鎖定檔之中。
.venv/*.bak!notes.bak每條規則都相對於它所屬的目錄來讀取。 外掛程式宣告的規則從來源目錄的根目錄讀取;.helmignore 的一行從持有該檔案的目錄讀取;你的 .aggregaignore 的一行從實體自己的目錄讀取。沒有斜線或只有結尾斜線的規則,會比對任何深度的名稱;結尾斜線只比對目錄;開頭的 ! 會把先前規則排除的內容找回來。規則排除的目錄不會被進入,因此其中的檔案要等目錄本身回來之後才會回來,在 .git/ 被排除時,單獨的 !.git/HEAD 不會把該檔案找回來,而 !.git/ 可以。
所讀取其規則的外掛程式,是你固定時在你的工作區中提供該能力的那一個:你的工作區為該能力設定的提供者繫結,否則就是內建於 aggrega 的外掛程式。此步驟以名稱(例如 provider/terraform,不含版本)記錄該外掛程式,並把它所組成的確切規則記錄在 entity.lock 中;以宣告相同規則之外掛程式的較新 aggrega 再次固定,鎖定檔不會改變。從此之後,每次讀取該目錄都套用所記錄的規則,不套用其他規則:實體的發布、pull 或 push 用來核對鎖定檔的比較、鎖定檔中該實體的列、建置的比較、將目錄交給提供者的渲染,以及 aggrega pull --verify。因此你發布的內容,正是你自己的建置所渲染的內容,而變更後的繫結、編輯過的 .aggregaignore 或較新的 aggrega,在你再次固定之前都不會改變任何東西,而到那時,鎖定檔的差異會顯示哪些內容變動了。外掛程式指名為忽略檔的檔案(例如 .helmignore)本身就是來源的檔案之一,除非有規則將它排除,否則會像任何其他檔案一樣被固定,因此不重新固定就編輯它,會在下一次 pull 或建置時被發現。未記錄任何規則的鎖定檔會保留該目錄之下的每個檔案。
使用端會渲染你的規則所保留的檔案。 外掛程式在使用相同 ABI 版本、其契約與其實體的宣告相符,且不需要已發布集合之外的任何檔案時,就能渲染為其能力所發布的 Recipe。需要集合所排除之檔案的外掛程式,必須讓其建置明確失敗並指出該檔案;主機的職責是拒絕對集合未攜帶之檔案的任何打包或讀取,並指出該檔案。若使用端的工作區為該能力所繫結的外掛程式,宣告的規則與你的鎖定檔所記錄的不同,使用端的 aggrega pull 會以警告說明這一點,指出兩個外掛程式與差異,然後繼續。
實體檔案之中的符號連結會被拒絕,無論它指向何處,也無論它能否解析,見 A symbolic link sits among the files an entity carries(實體所攜帶的檔案中有符號連結)。被你的規則排除的連結,會像它們排除的任何其他檔案一樣被略過。實體所指名的路徑若經過一個指向實體目錄之外的連結目錄,也同樣會在任何東西被固定之前被拒絕,見 A path names content outside the entity’s own directory(路徑指向實體自身目錄之外的內容)。
鎖定檔的位置
鎖定檔寫在你所指名的文件旁,同一個目錄中,因此實體需要一個可寫入的位置:位於你自己目錄中的文件。由 pull 從內容快取解析而來的實體沒有這樣的位置,絕不會被任何東西固定。
一個目錄,一個實體。 一個目錄只持有一個 entity.lock,因此此步驟會拒絕與任何其他實體共用目錄的 Recipe 或 FeatureRecipe,無論其中任一個是否有東西要固定,並指出擋在路上的每個實體,這個拒絕即 An entity shares its directory with another entity(實體與另一個實體共用目錄)。除了 Aggregate、Release 與 Manifest 可以並排之外,每個種類都有自己的目錄;push 對其所發布的實體也適用同一條規則,如 每個目錄一個實體 所述。此步驟只判斷它會為其寫出鎖定檔的實體,因此沒有東西可固定的 Component 或任何其他種類,會被回報為沒有東西可固定,而該拒絕會在該實體被發布時觸及它。實體旁不是實體文件的檔案(chart 檔案、被匯入的檔案本身)不算擋路。實體旁的每份文件只會從工作區內讀取,或者對於你指名的工作區之外的文件,從其自身目錄內讀取(鎖定檔也存放在那裡),因此是指向外部的連結者會讓此步驟停止,指出該連結而不讀取它,如 工作區邊界 所述。
誰來固定,何時固定
固定是撰寫者的職責。 輸入尚未被固定的實體還沒有準備好被使用,因此預設情況下 pull 不記錄任何固定項目:對於 Release 所建置、位於你目錄中的 Recipe 或 FeatureRecipe,它會把此步驟會記錄的內容與鎖定檔所持有的內容比較,並在固定項目缺少或不再與其輸入相符時中止。該中止會指出實體、每個輸入,以及它是遠端來源、被匯入的檔案還是本機來源的檔案,並指出此命令。它就是 An entity reads an input the lock beside it records no pin for(實體讀取了其旁鎖定檔未記錄固定項目的輸入)。push 對其所發布的實體適用同一項比較,並以同一個中止拒絕,因此實體無法在有固定項目未記錄的情況下透過 aggrega push 抵達登錄庫,發布前固定 對此有所說明。本機來源被當作一組檔案持有: 沒有記錄其中任何檔案的鎖定檔會讓 pull 或 push 停止,自固定之後有檔案被新增、變更或移除時也一樣,就像任何其他缺少或過時的固定項目。
首次 pull 的中止,該由發布者修正,絕不是使用端。 當你使用別人撰寫的目錄(例如它在你自己目錄中的一份檢出內容),而其中某個實體未被固定時,代表作者從未執行此步驟。你的補救辦法不是手動編輯他們的目錄:請設定下方的工作區鍵,讓你的 pull 自行記錄固定項目。
有兩個命令會代你執行這同一個步驟,並寫出相同的位元組:
aggrega pull --pin-sources會對 Release 所建置的實體執行它,而不是中止。aggrega push --pin-sources會在打包實體之前對它執行,因此它寫出的鎖定檔會成為所發布內容的一部分,而不是拒絕。
各自都有一個讓固定成為其預設的工作區鍵,即 pin_sources_at_pull 與 pin_sources_at_push,兩者預設皆為關閉,且各自只管轄自己的命令。旗標在兩個方向上都會覆寫其鍵:--pin-sources 無論鍵怎麼設定,都會為這一次執行固定,而 --pin-sources=false 則不會。因此設定為固定的工作區,仍可以為一次 pull 取回中止。填寫自己鎖定檔的建置就是一次 pull,因此它遵循 pin_sources_at_pull。這些鍵在 設定參考 中說明。
變更已發布的實體
最佳做法:對你已發布之實體的編輯,應放進新版本,然後再固定,絕不要重新固定已經發出去的版本。 將實體複製到新的版本目錄,在那裡進行變更,並對新版本執行 aggrega pin。已發布的版本會繼續準確描述它被發布時的位元組,而使用端改用新版本是有意為之。
本產品強制執行其中一半:在已發布的版本上發布變更過的內容會被拒絕,因此已發布的版本不會被悄悄取代。它不會在你自己的工作區中強制執行另一半。編輯之後重新固定既有版本,有時正是合適的做法,例如你在某個應用程式內使用而尚未發布的實體,因此沒有任何東西會阻止你,而紀律要由你自己維持。
其他介面上的同一個步驟
常駐程式以 aggrega/pin 承載此步驟(aggrega serve),工具通訊協定則以 pin 工具承載(aggrega mcp);兩者寫出的位元組都與此命令寫出的相同。透過 HTTP 監聽器時,該工具會在工作區內寫入並連到實體的來源所指名的主機,因此呼叫端需要工作區寫入範圍才能呼叫它,這與 pull 所需的授權相同。
另請參閱
- aggrega-pull.md — 實體鎖定檔、建置拿什麼與它比較,以及中止。
- aggrega-push.md — 發布實體,以及只發布一次版本。
- configuration.md —
pin_sources_at_pull與pin_sources_at_push。
概要
aggrega pin <entity-path> [flags]說明
Record, in the entity.lock beside a Recipe or FeatureRecipe, the content pin for every inputthe entity reads from outside its own document: a remote source: whose coordinates you wrote outin full, a file an artifacts entry imports with $import, and each file of a local source:.
Pinning is the entity author's step. Run it on an entity before it is consumed — before youpublish it, and after every change to one of its inputs — and commit the entity.lock it writesbeside the entity. A pull over an entity whose lock does not record these pins halts and namesthis command, and so does a push of it; so does one whose local source has had a file added,changed or removed since it was pinned.
No Release is needed. A source whose coordinates carry no template names one artifact for everyRelease that uses the entity, so it is resolved and pinned here, with nothing supplied. A remotesource whose coordinates are filled in from a template is not pinned here: which artifact it names isdecided by each Release, and each identity it resolves to is pinned in that Release's lockfile.A source that names a directory beside the entity is not fetched: each file it contributes to whata publication of the entity carries is digested as it stands and pinned by its path, so a buildrefuses a file added, changed or removed after the pin. A local source written as a templatecontributes every file in the entity's directory, so each of those is pinned.
Which files a source directory contributes is decided here, once, and recorded. The step reads theignore rules the plugin serving the entity's capability declares — this workspace's provider bindingfor that capability, or else the plugin built into aggrega — together with the ignore files thatplugin names inside the source, such as a chart's .helmignore, and the .aggregaignore beside theentity, in gitignore syntax, whose lines come last and so have the final say. It records the pluginand the composed rules in the entity.lock, and every publication, pull, build and render of theentity applies the recorded rules and no others, so a changed binding or a newer binary movesnothing until you pin again. A symbolic link among the files is refused rather than followed.
The step writes beside the entity, so the entity needs a writable home: the document you name isread from its own directory and the lock lands next to it. The entity file itself is neverwritten to. Re-running over unchanged inputs leaves the lock byte-identical; an entity that readsnothing a lock records has its lock removed. A Component, a Feature or any other kind that readsno such input is reported as having nothing to pin, and nothing beside it is touched.
A directory holds one entity.lock, so the step refuses a Recipe or FeatureRecipe that shares itsdirectory with any other entity, naming the entity in the way, whether or not either has anythingto pin. Every kind has a directory of its own except Aggregate, Release and Manifest, which may sitside by side; a push holds the entity it publishes to the same rule.
aggrega pull --pin-sources and aggrega push --pin-sources run this same step on your behalf, andwrite the same bytes.旗標
| 旗標 | 預設 | 說明 |
|---|---|---|
--dry-run | false | 解析實體的輸入,並印出此步驟將會寫出的 entity.lock 而不寫入:其路徑與將持有的內容會輸出到 stdout,磁碟上沒有任何東西會變動。此步驟會保持位元組完全相同的鎖定檔不會被印出。解析的執行方式與否則的情況完全相同,因此內容快取仍會被填入 |