Skip to content

Commit c65cd98

Browse files
fix: apply toyaml filter to all secret-backed credential fields in profiles template (#2124)
1 parent 9817afd commit c65cd98

3 files changed

Lines changed: 34 additions & 25 deletions

File tree

.github/workflows/test-all-warehouses.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ on:
55
branches: ["master"]
66
paths:
77
- elementary/**
8+
- tests/**
89
- .github/**
910
- pyproject.toml
1011
# For fork PRs - requires approval before running (has access to secrets)
1112
pull_request_target:
1213
branches: ["master"]
1314
paths:
1415
- elementary/**
16+
- tests/**
1517
- .github/**
1618
- pyproject.toml
1719
workflow_dispatch:

tests/profiles/generate_profiles.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,17 @@ def __bool__(self) -> bool:
2929

3030

3131
def _yaml_inline(value: Any) -> str:
32-
"""Dump *value* as a compact inline YAML scalar / mapping."""
32+
"""Render *value* for inline YAML.
33+
34+
* Dicts (e.g. bigquery keyfile) → compact ``{key: val, …}``
35+
* Undefined (docker-only, no secrets) → empty string ``''``
36+
* Everything else → pass through as-is
37+
"""
3338
if isinstance(value, Undefined):
34-
return "{}"
35-
return yaml.dump(value, default_flow_style=True).strip()
39+
return "''"
40+
if isinstance(value, dict):
41+
return yaml.dump(value, default_flow_style=True).strip()
42+
return value
3643

3744

3845
@click.command()

tests/profiles/profiles.yml.j2

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ elementary_tests:
2727

2828
snowflake: &snowflake
2929
type: snowflake
30-
account: {{ snowflake_account }}
31-
user: {{ snowflake_user }}
32-
password: {{ snowflake_password }}
33-
role: {{ snowflake_role }}
34-
database: {{ snowflake_database }}
35-
warehouse: {{ snowflake_warehouse }}
30+
account: {{ snowflake_account | toyaml }}
31+
user: {{ snowflake_user | toyaml }}
32+
password: {{ snowflake_password | toyaml }}
33+
role: {{ snowflake_role | toyaml }}
34+
database: {{ snowflake_database | toyaml }}
35+
warehouse: {{ snowflake_warehouse | toyaml }}
3636
schema: {{ schema_name }}
3737
threads: 4
3838

3939
bigquery: &bigquery
4040
type: bigquery
4141
method: service-account-json
42-
project: {{ bigquery_project }}
42+
project: {{ bigquery_project | toyaml }}
4343
dataset: {{ schema_name }}
4444
keyfile_json: {{ bigquery_keyfile | toyaml }}
4545
location: US
@@ -48,34 +48,34 @@ elementary_tests:
4848

4949
redshift: &redshift
5050
type: redshift
51-
host: {{ redshift_host }}
52-
user: {{ redshift_user }}
53-
password: {{ redshift_password }}
54-
port: {{ redshift_port }}
55-
dbname: {{ redshift_dbname }}
51+
host: {{ redshift_host | toyaml }}
52+
user: {{ redshift_user | toyaml }}
53+
password: {{ redshift_password | toyaml }}
54+
port: {{ redshift_port | toyaml }}
55+
dbname: {{ redshift_dbname | toyaml }}
5656
schema: {{ schema_name }}
5757
threads: 4
5858

5959
databricks_catalog: &databricks_catalog
6060
type: databricks
61-
host: {{ databricks_host }}
62-
http_path: {{ databricks_http_path }}
63-
catalog: {{ databricks_catalog }}
61+
host: {{ databricks_host | toyaml }}
62+
http_path: {{ databricks_http_path | toyaml }}
63+
catalog: {{ databricks_catalog | toyaml }}
6464
schema: {{ schema_name }}
6565
auth_type: oauth
66-
client_id: {{ databricks_client_id }}
67-
client_secret: {{ databricks_client_secret }}
66+
client_id: {{ databricks_client_id | toyaml }}
67+
client_secret: {{ databricks_client_secret | toyaml }}
6868
threads: 4
6969

7070
athena: &athena
7171
type: athena
72-
s3_staging_dir: {{ athena_s3_staging_dir }}
73-
s3_data_dir: {{ athena_s3_data_dir }}
74-
region_name: {{ athena_region }}
72+
s3_staging_dir: {{ athena_s3_staging_dir | toyaml }}
73+
s3_data_dir: {{ athena_s3_data_dir | toyaml }}
74+
region_name: {{ athena_region | toyaml }}
7575
database: awsdatacatalog
7676
schema: {{ schema_name }}
77-
aws_access_key_id: {{ athena_aws_access_key_id }}
78-
aws_secret_access_key: {{ athena_aws_secret_access_key }}
77+
aws_access_key_id: {{ athena_aws_access_key_id | toyaml }}
78+
aws_secret_access_key: {{ athena_aws_secret_access_key | toyaml }}
7979
threads: 4
8080

8181
# The internal CLI dbt_project uses profile "elementary", so we alias the

0 commit comments

Comments
 (0)