Skip to content

Commit

Permalink
sops lookup, decrypt filter: add ini as valid input and output type (
Browse files Browse the repository at this point in the history
…#204)

* add ini as possible choice for input-type, output-type.

* Add note from when on new types are supported.

* Add changelog fragment.

---------

Co-authored-by: David Lahm <[email protected]>
  • Loading branch information
felixfontein and David Lahm authored Sep 9, 2024
1 parent 32a1bcd commit 7f1b0ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/fragments/204-input-output-type-ini.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
minor_changes:
- "decrypt filter plugin - now supports the input and output type ``ini`` (https://github.com/ansible-collections/community.sops/pull/204)."
- "sops lookup plugin - now supports the input and output type ``ini`` (https://github.com/ansible-collections/community.sops/pull/204)."
6 changes: 5 additions & 1 deletion plugins/filter/decrypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,29 @@
- There is no auto-detection since we do not have a filename. By default
SOPS is told to treat the input as YAML. If that is wrong, please set this
option to the correct value.
- The value V(ini) is available since community.sops 1.9.0.
type: str
choices:
- binary
- json
- yaml
- dotenv
- ini
default: yaml
output_type:
description:
- Tell SOPS how to interpret the decrypted file.
- Please note that the output is always text or bytes, depending on the value of O(decode_output).
To parse the resulting JSON or YAML, use corresponding filters such as P(ansible.builtin.from_json#filter)
and P(ansible.builtin.from_yaml#filter).
- The value V(ini) is available since community.sops 1.9.0.
type: str
choices:
- binary
- json
- yaml
- dotenv
- ini
default: yaml
decode_output:
description:
Expand Down Expand Up @@ -111,7 +115,7 @@
from ansible_collections.community.sops.plugins.module_utils.sops import Sops, SopsError


_VALID_TYPES = set(['binary', 'json', 'yaml', 'dotenv'])
_VALID_TYPES = set(['binary', 'json', 'yaml', 'dotenv', 'ini'])


def decrypt_filter(data, input_type='yaml', output_type='yaml', sops_binary='sops', rstrip=True, decode_output=True,
Expand Down
4 changes: 4 additions & 0 deletions plugins/lookup/sops.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,28 @@
- By default, SOPS will chose the input type from the file extension.
If it detects the wrong type for a file, this could result in decryption
failing.
- The value V(ini) is available since community.sops 1.9.0.
type: str
choices:
- binary
- json
- yaml
- dotenv
- ini
output_type:
description:
- Tell SOPS how to interpret the decrypted file.
- By default, SOPS will chose the output type from the file extension.
If it detects the wrong type for a file, this could result in decryption
failing.
- The value V(ini) is available since community.sops 1.9.0.
type: str
choices:
- binary
- json
- yaml
- dotenv
- ini
empty_on_not_exist:
description:
- When set to V(true), will not raise an error when a file cannot be found,
Expand Down

0 comments on commit 7f1b0ff

Please sign in to comment.