Skip to content

Commit 052ede7

Browse files
fix: Fix the JSON schema of JsonConfigOverrides (#1245)
* fix: Fix the JSON schema of JsonConfigOverrides * test: Test JsonConfigOverrides in the DummyCluster instead of a unit test * Extend the documentation of the userProvided JsonConfigOverrides
1 parent bf80520 commit 052ede7

4 files changed

Lines changed: 52 additions & 17 deletions

File tree

crates/stackable-operator/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ All notable changes to this project will be documented in this file.
77
### Fixed
88

99
- [v2] Don't require the `attributed_string_type` macro caller to have `std::str::FromStr` in scope ([#1244]).
10+
- [v2] Fix the JSON schema of `JsonConfigOverrides` ([#1245]).
1011

1112
[#1244]: https://github.com/stackabletech/operator-rs/pull/1244
13+
[#1245]: https://github.com/stackabletech/operator-rs/pull/1245
1214

1315
## [0.113.2] - 2026-07-07
1416

crates/stackable-operator/crds/DummyCluster.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ spec:
979979
- required:
980980
- jsonMergePatch
981981
- required:
982-
- jsonPatches
982+
- jsonPatch
983983
- required:
984984
- userProvided
985985
properties:
@@ -989,22 +989,23 @@ spec:
989989
[RFC 7396](https://datatracker.ietf.org/doc/html/rfc7396) JSON merge patch.
990990
type: object
991991
x-kubernetes-preserve-unknown-fields: true
992-
jsonPatches:
992+
jsonPatch:
993993
description: |-
994-
List of [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patches.
994+
An [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patch.
995995
996996
Can be used when more flexibility is needed, e.g. to only modify elements
997997
in a list based on a condition.
998998
999999
A patch looks something like
10001000
1001-
`{"op": "test", "path": "/0/name", "value": "Andrew"}`
1001+
`- {"op": "test", "path": "/0/name", "value": "Andrew"}`
10021002
10031003
or
10041004
1005-
`{"op": "add", "path": "/0/happy", "value": true}`
1005+
`- {"op": "add", "path": "/0/happy", "value": true}`
10061006
items:
1007-
type: string
1007+
type: object
1008+
x-kubernetes-preserve-unknown-fields: true
10081009
type: array
10091010
userProvided:
10101011
description: |-
@@ -1657,7 +1658,7 @@ spec:
16571658
- required:
16581659
- jsonMergePatch
16591660
- required:
1660-
- jsonPatches
1661+
- jsonPatch
16611662
- required:
16621663
- userProvided
16631664
properties:
@@ -1667,22 +1668,23 @@ spec:
16671668
[RFC 7396](https://datatracker.ietf.org/doc/html/rfc7396) JSON merge patch.
16681669
type: object
16691670
x-kubernetes-preserve-unknown-fields: true
1670-
jsonPatches:
1671+
jsonPatch:
16711672
description: |-
1672-
List of [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patches.
1673+
An [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patch.
16731674
16741675
Can be used when more flexibility is needed, e.g. to only modify elements
16751676
in a list based on a condition.
16761677
16771678
A patch looks something like
16781679
1679-
`{"op": "test", "path": "/0/name", "value": "Andrew"}`
1680+
`- {"op": "test", "path": "/0/name", "value": "Andrew"}`
16801681
16811682
or
16821683
1683-
`{"op": "add", "path": "/0/happy", "value": true}`
1684+
`- {"op": "add", "path": "/0/happy", "value": true}`
16841685
items:
1685-
type: string
1686+
type: object
1687+
x-kubernetes-preserve-unknown-fields: true
16861688
type: array
16871689
userProvided:
16881690
description: |-

crates/stackable-operator/src/v2/config_overrides.rs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ use serde_json::json;
99
use tracing::warn;
1010

1111
use crate::{
12-
config::merge::Merge, k8s_openapi::DeepMerge, schemars, utils::crds::raw_object_schema,
12+
config::merge::Merge,
13+
k8s_openapi::DeepMerge,
14+
schemars,
15+
utils::crds::{raw_object_list_schema, raw_object_schema},
1316
};
1417

1518
// Variant of [`crate::config_overrides::KeyValueConfigOverrides`] that implements
@@ -93,10 +96,34 @@ pub enum JsonConfigOverrides {
9396
/// or
9497
///
9598
/// `- {"op": "add", "path": "/0/happy", "value": true}`
96-
#[schemars(schema_with = "raw_object_schema")]
99+
#[schemars(schema_with = "raw_object_list_schema")]
97100
JsonPatch(json_patch::Patch),
98101

99-
/// Override the entire config file with the specified JSON value.
102+
/// Override the entire config file with the specified JSON document.
103+
///
104+
/// Please note that you can in-line JSON into YAML as follows:
105+
///
106+
/// ```yaml
107+
/// # ... other YAML content
108+
/// userProvided: {
109+
/// "myString": "test",
110+
/// "myList": ["test"],
111+
/// "myBool": true,
112+
/// "my": {"nested.field.with.dots": 42}
113+
/// }
114+
/// ```
115+
///
116+
/// As an alternative you can also stick to YAML:
117+
///
118+
/// ```yaml
119+
/// # ... other YAML content
120+
/// userProvided:
121+
/// myString: test
122+
/// myList: [test]
123+
/// myBool: true
124+
/// my:
125+
/// nested.field.with.dots: 42
126+
/// ```
100127
#[schemars(schema_with = "raw_object_schema")]
101128
UserProvided(serde_json::Value),
102129

crates/xtask/src/crd/dummy.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ use serde::{Deserialize, Serialize};
44
use stackable_operator::{
55
commons::resources::{JvmHeapLimits, Resources},
66
config::fragment::Fragment,
7-
config_overrides::{JsonConfigOverrides, KeyValueConfigOverrides, KeyValueOverridesProvider},
8-
crd::{authentication, authentication::oidc, git_sync::v1alpha2::GitSync},
7+
config_overrides::{KeyValueConfigOverrides, KeyValueOverridesProvider},
8+
crd::{
9+
authentication::{self, oidc},
10+
git_sync::v1alpha2::GitSync,
11+
},
912
database_connections::{
1013
databases::{
1114
derby::DerbyConnection, mysql::MysqlConnection, postgresql::PostgresqlConnection,
@@ -21,6 +24,7 @@ use stackable_operator::{
2124
role_utils::Role,
2225
schemars::JsonSchema,
2326
status::condition::ClusterCondition,
27+
v2::config_overrides::JsonConfigOverrides,
2428
versioned::versioned,
2529
};
2630
use strum::EnumIter;

0 commit comments

Comments
 (0)