YAML2Jsonnet: Switch configuration languages
Converts YAML into Jsonnet (specifically targetting YAML for Kubernetes)
Suppose that you have some YAML that you use for Kubernetes (either hand-written or output by Helm. Now you'd like to use Jsonnet instead, for its fancier templating capabilities. This is a pain, because while YAML->JSON converters are easy to find, they produce ugly-looking (but valid!) Jsonnet.
YAML2Jsonnet makes the conversion a little easier: it transforms the YAML into slightly prettier Jsonnet, preserving comments along the way.
Example
A trivial YAML document:
---
# simple example
- hello: world
one: 1
Convert it to Jsonnet:
$ yaml2jsonnet trivial.yaml | jsonnetfmt - -o trivial.jsonnet
(Note that we run the output of yaml2jsonnet through the jsonnet formatter jsonnetfmt. This is strongly recommended, since the
raw output of yaml2jsonnet is quite ugly.)
The result:
[
// simple example
{
hello: 'world',
one: 1,
},
]
Installing
Yaml2Jsonnet expects Python 3.6 or above.
pip install yaml2jsonnet
Or, as this is meant as a stand-alone tool, you may prefer
pipx install yaml2jsonnet
Development
- Install Poetry
- Install Pre-commit
- Run
poetry installto install dependencies - Run
poetry run python -m yaml2jsonnet /path/to/yamlto convert a file - Probably, run
jsonnetfmton the output, since the only whitespace I provide is newlines
Metadata
Release files for yaml2jsonnet 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| yaml2jsonnet-1.0.1.tar.gz | 18.1 kB | Without provenance | Details for yaml2jsonnet-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| yaml2jsonnet-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for yaml2jsonnet-1.0.1-py3-none-any.whl |
Total release size: 37.2 kB
Release files / yaml2jsonnet-1.0.1.tar.gz
| Download URL | yaml2jsonnet-1.0.1.tar.gz |
|---|---|
| Size | 18.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3f77ec9f3a8bad6dd8513cb8fda7cc312998229bb80623ee75cb6140730726cc
|
|
BLAKE2b-256 checksum How to use checksums |
2f0f728115dcf90e7398a99ceedc1fc51783a1d40385f1214aaaa60f6af01de0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.10 CPython/3.8.5 Linux/5.4.0-1025-azure
|
Release files / yaml2jsonnet-1.0.1-py3-none-any.whl
| Download URL | yaml2jsonnet-1.0.1-py3-none-any.whl |
|---|---|
| Size | 19.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7af7ae431543a837600e8e21fbc8740ea3011ab1c8c543282e61142f9790255b
|
|
BLAKE2b-256 checksum How to use checksums |
ef8d475b5c707a5191f69c997b2e9425405b9dcfadb75bccc324d8bbbe4f5e91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.10 CPython/3.8.5 Linux/5.4.0-1025-azure
|
Security for yaml2jsonnet 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.