Skip to content

Commit 8d9c6cd

Browse files
committed
fix: addressed first round of review feedback
1 parent b261cc6 commit 8d9c6cd

File tree

3 files changed

+54
-24
lines changed

3 files changed

+54
-24
lines changed

crates/stackable-operator/crds/DummyCluster.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,56 @@ spec:
164164
type: object
165165
hostName:
166166
type: string
167+
jsonConfigOverrides:
168+
nullable: true
169+
oneOf:
170+
- required:
171+
- jsonMergePatch
172+
- required:
173+
- jsonPatches
174+
- required:
175+
- userProvided
176+
properties:
177+
jsonMergePatch:
178+
description: |-
179+
Can be set to arbitrary YAML content, which is converted to JSON and used as
180+
[RFC 7396](https://datatracker.ietf.org/doc/html/rfc7396) JSON merge patch.
181+
type: object
182+
x-kubernetes-preserve-unknown-fields: true
183+
jsonPatches:
184+
description: |-
185+
List of [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patches.
186+
187+
Can be used when more flexibility is needed, e.g. to only modify elements
188+
in a list based on a condition.
189+
190+
A patch looks something like
191+
192+
`{"op": "test", "path": "/0/name", "value": "Andrew"}`
193+
194+
or
195+
196+
`{"op": "add", "path": "/0/happy", "value": true}`
197+
items:
198+
type: string
199+
type: array
200+
userProvided:
201+
description: Override the entire config file with the specified String.
202+
type: string
203+
type: object
167204
kerberosRealmName:
168205
description: A validated kerberos realm name type, for use in CRDs.
169206
type: string
207+
keyValueConfigOverrides:
208+
additionalProperties:
209+
type: string
210+
description: |-
211+
Flat key-value overrides for `*.properties`, Hadoop XML, etc.
212+
213+
This is backwards-compatible with the existing flat key-value YAML format
214+
used by `HashMap<String, String>`.
215+
nullable: true
216+
type: object
170217
nodes:
171218
description: |-
172219
This struct represents a role - e.g. HDFS datanodes or Trino workers. It has a key-value-map containing

crates/stackable-operator/src/config_overrides.rs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,11 @@
77
88
use std::collections::{BTreeMap, HashMap};
99

10-
use schemars::{JsonSchema, Schema, json_schema};
10+
use schemars::JsonSchema;
1111
use serde::{Deserialize, Serialize};
1212
use snafu::{ResultExt, Snafu};
1313

14-
/// Generates a JSON schema that accepts any JSON value.
15-
///
16-
/// Kubernetes CRDs do not support the `true` schema shorthand that
17-
/// `serde_json::Value` generates by default. Instead we emit a schema
18-
/// with `x-kubernetes-preserve-unknown-fields: true` which tells the
19-
/// API server to store the value as-is.
20-
fn arbitrary_json_value(_gen: &mut schemars::generate::SchemaGenerator) -> Schema {
21-
json_schema!({
22-
"x-kubernetes-preserve-unknown-fields": true,
23-
})
24-
}
25-
26-
/// Generates a JSON schema for a list of JSON patch operation strings (RFC 6902).
27-
fn json_patch_string_list(_gen: &mut schemars::generate::SchemaGenerator) -> Schema {
28-
json_schema!({
29-
"type": "array",
30-
"items": {
31-
"type": "string",
32-
},
33-
})
34-
}
14+
use crate::utils::crds::raw_object_schema;
3515

3616
#[derive(Debug, Snafu)]
3717
pub enum Error {
@@ -107,7 +87,7 @@ impl KeyValueConfigOverrides {
10787
pub enum JsonConfigOverrides {
10888
/// Can be set to arbitrary YAML content, which is converted to JSON and used as
10989
/// [RFC 7396](https://datatracker.ietf.org/doc/html/rfc7396) JSON merge patch.
110-
#[schemars(schema_with = "arbitrary_json_value")]
90+
#[schemars(schema_with = "raw_object_schema")]
11191
JsonMergePatch(serde_json::Value),
11292

11393
/// List of [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patches.
@@ -122,7 +102,6 @@ pub enum JsonConfigOverrides {
122102
/// or
123103
///
124104
/// `{"op": "add", "path": "/0/happy", "value": true}`
125-
#[schemars(schema_with = "json_patch_string_list")]
126105
JsonPatches(Vec<String>),
127106

128107
/// Override the entire config file with the specified String.

crates/xtask/src/crd/dummy.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ pub mod versioned {
5454
#[serde(default)]
5555
pub object_overrides: ObjectOverrides,
5656

57+
json_config_overrides: Option<stackable_operator::config_overrides::JsonConfigOverrides>,
58+
key_value_config_overrides:
59+
Option<stackable_operator::config_overrides::KeyValueConfigOverrides>,
60+
5761
// Already versioned
5862
client_authentication_details:
5963
stackable_operator::crd::authentication::core::v1alpha1::ClientAuthenticationDetails,

0 commit comments

Comments
 (0)