Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relace contextfilter with pass_context #127

Merged
merged 3 commits into from
Jun 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions filter_plugins/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

import re

import jinja2
# NOTE: jinja2 3.1.0 dropped contextfilter in favour of pass_context.
try:
from jinja2 import pass_context
except ImportError:
from jinja2 import contextfilter as pass_context


def _fail(reason):
Expand Down Expand Up @@ -128,7 +132,7 @@ def _interface_check(context, interface, interface_type=None):
return _pass()


@jinja2.contextfilter
@pass_context
def ether_check(context, interface):
"""Check whether the active state of an Ethernet interface is as requested.

Expand All @@ -143,7 +147,7 @@ def ether_check(context, interface):
return result


@jinja2.contextfilter
@pass_context
def bridge_check(context, interface):
"""Check whether the active state of a bridge interface is as requested.

Expand Down Expand Up @@ -175,7 +179,7 @@ def bridge_check(context, interface):
return result


@jinja2.contextfilter
@pass_context
def bond_check(context, interface):
"""Check whether the active state of a bond interface is as requested.

Expand Down