Crossplane is a Python library and command-line interface (CLI) tool for reliably and quickly parsing and building NGINX configuration files. It handles includes, variables, and common NGINX directives, providing a structured JSON representation of the configuration. The current version is 0.5.8, with releases occurring periodically to update NGINX directive definitions and fix bugs.
pip install crossplaneVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `crossplane.parse()` to transform an NGINX configuration string into a structured Python object (often represented as JSON), and then `crossplane.build()` to convert it back into an NGINX configuration string. This allows for programmatic inspection and modification of NGINX configurations.
If your automation relied on comment removal during formatting, update your logic or use an older version. Otherwise, be aware that formatting output will now include comments.
Upgrade to crossplane v0.5.8 or newer for robust handling of diverse character encodings in NGINX configurations.
Upgrade to crossplane v0.5.1 or newer. If on an older version, ensure no comments are placed within a directive's argument list.
Consider using the `--strict` flag (or its Python API equivalent if available) in critical parsing operations to enforce stricter validation of NGINX configuration syntax against known directives.
Install the package using pip: `pip install crossplane`
Ensure the package is installed via `pip install crossplane`. If installed, verify that the Python script directory (often `~/.local/bin` or a virtual environment's `bin` directory) is in your system's PATH. You may also be able to run it using `python -m crossplane`.
Carefully review the structure of the JSON output returned by `crossplane.parse()`. Ensure you are using correct dictionary keys (strings) to access directive properties and list indices (integers) for arrays of directives or blocks. For example, `config['config'][0]['parsed']` for the top-level parsed array, and then iterating or accessing elements within it by index for lists or by key for dictionaries.
Verify that the NGINX configuration file specified exists at the given path. Provide the correct absolute or relative path to the file.
Examine the NGINX configuration file, specifically around the indicated line number (if provided in `crossplane`'s error output), to identify and correct the syntax error. `crossplane` provides detailed error messages within the `errors` array of its JSON output, including the specific error and line number.
No dependency data recorded yet.