Skip to content

Commit 7bfd029

Browse files
feat: Support jsonPatch in configOverrides
1 parent e62d296 commit 7bfd029

8 files changed

Lines changed: 277 additions & 117 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.nix

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ stackable-operator = { git = "https://github.com/stackabletech/operator-rs.git",
1515
built = { version = "0.8.0", features = ["chrono", "git2"] }
1616
clap = "4.5"
1717
futures = { version = "0.3", features = ["compat"] }
18+
json-patch = { version = "4.2", features = ["schemars"] }
1819
pretty_assertions = "1.4"
1920
regex = "1.11"
2021
rstest = "0.26"

extra/crds.yaml

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,10 +1870,11 @@ spec:
18701870
default:
18711871
jsonMergePatch: {}
18721872
description: |-
1873-
ConfigOverrides as key-value pairs, JSON merge patch or JSON object.
1873+
ConfigOverrides as key-value pairs, JSON merge patch, JSON patch or JSON object.
18741874
1875-
The key-value pairs and the JSON merge patch are merged with the configuration provided by the
1876-
operator. The user provided JSON object replaces the configuration of the operator.
1875+
The key-value pairs, JSON merge patch and JSON patch are merged with/applied to the
1876+
configuration provided by the operator. The user-provided JSON object replaces the
1877+
configuration of the operator.
18771878
18781879
Example for key-value pairs:
18791880
@@ -1888,6 +1889,13 @@ spec:
18881889
nestedProperty:
18891890
key: value
18901891
1892+
Example for a JSON patch:
1893+
1894+
jsonPatch:
1895+
- op: replace
1896+
path: /stringProperty
1897+
value: new value
1898+
18911899
Example for a JSON object:
18921900
18931901
userProvided:
@@ -2585,10 +2593,11 @@ spec:
25852593
default:
25862594
jsonMergePatch: {}
25872595
description: |-
2588-
ConfigOverrides as key-value pairs, JSON merge patch or JSON object.
2596+
ConfigOverrides as key-value pairs, JSON merge patch, JSON patch or JSON object.
25892597
2590-
The key-value pairs and the JSON merge patch are merged with the configuration provided by the
2591-
operator. The user provided JSON object replaces the configuration of the operator.
2598+
The key-value pairs, JSON merge patch and JSON patch are merged with/applied to the
2599+
configuration provided by the operator. The user-provided JSON object replaces the
2600+
configuration of the operator.
25922601
25932602
Example for key-value pairs:
25942603
@@ -2603,6 +2612,13 @@ spec:
26032612
nestedProperty:
26042613
key: value
26052614
2615+
Example for a JSON patch:
2616+
2617+
jsonPatch:
2618+
- op: replace
2619+
path: /stringProperty
2620+
value: new value
2621+
26062622
Example for a JSON object:
26072623
26082624
userProvided:

rust/operator-binary/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ stackable-operator.workspace = true
1414

1515
clap.workspace = true
1616
futures.workspace = true
17+
json-patch.workspace = true
1718
regex.workspace = true
1819
serde.workspace = true
1920
serde_json.workspace = true

rust/operator-binary/src/controller/build/node_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl NodeConfig {
190190
.opensearch_yml
191191
.clone();
192192

193-
overrides.apply(&config).into_owned()
193+
overrides.apply(&config)
194194
}
195195

196196
/// Creates the main OpenSearch configuration file as JSON map

rust/operator-binary/src/controller/validate.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,20 @@ mod tests {
630630
termination_grace_period_seconds: 300,
631631
},
632632
config_overrides: ValidatedOpenSearchConfigOverrides {
633-
opensearch_yml: JsonConfigOverrides::JsonMergePatch(json!({
634-
"setting1": "value from role level",
635-
"setting2": "value from role-group level",
636-
"setting3": "value from role-group level",
637-
}),)
633+
opensearch_yml: JsonConfigOverrides::Sequence(vec![
634+
JsonConfigOverrides::JsonMergePatch(json!(
635+
{
636+
"setting2": "value from role-group level",
637+
"setting3": "value from role-group level"
638+
}
639+
)),
640+
JsonConfigOverrides::JsonMergePatch(json!(
641+
{
642+
"setting1": "value from role level",
643+
"setting2": "value from role level"
644+
}
645+
))
646+
]),
638647
},
639648
env_overrides: EnvVarSet::new().with_values([
640649
(

0 commit comments

Comments
 (0)