Resolve Databricks config variables from literals, environment variables, and Azure Key Vault secrets, and substitute them into JSON config files.
Project description
brickvar
Resolve configuration variables for Databricks jobs from literals, environment variables, and Azure Key Vault secrets, and substitute them into JSON config files.
brickvar reads a JSON "variables" file in which each entry is one of:
- a literal string (which may reference other variables with
${VAR}), - an environment variable reference —
{"env": "NAME"}, or - a Databricks / Azure Key Vault secret —
{"scope": ..., "key": ..., "base"?: ...}, read through the Databricksdbutils.secretsAPI.
Resolution is two-pass, so a secret's scope/key can themselves reference
already-resolved literal or environment values. It can also substitute ${VAR}
placeholders into any JSON file, leaving unknown placeholders intact.
Install
pip install brickvar
Usage
from brickvar import ConfigManager
# dbutils is provided by the Databricks runtime; required only when a
# variables file contains Key Vault secret entries.
cfg = ConfigManager(dbutils=dbutils)
# Resolve a variables file to a dict.
variables = cfg.read_variables("variables.json")
# Read a JSON file and substitute its ${VAR} placeholders from a variables file.
spec = cfg.read_json("spec.json", "variables.json")
Example variables.json:
{
"SECRET_SCOPE": { "env": "SECRET_SCOPE" },
"HOST": "example.documents.azure.us",
"CLIENT_ID": { "scope": "${SECRET_SCOPE}", "key": "SP-CLIENT-ID" },
"STORAGE": { "scope": "kv", "key": "ACCOUNT", "base": "abfss://data@{}/curated" }
}
HOSTis a literal.SECRET_SCOPEcomes from theSECRET_SCOPEenvironment variable.CLIENT_IDis a secret whose scope is filled from the resolvedSECRET_SCOPE.STORAGEis a secret wrapped by itsbaseformat string.
Development
python -m venv venv && source venv/bin/activate
pip install -e ".[dev]"
pytest
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file brickvar-0.0.1.tar.gz.
File metadata
- Download URL: brickvar-0.0.1.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bbb0c460ee28ff125c57f803183a63d063e1fc35647803130fe1ce8ba03e06cf
|
|
| MD5 |
a808ac5ced6754f3ed45361310f3b366
|
|
| BLAKE2b-256 |
96d252df681e4c7df1f184e0f2cbf3bb8909373a733297f3ae09c09595477aa9
|
File details
Details for the file brickvar-0.0.1-py3-none-any.whl.
File metadata
- Download URL: brickvar-0.0.1-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb688449abdb2359e70de2be2e5a25fec545b8245d139cd90f276edf87f6181d
|
|
| MD5 |
f5fe15a317edef794b40a549ae730dd6
|
|
| BLAKE2b-256 |
783c957e36503346b24077a76b18933b62e676a4a1a2cf80005e66d78502af47
|