Skip to content

Commit

Permalink
Fix separator getting added to variables_prefix when empty (#26749)
Browse files Browse the repository at this point in the history
Fix separator getting added to variables_prefix

azure key vault adds a - between the key prefix and the secret name when it reads it from azure key vault. It does this even when the key prefix is "" so secrets end up named -my-secret instead of my-secret.
  • Loading branch information
rajaths010494 authored Sep 30, 2022
1 parent 7363e35 commit 32434a1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion airflow/providers/microsoft/azure/secrets/key_vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,11 @@ def build_path(path_prefix: str, secret_id: str, sep: str = '-') -> str:
:param secret_id: Name of the secret
:param sep: Separator used to concatenate path_prefix and secret_id
"""
path = f'{path_prefix}{sep}{secret_id}'
# When an empty prefix is given, do not add a separator to the secret name
if path_prefix == "":
path = f'{secret_id}'
else:
path = f'{path_prefix}{sep}{secret_id}'
return path.replace('_', sep)

def _get_secret(self, path_prefix: str, secret_id: str) -> str | None:
Expand Down

0 comments on commit 32434a1

Please sign in to comment.