diff --git a/crates/stackable-operator/CHANGELOG.md b/crates/stackable-operator/CHANGELOG.md index 7f54726ef..9036f8554 100644 --- a/crates/stackable-operator/CHANGELOG.md +++ b/crates/stackable-operator/CHANGELOG.md @@ -7,8 +7,10 @@ All notable changes to this project will be documented in this file. ### Fixed - [v2] Don't require the `attributed_string_type` macro caller to have `std::str::FromStr` in scope ([#1244]). +- [v2] Fix the JSON schema of `JsonConfigOverrides` ([#1245]). [#1244]: https://github.com/stackabletech/operator-rs/pull/1244 +[#1245]: https://github.com/stackabletech/operator-rs/pull/1245 ## [0.113.2] - 2026-07-07 diff --git a/crates/stackable-operator/crds/DummyCluster.yaml b/crates/stackable-operator/crds/DummyCluster.yaml index 79692113e..ac014b438 100644 --- a/crates/stackable-operator/crds/DummyCluster.yaml +++ b/crates/stackable-operator/crds/DummyCluster.yaml @@ -979,7 +979,7 @@ spec: - required: - jsonMergePatch - required: - - jsonPatches + - jsonPatch - required: - userProvided properties: @@ -989,22 +989,23 @@ spec: [RFC 7396](https://datatracker.ietf.org/doc/html/rfc7396) JSON merge patch. type: object x-kubernetes-preserve-unknown-fields: true - jsonPatches: + jsonPatch: description: |- - List of [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patches. + An [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patch. Can be used when more flexibility is needed, e.g. to only modify elements in a list based on a condition. A patch looks something like - `{"op": "test", "path": "/0/name", "value": "Andrew"}` + `- {"op": "test", "path": "/0/name", "value": "Andrew"}` or - `{"op": "add", "path": "/0/happy", "value": true}` + `- {"op": "add", "path": "/0/happy", "value": true}` items: - type: string + type: object + x-kubernetes-preserve-unknown-fields: true type: array userProvided: description: |- @@ -1657,7 +1658,7 @@ spec: - required: - jsonMergePatch - required: - - jsonPatches + - jsonPatch - required: - userProvided properties: @@ -1667,22 +1668,23 @@ spec: [RFC 7396](https://datatracker.ietf.org/doc/html/rfc7396) JSON merge patch. type: object x-kubernetes-preserve-unknown-fields: true - jsonPatches: + jsonPatch: description: |- - List of [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patches. + An [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patch. Can be used when more flexibility is needed, e.g. to only modify elements in a list based on a condition. A patch looks something like - `{"op": "test", "path": "/0/name", "value": "Andrew"}` + `- {"op": "test", "path": "/0/name", "value": "Andrew"}` or - `{"op": "add", "path": "/0/happy", "value": true}` + `- {"op": "add", "path": "/0/happy", "value": true}` items: - type: string + type: object + x-kubernetes-preserve-unknown-fields: true type: array userProvided: description: |- diff --git a/crates/stackable-operator/src/v2/config_overrides.rs b/crates/stackable-operator/src/v2/config_overrides.rs index 2b404ea99..ff40cf68d 100644 --- a/crates/stackable-operator/src/v2/config_overrides.rs +++ b/crates/stackable-operator/src/v2/config_overrides.rs @@ -9,7 +9,10 @@ use serde_json::json; use tracing::warn; use crate::{ - config::merge::Merge, k8s_openapi::DeepMerge, schemars, utils::crds::raw_object_schema, + config::merge::Merge, + k8s_openapi::DeepMerge, + schemars, + utils::crds::{raw_object_list_schema, raw_object_schema}, }; // Variant of [`crate::config_overrides::KeyValueConfigOverrides`] that implements @@ -93,10 +96,34 @@ pub enum JsonConfigOverrides { /// or /// /// `- {"op": "add", "path": "/0/happy", "value": true}` - #[schemars(schema_with = "raw_object_schema")] + #[schemars(schema_with = "raw_object_list_schema")] JsonPatch(json_patch::Patch), - /// Override the entire config file with the specified JSON value. + /// Override the entire config file with the specified JSON document. + /// + /// Please note that you can in-line JSON into YAML as follows: + /// + /// ```yaml + /// # ... other YAML content + /// userProvided: { + /// "myString": "test", + /// "myList": ["test"], + /// "myBool": true, + /// "my": {"nested.field.with.dots": 42} + /// } + /// ``` + /// + /// As an alternative you can also stick to YAML: + /// + /// ```yaml + /// # ... other YAML content + /// userProvided: + /// myString: test + /// myList: [test] + /// myBool: true + /// my: + /// nested.field.with.dots: 42 + /// ``` #[schemars(schema_with = "raw_object_schema")] UserProvided(serde_json::Value), diff --git a/crates/xtask/src/crd/dummy.rs b/crates/xtask/src/crd/dummy.rs index b1e070768..67cbbfe11 100644 --- a/crates/xtask/src/crd/dummy.rs +++ b/crates/xtask/src/crd/dummy.rs @@ -4,8 +4,11 @@ use serde::{Deserialize, Serialize}; use stackable_operator::{ commons::resources::{JvmHeapLimits, Resources}, config::fragment::Fragment, - config_overrides::{JsonConfigOverrides, KeyValueConfigOverrides, KeyValueOverridesProvider}, - crd::{authentication, authentication::oidc, git_sync::v1alpha2::GitSync}, + config_overrides::{KeyValueConfigOverrides, KeyValueOverridesProvider}, + crd::{ + authentication::{self, oidc}, + git_sync::v1alpha2::GitSync, + }, database_connections::{ databases::{ derby::DerbyConnection, mysql::MysqlConnection, postgresql::PostgresqlConnection, @@ -21,6 +24,7 @@ use stackable_operator::{ role_utils::Role, schemars::JsonSchema, status::condition::ClusterCondition, + v2::config_overrides::JsonConfigOverrides, versioned::versioned, }; use strum::EnumIter;