Skip to content

Commit bbf0c20

Browse files
committed
fix: use JsonConfigOverrides instead of JsonOrKeyValueConfigOverrides
1 parent c563234 commit bbf0c20

3 files changed

Lines changed: 175 additions & 15 deletions

File tree

extra/crds.yaml

Lines changed: 170 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ spec:
1818
name: v1alpha2
1919
schema:
2020
openAPIV3Schema:
21-
description: Auto-generated derived type for OpaClusterSpec via `CustomResource`
21+
description: An Open Policy Agent (OPA) cluster stacklet. This resource is managed by the Stackable operator for OPA.
2222
properties:
2323
spec:
2424
description: |-
@@ -303,7 +303,7 @@ spec:
303303
type: array
304304
type: object
305305
secretClass:
306-
description: '[SecretClass](https://docs.stackable.tech/home/nightly/secret-operator/secretclass) containing the LDAP bind credentials.'
306+
description: '[SecretClass](https://docs.stackable.tech/home/nightly/secret-operator/secretclass) providing the requested secrets.'
307307
type: string
308308
required:
309309
- secretClass
@@ -1158,8 +1158,41 @@ spec:
11581158
default:
11591159
jsonMergePatch: {}
11601160
description: Overrides for the OPA `config.json` file.
1161+
oneOf:
1162+
- required:
1163+
- jsonMergePatch
1164+
- required:
1165+
- jsonPatch
1166+
- required:
1167+
- userProvided
1168+
properties:
1169+
jsonMergePatch:
1170+
description: |-
1171+
Can be set to arbitrary YAML content, which is converted to JSON and used as
1172+
[RFC 7396](https://datatracker.ietf.org/doc/html/rfc7396) JSON merge patch.
1173+
type: object
1174+
x-kubernetes-preserve-unknown-fields: true
1175+
jsonPatch:
1176+
description: |-
1177+
An [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patch.
1178+
1179+
Can be used when more flexibility is needed, e.g. to only modify elements
1180+
in a list based on a condition.
1181+
1182+
A patch looks something like
1183+
1184+
`- {"op": "test", "path": "/0/name", "value": "Andrew"}`
1185+
1186+
or
1187+
1188+
`- {"op": "add", "path": "/0/happy", "value": true}`
1189+
type: object
1190+
x-kubernetes-preserve-unknown-fields: true
1191+
userProvided:
1192+
description: Override the entire config file with the specified JSON value.
1193+
type: object
1194+
x-kubernetes-preserve-unknown-fields: true
11611195
type: object
1162-
x-kubernetes-preserve-unknown-fields: true
11631196
type: object
11641197
envOverrides:
11651198
additionalProperties:
@@ -1719,8 +1752,41 @@ spec:
17191752
default:
17201753
jsonMergePatch: {}
17211754
description: Overrides for the OPA `config.json` file.
1755+
oneOf:
1756+
- required:
1757+
- jsonMergePatch
1758+
- required:
1759+
- jsonPatch
1760+
- required:
1761+
- userProvided
1762+
properties:
1763+
jsonMergePatch:
1764+
description: |-
1765+
Can be set to arbitrary YAML content, which is converted to JSON and used as
1766+
[RFC 7396](https://datatracker.ietf.org/doc/html/rfc7396) JSON merge patch.
1767+
type: object
1768+
x-kubernetes-preserve-unknown-fields: true
1769+
jsonPatch:
1770+
description: |-
1771+
An [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patch.
1772+
1773+
Can be used when more flexibility is needed, e.g. to only modify elements
1774+
in a list based on a condition.
1775+
1776+
A patch looks something like
1777+
1778+
`- {"op": "test", "path": "/0/name", "value": "Andrew"}`
1779+
1780+
or
1781+
1782+
`- {"op": "add", "path": "/0/happy", "value": true}`
1783+
type: object
1784+
x-kubernetes-preserve-unknown-fields: true
1785+
userProvided:
1786+
description: Override the entire config file with the specified JSON value.
1787+
type: object
1788+
x-kubernetes-preserve-unknown-fields: true
17221789
type: object
1723-
x-kubernetes-preserve-unknown-fields: true
17241790
type: object
17251791
envOverrides:
17261792
additionalProperties:
@@ -1752,6 +1818,21 @@ spec:
17521818
nullable: true
17531819
type: integer
17541820
type: object
1821+
description: |-
1822+
The set of role groups for this role, keyed by their name.
1823+
1824+
A role group is a subset of the replicas of a role that share the same configuration,
1825+
allowing finer-grained control than the role level. This is useful to e.g. schedule groups
1826+
onto different classes of nodes or into different regions, or to run them with different
1827+
settings. Configuration set on a role group is merged on top of the role-level `config`,
1828+
with the more specific role group values taking precedence.
1829+
1830+
Every role needs at least one role group. A role with a single role group conventionally
1831+
names it `default`.
1832+
1833+
Read the
1834+
[roles and role groups concept documentation](https://docs.stackable.tech/home/nightly/concepts/roles-and-role-groups)
1835+
for more details.
17551836
type: object
17561837
required:
17571838
- roleGroups
@@ -1814,7 +1895,7 @@ spec:
18141895
name: v1alpha1
18151896
schema:
18161897
openAPIV3Schema:
1817-
description: Auto-generated derived type for OpaClusterSpec via `CustomResource`
1898+
description: An Open Policy Agent (OPA) cluster stacklet. This resource is managed by the Stackable operator for OPA.
18181899
properties:
18191900
spec:
18201901
description: |-
@@ -2099,7 +2180,7 @@ spec:
20992180
type: array
21002181
type: object
21012182
secretClass:
2102-
description: '[SecretClass](https://docs.stackable.tech/home/nightly/secret-operator/secretclass) containing the LDAP bind credentials.'
2183+
description: '[SecretClass](https://docs.stackable.tech/home/nightly/secret-operator/secretclass) providing the requested secrets.'
21032184
type: string
21042185
required:
21052186
- secretClass
@@ -2954,8 +3035,41 @@ spec:
29543035
default:
29553036
jsonMergePatch: {}
29563037
description: Overrides for the OPA `config.json` file.
3038+
oneOf:
3039+
- required:
3040+
- jsonMergePatch
3041+
- required:
3042+
- jsonPatch
3043+
- required:
3044+
- userProvided
3045+
properties:
3046+
jsonMergePatch:
3047+
description: |-
3048+
Can be set to arbitrary YAML content, which is converted to JSON and used as
3049+
[RFC 7396](https://datatracker.ietf.org/doc/html/rfc7396) JSON merge patch.
3050+
type: object
3051+
x-kubernetes-preserve-unknown-fields: true
3052+
jsonPatch:
3053+
description: |-
3054+
An [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patch.
3055+
3056+
Can be used when more flexibility is needed, e.g. to only modify elements
3057+
in a list based on a condition.
3058+
3059+
A patch looks something like
3060+
3061+
`- {"op": "test", "path": "/0/name", "value": "Andrew"}`
3062+
3063+
or
3064+
3065+
`- {"op": "add", "path": "/0/happy", "value": true}`
3066+
type: object
3067+
x-kubernetes-preserve-unknown-fields: true
3068+
userProvided:
3069+
description: Override the entire config file with the specified JSON value.
3070+
type: object
3071+
x-kubernetes-preserve-unknown-fields: true
29573072
type: object
2958-
x-kubernetes-preserve-unknown-fields: true
29593073
type: object
29603074
envOverrides:
29613075
additionalProperties:
@@ -3515,8 +3629,41 @@ spec:
35153629
default:
35163630
jsonMergePatch: {}
35173631
description: Overrides for the OPA `config.json` file.
3632+
oneOf:
3633+
- required:
3634+
- jsonMergePatch
3635+
- required:
3636+
- jsonPatch
3637+
- required:
3638+
- userProvided
3639+
properties:
3640+
jsonMergePatch:
3641+
description: |-
3642+
Can be set to arbitrary YAML content, which is converted to JSON and used as
3643+
[RFC 7396](https://datatracker.ietf.org/doc/html/rfc7396) JSON merge patch.
3644+
type: object
3645+
x-kubernetes-preserve-unknown-fields: true
3646+
jsonPatch:
3647+
description: |-
3648+
An [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) JSON patch.
3649+
3650+
Can be used when more flexibility is needed, e.g. to only modify elements
3651+
in a list based on a condition.
3652+
3653+
A patch looks something like
3654+
3655+
`- {"op": "test", "path": "/0/name", "value": "Andrew"}`
3656+
3657+
or
3658+
3659+
`- {"op": "add", "path": "/0/happy", "value": true}`
3660+
type: object
3661+
x-kubernetes-preserve-unknown-fields: true
3662+
userProvided:
3663+
description: Override the entire config file with the specified JSON value.
3664+
type: object
3665+
x-kubernetes-preserve-unknown-fields: true
35183666
type: object
3519-
x-kubernetes-preserve-unknown-fields: true
35203667
type: object
35213668
envOverrides:
35223669
additionalProperties:
@@ -3548,6 +3695,21 @@ spec:
35483695
nullable: true
35493696
type: integer
35503697
type: object
3698+
description: |-
3699+
The set of role groups for this role, keyed by their name.
3700+
3701+
A role group is a subset of the replicas of a role that share the same configuration,
3702+
allowing finer-grained control than the role level. This is useful to e.g. schedule groups
3703+
onto different classes of nodes or into different regions, or to run them with different
3704+
settings. Configuration set on a role group is merged on top of the role-level `config`,
3705+
with the more specific role group values taking precedence.
3706+
3707+
Every role needs at least one role group. A role with a single role group conventionally
3708+
names it `default`.
3709+
3710+
Read the
3711+
[roles and role groups concept documentation](https://docs.stackable.tech/home/nightly/concepts/roles-and-role-groups)
3712+
for more details.
35513713
type: object
35523714
required:
35533715
- roleGroups

rust/operator-binary/src/controller/build/properties/config_json.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ use serde::Serialize;
44
use snafu::{ResultExt, Snafu};
55
use stackable_operator::{
66
product_logging::spec::LogLevel,
7-
v2::{
8-
config_overrides::JsonConfigOverrides,
9-
product_logging::framework::ValidatedContainerLogConfigChoice,
10-
},
7+
v2::product_logging::framework::ValidatedContainerLogConfigChoice,
118
};
129

1310
use super::ConfigFileName;
@@ -66,7 +63,7 @@ pub fn build(
6663
// Apply the merged user `configOverrides`. The merge built a sequence that applies the
6764
// role-level patch first, then the role-group-level patch on top. `apply` is infallible; an
6865
// invalid patch is logged and skipped.
69-
let config_json = JsonConfigOverrides::from(config_overrides.config_json.clone());
66+
let config_json = config_overrides.config_json.clone();
7067
let config_value = config_json.apply(&config_value);
7168

7269
serde_json::to_string_pretty(&config_value).with_context(|_| SerializeConfigFileSnafu {

rust/operator-binary/src/crd/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use stackable_operator::{
1919
shared::time::Duration,
2020
status::condition::{ClusterCondition, HasStatusCondition},
2121
v2::{
22-
config_overrides::JsonOrKeyValueConfigOverrides,
22+
config_overrides::JsonConfigOverrides,
2323
role_utils::GenericCommonConfig,
2424
types::kubernetes::{ConfigMapName, SecretClassName},
2525
},
@@ -56,6 +56,7 @@ pub mod versioned {
5656
/// Find more information on how to use it and the resources that the operator generates in the
5757
/// [operator documentation](DOCS_BASE_URL_PLACEHOLDER/opa/).
5858
#[versioned(crd(
59+
doc = "An Open Policy Agent (OPA) cluster stacklet. This resource is managed by the Stackable operator for OPA.",
5960
group = "opa.stackable.tech",
6061
status = "OpaClusterStatus",
6162
shortname = "opa",
@@ -157,7 +158,7 @@ pub mod versioned {
157158
pub struct OpaConfigOverrides {
158159
/// Overrides for the OPA `config.json` file.
159160
#[serde(default, rename = "config.json")]
160-
pub config_json: JsonOrKeyValueConfigOverrides,
161+
pub config_json: JsonConfigOverrides,
161162
}
162163

163164
#[allow(clippy::derive_partial_eq_without_eq)]

0 commit comments

Comments
 (0)