Package: reclass-rs
reclass-rs: A Reclass implementation in RustReclass 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 theReclass forkmaintained bykapicorp.
The Reclass implementation provided in this repository can be used both from other Rust programs and in Python programs.
Thereclass-rsPython module is implemented directly in Rust withPyO3.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:The Reclass optionsnodes_pathandclasses_pathThe Reclass optionignore_class_notfoundThe Reclass optionignore_class_notfound_regexpEscaped parameter referencesMerging referenced lists and dictionariesConstant parametersNested referencesReferences in class namesLoading classes with relative namesLoading Reclass configuration options fromreclass-config.yamlThe Reclass optioncomponse_node_namereclass-rs provides a non-compatible mode forcompose_node_namewhich preserves literal dots in node namesThe following Kapicorp Reclass features aren't supported:Ignoring overwritten missing referencesInventory QueriesThe Reclass optionallow_none_overridecan't be set toFalseThe Reclassyaml_gitandmixedstorage typesAny Reclass option which is not mentioned explicitly here or aboveDocumentation for the original Reclass can be found athttps://reclass.pantsfullofunix.net/.
Documentation on Reclass extensions introduced in the Kapicorp Reclass fork can be found athttps://github.com/kapicorp/reclass/blob/develop/README-extensions.rst.PrerequisitesPython >= 3.8Rust >= 1.56 (we recommend installing the latest stable toolchain withrustup)Setup local development environment for Python bindingsCreate a local virtualenv for running Python tests and installmaturinand pytestpython -m venv .venv
source .venv/bin/activate
pip install maturin pytestBuild the reclass-rs Python library and install it in the virtualenvmaturin developRun Python testspytestRust developmentYou should be able to run the Rust tests through Cargo if you have the Rust toolchain setup:cargo testLinting and formattingUsecargo fmtto format codeUsecargo checkfor checking that the code compilesUsecargo clippyto check for code issuesBenchmarksYou can run benchmarks forReclass::render_inventory()withcargo bench -F benchThe benchmarks are implemented withcriterion.Testing reclass-rs in KapitanIf you're usingKapitan, you can test reclass-rs by installingreclass-rsin your Kapitan virtualenv:Installreclass-rsin your Kapitan virtualenvKAPITAN_VENV=/path/to/your/kapitan/virtualenv
source ${KAPITAN_VENV}/bin/activate
pip install reclass-rsPatch the Kapitan package in the virtualenv with the following commandpatch -p1 -d $KAPITAN_VENV < hack/kapitan_0.32_reclass_rs.patchPlease note that we've only tested the patch against the Kapitan 0.32 release as published on PyPI.Automated package version managementWe generate the package version ofreclass-rsfrom the latest Git tag when building Python wheels.
To ensure this always works, we keep the version in the committedCargo.tomlas0.0.0.We generate the package version from Git by callinggit describe --tags --always --match=v*.
This command produces something likev0.1.1-61-g531ca91.
We always strip the leadingv, since neither Cargo nor maturin support versions with leadingv.
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 become0.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 withcargo-edit'scargo set-versionbefore the Python wheels are built.See the"Python" workflowfor more details.