Skip to content

Conversation

@rStelmach
Copy link
Contributor

TL;DR

  • Streams OAS / Zod has been reshaped so that Streamlang conditions, steps, ingest lifecycle, _ingest, and _group are all strongly typed in the generated Go client (no more interface{} / json.RawMessage for these parts).
  • We regenerated the full kibana.yaml from this branch and confirmed that a Terraform POC can use a client generated from it via a new elasticstack_kibana_stream resource.
  • On the Terraform side, we added Streams client helpers, a new stream resource schema, flatten/expand utilities, and a small internal condition DSL, proving that the new OAS is working as expected.

Background

  • Previously, key parts of Streams (Streamlang conditions, processing steps, ingest lifecycle) were expressed as anonymous unions in OAS, which generated interface{}/json.RawMessage in Go.
  • That made it hard to expose Streams as a strongly typed Terraform resource without custom JSON handling.
  • This work makes the Streams OAS generator‑friendly and ensures the generated Go client exposes concrete types for the write APIs Terraform cares about.

Kibana: Streams + OAS changes (this PR)

  • Streamlang conditions

    • conditionSchema stays a z.discriminatedUnion('type', ['filter','and','or','not','never','always']) and is tagged as @kbn/oas-component:StreamlangCondition.
    • The router‑to‑OAS converter extracts it as components.schemas.StreamlangCondition and rewrites recursive positions (and.items, or.items, not) to self‑$ref.
    • Result: in kibana.yaml / Go, all recursive condition slots are StreamlangCondition (And []StreamlangCondition, Or []StreamlangCondition, Not StreamlangCondition), not interface{}.
  • Streamlang steps

    • Processor steps and where‑blocks now carry an optional kind discriminator and are wrapped into a StreamlangStep union, tagged as @kbn/oas-component:StreamlangStep.
    • The converter rewrites all processing.steps.items (including nested where.steps) to $ref: '#/components/schemas/StreamlangStep'.
    • Result: processing.steps is []StreamlangStep in Go, with proper union wrappers instead of []interface{}.
  • Ingest lifecycle

    • Lifecycle moved from marker‑object unions (e.g. { dsl: {...} } | { ilm: {...} } | { inherit: {} }) to a type‑tagged discriminated union.
    • Preprocessors infer type from legacy keys on read so existing documents stay valid.
    • Result: ingest.lifecycle is a tagged union in OAS and a set of concrete structs in Go.
  • GET/DELETE request bodies

    • Added isVoidRequestBodySchema to the router‑to‑OAS layer to detect the z.undefined() sentinel and drop operation.requestBody for real body‑less GET/DELETE routes.
    • Result: Streams GET /api/streams* and DELETE /api/streams* no longer have bogus request bodies, and the generated client drops the ...JSONBody = interface{} aliases and WithBody helpers for those operations.
  • Full OAS regeneration

    • Enabled server.oas.enabled, captured a clean Streams‑only snapshot (for linting) and then regenerated the full OAS to oas_docs/output/kibana.yaml.
    • Verified that regenerating the Go client against this full spec preserves existing behavior while exposing the new strong types for Streams.

terraform's PR : elastic/terraform-provider-elasticstack#1473

@elasticmachine
Copy link
Contributor

🤖 Jobs for this PR can be triggered through checkboxes. 🚧

ℹ️ To trigger the CI, please tick the checkbox below 👇

  • Click to trigger kibana-pull-request for this PR!
  • Click to trigger kibana-deploy-project-from-pr for this PR!
  • Click to trigger kibana-deploy-cloud-from-pr for this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants