Skip to content

Commit

Permalink
Update code to Jinja 3.0 style
Browse files Browse the repository at this point in the history
Xena cycle uses Jinja 3.0 so let update Kolla's code for it.

From Jinja2 documentation:

jinja2.contextfunction(f: F) → F
    Pass the context as the first argument to the decorated function.
    Deprecated since version 3.0: Will be removed in Jinja 3.1. Use pass_context() instead.

jinja2.contextfilter(f)
    Pass the context as the first argument to the decorated function.
    Deprecated since version 3.0: Will be removed in Jinja 3.1. Use pass_context() instead.

Also bumped version in requirements.txt to same as in openstack/requirements

Change-Id: I51fbb7b9ff7c29cb355437efa4576be9bc035699
  • Loading branch information
hrw committed Jul 29, 2021
1 parent 796a8ec commit 383364e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions kolla/template/filters.py
Expand Up @@ -12,11 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from jinja2 import contextfilter
from jinja2 import 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
Expand Down
4 changes: 2 additions & 2 deletions kolla/template/methods.py
Expand Up @@ -15,7 +15,7 @@
import os
import yaml

from jinja2 import contextfunction
from jinja2 import pass_context


def debian_package_install(packages, clean_package_cache=True):
Expand Down Expand Up @@ -71,7 +71,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.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
@@ -1,5 +1,5 @@
pbr!=2.1.0,>=2.0.0 # Apache-2.0
docker>=2.4.2 # Apache-2.0
Jinja2>=2.8 # BSD License (3 clause)
Jinja2>=3.0.1 # BSD License (3 clause)
GitPython>=1.0.1 # BSD License (3 clause)
oslo.config>=5.1.0 # Apache-2.0

0 comments on commit 383364e

Please sign in to comment.