Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SnowflakePrivateKeyPemProfileMapping private_key reference #501

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cosmos/profiles/snowflake/user_privatekey.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class SnowflakePrivateKeyPemProfileMapping(BaseProfileMapping):
"database",
"warehouse",
"schema",
"private_key_content",
"private_key",
]
secret_fields = [
"private_key_content",
"private_key",
]
airflow_param_mapping = {
"account": "extra.account",
Expand All @@ -39,7 +39,7 @@ class SnowflakePrivateKeyPemProfileMapping(BaseProfileMapping):
"warehouse": "extra.warehouse",
"schema": "schema",
"role": "extra.role",
"private_key_content": "extra.private_key_content",
"private_key": "extra.private_key_content",
}

@property
Expand Down Expand Up @@ -68,7 +68,7 @@ def profile(self) -> dict[str, Any | None]:
**self.mapped_params,
**self.profile_args,
# private_key should always get set as env var
"private_key_content": self.get_env_var_format("private_key_content"),
"private_key": self.get_env_var_format("private_key"),
}

# remove any null values
Expand Down
10 changes: 5 additions & 5 deletions tests/profiles/snowflake/test_snowflake_user_privatekey.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_profile_args(
assert profile_mapping.profile == {
"type": mock_snowflake_conn.conn_type,
"user": mock_snowflake_conn.login,
"private_key_content": "{{ env_var('COSMOS_CONN_SNOWFLAKE_PRIVATE_KEY_CONTENT') }}",
"private_key": "{{ env_var('COSMOS_CONN_SNOWFLAKE_PRIVATE_KEY') }}",
"schema": mock_snowflake_conn.schema,
"account": mock_snowflake_conn.extra_dejson.get("account"),
"database": mock_snowflake_conn.extra_dejson.get("database"),
Expand All @@ -158,7 +158,7 @@ def test_profile_args_overrides(
assert profile_mapping.profile == {
"type": mock_snowflake_conn.conn_type,
"user": mock_snowflake_conn.login,
"private_key_content": "{{ env_var('COSMOS_CONN_SNOWFLAKE_PRIVATE_KEY_CONTENT') }}",
"private_key": "{{ env_var('COSMOS_CONN_SNOWFLAKE_PRIVATE_KEY') }}",
"schema": mock_snowflake_conn.schema,
"account": mock_snowflake_conn.extra_dejson.get("account"),
"database": "my_db_override",
Expand All @@ -176,7 +176,7 @@ def test_profile_env_vars(
mock_snowflake_conn.conn_id,
)
assert profile_mapping.env_vars == {
"COSMOS_CONN_SNOWFLAKE_PRIVATE_KEY_CONTENT": mock_snowflake_conn.extra_dejson.get("private_key_content"),
"COSMOS_CONN_SNOWFLAKE_PRIVATE_KEY": mock_snowflake_conn.extra_dejson.get("private_key_content"),
}


Expand Down Expand Up @@ -204,7 +204,7 @@ def test_old_snowflake_format() -> None:
assert profile_mapping.profile == {
"type": conn.conn_type,
"user": conn.login,
"private_key_content": "{{ env_var('COSMOS_CONN_SNOWFLAKE_PRIVATE_KEY_CONTENT') }}",
"private_key": "{{ env_var('COSMOS_CONN_SNOWFLAKE_PRIVATE_KEY') }}",
"schema": conn.schema,
"account": conn.extra_dejson.get("account"),
"database": conn.extra_dejson.get("database"),
Expand Down Expand Up @@ -237,7 +237,7 @@ def test_appends_region() -> None:
assert profile_mapping.profile == {
"type": conn.conn_type,
"user": conn.login,
"private_key_content": "{{ env_var('COSMOS_CONN_SNOWFLAKE_PRIVATE_KEY_CONTENT') }}",
"private_key": "{{ env_var('COSMOS_CONN_SNOWFLAKE_PRIVATE_KEY') }}",
"schema": conn.schema,
"account": f"{conn.extra_dejson.get('account')}.{conn.extra_dejson.get('region')}",
"database": conn.extra_dejson.get("database"),
Expand Down
Loading