Reclass is a library which defines a syntax and directory structure for recursively merging YAML data sources.
This repository contains a Rust implementation of Reclass which is based on the Reclass fork maintained by kapicorp.
The Reclass implementation provided in this repository can be used both from other Rust programs and in Python programs.
The reclass-rs
Python module is implemented directly in Rust with PyO3.
Please note that this implementation doesn't yet support all the features and extensions which are available in Kapitan Reclass. However, for features which are implemented, we aim to be compatible with Kapitan Reclass.
The implementation currently supports the following features of Kapicorp Reclass:
nodes_path
and classes_path
ignore_class_notfound
ignore_class_notfound_regexp
reclass-config.yaml
componse_node_name
compose_node_name
which preserves literal dots in node namesThe following Kapicorp Reclass features aren't supported:
allow_none_override
can't be set to False
yaml_git
and mixed
storage typesDocumentation for the original Reclass can be found at https://reclass.pantsfullofunix.net/. Documentation on Reclass extensions introduced in the Kapicorp Reclass fork can be found at https://github.com/kapicorp/reclass/blob/develop/README-extensions.rst.
python -m venv .venv
source .venv/bin/activate
pip install maturin pytest
maturin develop
pytest
You should be able to run the Rust tests through Cargo if you have the Rust toolchain setup:
cargo test
cargo fmt
to format codecargo check
for checking that the code compilescargo clippy
to check for code issuesYou can run benchmarks for Reclass::render_inventory()
with
cargo bench -F bench
The benchmarks are implemented with criterion
.
If you're using Kapitan, you can test reclass-rs by installing reclass-rs
in your Kapitan virtualenv:
reclass-rs
in your Kapitan virtualenvKAPITAN_VENV=/path/to/your/kapitan/virtualenv
source ${KAPITAN_VENV}/bin/activate
pip install reclass-rs
patch -p1 -d $KAPITAN_VENV < hack/kapitan_0.32_reclass_rs.patch
Please note that we've only tested the patch against the Kapitan 0.32 release as published on PyPI.
We generate the package version of reclass-rs
from the latest Git tag when building Python wheels.
To ensure this always works, we keep the version in the committed Cargo.toml
as 0.0.0
.
We generate the package version from Git by calling git describe --tags --always --match=v*
.
This command produces something like v0.1.1-61-g531ca91
.
We always strip the leading v
, since neither Cargo nor maturin support versions with leading v
.
If we're building a branch or PR, we discard the component derived from the commit hash.
For the example output above, the package version for a branch or PR build will become 0.1.1.post61
.
For tag builds, the command ouptut will be just the tag, so the package version will match the tag.
The version is injected with cargo-edit's cargo set-version
before the Python wheels are built.
See the "Python" workflow for more details.