]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: add shellquote filter to template
authorJohn Mulligan <jmulligan@redhat.com>
Thu, 28 Sep 2023 20:44:14 +0000 (16:44 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Sun, 10 Dec 2023 15:13:31 +0000 (10:13 -0500)
This is to support generating command lines or shell scripts using
Jinja2 templates in the future.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/cephadm/cephadmlib/templating.py

index a431ba669999d7e6fd34657c3044fffa46c11904..5f4dda0560864fda415ca90e7d6f5a883696ca04 100644 (file)
@@ -3,6 +3,7 @@
 import enum
 import os
 import posixpath
+import shlex
 import zipimport
 
 from typing import Any, Optional, IO, Tuple, Callable, cast
@@ -113,6 +114,7 @@ class Templater:
     def _env(self) -> jinja2.Environment:
         if self._jinja2_env is None:
             self._jinja2_env = jinja2.Environment(loader=self._loader)
+            self._jinja2_env.filters['shellquote'] = shlex.quote
         return self._jinja2_env
 
     @property