A Python library for testing Helm chart rendering
Project description
Pyckelhaube
Introduction
Pyckelhaube, resembling to Pickelhaube is some random name, based on the german military spiked helmet from the 19th and 20th centuries, for a Python library that aims towards testing helm charts rendering.
Its goal is to provide a simple way to write unit tests for helm charts, providing an explicit API to render helm charts and assert on the rendered Kubernetes resources.
Structure
The project uses Poetry as a dependency manager and build tool.
The source code is located in the src directory, while tests are in the test directory.
Installation
You can install Pyckelhaube using pip:
pip install pyckelhaube
Usage
Here's a simple example of how to use Pyckelhaube to test a Helm chart:
From a file
from pyckelhaube import HelmChart, render_chart
helm_chart = HelmChart(path="path/to/your/chart.yaml")
rendered_resources = render_chart(helm_chart=helm_chart, values={"replicaCount": 3})
# Assert on the rendered resources
for resource in rendered_resources:
if resource.kind == "Deployment":
assert resource.spec.replicas == 3
From a string
from pyckelhaube import HelmChart, render_chart
chart_yaml = """
apiVersion: v2
name: my-chart
version: 0.1.0
...
"""
helm_chart = HelmChart(yaml_content=chart_yaml)
rendered_resources = render_chart(helm_chart=helm_chart, values={"replicaCount": 3})
# Assert on the rendered resources
for resource in rendered_resources:
if resource.kind == "Deployment":
assert resource.spec.replicas == 3
Using a Custom Helm Executable
If Helm is not in your system PATH or you need to use a specific version of Helm, you can specify the path to the Helm executable:
from pyckelhaube import (
HelmChart,
render_chart,
set_helm_executable_path,
reset_helm_executable_path,
)
set_helm_executable_path("/usr/local/bin/helm")
set_helm_executable_path("/custom/helm/directory")
helm_chart = HelmChart(yaml_content="...")
resources = render_chart(helm_chart)
reset_helm_executable_path()
Helm Path Functions
set_helm_executable_path(path: str)- Set the path to the Helm executable (full path or directory)get_helm_executable_path() -> str- Get the currently configured Helm executable pathreset_helm_executable_path()- Reset to using the defaulthelmfrom system PATH
Contributing
The rules for the coding style are simple yet strict:
- All arguments, functions and methods must have type hints, as precise as possible.
- All public functions and methods must have docstrings explaining their purpose, parameters, return values, and exceptions raised, in reST style, in the following order:
- Short description of the function/method.
- Parameters section.
- Return section (if applicable).
- Raises section (if applicable).
- Tests must be provided for all new features and bug fixes.
- Do never nest more than 2 levels deep.
To secure the quality of your code, you may run the following command:
./lint.ps1
Project details
Release history Release notifications | RSS feed
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 pyckelhaube-0.2.0.tar.gz.
File metadata
- Download URL: pyckelhaube-0.2.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.1 CPython/3.12.12 Linux/5.15.154+
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c29c091e117da32f7e7edeca65a9929f3775ea4392db83fb3ee55ee5cd07931
|
|
| MD5 |
39316fc8e28f1977027606c34ad756be
|
|
| BLAKE2b-256 |
a343f07bf606deb342dd5dba87175faa97f26bfa02b5a662e485a980caf63330
|
File details
Details for the file pyckelhaube-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pyckelhaube-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.1 CPython/3.12.12 Linux/5.15.154+
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f974bae1345e8848db37bdf9c19e0d0377e5f55ad64b945bc1a17f0089030a0
|
|
| MD5 |
014f90dcb37bd2e1ea309a8dac335c1c
|
|
| BLAKE2b-256 |
45677229080e1ab32607886c44ec921d158484be9f6ea7bf256e251360ed392e
|