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}), null, which substitutes a JSONnullinto the config file,- 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.
A null variable substitutes a real JSON null. Because substitution is textual,
its placeholder must be a complete string value — "${VAR}" becomes null (quotes
and all). A null variable embedded in a larger string ("prefix-${VAR}") cannot
become null and is left intact with a warning.
Install
pip install brickvar
Usage
from brickvar import configure_json
# Read a JSON file and substitute its ${VAR} placeholders from a variables file,
# in one call. dbutils is provided by the Databricks runtime and is required only
# when the variables file contains Key Vault secret entries.
spec = configure_json("spec.json", dbutils=dbutils, var_filepath="variables.json")
To merge several config files (and/or several variables files) in one call, use
configure_jsons:
from brickvar import configure_jsons
# Variables files are merged *before* resolution, so a variable in one file may
# reference one defined in an earlier file. The config files are shallow-merged at
# the top level: a key defined by more than one file takes the last file's value
# (a conflict is logged as a warning).
spec = configure_jsons(
["base.json", "prod.json"],
dbutils=dbutils,
var_filepaths=["base.variables.json", "prod.variables.json"],
)
For finer-grained control, use the VariableResolver class directly:
from brickvar import VariableResolver
cfg = VariableResolver(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",
"PROXY": null,
"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.PROXYisnull— a"${PROXY}"placeholder becomes a JSONnull.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.4.tar.gz.
File metadata
- Download URL: brickvar-0.0.4.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55a8364b03d396c6e19bb6bd7dcd0dac1d2c79b62ca835d8ca0bc80fc5fec7fe
|
|
| MD5 |
1423d3a09990b6fd49be7c42ab904eb3
|
|
| BLAKE2b-256 |
fa9fd72dd1db3bd21b097ba9878d1d605b9811a8823db732fccafb72e156c2a1
|
Provenance
The following attestation bundles were made for brickvar-0.0.4.tar.gz:
Publisher:
release.yml on amida-tech/brickvar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
brickvar-0.0.4.tar.gz -
Subject digest:
55a8364b03d396c6e19bb6bd7dcd0dac1d2c79b62ca835d8ca0bc80fc5fec7fe - Sigstore transparency entry: 1971102950
- Sigstore integration time:
-
Permalink:
amida-tech/brickvar@10d0886693002569412e42ce919b97eb9ee429d6 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/amida-tech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@10d0886693002569412e42ce919b97eb9ee429d6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file brickvar-0.0.4-py3-none-any.whl.
File metadata
- Download URL: brickvar-0.0.4-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd34d27a60c9a41a3848b130768336b1d4b7e04f5f298fc69fb1c4dc6cdf547e
|
|
| MD5 |
2ad12a2081a49f391f22c2f847c6b254
|
|
| BLAKE2b-256 |
babfa8e72a735c370119fca040418c9de1a17e3ad6a25737fae38091eecb275b
|
Provenance
The following attestation bundles were made for brickvar-0.0.4-py3-none-any.whl:
Publisher:
release.yml on amida-tech/brickvar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
brickvar-0.0.4-py3-none-any.whl -
Subject digest:
dd34d27a60c9a41a3848b130768336b1d4b7e04f5f298fc69fb1c4dc6cdf547e - Sigstore transparency entry: 1971103028
- Sigstore integration time:
-
Permalink:
amida-tech/brickvar@10d0886693002569412e42ce919b97eb9ee429d6 -
Branch / Tag:
refs/tags/v0.0.4 - Owner: https://github.com/amida-tech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@10d0886693002569412e42ce919b97eb9ee429d6 -
Trigger Event:
release
-
Statement type: