Parse and validate kustomize output
Project description
pytest_kustomize
Parse and validate kustomize output
Example
from pytest_kustomize import resolve_configmaps, extract_externalsecret_data
import pytest
@pytest.mark.parametrize("environment, value", [
("staging", "shared-db.staging.example.com"),
("production", "myservice-db.production.example.com"),
])
def test_database_matches_environment(kustomize_resources, environment, value):
config = resolve_configmaps(kustomize_resources[environment])
for deployment in ["webui", "api"]:
assert config[deployment]["db_host"] == value
def test_production_has_no_staging_vault_paths(kustomize_resources):
for secret in extract_externalsecret_data(kustomize_resources["production"]).values():
assert "staging" not in secret["key"]
Usage
You can access the kustomize output as follows:
- The
kustomize_manifestsfixture returns adict[str, str], environment name:kustomize buildoutput - The
kustomize_resourcesfixture returns adict[str, List[dict]], environment name: yaml-parsed output
Optionally, define the directory where kustomize manifests are looked up by providing this fixture
@pytest.fixture(scope="session")
def kustomize_root_directory():
return "/path/to/kustomizations"
Default: ./k8s
Optionally, define for which subdirectories manifests should be generated by providing this fixture
@pytest.fixture(scope="session")
def kustomize_environment_names():
return ["overlays/staging", "overlays/production"]
Default: All direct subdirectories that contain a kustomization.yaml
API
The package provides these helper functions:
resolve_configmaps()resolvesenvFromreferences toConfigMaps inDeployments. It takes a list of yaml dicts (usuallykustomize_resources[environment]) and returns adict[str, dict[str, str]], deploment name: {key: value}.extract_externalsecret_data()extracts thedatasections of allExternalSecretresources. It takes a list of yaml dicts and returns{"key_in_secret": {"key": "example/vault/path", "property": "token"}}
These take an optional name_transform callable which defaults to lambda x: x.split('-')[0], to normalize e.g. kustomize-generated ConfigMap names like project-44fb7dkk64.
pytest_kustomize Changes
1.0.0 (2025-07-03)
- Initial release (initial)
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 pytest_kustomize-1.0.0.tar.gz.
File metadata
- Download URL: pytest_kustomize-1.0.0.tar.gz
- Upload date:
- Size: 39.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b260789bcef09f693bd516ce51ede0377084e515a27de105eb1fbace14382ddd
|
|
| MD5 |
60886e5b1e20fd98c746ea70749fe809
|
|
| BLAKE2b-256 |
550d0fb9c6e5dab986618282c907cc7c3b844c5477e3fdbcdc9d43b4c4798d71
|
File details
Details for the file pytest_kustomize-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pytest_kustomize-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fe3f6074319eff9940bf7e4d3e87360b8faa7e8b0a5d5ba0ca5b532e55c0aab
|
|
| MD5 |
5a1f5b85b2061941838396ae494e1a83
|
|
| BLAKE2b-256 |
56801368d718bf23e6141e21675c7cc330a6316c1f2a898ff05d894eaac40f1b
|