Skip to content

Commit

Permalink
Allow aliases for key vault config
Browse files Browse the repository at this point in the history
To keep consistency with the dotnet variant, let's also allow to
configure `key-vault` as an alias for `azure-keyvault` and
`key-vault-name` as an alias for `keyvault-name`.
  • Loading branch information
mathialo committed Jan 19, 2024
1 parent 17dc731 commit 4500853
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Changes are grouped as follows
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [6.3.2]

### Added

* Aliases for keyvault config to align with dotnet utils

## [6.3.1]

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion cognite/extractorutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
Cognite extractor utils is a Python package that simplifies the development of new extractors.
"""

__version__ = "6.3.0"
__version__ = "6.3.2"
from .base import Extractor
7 changes: 4 additions & 3 deletions cognite/extractorutils/configtools/loaders.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ def _init_client(self) -> None:
"Include an `azure-keyvault` section in your config to use the !keyvault tag."
)

if "keyvault-name" not in self.config:
keyvault_name = self.config.get("keyvault-name", self.config.get("key-vault-name"))
if not keyvault_name:
raise InvalidConfigError("Please add the keyvault-name")

if "authentication-method" not in self.config:
Expand All @@ -70,7 +71,7 @@ def _init_client(self) -> None:
"Possible values are: default or client-secret"
)

vault_url = f"https://{self.config['keyvault-name']}.vault.azure.net"
vault_url = f"https://{keyvault_name}.vault.azure.net"

if self.config["authentication-method"] == KeyVaultAuthenticationMethod.DEFAULT.value:
_logger.info("Using Azure DefaultCredentials to access KeyVault")
Expand Down Expand Up @@ -151,7 +152,7 @@ def ignore_unknown(self, node: yaml.Node) -> None:
if not isinstance(source, str):
source.seek(0)

keyvault_config = initial_load.get("azure-keyvault")
keyvault_config = initial_load.get("azure-keyvault", initial_load.get("key-vault"))

_EnvLoader.add_implicit_resolver("!env", re.compile(r"\$\{([^}^{]+)\}"), None)
_EnvLoader.add_constructor("!env", _env_constructor)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cognite-extractor-utils"
version = "6.3.1"
version = "6.3.2"
description = "Utilities for easier development of extractors for CDF"
authors = ["Mathias Lohne <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 4500853

Please sign in to comment.