Skip to content

Commit b0e1dc8

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

File tree

4 files changed

+64
-23
lines changed

4 files changed

+64
-23
lines changed

crates/stackable-operator/crds/DummyCluster.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,55 @@ 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+
x-kubernetes-preserve-unknown-fields: true
182+
jsonPatches:
183+
description: |-
184+
List of [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patches.
185+
186+
Can be used when more flexibility is needed, e.g. to only modify elements
187+
in a list based on a condition.
188+
189+
A patch looks something like
190+
191+
`{"op": "test", "path": "/0/name", "value": "Andrew"}`
192+
193+
or
194+
195+
`{"op": "add", "path": "/0/happy", "value": true}`
196+
items:
197+
type: string
198+
type: array
199+
userProvided:
200+
description: Override the entire config file with the specified String.
201+
type: string
202+
type: object
167203
kerberosRealmName:
168204
description: A validated kerberos realm name type, for use in CRDs.
169205
type: string
206+
keyValueConfigOverrides:
207+
additionalProperties:
208+
type: string
209+
description: |-
210+
Flat key-value overrides for `*.properties`, Hadoop XML, etc.
211+
212+
This is backwards-compatible with the existing flat key-value YAML format
213+
used by `HashMap<String, String>`.
214+
nullable: true
215+
type: object
170216
nodes:
171217
description: |-
172218
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: 2 additions & 23 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::arbitrary_json_value;
3515

3616
#[derive(Debug, Snafu)]
3717
pub enum Error {
@@ -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/stackable-operator/src/utils/crds.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ pub fn raw_optional_object_schema(_: &mut schemars::generate::SchemaGenerator) -
1515
})
1616
}
1717

18+
/// Generates a JSON schema that accepts any JSON value.
19+
///
20+
/// Kubernetes CRDs do not support the `true` schema shorthand that
21+
/// `serde_json::Value` generates by default. Instead we emit a schema
22+
/// with `x-kubernetes-preserve-unknown-fields: true` which tells the
23+
/// API server to store the value as-is.
24+
pub fn arbitrary_json_value(_: &mut schemars::generate::SchemaGenerator) -> Schema {
25+
json_schema!({
26+
"x-kubernetes-preserve-unknown-fields": true,
27+
})
28+
}
29+
1830
pub fn raw_object_list_schema(_: &mut schemars::generate::SchemaGenerator) -> Schema {
1931
json_schema!({
2032
"type": "array",

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)