jinja-unquote-resolvers-filter


Namejinja-unquote-resolvers-filter JSON
Version 1.1.0 PyPI version JSON
download
home_pagehttps://github.com/Sceptre/jinja-unquote-resolvers-filter
SummaryA Jinja filter for allowing Sceptre resolvers in var files
upload_time2024-09-26 11:16:02
maintainerNone
docs_urlNone
authorSceptre
requires_python<4.0,>=3.8
licenseApache-2.0
keywords sceptre jinja
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # README

## Overview

A custom Jinja filter for Sceptre for unquoting resolvers appearing in
var files.

## Motivation

In Sceptre, resolvers are an essential feature for simplifying complex
configurations by enabling dynamic data retrieval. Resolvers such as
`!stack_output_external` and `!stack_output` are particularly useful
for referencing output values from other stacks or external sources,
among many others.

When using resolvers in var files, however, they must be protected from
being interpreted as YAML tags by the YAML loader.

This plugin addresses this challenge by allowing you to safely include
resolvers in your var files. It ensures that resolvers are not processed
as YAML tags by the loader, and then turned back into YAML tags after
Jinja interpolation in the generated config.

## Installation

Installation instructions

To install directly from PyPI
```shell
pip install jinja-unquote-resolvers-filter
```

To install from the git repo
```shell
pip install git+https://github.com/Sceptre/jinja-unquote-resolvers-filter.git
```

## Usage/Examples

In your var file:

```yaml
Subnets:
  - '!stack_output_external mystack::subnet_a'  # Quotes needed to protect a YAML tag.
  - '!stack_output_external mystack::subnet_b'

VPC: '!stack_output_external mystack::vpc_id'
```

In your config:

```yaml
j2_environment:
  extensions:
    - jinja_unquote_resolvers_filter.UnquoteResolversFilterExtension

sceptre_user_data:
  subnets:
    {{ var.Subnets | unquote_resolvers(output_indent=4, trim=True) }}
  vpc: {{ var.VPC }}  # This filter is not needed if the quoted resolvers are passed in as scalars.
```

## Arguments

- `indent` (optional, default=2): The number of spaces to use for indentation of nested structures in the output YAML.
- `output_indent` (optional, default=0): The number of spaces to use for indentation of the entire output YAML.
- `trim` (optional, default=False): Whether to trim leading and trailing spaces in the output YAML.

## Limitations

At this time, resolver expressions must be wrapped in a single line of text. That is, instead of:

```yaml
my_multiline_resolver: |
  !from_json
    - !request http://www.whatever.com
```

Instead write:

```yaml
my_multiline_resolver: '!from_json [!request http://www.whatever.com]'
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Sceptre/jinja-unquote-resolvers-filter",
    "name": "jinja-unquote-resolvers-filter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "sceptre, jinja",
    "author": "Sceptre",
    "author_email": "sceptreorg@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/47/d0/17b34440692a508daaa0b8a206cacd3e713731a51736cee303ea85a051c4/jinja_unquote_resolvers_filter-1.1.0.tar.gz",
    "platform": null,
    "description": "# README\n\n## Overview\n\nA custom Jinja filter for Sceptre for unquoting resolvers appearing in\nvar files.\n\n## Motivation\n\nIn Sceptre, resolvers are an essential feature for simplifying complex\nconfigurations by enabling dynamic data retrieval. Resolvers such as\n`!stack_output_external` and `!stack_output` are particularly useful\nfor referencing output values from other stacks or external sources,\namong many others.\n\nWhen using resolvers in var files, however, they must be protected from\nbeing interpreted as YAML tags by the YAML loader.\n\nThis plugin addresses this challenge by allowing you to safely include\nresolvers in your var files. It ensures that resolvers are not processed\nas YAML tags by the loader, and then turned back into YAML tags after\nJinja interpolation in the generated config.\n\n## Installation\n\nInstallation instructions\n\nTo install directly from PyPI\n```shell\npip install jinja-unquote-resolvers-filter\n```\n\nTo install from the git repo\n```shell\npip install git+https://github.com/Sceptre/jinja-unquote-resolvers-filter.git\n```\n\n## Usage/Examples\n\nIn your var file:\n\n```yaml\nSubnets:\n  - '!stack_output_external mystack::subnet_a'  # Quotes needed to protect a YAML tag.\n  - '!stack_output_external mystack::subnet_b'\n\nVPC: '!stack_output_external mystack::vpc_id'\n```\n\nIn your config:\n\n```yaml\nj2_environment:\n  extensions:\n    - jinja_unquote_resolvers_filter.UnquoteResolversFilterExtension\n\nsceptre_user_data:\n  subnets:\n    {{ var.Subnets | unquote_resolvers(output_indent=4, trim=True) }}\n  vpc: {{ var.VPC }}  # This filter is not needed if the quoted resolvers are passed in as scalars.\n```\n\n## Arguments\n\n- `indent` (optional, default=2): The number of spaces to use for indentation of nested structures in the output YAML.\n- `output_indent` (optional, default=0): The number of spaces to use for indentation of the entire output YAML.\n- `trim` (optional, default=False): Whether to trim leading and trailing spaces in the output YAML.\n\n## Limitations\n\nAt this time, resolver expressions must be wrapped in a single line of text. That is, instead of:\n\n```yaml\nmy_multiline_resolver: |\n  !from_json\n    - !request http://www.whatever.com\n```\n\nInstead write:\n\n```yaml\nmy_multiline_resolver: '!from_json [!request http://www.whatever.com]'\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "A Jinja filter for allowing Sceptre resolvers in var files",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/Sceptre/jinja-unquote-resolvers-filter",
        "Repository": "https://github.com/Sceptre/jinja-unquote-resolvers-filter"
    },
    "split_keywords": [
        "sceptre",
        " jinja"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "818d60bef9766c34b85bd1fbfb54fedddf55f35619235c4cf5801a2ee8d0a62d",
                "md5": "0eaa3386fd2aacd05ba8f9425614adc5",
                "sha256": "d931355ecf391984d6a7ebc9d4cabc1243ce82eefea307e5c3e7cd8118d3e398"
            },
            "downloads": -1,
            "filename": "jinja_unquote_resolvers_filter-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0eaa3386fd2aacd05ba8f9425614adc5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 3932,
            "upload_time": "2024-09-26T11:16:01",
            "upload_time_iso_8601": "2024-09-26T11:16:01.374947Z",
            "url": "https://files.pythonhosted.org/packages/81/8d/60bef9766c34b85bd1fbfb54fedddf55f35619235c4cf5801a2ee8d0a62d/jinja_unquote_resolvers_filter-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47d017b34440692a508daaa0b8a206cacd3e713731a51736cee303ea85a051c4",
                "md5": "7bdf382789848e8903414f2b04bce4ea",
                "sha256": "f78794403019b26de484a25cb0ea3682580a6d54e5cf456a0a5604e6c35e22ab"
            },
            "downloads": -1,
            "filename": "jinja_unquote_resolvers_filter-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7bdf382789848e8903414f2b04bce4ea",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 3196,
            "upload_time": "2024-09-26T11:16:02",
            "upload_time_iso_8601": "2024-09-26T11:16:02.610084Z",
            "url": "https://files.pythonhosted.org/packages/47/d0/17b34440692a508daaa0b8a206cacd3e713731a51736cee303ea85a051c4/jinja_unquote_resolvers_filter-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-26 11:16:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Sceptre",
    "github_project": "jinja-unquote-resolvers-filter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "jinja-unquote-resolvers-filter"
}
        
Elapsed time: 0.42319s