You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/test/units/plugins
Daniel Goldman 989eeb243f
Add an `undef` global Jinja function (#75435)
* add tests for fail filter

also tests that fail does not block inspectability

* add fail filter

fallback message is a bit clunky,
since you can't invoke a filter without specifying an input.
That is, "{{ fail }}" doesn't work,
so you have to do "{{ None | fail }}"

* document 'fail' filter

* add changelog fragment

* fail filter uses default message on Undefined or emptystring

makes it slightly easier to use the default message:
```diff
- "{{ None | fail }}"
+ "{{ '' | fail }}"
```

and the user sees a slightly more relevant message
if the message itself is undefined:

```diff
- The error was: {{ failmsg | fail }}: 'failmsg' is undefined
+ The error was: {{ failmsg | fail }}: Mandatory variable has not been overridden
```

* rebuild as the builtin `Undefined`

* harmonise `hint` parameter for make_undefined with jinja

* use code block for documentation item

[ref](https://github.com/ansible/ansible/pull/75435#discussion_r707661035)

* rename to `undef` to expose less Python into the Jinja

[ref](https://github.com/ansible/ansible/pull/75435#pullrequestreview-757799031)

* explicitly instantiate undefined value now that it's possible

see I knew we would break something with reflection

* preserve test coverage of undefined variable

Co-authored-by: Matt Davis <nitzmahone@users.noreply.github.com>
3 years ago
..
action Clean up unit tests to prepare for pylint update. (#75473) 3 years ago
become Remove deprecated PlayContext.make_become_cmd (#74790) 4 years ago
cache Fix BaseFileCacheModule#keys to respect prefix (#72789) 4 years ago
callback Fix missing delegate display (#74370) 4 years ago
connection task_executor - use correct value for ssh connection retries (#75155) 3 years ago
filter Add an `undef` global Jinja function (#75435) 3 years ago
inventory constructed - Add keyed_groups suboptions 'default_value' and 'trailing_separator' (#74005) 4 years ago
loader_fixtures Clean up unit test boilerplate. 4 years ago
lookup Fix an exception when passlib library is used with a wrapped algo (#75527) 3 years ago
shell powershell - fix nested CLIXML parser (#71412) 4 years ago
strategy Temporarily disable strategy units (#74048) 4 years ago
__init__.py Add empty-init code-smell script. (#18406) 8 years ago
test_plugins.py plugin loader: return collection name; ansible-doc: handle ansible.builtin correctly (#70026) 4 years ago