You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(opensearchapi)!: regenerate with typed string enums
Regenerate opensearchapi and plugins after the osgen string-enum change.
Enum-like fields and query parameters that were plain string are now named
types with exported consts: NodeRole (cat-nodes, nodes-info), Result and
VersionType (write ops), TimeUnit (cat time params), OpType, SearchType,
and the rest. NodeRole now carries the search and warm roles.
BREAKING CHANGE: fields and query params across opensearchapi and plugins
change from string to named enum types (e.g. Roles []string -> []NodeRole,
Result string -> Result). Values still assign and compare as strings via
the named type; type-strict comparisons against untyped string literals
need the const (e.g. opensearchapi.ResultUpdated). Updates the one such
hand-written assertion in api_document_lifecycle_test.go.
Signed-off-by: Sean Chittenden <sean.chittenden@crowdstrike.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6
6
7
7
### Added
8
8
9
+
- `cmd/osgen`: emit enum-like `oneOf`-of-`{type: string, const: X}` schemas as named Go string types with one exported const per value (e.g. `type NodeRole string` with `NodeRoleData`, `NodeRoleSearch`, `NodeRoleWarm`, ...), instead of collapsing them to a plain `string`. The type is permissive: backed by `string`, `encoding/json` round-trips any value, so an unknown value a newer server or plugin introduces decodes cleanly rather than erroring (unlike the closed int-backed `RestStatus` enum, whose `UnmarshalJSON` rejects unknown values). No custom `(Un)MarshalJSON` is generated; the consts add discoverability, compile-time typo protection, and spec-driven drift detection. Detection is default-on for the const-`oneOf` shape (deny-list to opt out); branches are version-filtered, then reduced to values yielding a valid, unique Go const identifier and deduplicated by generated const name (collapsing `NodeRole`'s duplicate `search` across a version boundary and `TranslogDurability`'s `ASYNC`/`async` casing collision, reporting a dropped distinct value to stderr). Query parameters whose schema is a const-`oneOf` are typed too. Also bundles the `search` and `warm` node roles into the vendored spec ([#998](https://github.com/opensearch-project/opensearch-go/pull/998))
9
10
- Export the `opensearchapi` and plugin sub-client types (`documentClient` -> `DocumentClient`, `catClient` -> `CatClient`, plugin `roleClient` -> `RoleClient`, etc.), so each sub-client renders its own godoc page with a navigable method list instead of being an unexported type reachable only through a `Client` field. The change is additive and non-breaking: field access (`client.Doc.Get`) is unchanged, the `apiClient`/`client` back-pointer stays unexported so external populated construction remains impossible, and each generated type carries a doc comment noting it must be obtained via `NewClient` (the zero value is not usable). Adds a receiver-to-sub-client map to the `opensearchapi` package doc and generated package docs to the plugin packages that have sub-clients ([#989](https://github.com/opensearch-project/opensearch-go/pull/989))
10
11
- Add `VerifyDeadAfter` (`opensearch.Config` / `opensearchtransport.Config`, env override `OPENSEARCH_GO_VERIFY_DEAD_AFTER`): bounds how long a connection proven reachable may still be blindly resurrected as a last-resort "zombie" while dead. Each discovery cycle clears the viability mark on any non-seed connection that has been dead longer than the window, so a node that never recovers stops absorbing requests and must health-check clean again before it is routed to; seed connections are exempt. The env var accepts a boolean (`true` selects the 15m default, `false` disables the expiry) or a `time.ParseDuration` string; the `Config` field follows the `0` = default, `<0` = disabled, `>0` = explicit convention. See `guides/transport-routing.md` (Zombie Connection Resurrection and Connection Viability) and `guides/config-envvars.md`
11
12
- Add response observer events to `opensearchtransport.ConnectionObserver`: `OnRequestResponse(RequestResponseEvent)` fired once per request by `Transport.Request` (full-read duration, exact response-byte count) and `OnStreamResponse(StreamResponseEvent)` fired by `Transport.Stream` (time-to-first-byte, Content-Length header). Both events are flat value types passed by value, so the fire path is allocation-free and a nil observer costs nothing; `BaseConnectionObserver` gains no-op defaults so existing observers are unaffected. Adds `opensearchtransport.Transport.Request` (and an `opensearch.Client.Request` passthrough) as the buffered counterpart to `Stream`, through which `opensearch.Execute[T]` now routes
@@ -175,6 +176,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
175
176
176
177
### Changed
177
178
179
+
-**BREAKING**: `cmd/osgen` now types enum-like `oneOf`-of-const fields and query parameters across `opensearchapi` and the plugin packages, so fields and params that were `string` change to named enum types (e.g. `Roles []string` -> `Roles []NodeRole`, `Result string` -> `Result Result`, the `cat``time` param `string` -> `TimeUnit`, and similarly `OpType`, `SearchType`, `VersionType`, ...). Values still assign and compare as strings through the named type, so most call sites are unaffected; only type-strict comparisons against untyped string literals need the const (e.g. `require.Equal(t, opensearchapi.ResultUpdated, resp.Result)` instead of `"updated"`). ([#998](https://github.com/opensearch-project/opensearch-go/pull/998))
178
180
-`cmd/osapifix`: map the v4 -> v5 partial-failure type renames from `opensearchapi/UPGRADING_V4_TO_V5.md` in the v4 -> v5 hop, so code walking the per-shard failure slice migrates instead of silently breaking. `ResponseShards` -> `ShardStatistics` and `ResponseShardsFailure` -> `ShardSearchFailure` (dropping the removed `Primary`/`Status` fields) are rewritten; `DocumentError` -> `ErrorRespBase` is reported as a manual semantic followup because the two types share no fields. ([#963](https://github.com/opensearch-project/opensearch-go/pull/963))
179
181
- Add a first-class container-provider abstraction to the test harness `Makefile`. `CONTAINER_PROVIDER` is auto-detected by CLI presence in the order Colima -> Rancher Desktop (`rdctl`) -> Docker, and overridable with `CONTAINER_PROVIDER=colima|rancher|docker`. Selecting a provider pins the docker context (`colima` / `rancher-desktop`; the Docker provider leaves the active context alone, and a pre-set `DOCKER_CONTEXT` in the environment is respected), resolves the CLI runtime `$(CTR)` (now `docker` by default for every provider, with `CONTAINER_RUNTIME=nerdctl` as an advanced override), ensures the backing VM/daemon is running via the new `cluster.provider.ensure` target (wired into `cluster.start`), and sets `vm.max_map_count` through the provider's VM (`colima ssh` / `rdctl shell`) or a privileged helper container. Previously `$(CTR)` preferred `nerdctl` whenever it was on `PATH`, so a Rancher-installed `nerdctl` could hijack a Colima session. `make cluster.runtime` now reports the detected provider, docker context, and runtime
180
182
-**BREAKING**: Per-request transport metrics (`requests`, `failures`, responses-by-status) are now always collected via lock-free atomics, independent of `EnableMetrics`. `EnableMetrics` now gates only the detailed-metrics snapshot (per-connection, per-policy, and router state returned by `Metrics()`). The responses-by-status counter moved from a mutex-guarded map to a lock-free atomic array. `Metrics()` no longer returns an error when metrics are disabled -- it always returns the per-request counters (callers that branched on `if err != nil` for the disabled case should drop that check). See [`UPGRADING_V5.md`](UPGRADING_V5.md#metrics-error-on-disabled-removed) for migration. ([#891](https://github.com/opensearch-project/opensearch-go/issues/891))
0 commit comments