Skip to content

Commit 75af62a

Browse files
committed
feat: typed config overrides
1 parent 3fc9756 commit 75af62a

6 files changed

Lines changed: 115 additions & 31 deletions

File tree

extra/crds.yaml

Lines changed: 59 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ spec:
3030
anyOf:
3131
- required:
3232
- zookeeperConfigMapName
33-
- {}
33+
- type: object
3434
description: |-
3535
Settings that affect all roles and role groups.
3636
The settings in the `clusterConfig` are cluster wide settings that do not need to be configurable at role or role group level.
@@ -48,6 +48,16 @@ spec:
4848
description: This field contains OIDC-specific configuration. It is only required in case OIDC is used.
4949
nullable: true
5050
properties:
51+
clientAuthenticationMethod:
52+
default: client_secret_basic
53+
description: 'The client authentication method used when communicating with the token endpoint. Defaults to `client_secret_basic`. The required contents of `clientCredentialsSecret` depend on the chosen method: secret-based methods (`client_secret_basic`, `client_secret_post`, `client_secret_jwt`) expect a client secret, while `private_key_jwt` expects a private key.'
54+
enum:
55+
- client_secret_basic
56+
- client_secret_post
57+
- client_secret_jwt
58+
- private_key_jwt
59+
- none
60+
type: string
5161
clientCredentialsSecret:
5262
description: |-
5363
A reference to the OIDC client credentials secret. The secret contains
@@ -523,7 +533,7 @@ spec:
523533
type: string
524534
type: object
525535
custom:
526-
description: Log configuration provided in a ConfigMap
536+
description: Custom log configuration provided in a ConfigMap
527537
properties:
528538
configMap:
529539
description: ConfigMap containing the log configuration files
@@ -603,7 +613,7 @@ spec:
603613
type: string
604614
type: object
605615
custom:
606-
description: Log configuration provided in a ConfigMap
616+
description: Custom log configuration provided in a ConfigMap
607617
properties:
608618
configMap:
609619
description: ConfigMap containing the log configuration files
@@ -683,7 +693,7 @@ spec:
683693
type: string
684694
type: object
685695
custom:
686-
description: Log configuration provided in a ConfigMap
696+
description: Custom log configuration provided in a ConfigMap
687697
properties:
688698
configMap:
689699
description: ConfigMap containing the log configuration files
@@ -763,7 +773,7 @@ spec:
763773
type: string
764774
type: object
765775
custom:
766-
description: Log configuration provided in a ConfigMap
776+
description: Custom log configuration provided in a ConfigMap
767777
properties:
768778
configMap:
769779
description: ConfigMap containing the log configuration files
@@ -816,7 +826,7 @@ spec:
816826
type: object
817827
type: object
818828
enableVectorAgent:
819-
description: Wether or not to deploy a container with the Vector log agent.
829+
description: Whether or not to deploy a container with the Vector log agent.
820830
nullable: true
821831
type: boolean
822832
type: object
@@ -1176,17 +1186,31 @@ spec:
11761186
type: object
11771187
type: object
11781188
configOverrides:
1179-
additionalProperties:
1180-
additionalProperties:
1181-
type: string
1182-
type: object
1183-
default: {}
11841189
description: |-
11851190
The `configOverrides` can be used to configure properties in product config files
11861191
that are not exposed in the CRD. Read the
11871192
[config overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#config-overrides)
11881193
and consult the operator specific usage guide documentation for details on the
11891194
available config files and settings for the specific product.
1195+
properties:
1196+
bootstrap.conf:
1197+
additionalProperties:
1198+
type: string
1199+
description: Overrides for the `bootstrap.conf` file.
1200+
nullable: true
1201+
type: object
1202+
nifi.properties:
1203+
additionalProperties:
1204+
type: string
1205+
description: Overrides for the `nifi.properties` file.
1206+
nullable: true
1207+
type: object
1208+
security.properties:
1209+
additionalProperties:
1210+
type: string
1211+
description: Overrides for the `security.properties` file.
1212+
nullable: true
1213+
type: object
11901214
type: object
11911215
envOverrides:
11921216
additionalProperties:
@@ -1368,7 +1392,7 @@ spec:
13681392
type: string
13691393
type: object
13701394
custom:
1371-
description: Log configuration provided in a ConfigMap
1395+
description: Custom log configuration provided in a ConfigMap
13721396
properties:
13731397
configMap:
13741398
description: ConfigMap containing the log configuration files
@@ -1448,7 +1472,7 @@ spec:
14481472
type: string
14491473
type: object
14501474
custom:
1451-
description: Log configuration provided in a ConfigMap
1475+
description: Custom log configuration provided in a ConfigMap
14521476
properties:
14531477
configMap:
14541478
description: ConfigMap containing the log configuration files
@@ -1528,7 +1552,7 @@ spec:
15281552
type: string
15291553
type: object
15301554
custom:
1531-
description: Log configuration provided in a ConfigMap
1555+
description: Custom log configuration provided in a ConfigMap
15321556
properties:
15331557
configMap:
15341558
description: ConfigMap containing the log configuration files
@@ -1608,7 +1632,7 @@ spec:
16081632
type: string
16091633
type: object
16101634
custom:
1611-
description: Log configuration provided in a ConfigMap
1635+
description: Custom log configuration provided in a ConfigMap
16121636
properties:
16131637
configMap:
16141638
description: ConfigMap containing the log configuration files
@@ -1661,7 +1685,7 @@ spec:
16611685
type: object
16621686
type: object
16631687
enableVectorAgent:
1664-
description: Wether or not to deploy a container with the Vector log agent.
1688+
description: Whether or not to deploy a container with the Vector log agent.
16651689
nullable: true
16661690
type: boolean
16671691
type: object
@@ -2021,17 +2045,31 @@ spec:
20212045
type: object
20222046
type: object
20232047
configOverrides:
2024-
additionalProperties:
2025-
additionalProperties:
2026-
type: string
2027-
type: object
2028-
default: {}
20292048
description: |-
20302049
The `configOverrides` can be used to configure properties in product config files
20312050
that are not exposed in the CRD. Read the
20322051
[config overrides documentation](https://docs.stackable.tech/home/nightly/concepts/overrides#config-overrides)
20332052
and consult the operator specific usage guide documentation for details on the
20342053
available config files and settings for the specific product.
2054+
properties:
2055+
bootstrap.conf:
2056+
additionalProperties:
2057+
type: string
2058+
description: Overrides for the `bootstrap.conf` file.
2059+
nullable: true
2060+
type: object
2061+
nifi.properties:
2062+
additionalProperties:
2063+
type: string
2064+
description: Overrides for the `nifi.properties` file.
2065+
nullable: true
2066+
type: object
2067+
security.properties:
2068+
additionalProperties:
2069+
type: string
2070+
description: Overrides for the `security.properties` file.
2071+
nullable: true
2072+
type: object
20352073
type: object
20362074
envOverrides:
20372075
additionalProperties:

rust/operator-binary/src/config/jvm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use stackable_operator::{
66

77
use crate::{
88
config::{JVM_SECURITY_PROPERTIES_FILE, NIFI_CONFIG_DIRECTORY},
9-
crd::{NifiConfig, NifiConfigFragment, NifiNodeRoleConfig},
9+
crd::{NifiConfig, NifiConfigFragment, NifiConfigOverrides, NifiNodeRoleConfig},
1010
security::{
1111
authentication::{STACKABLE_SERVER_TLS_DIR, STACKABLE_TLS_STORE_PASSWORD},
1212
authorization::ResolvedNifiAuthorizationConfig,
@@ -33,7 +33,7 @@ pub enum Error {
3333
/// Create the NiFi bootstrap.conf
3434
pub fn build_merged_jvm_config(
3535
merged_config: &NifiConfig,
36-
role: &Role<NifiConfigFragment, NifiNodeRoleConfig, JavaCommonConfig>,
36+
role: &Role<NifiConfigFragment, NifiConfigOverrides, NifiNodeRoleConfig, JavaCommonConfig>,
3737
role_group: &str,
3838
authorization_config: Option<&ResolvedNifiAuthorizationConfig>,
3939
) -> Result<JvmArgumentOverrides, Error> {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use strum::{Display, EnumIter};
2020

2121
use crate::{
2222
crd::{
23-
HTTPS_PORT, NifiConfig, NifiConfigFragment, NifiNodeRoleConfig, NifiRole,
23+
HTTPS_PORT, NifiConfig, NifiConfigFragment, NifiConfigOverrides, NifiNodeRoleConfig, NifiRole,
2424
NifiStorageConfig, PROTOCOL_PORT, sensitive_properties,
2525
v1alpha1::{self, NifiClusteringBackend},
2626
},
@@ -116,7 +116,7 @@ pub enum Error {
116116
pub fn build_bootstrap_conf(
117117
merged_config: &NifiConfig,
118118
overrides: BTreeMap<String, String>,
119-
role: &Role<NifiConfigFragment, NifiNodeRoleConfig, JavaCommonConfig>,
119+
role: &Role<NifiConfigFragment, NifiConfigOverrides, NifiNodeRoleConfig, JavaCommonConfig>,
120120
role_group: &str,
121121
authorization_config: Option<&crate::security::authorization::ResolvedNifiAuthorizationConfig>,
122122
) -> Result<String, Error> {
@@ -756,7 +756,7 @@ pub fn build_state_management_xml(clustering_backend: &NifiClusteringBackend) ->
756756
pub fn validated_product_config(
757757
resource: &v1alpha1::NifiCluster,
758758
version: &str,
759-
role: &Role<NifiConfigFragment, NifiNodeRoleConfig, JavaCommonConfig>,
759+
role: &Role<NifiConfigFragment, NifiConfigOverrides, NifiNodeRoleConfig, JavaCommonConfig>,
760760
product_config: &ProductConfigManager,
761761
) -> Result<ValidatedRoleConfigByPropertyKind, Error> {
762762
let mut roles = HashMap::new();

rust/operator-binary/src/controller.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@ use crate::{
8484
},
8585
crd::{
8686
APP_NAME, BALANCE_PORT, BALANCE_PORT_NAME, Container, HTTPS_PORT, HTTPS_PORT_NAME,
87-
METRICS_PORT, METRICS_PORT_NAME, NifiConfig, NifiConfigFragment, NifiNodeRoleConfig,
88-
NifiRole, NifiStatus, PROTOCOL_PORT, PROTOCOL_PORT_NAME, STACKABLE_LOG_CONFIG_DIR,
87+
METRICS_PORT, METRICS_PORT_NAME, NifiConfig, NifiConfigFragment, NifiConfigOverrides,
88+
NifiNodeRoleConfig, NifiRole, NifiStatus, PROTOCOL_PORT, PROTOCOL_PORT_NAME,
89+
STACKABLE_LOG_CONFIG_DIR,
8990
STACKABLE_LOG_DIR, authentication::AuthenticationClassResolved,
9091
authorization::NifiAccessPolicyProvider, v1alpha1,
9192
},
@@ -719,7 +720,7 @@ async fn build_node_rolegroup_config_map(
719720
resolved_product_image: &ResolvedProductImage,
720721
authentication_config: &NifiAuthenticationConfig,
721722
authorization_config: &ResolvedNifiAuthorizationConfig,
722-
role: &Role<NifiConfigFragment, NifiNodeRoleConfig, JavaCommonConfig>,
723+
role: &Role<NifiConfigFragment, NifiConfigOverrides, NifiNodeRoleConfig, JavaCommonConfig>,
723724
rolegroup: &RoleGroupRef<v1alpha1::NifiCluster>,
724725
rolegroup_config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
725726
merged_config: &NifiConfig,
@@ -843,7 +844,7 @@ async fn build_node_rolegroup_statefulset(
843844
resolved_product_image: &ResolvedProductImage,
844845
cluster_info: &KubernetesClusterInfo,
845846
rolegroup_ref: &RoleGroupRef<v1alpha1::NifiCluster>,
846-
role: &Role<NifiConfigFragment, NifiNodeRoleConfig, JavaCommonConfig>,
847+
role: &Role<NifiConfigFragment, NifiConfigOverrides, NifiNodeRoleConfig, JavaCommonConfig>,
847848
rolegroup_config: &HashMap<PropertyNameKind, BTreeMap<String, String>>,
848849
merged_config: &NifiConfig,
849850
authentication_config: &NifiAuthenticationConfig,

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

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use stackable_operator::{
2525
fragment::{self, Fragment, ValidationError},
2626
merge::Merge,
2727
},
28+
config_overrides::{KeyValueConfigOverrides, KeyValueOverridesProvider},
2829
crd::{authentication::core as auth_core, git_sync},
2930
deep_merger::ObjectOverrides,
3031
k8s_openapi::{
@@ -100,7 +101,7 @@ pub mod versioned {
100101

101102
// no doc - docs in Role struct.
102103
#[serde(default, skip_serializing_if = "Option::is_none")]
103-
pub nodes: Option<Role<NifiConfigFragment, NifiNodeRoleConfig, JavaCommonConfig>>,
104+
pub nodes: Option<Role<NifiConfigFragment, NifiConfigOverrides, NifiNodeRoleConfig, JavaCommonConfig>>,
104105

105106
// no doc - docs in ProductImage struct.
106107
pub image: ProductImage,
@@ -522,6 +523,49 @@ pub struct NifiStorageConfig {
522523
pub filebased_repo: PvcConfig,
523524
}
524525

526+
/// Typed config overrides for NiFi configuration files.
527+
///
528+
/// Each field corresponds to a configuration file that supports key-value overrides.
529+
/// The field names match the actual file names used by NiFi.
530+
#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
531+
#[serde(rename_all = "camelCase")]
532+
pub struct NifiConfigOverrides {
533+
/// Overrides for the `bootstrap.conf` file.
534+
#[serde(rename = "bootstrap.conf")]
535+
pub bootstrap_conf: Option<KeyValueConfigOverrides>,
536+
537+
/// Overrides for the `nifi.properties` file.
538+
#[serde(rename = "nifi.properties")]
539+
pub nifi_properties: Option<KeyValueConfigOverrides>,
540+
541+
/// Overrides for the `security.properties` file.
542+
#[serde(rename = "security.properties")]
543+
pub security_properties: Option<KeyValueConfigOverrides>,
544+
}
545+
546+
impl KeyValueOverridesProvider for NifiConfigOverrides {
547+
fn get_key_value_overrides(&self, file: &str) -> BTreeMap<String, Option<String>> {
548+
match file {
549+
"bootstrap.conf" => self
550+
.bootstrap_conf
551+
.as_ref()
552+
.map(|kv| kv.as_overrides())
553+
.unwrap_or_default(),
554+
"nifi.properties" => self
555+
.nifi_properties
556+
.as_ref()
557+
.map(|kv| kv.as_overrides())
558+
.unwrap_or_default(),
559+
"security.properties" => self
560+
.security_properties
561+
.as_ref()
562+
.map(|kv| kv.as_overrides())
563+
.unwrap_or_default(),
564+
_ => BTreeMap::new(),
565+
}
566+
}
567+
}
568+
525569
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Serialize)]
526570
#[serde(rename_all = "camelCase")]
527571
pub struct NifiNodeRoleConfig {

rust/operator-binary/src/security/oidc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ mod tests {
187187
let oidc = oidc::v1alpha1::ClientAuthenticationOptions {
188188
client_credentials_secret_ref: "nifi-keycloak-client".to_owned(),
189189
extra_scopes: vec![],
190+
client_authentication_method: Default::default(),
190191
product_specific_fields: (),
191192
};
192193

0 commit comments

Comments
 (0)