diff --git a/rust/crd/src/lib.rs b/rust/crd/src/lib.rs index 94edcb13..00d6a13c 100644 --- a/rust/crd/src/lib.rs +++ b/rust/crd/src/lib.rs @@ -347,6 +347,28 @@ pub struct SupersetConfig { /// Time period Pods have to gracefully shut down, e.g. `30m`, `1h` or `2d`. Consult the operator documentation for details. #[fragment_attrs(serde(default))] pub graceful_shutdown_timeout: Option, + + #[fragment_attrs(serde(default))] + pub unsafe_python_customizations: PythonCustomizations, +} + +#[derive(Clone, Debug, Default, Fragment, JsonSchema, PartialEq)] +#[fragment_attrs( + derive( + Clone, + Debug, + Default, + Deserialize, + Merge, + JsonSchema, + PartialEq, + Serialize + ), + serde(rename_all = "camelCase") +)] +pub struct PythonCustomizations { + prefix: Option, + suffix: Option, } impl SupersetConfig { @@ -369,7 +391,9 @@ impl SupersetConfig { logging: product_logging::spec::default_logging(), affinity: get_affinity(cluster_name, role), graceful_shutdown_timeout: Some(DEFAULT_NODE_GRACEFUL_SHUTDOWN_TIMEOUT), - ..Default::default() + row_limit: None, + webserver_timeout: None, + unsafe_python_customizations: Default::default(), } } } diff --git a/rust/operator-binary/src/superset_controller.rs b/rust/operator-binary/src/superset_controller.rs index a559c7e3..8b568d5a 100644 --- a/rust/operator-binary/src/superset_controller.rs +++ b/rust/operator-binary/src/superset_controller.rs @@ -2,6 +2,7 @@ use std::{ borrow::Cow, collections::{BTreeMap, BTreeSet, HashMap}, + io::Write, sync::Arc, }; @@ -523,6 +524,10 @@ fn build_rolegroup_config_map( ); let mut config_file = Vec::new(); + + if let Some(prefix) = config_properties.remove("EXPERIMENTAL_FILE_HEADER") { + writeln!(config_file, "{}", prefix).unwrap(); + } flask_app_config_writer::write::( &mut config_file, config_properties.iter(), @@ -531,7 +536,9 @@ fn build_rolegroup_config_map( .with_context(|_| BuildRoleGroupConfigFileSnafu { rolegroup: rolegroup.clone(), })?; - + if let Some(prefix) = config_properties.remove("EXPERIMENTAL_FOOTER") { + writeln!(config_file, "{}", prefix).unwrap(); + } let mut cm_builder = ConfigMapBuilder::new(); cm_builder diff --git a/tests/templates/kuttl/smoke/30-install-superset.yaml.j2 b/tests/templates/kuttl/smoke/30-install-superset.yaml.j2 index 7739c151..f2db46f8 100644 --- a/tests/templates/kuttl/smoke/30-install-superset.yaml.j2 +++ b/tests/templates/kuttl/smoke/30-install-superset.yaml.j2 @@ -36,6 +36,17 @@ spec: config: logging: enableVectorAgent: {{ lookup('env', 'VECTOR_AGGREGATOR') | length > 0 }} + configOverrides: + superset_config.py: + EXPERIMENTAL_FILE_HEADER: | + COMMON_HEADER_VAR = "role-value" + ROLE_HEADER_VAR = "role-value" + EXPERIMENTAL_FILE_FOOTER: | + ROLE_FOOTER_VAR = "role-value" roleGroups: default: replicas: 1 + configOverrides: + superset_config.py: + EXPERIMENTAL_FILE_HEADER: | + COMMON_HEADER_VAR = "group-value" diff --git a/tests/templates/kuttl/smoke/31-assert.yaml b/tests/templates/kuttl/smoke/31-assert.yaml new file mode 100644 index 00000000..d1063850 --- /dev/null +++ b/tests/templates/kuttl/smoke/31-assert.yaml @@ -0,0 +1,11 @@ +--- +apiVersion: kuttl.dev/v1beta1 +kind: TestAssert +timeout: 600 +commands: + # + # Test envOverrides + # + - script: | + kubectl -n $NAMESPACE get cm superset-node-default -o yaml | yq -e '.data."superset_config.py"' | grep "COMMON_HEADER_VAR = "group-value"" + kubectl -n $NAMESPACE get cm superset-node-default -o yaml | yq -e '.data."superset_config.py"' | grep "ROLE_FOOTER_VAR = "role-value""