撰寫提供者:完整的逐步說明
本頁逐步說明撰寫提供者客體的整個工作,從空目錄一路到產生提供者所渲染檔案的建置。它是外掛程式開發者指南(記載實體與生命週期)以及外掛程式契約(記載插槽)的實作搭配說明。
這裡建置的提供者小到可以一口氣讀完,卻做真正的工作:它渲染環境檔案。這個目標是很好的第一個提供者,因為它的轉換確實是特定格式的——環境檔案有自己的鍵語法、自己的引號規則,也沒有可放建置出處的中繼資料區塊——所以客體必須做出較大的提供者所做的每一項決定,卻沒有大量程式碼把它們藏起來。
關於本頁的區塊。 每個顯示輸出的區塊,都是依照下列步驟的順序,從實際執行複製而來,並遵循輸出慣例:區塊要嘛完整,要嘛是標明省略了哪些行的節錄。這是需要你自行組合的逐步說明,而不是可以複製的工作區,因此來源區塊是要建立的檔案,而不是要檢出的檔案。
你需要什麼
- Go 工具鏈,可編譯為 WebAssembly,無需額外工具。
- 外掛程式開發套件的一份檢出,外掛程式開發者指南有介紹,還有該套件所建構於其上的 ABI 套件的檢出:下方客體的
go.mod指向兩者。 aggrega二進位檔。
完成後的樣子
提供者是兩個成品:一個 .wasm 客體,以及把它帶入目錄的 Plugin 實體。除此之外沒有別的——不必修改主機、不必註冊、不必建置編譯器。新增提供者,就是把這兩個檔案放在建置看得到的地方。
本逐步說明最後的工作區:
dotenv-walkthrough/ guest/ the Go module that compiles to the .wasm go.mod go.sum main.go catalog/ the Component and Recipe you author component/example/compute/checkout/1.0.0/component.yaml recipe/dotenv/checkout/1.0.0/recipe.yaml dev-catalog/ the generated Plugin entity, with the .wasm beside it plugin/provider/dotenv/0.1.0/plugin.yaml plugin/provider/dotenv/0.1.0/provider--dotenv.wasm dotenv.wasm the compiled guest overlay.yaml the identity you supply to the entity generator aggregate.yaml manifest.yaml release.yaml .aggrega-config.yaml1. 客體的自我回報
每個外掛程式都匯出 describe()。主機在載入客體時呼叫它一次,並把回答當作客體對自身的說明。對提供者而言,該回答有四個部分很重要。
建立 guest/main.go:
// A provider guest that renders environment-file artifacts.package main
import ( "bytes" "fmt" "sort" "strings"
pdk "github.com/extism/go-pdk"
"github.com/aggrega-ai/aggrega-pdk/go/pkg/aggrega")
func descriptor() aggrega.PluginDescriptor { return aggrega.PluginDescriptor{ AbiVersion: aggrega.APIVersion, PluginType: "provider", Description: "Render artifact bodies into environment files, quoting and escaping each value as the format requires.", Capabilities: []string{"dotenv"}, Exports: []aggrega.PluginExport{ {Name: "render_node"}, }, Metadata: &aggrega.PluginDescriptorMeta{License: "Apache-2.0"}, }}
//go:wasmexport describefunc describe() int32 { out, err := aggrega.MarshalDescriptor(descriptor()) if err != nil { pdk.SetError(err) return 1 } pdk.Output(out) return 0}PluginType 說明這個客體服務哪個插槽。Capabilities 是 Recipe 據以解析的清單:spec.capability 為 dotenv 的 Recipe 會被路由到這個客體。Exports 指名主機可分派到的進入點;render_node 是每個提供者都必須有的一個。
這個描述項刻意不完整,就像初稿通常那樣。下面的第一次建置會顯示這一點。
2. 渲染節點
render_node 會針對建置透過這個提供者渲染的每個元件呼叫一次。它會收到節點的身分、渲染情境,以及所繫結 Recipe 所宣告的任何預先評估輸入——這裡是主機已經讀取並當作範本評估過的成品集。
客體的全部工作,就是決定輸出什麼位元組。把以下內容加入 guest/main.go:
// needsQuoting reports whether a value cannot be written bare in an// environment file. A bare value ends at the first space, so anything// carrying whitespace has to be quoted; the quote characters, the comment// introducer and the expansion introducer would each be read as syntax.func needsQuoting(v string) bool { if v == "" { return true } return strings.ContainsAny(v, " \t\n\r\"'#$\\")}
// quote wraps a value in double quotes and escapes what the format reads as// syntax inside them. Order matters: the backslash is escaped first, or the// escapes introduced afterwards would be escaped a second time.func quote(v string) string { v = strings.ReplaceAll(v, `\`, `\\`) v = strings.ReplaceAll(v, `"`, `\"`) v = strings.ReplaceAll(v, "\n", `\n`) v = strings.ReplaceAll(v, "\r", `\r`) v = strings.ReplaceAll(v, "\t", `\t`) return `"` + v + `"`}
// normaliseKey maps an authored key into the environment-variable grammar:// upper case, with the separators an author reaches for folded to// underscores. It reports an error rather than correcting a key that still// does not fit, because a silently-renamed variable is one the application// never reads.func normaliseKey(k string) (string, error) { n := strings.ToUpper(k) n = strings.NewReplacer("-", "_", ".", "_", "/", "_").Replace(n) if n == "" { return "", fmt.Errorf("empty key") } for i, r := range n { switch { case r >= 'A' && r <= 'Z', r == '_': case r >= '0' && r <= '9' && i > 0: default: return "", fmt.Errorf("key %q maps to %q, which is not a valid environment-variable name", k, n) } } return n, nil}該片段中的三個決定屬於提供者自己,沒有其他層能做這些決定。哪些字元會強制加引號,是關於環境檔案的事實。變數名稱語法也是,而拒絕不合適的鍵、而不是重新命名它的選擇也是——重新命名後的變數,是應用程式去找卻找不到的變數,這比中止的建置更糟。
現在是剩下的兩個部分:出處放在哪裡,以及匯出本身。
// provenanceComment renders the build-provenance key set the host computed as// comment lines. An environment file has no metadata block, so a comment// header is where provenance can go; the keys are emitted in sorted order so// the bytes are identical across runs of identical input.func provenanceComment(annotations map[string]string) []byte { if len(annotations) == 0 { return nil } keys := make([]string, 0, len(annotations)) for k := range annotations { keys = append(keys, k) } sort.Strings(keys) var out bytes.Buffer for _, k := range keys { fmt.Fprintf(&out, "# %s=%s\n", k, annotations[k]) } out.WriteByte('\n') return out.Bytes()}
// renderBody translates one artifact body into environment-file lines. A// blank line and a comment pass through untouched; every other line is// KEY=value, and a line carrying no separator is a loud failure rather than a// line the guest guesses at.func renderBody(name string, body []byte) ([]byte, error) { var out bytes.Buffer for i, raw := range strings.Split(string(body), "\n") { line := strings.TrimSpace(raw) if line == "" || strings.HasPrefix(line, "#") { continue } k, v, found := strings.Cut(line, "=") if !found { return nil, fmt.Errorf("%s line %d: %q declares no value; an entry is KEY=value", name, i+1, line) } key, err := normaliseKey(strings.TrimSpace(k)) if err != nil { return nil, fmt.Errorf("%s line %d: %w", name, i+1, err) } val := strings.TrimSpace(v) if needsQuoting(val) { val = quote(val) } fmt.Fprintf(&out, "%s=%s\n", key, val) } return out.Bytes(), nil}
//go:wasmexport render_nodefunc render_node() int32 { var in aggrega.RenderNodeInput if err := in.DecodeCBOR(pdk.Input()); err != nil { pdk.SetError(fmt.Errorf("dotenv: decode RenderNodeInput: %w", err)) return 1 }
if in.ArtifactsProjection == nil || len(in.ArtifactsProjection.Entries) == 0 { pdk.SetError(fmt.Errorf("dotenv: node %q supplied no artifacts to render", in.Node.ID)) return 1 }
var files []aggrega.RenderedFile for _, e := range in.ArtifactsProjection.Entries { body, err := renderBody(e.Name, e.Content) if err != nil { pdk.SetError(fmt.Errorf("dotenv: %w", err)) return 1 } files = append(files, aggrega.RenderedFile{ Path: e.Name, Content: append(provenanceComment(e.Annotations), body...), Format: "text", }) }
outputBytes, err := aggrega.RenderNodeOutput{Files: files}.EncodeCBOR() if err != nil { pdk.SetError(fmt.Errorf("dotenv: encode RenderNodeOutput: %w", err)) return 1 } pdk.Output(outputBytes) return 0}
func main() {}酬載以二進位編碼跨越邊界,而套件負責讀寫它。 主機以標準 CBOR 把輸入交給 render_node,並以同樣的編碼讀回回答,所以客體用輸入型別的 DecodeCBOR 解碼,用輸出型別的 EncodeCBOR 編碼——不需要 CBOR 程式庫,也沒有任何東西要手動解析。檔案的 Content 是由客體填入要寫入的確切位元組的位元組切片;編碼器把它們當作原始位元組攜帶,主機則逐字寫入。
主機交給客體的是它已經評估過的內容。 每個成品項目的 Content 是作者撰寫的內容,其範本運算式已依渲染情境解析——客體從不評估範本,也從不讀取檔案。這正是讓編譯器的預先編譯邊界保持完整的原因:客體是從酬載到位元組的純函式。
決定性是客體的責任。 在一般建置中,沒有任何東西會替你檢查它。這裡它來自在輸出之前先排序出處鍵,以及依酬載攜帶的順序走訪成品項目,而本頁接近結尾的檢查會衡量結果。
guest/go.mod 參照你的套件檢出:
module example.com/dotenv-provider
go 1.26.0
require ( github.com/aggrega-ai/aggrega-pdk/go v0.0.0 github.com/extism/go-pdk v1.1.3)
require github.com/aggrega-ai/aggrega-abi/go v0.0.0 // indirect
replace github.com/aggrega-ai/aggrega-pdk/go => /path/to/aggrega-pdk/go
replace github.com/aggrega-ai/aggrega-abi/go => /path/to/aggrega-abi/go3. 建置客體
客體是選定 WebAssembly 目標的一般 Go 建置:
cd guestgo mod tidyGOWORK=off GOOS=wasip1 GOARCH=wasm go build -trimpath -buildvcs=false \ -ldflags "-X github.com/aggrega-ai/aggrega-pdk/go/pkg/aggrega.Version=0.1.0 \ -X github.com/aggrega-ai/aggrega-pdk/go/pkg/aggrega.Commit=walkthru" \ -buildmode=c-shared -o ../dotenv.wasm ./go mod tidy 會寫入 go.sum,也就是相依項目的檢查碼,沒有它建置會拒絕執行。-trimpath 與 -buildvcs=false 讓建置路徑與版本控制戳記不進入二進位檔,所以在相同提交下的相同來源會產生相同的位元組。兩個 -ldflags 值會把客體自己的版本蓋印進去,下一步會讀取它。
在繼續之前,先確認匯出:
aggrega inspect --plugin dotenv.wasmPlugin .wasm: dotenv.wasmExports: render_nodehostFunctions (derived from binary, not yet recorded by aggrega plugin sync): (none)這個客體不匯入任何主機函式,這是最小權限的預設:它既不需要檔案系統,也不需要網路,因為它渲染的一切都隨酬載抵達。
4. 產生 Plugin 實體
實體的契約欄位不是手寫的——它們是從客體讀出來的,所以實體不可能承諾二進位檔做不到的事。你只需要在一個小型覆蓋層中提供身分。
overlay.yaml:
apiVersion: aggrega.ai/v1beta1kind: Pluginmetadata: name: dotenvaggrega plugin gen-catalog --plugin dotenv.wasm \ --overlay overlay.yaml --output-dir dev-catalog/plugingenerated dev-catalog/plugin/provider/dotenv/0.1.0/plugin.yaml產生的實體:
# Generated from the plugin by `aggrega plugin gen-catalog`. You may narrow its capability lists; edit nothing else here.apiVersion: aggrega.ai/v1beta1kind: Pluginmetadata: name: dotenv version: 0.1.0 pluginType: provider description: Render artifact bodies into environment files, quoting and escaping each value as the format requires.spec: abiVersion: v1beta1 exports: - name: render_node provider: capabilities: - dotenv請注意沒有的東西:任何指向 .wasm 的指標。外掛程式的位置是從它的身分衍生的——pluginType/name 座標,加上所設定的任何登錄庫——所以沒有位置欄位需要撰寫,也沒有可能寫錯的欄位。內容摘要是在 Release 解析時記錄在該 Release 的鎖定檔中,而不是在實體中。
5. 把客體放在建置會找到它的地方
開發客體期間沒有任何已發布的東西可取得,所以建置會從目錄資料夾讀取它:.wasm 就放在它的實體旁邊,以插槽與外掛程式命名。
dev-catalog/plugin/provider/dotenv/0.1.0/plugin.yamldev-catalog/plugin/provider/dotenv/0.1.0/provider--dotenv.wasmcp dotenv.wasm dev-catalog/plugin/provider/dotenv/0.1.0/provider--dotenv.wasm檔名同時帶有插槽與名稱,因為單純的外掛程式名稱只在它自己的插槽內是唯一的——在不同插槽、都叫 dotenv 的兩個外掛程式,必須對應到兩個檔案。
請把建置好的檔案複製到那裡,而不要連結到它。放在該位置的連結只會被跟隨到工作區內部的某處——或者,對於列在工作區之外的目錄資料夾,則是該目錄內部的某處;再往外的連結會使建置與 pull 停止並指出該連結,如工作區邊界所述。
目錄資料夾中提供者的外掛程式實體永遠不會被固定,pull 與建置都不會取得它的 .wasm,所以在 Release 解析時檔案必須已經在那裡。pull 會在寫入鎖定檔之前檢查:如果它在實體旁邊,或建置讀取外掛程式的任何其他地方都找不到 .wasm,它會停止並指出檔案與它預期的目錄,如 A plugin’s .wasm is not on this machine(外掛程式的模組檔不在本機上)所述。
在 .aggrega-config.yaml 中,讓工作區指向兩個目錄資料夾:
workspace: catalog_dirs: - catalog - dev-catalogauto_pull: trueauto_pull 讓 aggrega build 在處理程序內解析 Release,因此第一次建置不需要另外的解析步驟。
6. 以提供者為目標的文件
四個檔案。Component 宣告作者可以設定什麼;Recipe 繫結能力並撰寫成品;Aggregate 陳述意圖;Release 加以安置。
catalog/component/example/compute/checkout/1.0.0/component.yaml:
apiVersion: aggrega.ai/v1beta1kind: Componentmetadata: name: example/compute/checkout version: 1.0.0 description: An application whose configuration is delivered as an environment file. labels: component.aggrega.ai/type: server component.aggrega.ai/category: computespec: schema: values: service_name: type: string default: checkout description: The name the application reports itself under. log_level: type: string default: info description: The application's log verbosity. greeting: type: string default: hello description: A value carrying characters the environment-file format must quote. infra: endpoint: type: string default: http://localhost:8080 description: The endpoint the operator points the application at.catalog/recipe/dotenv/checkout/1.0.0/recipe.yaml:
apiVersion: aggrega.ai/v1beta1kind: Recipemetadata: name: checkout version: 1.0.0 description: Renders the application's configuration as an environment file.spec: capability: dotenv implements: example/compute/checkout:1.0.0
artifacts: app.env: | service-name = {{ .values.service_name }} log.level = {{ .values.log_level }} greeting = {{ .values.greeting }} endpoint = {{ .infra.endpoint }}spec.capability: dotenv 就是整個繫結。它指名的是能力,而不是外掛程式:建置會把它解析到宣告該能力的任何提供者外掛程式。恰好有一個這樣的外掛程式時——如這裡——就不需要其他東西。
撰寫的鍵刻意不是環境變數的形式。service-name 與 log.level 是作者自然會寫的拼法,而將它們正規化是提供者的工作。
aggregate.yaml:
apiVersion: aggrega.ai/v1beta1kind: Aggregatemetadata: name: aggregate version: "1.0.0" description: One application whose configuration is an environment file.spec: components: app: type: example/compute/checkout values: service_name: checkout log_level: debug greeting: hello worldmanifest.yaml:
apiVersion: aggrega.ai/v1beta1kind: Manifestmetadata: name: manifest version: "1.0.0" description: Binds the component type to the environment-file recipe.spec: mappings: components: type: example/compute/checkout:1.0.0: checkout:1.0.0release.yaml:
apiVersion: aggrega.ai/v1beta1kind: Releasemetadata: name: walkthrough environment: production version: "1.0.0"spec: aggregate: aggregate manifest: manifest boundaries: infra: directory: infra components: app: infra: endpoint: "https://checkout.example.net"7. 第一次建置,以及它拒絕的東西
aggrega build --release release.yaml --auto-pull warning: plugin "provider/dotenv" resolved from local with no recorded digest to check it against, so it runs unverified; it is read from beside its Plugin entity in a catalog directory on every build, and a pull records its digest only for a plugin attached at a transform role; otherwise publish the plugin and reference the published entity to have its digest recorded[… omitted: the notice saying the Release could not be rendered to discover its external inputs, carrying the error below beneath its first line]Pull complete: release.lock (entities=5, source_artifacts=0, external_inputs=0)[… omitted: a line saying again that external inputs were not fully discovered][CATALOG_ERROR E0265] instance app provider does not support the node's input kind (node "app"). provider "dotenv" does not support artifacts-only recipes (this provider supports: none); declare one of the supported input kinds, or target a provider that supports artifacts-only請分開閱讀這兩行,因為它們說的是不同的事。
開發期間出現警告是預期中的,而且不會消失。 它說的是客體在執行時,沒有已記錄的內容摘要可以用來檢查,這正是你一分鐘前才建置的客體的真實情況:沒有任何東西發布過它,所以沒有任何摘要記錄。它也說明了為什麼再次解析 Release 不會改變這一點——從目錄資料夾中其實體旁邊讀取的客體,每次建置都會重新讀取,而 pull 只會為附加在轉換角色的治理外掛程式記錄摘要,這個客體不是——以及什麼能改變:發布該外掛程式並參照已發布的實體。請把警告當作建置正確地拒絕宣稱它並未執行的驗證,只要客體還在本機,就預期會看到它。
錯誤才是真正的發現,而括號就是診斷。 提供者被找到、載入,並被詢問它渲染什麼,它回答 none——this provider supports: none。一開始寫的描述項指名了插槽、能力與匯出,卻從未說明客體處理三種 Recipe 輸入種類中的哪一種。主機不會猜測:輸入種類關卡會讀取客體宣告的集合,並拒絕客體從未聲明的節點。
這是大多數第一個提供者失敗的樣子。客體沒問題;它的自我回報不完整。describe() 不是主機勉強容忍的形式——它是與格式無關的主機決定把什麼送到哪裡的全部依據。
8. 宣告渲染行為契約
把契約加入 guest/main.go 中的描述項:
Capabilities: []string{"dotenv"}, Contract: &aggrega.ProviderContract{ InputKinds: aggrega.InputKinds{ Sourced: false, Synthesized: false, ArtifactsStandalone: true, }, BoundaryAssembly: "none", }, Exports: []aggrega.PluginExport{ArtifactsStandalone: true 就是關卡所尋找的聲明。兩個 false 值也是聲明,而把它們寫出來正是重點:vendor 一棵來源樹的 Recipe,或宣告工作負載的 Recipe,現在會在任何渲染開始之前就被拒絕,並附上指名這個提供者的訊息——而不是進到 render_node 之後在其內部某處失敗。
BoundaryAssembly: "none" 表示每個節點的輸出寫在它落地的位置,沒有東西要合併。把多個元件摺疊成一份文件的提供者,改為宣告 merge 或 nest,並匯出 assemble_boundary 來完成它。這是為這個提供者自然會新增的下一件事,並記載於外掛程式契約。
重建客體、重新產生實體,並把新的 .wasm 放回它旁邊:
cd guestGOWORK=off GOOS=wasip1 GOARCH=wasm go build -trimpath -buildvcs=false \ -ldflags "-X github.com/aggrega-ai/aggrega-pdk/go/pkg/aggrega.Version=0.1.0 \ -X github.com/aggrega-ai/aggrega-pdk/go/pkg/aggrega.Commit=walkthru" \ -buildmode=c-shared -o ../dotenv.wasm ./cd ..aggrega plugin gen-catalog --plugin dotenv.wasm \ --overlay overlay.yaml --output-dir dev-catalog/plugincp dotenv.wasm dev-catalog/plugin/provider/dotenv/0.1.0/provider--dotenv.wasm重新產生的實體現在帶有從二進位檔讀出的契約:
[… omitted: the header comments and the metadata block, unchanged from the first generation]spec: abiVersion: v1beta1 exports: - name: render_node provider: capabilities: - dotenv contract: inputKinds: artifactsStandalone: true boundaryAssembly: none每次重建客體後重新產生實體,是這個迴圈的一部分。 實體重述二進位檔回報的內容,而客體載入時會交叉檢查兩者:實體聲稱而二進位檔未回報的匯出或契約值,是建置會中止並指出該聲稱的不一致。實體省略的聲稱則不會被檢查,因此在二進位檔新增了內容的重建之後(如這一步)遺留下來的實體仍會載入,卻不再描述它。
9. 渲染的建置
aggrega build --release release.yaml --auto-pull warning: plugin "provider/dotenv" resolved from local with no recorded digest to check it against, so it runs unverified; it is read from beside its Plugin entity in a catalog directory on every build, and a pull records its digest only for a plugin attached at a transform role; otherwise publish the plugin and reference the published entity to have its digest recordedPull complete: release.lock (entities=5, source_artifacts=0, external_inputs=0)[… omitted: a line reporting total build time, which differs on every run]Build completed: 1 file written to <workspace>/dist結尾的那一行會完整指出輸出目錄,其中 <workspace> 代表工作區根目錄。其下渲染出的樹狀結構:
dist/infra/dotenv/app/app.env以及提供者寫出的檔案,完整內容:
# aggrega.ai/boundary-path=infraSERVICE_NAME=checkoutLOG_LEVEL=debugGREETING="hello world"ENDPOINT=https://checkout.example.net客體做的每個決定,都看得到在這七行之中。
service-name與log.level以撰寫時的樣子抵達,並以SERVICE_NAME與LOG_LEVEL離開。作者從來不必寫出目標的語法。GREETING有加引號,其他三個沒有。hello world含有空格,所以不加引號的話會在hello結束;端點不含任何格式視為語法的字元,因此加引號只會增加雜訊。- 兩個出處鍵是註解,因為環境檔案沒有別的地方可放。輸出有中繼資料區塊的提供者,會改把同樣的鍵放在那裡。主機計算了鍵;客體選擇了位置。
- 這些值來自兩位不同的作者。
service_name、log_level與greeting是開發者的意圖,來自 Aggregate。endpoint是操作員的,來自 Release。客體看不出這兩者的差別——它收到的是一份已評估的主體。
10. 信任它之前值得檢查的兩件事
它是確定性的。 擷取輸出,重建,然後比較:
cp -r dist ../capture && rm -rf distaggrega build --release release.yamldiff -r ../capture distdiff 什麼都沒印出,就是你想要的結果。決定性是客體的契約,不是主機的,而在輸出路徑某處迭代 Go map 的客體,會在這項檢查失敗,卻在單次建置中看起來完全正確。
它的拒絕是明確的。 破壞 Recipe 成品的其中一行,讓它沒有宣告任何值:
artifacts: app.env: | service-name = {{ .values.service_name }} this line declares no value[… omitted: the unverified-plugin warning, and the pull's lines saying the Release could not be rendered to discover its external inputs][CATALOG_ERROR] instance app rendering node "app" caused by: wasm: plugin "provider/dotenv:0.1.0" call to render_node: dotenv: app.env line 2: "this line declares no value" declares no value; an entry is KEY=value客體自己的訊息會完整抵達作者,連同它來自的檔案與行。這值得刻意檢查,因為另一種失敗——客體悄悄略過它無法解析的一行——會產生成功的建置,以及缺少某個變數的部署,而輸出中沒有任何東西這樣告訴你。
11. 接下來要新增什麼
這裡建置的提供者是完整的,但很精簡。以下大致依各項被需要的頻率排序:
-
assemble_boundary,把多個元件的輸出摺疊成一份文件,透過BoundaryAssembly宣告。 -
validate_node_input,在任何渲染開始之前,以結構方式檢查節點的輸入,讓格式錯誤的輸入在撰寫邊界就被回報,而不是在渲染中途。 -
渲染事實,用來回報關於客體所寫內容的某些事,這些事只有這個提供者對環境檔案格式的認識才看得到——這裡是每個檔案所定義的變數名稱。事實是一個名稱加上一份清單,兩者都是這個提供者自己的詞彙,與檔案一起回傳——而且值永遠是 JSON 陣列,即使只有一個項目,否則建置會中止:
// names lists the variables the files define, in the order they were written.value, err := json.Marshal(names)if err != nil {pdk.SetError(fmt.Errorf("dotenv: marshal render fact: %w", err))return 1}out := aggrega.RenderNodeOutput{Files: files,RenderFacts: []aggrega.RenderFact{{Name: "variable_names", Value: value}},}編譯器依客體列出的順序保留這些事實,只檢查每個值是不是清單,把清單交給讀取它們的 Feature 範本,而且無論是否回報它們,都寫出相同的檔案。請把每個事實的名稱及其項目所含的內容,記載為提供者契約的一部分。
-
省略項目,在提供者渲染來源之後。來源渲染的輸入可以在其
SourceListing旁帶有Omits,也就是指名要省略的已渲染單元的項目;遵守它們的提供者,會把每個符合的單元從它回傳的內容中省略,在Omitted中為每個項目回報一個計數,並在其契約上宣告Omits: true。它們絕不會伴隨像這個提供者這樣的僅有成品渲染,所以它只有在渲染來源式輸入之後才會遇到它們。外掛程式契約中的省略已渲染的單元有完整的形狀。 -
發布,把本機的
dev-catalog安排變成 Release 解析並驗證、以摘要固定的成品。外掛程式開發者指南在發布、pull 與建置各階段之下涵蓋該生命週期。
每個插槽的酬載與結果形狀,都在外掛程式契約中。
相關參考
- Wasm 外掛程式開發者指南——
Plugin實體、能力介面,以及發布生命週期。 - Plugin 契約 — 每個插槽的輸入與輸出形狀。
- Provider 架構 — 提供者如何融入編譯管線。
- Provider 參考索引 — 每個標準程式庫提供者會產生什麼。
- 閱讀本頁的輸出——上述輸出區塊所遵循的慣例。