diff --git a/.github/workflows/test-packages-action.yml b/.github/workflows/test-packages-action.yml index 9cc47b684c1b..870ebbda321c 100644 --- a/.github/workflows/test-packages-action.yml +++ b/.github/workflows/test-packages-action.yml @@ -125,6 +125,10 @@ jobs: with: name: nox-linux-${{ matrix.arch }}-${{ inputs.nox-session }} + - name: "Ensure docker is running" + run: | + sudo systemctl start containerd || exit 0 + - name: "Pull container ${{ matrix.container }}" run: | docker pull ${{ matrix.container }} diff --git a/changelog/67017.fixed.md b/changelog/67017.fixed.md new file mode 100644 index 000000000000..69de78c0abc4 --- /dev/null +++ b/changelog/67017.fixed.md @@ -0,0 +1 @@ +Update for deprecation of hex in pygit2 1.15.0 and above diff --git a/changelog/67019.fixed.md b/changelog/67019.fixed.md new file mode 100644 index 000000000000..d686ed7d849b --- /dev/null +++ b/changelog/67019.fixed.md @@ -0,0 +1 @@ +Fixed blob path for salt.ufw in the firewall tutorial documentation diff --git a/doc/topics/jinja/index.rst b/doc/topics/jinja/index.rst index ad8e436a00a5..79d88c4f149b 100644 --- a/doc/topics/jinja/index.rst +++ b/doc/topics/jinja/index.rst @@ -405,8 +405,9 @@ This text will be wrapped in quotes. .. versionadded:: 2017.7.0 -Scan through string looking for a location where this regular expression -produces a match. Returns ``None`` in case there were no matches found +Looks for a match for the specified regex anywhere in the string. If the string +does not match the regex, this filter returns ``None``. If the string _does_ +match the regex, then the `capture groups`_ for the regex will be returned. Example: @@ -420,6 +421,29 @@ Returns: ("defabcdef",) +If the regex you use does not contain a capture group then the number of +capture groups will be zero, and a matching regex will return an empty tuple. +This means that the following ``if`` statement would evaluate as ``False``: + +.. code-block:: jinja + + {%- if 'foobar' | regex_search('foo') %} + +If you do not need a capture group and are just looking to test if a string +matches a regex, then you should check to see if the filter returns ``None``: + +.. code-block:: jinja + + {%- if (some_var | regex_search('foo')) is not none %} + +.. note:: + + In a Jinja statement, a null value (i.e. a Python ``None``) should be + expressed as ``none`` (i.e. lowercase). More info on this can be found in + the **Note** section here in the `jinja docs`_. + +.. _`capture groups`: https://docs.python.org/3/library/re.html#re.Match.groups +.. _`jinja docs`: https://jinja.palletsprojects.com/en/stable/templates/#literals .. jinja_ref:: regex_match @@ -428,8 +452,8 @@ Returns: .. versionadded:: 2017.7.0 -If zero or more characters at the beginning of string match this regular -expression, otherwise returns ``None``. +Works exactly like :jinja_ref:`regex_search`, but only checks for matches at +the _beginning_ of the string passed into this filter. Example: diff --git a/doc/topics/tutorials/firewall.rst b/doc/topics/tutorials/firewall.rst index d7b199e31363..e91b4db8121e 100644 --- a/doc/topics/tutorials/firewall.rst +++ b/doc/topics/tutorials/firewall.rst @@ -176,7 +176,7 @@ to allow traffic on ``tcp/4505`` and ``tcp/4506``: **Ubuntu** Salt installs firewall rules in :blob:`/etc/ufw/applications.d/salt.ufw -`. Enable with: +`. Enable with: .. code-block:: bash diff --git a/salt/utils/gitfs.py b/salt/utils/gitfs.py index e988959109e8..09076406f84a 100644 --- a/salt/utils/gitfs.py +++ b/salt/utils/gitfs.py @@ -528,7 +528,6 @@ def _val_cb(x, y): if HAS_PSUTIL: cur_pid = os.getpid() process = psutil.Process(cur_pid) - dgm_process_dir = dir(process) cache_dir = self.opts.get("cachedir", None) gitfs_active = self.opts.get("gitfs_remotes", None) if cache_dir and gitfs_active: @@ -1780,7 +1779,7 @@ def checkout(self, fetch_on_fail=True): return None try: - head_sha = self.peel(local_head).hex + head_sha = str(self.peel(local_head).id) except AttributeError: # Shouldn't happen, but just in case a future pygit2 API change # breaks things, avoid a traceback and log an error. @@ -1839,7 +1838,10 @@ def _perform_checkout(checkout_ref, branch=True): self.repo.create_reference(local_ref, pygit2_id) try: - target_sha = self.peel(self.repo.lookup_reference(remote_ref)).hex + target_sha = str( + self.peel(self.repo.lookup_reference(remote_ref)).id + ) + except KeyError: log.error( "pygit2 was unable to get SHA for %s in %s remote '%s'", @@ -1920,10 +1922,11 @@ def _perform_checkout(checkout_ref, branch=True): else: try: # If no AttributeError raised, this is an annotated tag - tag_sha = tag_obj.target.hex + tag_sha = str(tag_obj.target.id) + except AttributeError: try: - tag_sha = tag_obj.hex + tag_sha = str(tag_obj.id) except AttributeError: # Shouldn't happen, but could if a future pygit2 # API change breaks things. @@ -2277,7 +2280,7 @@ def find_file(self, path, tgt_env): blob = None break if isinstance(blob, pygit2.Blob): - return blob, blob.hex, mode + return blob, str(blob.id), mode return None, None, None def get_tree_from_branch(self, ref): diff --git a/tests/pytests/unit/utils/test_gitfs.py b/tests/pytests/unit/utils/test_gitfs.py index 4b0c11afd60f..03e4398dd98f 100644 --- a/tests/pytests/unit/utils/test_gitfs.py +++ b/tests/pytests/unit/utils/test_gitfs.py @@ -23,6 +23,14 @@ if HAS_PYGIT2: import pygit2 + try: + from pygit2.enums import ObjectType + + HAS_PYGIT2_ENUMS = True + + except ModuleNotFoundError: + HAS_PYGIT2_ENUMS = False + @pytest.fixture def minion_opts(tmp_path): @@ -147,9 +155,14 @@ def _prepare_remote_repository_pygit2(tmp_path): tree, [repository.head.target], ) - repository.create_tag( - "annotated_tag", commit, pygit2.GIT_OBJ_COMMIT, signature, "some message" - ) + if HAS_PYGIT2_ENUMS: + repository.create_tag( + "annotated_tag", commit, ObjectType.COMMIT, signature, "some message" + ) + else: + repository.create_tag( + "annotated_tag", commit, pygit2.GIT_OBJ_COMMIT, signature, "some message" + ) return remote