Use jinja2.pass_context instead of contextfilter
The contextfilter decorator was deprecated in jinja2 3.0.0, and has been dropped in 3.1.0. This results in the following warning, and failed attempts to use filters: [WARNING]: Skipping plugin (filters.py) as it seems to be invalid: module 'jinja2' has no attribute 'contextfilter' This change switches to use the pass_context decorator. The minimum version of Jinja2 is raised to 3 to ensure pass_context is present. This change has been updated to also support Jinja2 2.x releases, since the Wallaby upper constraints specify 2.11.3. In practice, most users will not use UC to install kolla. CoAuthored-by: Mark Goddard <mark@stackhpc.com> Change-Id: I5efab66e487e06abd1a56af97d7e7caa1ebc880d
This commit is contained in:
parent
ebb2b09558
commit
3a6a17970e
|
@ -12,11 +12,16 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from jinja2 import contextfilter
|
||||
# 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
|
||||
|
||||
from jinja2 import Undefined
|
||||
|
||||
|
||||
@contextfilter
|
||||
@pass_context
|
||||
def customizable(context, val_list, call_type):
|
||||
# NOTE(mgoddard): Don't try to customise undefined values. There are cases
|
||||
# where this might happen, for example using a generic template overrides
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
import os
|
||||
import yaml
|
||||
|
||||
from jinja2 import contextfunction
|
||||
# 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 debian_package_install(packages, clean_package_cache=True):
|
||||
|
@ -71,7 +75,7 @@ def debian_package_install(packages, clean_package_cache=True):
|
|||
return ' && '.join(cmds)
|
||||
|
||||
|
||||
@contextfunction
|
||||
@pass_context
|
||||
def handle_repos(context, reponames, mode):
|
||||
"""NOTE(hrw): we need to handle CentOS, Debian and Ubuntu with one macro.
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes an issue seen when using Jinja2 3.1.0.
|
Loading…
Reference in New Issue