Repository navigation
kubectl-ate: create every actor-template in a multi-document manifest - #4102
Peter Pan (panpan0000) wants to merge 3 commits into
Conversation
324b949 to
258a766
Compare
| // instance of msg's message type. YAML is a superset of JSON, so one decoder | ||
| // parses both. Documents are split on "---" the way kubectl splits them, and | ||
| // empty documents are skipped. Parsing is strict: unknown fields are an error. | ||
| func manifestMessages(data []byte, msg proto.Message) ([]proto.Message, error) { |
There was a problem hiding this comment.
🤖 question 🟢 – Should this parser live in internal/manifest (here or in a follow-up) so cmd/ate-setup/internal/steps/substrate.go:63 (ActorTemplateFromManifest, which still calls yaml.YAMLToJSON directly and drops trailing documents) and internal/e2e/fixture.go:67 (decodeSubstrateTemplates, which splits on "\n---") share the same implementation? Both already document matching kubectl ate create actor-template.
There was a problem hiding this comment.
Thanks! I suggest moving the parser and updating both callers in a follow-up to keep this PR focused.
|
Context for reviewers, since
Please update the PR description to drop the dead |
actorTemplateFromManifest parsed only the first document and silently dropped the rest. Parse all documents and create each one in order, continuing past failures and reporting them together, the way kubectl handles a multi-document file. The egress- and access-policy manifests keep their single-document contract through the same parser. Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>
258a766 to
0933121
Compare
|
Pushed 5847642 with fixes and tests for the output schema, errors, manifest wording, and parsing. I kept the parser in kubectl for now. Moving it and updating ate-setup and the e2e fixture can be a follow-up. Empty YAML documents are now skipped for all three manifest types; egress and access policies still reject multiple non-empty documents. |
Name the document in parse and create errors, keep the -o yaml/-o json schema stable when only some documents are created, and say that only YAML is a multi-document format. The parser and the runner are now covered by table tests, including both JSON objects without a separator, an unknown field in a second document, top-level sequences, YAML aliases, and a partial create. The parser stays in cmd/kubectl-ate/internal/cmd for now; sharing it with ate-setup and the e2e fixture is a follow-up. Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>
0933121 to
5847642
Compare
Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>
|
The PR description still has |
| wantIndexes: []int{1}, | ||
| }, | ||
| { | ||
| name: "block-style YAML documents", |
There was a problem hiding this comment.
🤖 nit 🟢 – This case uses flow-style mappings (metadata: {name: one}). Change the input to indented block style (metadata:\n name: one\n---\nmetadata:\n name: two\n) so it matches the test name, and optionally keep flow-style YAML as its own case.
| fail: map[string]error{"": status.Error(codes.InvalidArgument, "metadata is required")}, | ||
| wantCalls: []string{"one", ""}, | ||
| wantErrs: []string{"document 2: failed to create actor template: rpc error", "metadata is required"}, | ||
| // The empty metadata rendered as "/:" before the document was named. |
There was a problem hiding this comment.
🤖 nit 🟢 – Drop this comment referencing the earlier revision of the PR. Per AGENTS.md, comments should describe the final state of the code (for example, that missing metadata must not produce an empty atespace/name prefix).
kubectl ate create actor-template -fused to parse only the first YAML document and silently drop the rest. It now parses every document and creates each one in order, continuing past failures and reporting them together, the way kubectl handles a multi-document file. The egress- and access-policy manifests keep their single-document contract through the same parser.Related: #2157, which tracked multi-document support in
kubectl ate create actor-template.AI use:
AI-assisted; I reviewed the diff and ran
go test -race ./cmd/kubectl-ate/....Breaking change:
No. Note: empty YAML documents (a trailing
---, or comments between separators) are now skipped for every manifest, matching kubectl. The egress- and access-policy parsers previously rejected them.