|
23 | 23 | from typing import ( |
24 | 24 | Any, |
25 | 25 | Dict, |
| 26 | + Final, |
26 | 27 | List, |
27 | 28 | Literal, |
28 | 29 | Optional, |
@@ -91,6 +92,12 @@ class Empty: |
91 | 92 | FEATURE_FLAGS_SECTION_PATH = [CLI_SECTION, "features"] |
92 | 93 |
|
93 | 94 |
|
| 95 | +LEGACY_OAUTH_PKCE_KEY: Literal["oatuh_enable_pkce"] = "oatuh_enable_pkce" |
| 96 | +LEGACY_CONNECTION_SETTING_ALIASES: Final[dict[str, str]] = { |
| 97 | + LEGACY_OAUTH_PKCE_KEY: "oauth_enable_pkce", |
| 98 | +} |
| 99 | + |
| 100 | + |
94 | 101 | @dataclass |
95 | 102 | class ConnectionConfig: |
96 | 103 | account: Optional[str] = None |
@@ -130,12 +137,17 @@ def from_dict(cls, config_dict: dict) -> ConnectionConfig: |
130 | 137 | known_settings = {} |
131 | 138 | other_settings = {} |
132 | 139 | for key, value in config_dict.items(): |
133 | | - if key in cls.__dict__: |
134 | | - known_settings[key] = value |
| 140 | + normalized_key = cls._normalize_setting_key(key) |
| 141 | + if normalized_key in cls.__dict__: |
| 142 | + known_settings[normalized_key] = value |
135 | 143 | else: |
136 | 144 | other_settings[key] = value |
137 | 145 | return cls(**known_settings, _other_settings=other_settings) |
138 | 146 |
|
| 147 | + @staticmethod |
| 148 | + def _normalize_setting_key(key: str) -> str: |
| 149 | + return LEGACY_CONNECTION_SETTING_ALIASES.get(key, key) |
| 150 | + |
139 | 151 | def to_dict_of_known_non_empty_values(self) -> dict: |
140 | 152 | return { |
141 | 153 | k: v |
@@ -340,7 +352,9 @@ def get_connection_dict(connection_name: str) -> dict: |
340 | 352 | from snowflake.cli.api.config_provider import get_config_provider_singleton |
341 | 353 |
|
342 | 354 | provider = get_config_provider_singleton() |
343 | | - return provider.get_connection_dict(connection_name) |
| 355 | + connection_raw = provider.get_connection_dict(connection_name) |
| 356 | + connection = ConnectionConfig.from_dict(connection_raw) |
| 357 | + return connection.to_dict_of_all_non_empty_values() |
344 | 358 |
|
345 | 359 |
|
346 | 360 | def get_default_connection_name() -> str: |
|
0 commit comments