Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sops lookup, decrypt filter: add ini as valid input and output type #204

Merged
merged 3 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading