Skip to content

Commit 4fc96c9

Browse files
committed
replace eval with os.path.expandvars
1 parent 51c75c4 commit 4fc96c9

5 files changed

Lines changed: 21 additions & 42 deletions

File tree

Cargo.nix

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

crate-hashes.json

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

rust/operator-binary/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn add_superset_config(
4747
);
4848
config.insert(
4949
SupersetConfigOptions::SqlalchemyDatabaseUri.to_string(),
50-
"os.environ.get('SQLALCHEMY_DATABASE_URI')".to_owned(),
50+
"os.path.expandvars(os.environ.get('SQLALCHEMY_DATABASE_URI'))".to_owned(),
5151
);
5252
config.insert(
5353
SupersetConfigOptions::StatsLogger.to_string(),

rust/operator-binary/src/druid_connection_controller.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ async fn build_import_job(
318318
) -> Result<Job> {
319319
let mut commands = vec![];
320320

321-
let config = "import os; SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI')";
321+
let config = "import os; SQLALCHEMY_DATABASE_URI = os.path.expandvars(os.environ.get('SQLALCHEMY_DATABASE_URI'))";
322322
commands.push(format!("mkdir -p {PYTHONPATH}"));
323323
commands.push(format!(
324324
"echo \"{config}\" > {PYTHONPATH}/{SUPERSET_CONFIG_FILENAME}"
@@ -345,20 +345,7 @@ async fn build_import_job(
345345
container_builder
346346
.image_from_product_image(resolved_product_image)
347347
.command(vec!["/bin/bash".to_string()])
348-
.args(vec![
349-
String::from("-c"),
350-
// SQLALCHEMY_DATABASE_URI contains a template with bash variable references
351-
// (e.g. ${METADATA_DATABASE_USERNAME}) that must be resolved before Python
352-
// reads it via os.environ. Airflow's config system calls expandvars()
353-
// on env var values automatically (see [1]), but Superset does not - so we
354-
// resolve them here with eval.
355-
// [1] https://github.com/apache/airflow/blob/2.10.5/airflow/configuration.py#L1084-L1086
356-
// (same behaviour in 3.x: shared/configuration/src/airflow_shared/configuration/parser.py)
357-
format!(
358-
"export SQLALCHEMY_DATABASE_URI=$(eval echo \"$SQLALCHEMY_DATABASE_URI\")\n{}",
359-
commands.join("; ")
360-
),
361-
])
348+
.args(vec![String::from("-c"), commands.join("; ")])
362349
.add_env_var(
363350
"SQLALCHEMY_DATABASE_URI",
364351
metadata_database_connection_details.url_template.clone(),

rust/operator-binary/src/superset_controller.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -803,14 +803,6 @@ fn build_server_rolegroup_statefulset(
803803
804804
{auth_commands}
805805
806-
# SQLALCHEMY_DATABASE_URI contains a template with bash variable references
807-
# (e.g. ${{METADATA_DATABASE_USERNAME}}) that must be resolved before Python
808-
# reads it via os.environ.get(). Airflow's config system calls expandvars()
809-
# on env var values automatically (see [1]), but Superset does not - so we
810-
# resolve them here with eval.
811-
# [1] https://github.com/apache/airflow/blob/2.10.5/airflow/configuration.py#L1084-L1086
812-
# (same behaviour in 3.x: shared/configuration/src/airflow_shared/configuration/parser.py)
813-
export SQLALCHEMY_DATABASE_URI=$(eval echo \"$SQLALCHEMY_DATABASE_URI\")
814806
superset db upgrade
815807
set +x
816808
echo 'Running \"superset fab create-admin [...]\", which is not shown as it leaks the Superset admin credentials'

0 commit comments

Comments
 (0)