Skip to content

Commit b9a16a9

Browse files
committed
Switch to config-utils templating
1 parent 32c0ec9 commit b9a16a9

5 files changed

Lines changed: 10 additions & 10 deletions

File tree

crates/stackable-operator/src/crd/database/databases/postgresql.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ impl SQLAlchemyDatabaseConnection for PostgresqlConnection {
9595
username_and_password_envs(unique_database_name, credentials_secret);
9696

9797
let uri_template = format!(
98-
"postgresql+psycopg2://${{{username_env_name}}}:${{{password_env_name}}}@{host}:{port}/{database}{parameters}",
98+
"postgresql+psycopg2://${{env:{username_env_name}}}:${{env:{password_env_name}}}@{host}:{port}/{database}{parameters}",
9999
username_env_name = username_env.name,
100100
password_env_name = password_env.name,
101101
parameters = connection_parameters_as_url_query_parameters(parameters)
@@ -129,7 +129,7 @@ mod tests {
129129
postgres_connection.sqlalchemy_connection_details(UNIQUE_DATABASE_NAME);
130130
assert_eq!(
131131
sqlalchemy_connection_details.uri_template,
132-
"postgresql+psycopg2://${METADATA_DATABASE_USERNAME}:${METADATA_DATABASE_PASSWORD}@airflow-postgresql:5432/airflow"
132+
"postgresql+psycopg2://${env:METADATA_DATABASE_USERNAME}:${env:METADATA_DATABASE_PASSWORD}@airflow-postgresql:5432/airflow"
133133
);
134134
assert!(sqlalchemy_connection_details.username_env.is_some());
135135
assert!(sqlalchemy_connection_details.password_env.is_some());
@@ -171,7 +171,7 @@ mod tests {
171171
postgres_connection.sqlalchemy_connection_details(UNIQUE_DATABASE_NAME);
172172
assert_eq!(
173173
sqlalchemy_connection_details.uri_template,
174-
"postgresql+psycopg2://${METADATA_DATABASE_USERNAME}:${METADATA_DATABASE_PASSWORD}@my-airflow.default.svc.cluster.local:1234/my_database?createDatabaseIfNotExist=true&foo=bar"
174+
"postgresql+psycopg2://${env:METADATA_DATABASE_USERNAME}:${env:METADATA_DATABASE_PASSWORD}@my-airflow.default.svc.cluster.local:1234/my_database?createDatabaseIfNotExist=true&foo=bar"
175175
);
176176

177177
let jdbc_connection_details = postgres_connection

crates/stackable-operator/src/crd/database/databases/redis.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl CeleryDatabaseConnection for RedisConnection {
5353
username_and_password_envs(unique_database_name, credentials_secret);
5454

5555
let uri_template = format!(
56-
"redis://${{{username_env_name}}}:${{{password_env_name}}}@{host}:{port}/{database_id}",
56+
"redis://${{env:{username_env_name}}}:${{{password_env_name}}}@{host}:{port}/{database_id}",
5757
username_env_name = username_env.name,
5858
password_env_name = password_env.name,
5959
);
@@ -87,7 +87,7 @@ mod tests {
8787
redis_connection.celery_connection_details(UNIQUE_DATABASE_NAME);
8888
assert_eq!(
8989
celery_connection_details.uri_template,
90-
"redis://${WORKER_QUEUE_DATABASE_USERNAME}:${WORKER_QUEUE_DATABASE_PASSWORD}@my-redis:42/13"
90+
"redis://${env:WORKER_QUEUE_DATABASE_USERNAME}:${WORKER_QUEUE_DATABASE_PASSWORD}@my-redis:42/13"
9191
);
9292
assert!(celery_connection_details.username_env.is_some());
9393
assert!(celery_connection_details.password_env.is_some());

crates/stackable-operator/src/crd/database/drivers/celery.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub trait CeleryDatabaseConnection {
1515

1616
pub struct CeleryDatabaseConnectionDetails {
1717
/// The connection URI, which can contain env variable templates, e.g.
18-
/// `redis://:${METADATA_DATABASE_PASSWORD}@airflow-redis-master:6379/0`
18+
/// `redis://:${env:METADATA_DATABASE_PASSWORD}@airflow-redis-master:6379/0`
1919
/// or
2020
/// `<generic URI from the user>`.
2121
pub uri_template: String,
@@ -66,7 +66,7 @@ impl CeleryDatabaseConnection for GenericCeleryDatabaseConnection {
6666
let uri_env_var = env_var_from_secret(&uri_env_name, &self.uri_secret, "uri");
6767

6868
CeleryDatabaseConnectionDetails {
69-
uri_template: format!("${{{uri_env_name}}}"),
69+
uri_template: format!("${{env:{uri_env_name}}}"),
7070
username_env: None,
7171
password_env: None,
7272
generic_uri_var: Some(uri_env_var),

crates/stackable-operator/src/crd/database/drivers/sqlalchemy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub trait SQLAlchemyDatabaseConnection {
1515

1616
pub struct SQLAlchemyDatabaseConnectionDetails {
1717
/// The connection URI, which can contain env variable templates, e.g.
18-
/// `postgresql+psycopg2://${METADATA_DATABASE_USERNAME}:${METADATA_DATABASE_PASSWORD}@airflow-postgresql:5432/airflow`
18+
/// `postgresql+psycopg2://${env:METADATA_DATABASE_USERNAME}:${env:METADATA_DATABASE_PASSWORD}@airflow-postgresql:5432/airflow`
1919
/// or
2020
/// `<generic URI from the user>`.
2121
pub uri_template: String,
@@ -66,7 +66,7 @@ impl SQLAlchemyDatabaseConnection for GenericSQLAlchemyDatabaseConnection {
6666
let uri_env_var = env_var_from_secret(&uri_env_name, &self.uri_secret, "uri");
6767

6868
SQLAlchemyDatabaseConnectionDetails {
69-
uri_template: format!("${{{uri_env_name}}}"),
69+
uri_template: format!("${{env:{uri_env_name}}}"),
7070
username_env: None,
7171
password_env: None,
7272
generic_uri_var: Some(uri_env_var),

crates/stackable-operator/src/crd/database/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn test_dummy_celery_database_usage() {
102102

103103
assert_eq!(
104104
celery_connection_details.uri_template,
105-
"${WORKER_QUEUE_DATABASE_URI}"
105+
"${env:WORKER_QUEUE_DATABASE_URI}"
106106
);
107107
assert_eq!(
108108
container

0 commit comments

Comments
 (0)