Skip to content

Commit 3f5fca1

Browse files
authored
feat: add base64binascii_decode to Jinja interpolation (#424)
Signed-off-by: Artem Inzhyyants <artem.inzhyyants@gmail.com>
1 parent df5c8cb commit 3f5fca1

File tree

1 file changed

+19
-1
lines changed
  • airbyte_cdk/sources/declarative/interpolation

1 file changed

+19
-1
lines changed

‎airbyte_cdk/sources/declarative/interpolation/filters.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,24 @@ def base64decode(value: str) -> str:
9393
return base64.b64decode(value.encode("utf-8")).decode()
9494

9595

96+
def base64binascii_decode(value: str) -> str:
97+
"""
98+
Implementation of a custom Jinja2 filter to decode base64 strings using ASCII encoding
99+
100+
For example:
101+
102+
OAuthAuthenticator:
103+
$ref: "#/definitions/OAuthAuthenticator"
104+
$parameters:
105+
name: "client_id"
106+
value: "{{ config['client_id'] | base64binascii_decode }}"
107+
108+
:param value: value to be decoded from base64 using ascii
109+
:return: base64 decoded string ascii
110+
"""
111+
return base64.standard_b64encode(value.encode("ascii")).decode("ascii")
112+
113+
96114
def string(value: Any) -> str:
97115
"""
98116
Converts the input value to a string.
@@ -117,5 +135,5 @@ def regex_search(value: str, regex: str) -> str:
117135
return ""
118136

119137

120-
_filters_list = [hash, base64encode, base64decode, string, regex_search]
138+
_filters_list = [hash, base64encode, base64decode, base64binascii_decode, string, regex_search]
121139
filters = {f.__name__: f for f in _filters_list}

0 commit comments

Comments
 (0)