Skip to content

Commit

Permalink
Use double quotes instead of single quotes in ini
Browse files Browse the repository at this point in the history
Within Icinga Web's ini files double quotes are needed to encapsulate
certain values. Changed single quotes to double quotes in template.

Fixes #301
  • Loading branch information
Donien committed Jul 31, 2024
1 parent cf33636 commit fd8667e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/fix_issue_301.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "Certain values within Icinga Web :code:`ini` files got quoted incorrectly using single quotes. They are now quoted properly using double quotes (#301)."
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def test_advanced_filter(host):
i2_file = host.file("/tmp/advanced_filter")
print(i2_file.content_string)
assert i2_file.is_file
assert i2_file.content_string == "\n[section]\ntest = '!(objectClass=user)'\ntest2 = '!(objectClass=user)'\ntest3 = '!attribute'\n"
assert i2_file.content_string == '\n[section]\ntest = "!(objectClass=user)"\ntest2 = "!(objectClass=user)"\ntest3 = "!attribute"\n'

def test_equal_sign(host):
i2_file = host.file("/tmp/equal_sign")
print(i2_file.content_string)
assert i2_file.is_file
assert i2_file.content_string == "\n[section]\ntest = 'equal=sign'\n"
assert i2_file.content_string == '\n[section]\ntest = "equal=sign"\n'
4 changes: 2 additions & 2 deletions roles/icingaweb2/templates/ini_template.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
{{ option }} = "{{ value }}"
{% elif value is iterable and (value is not string and value is not mapping) %}
{{ option }} = "{{ value | join(', ') }}"
{% elif ( value is string and ( "=" in value or "!" in value ) )%}
{{ option }} = '{{ value }}'
{% elif ( value is string and ( "=" in value or "!" in value or " " in value ) )%}
{{ option }} = "{{ value }}"
{% else %}
{{ option }} = {{ value }}
{% endif %}
Expand Down

0 comments on commit fd8667e

Please sign in to comment.