Skip to content

Commit

Permalink
Fix secret parsing, when there is no secret in secret yaml file
Browse files Browse the repository at this point in the history
This will fix the edge case when there is an empty list ([]) or no
secret in the secret values file for a pattern, the validation and
the parsing would fail the module. Now it only throws a warning for both
validation and parsing.
  • Loading branch information
darkdoc committed Oct 8, 2024
1 parent c6ffde9 commit 630a7f8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions plugins/module_utils/parse_secrets_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,11 @@ def parse(self):
secrets = self._get_secrets()

total_secrets = 0 # Counter for all the secrets uploaded

if secrets == 'None' or len(secrets) == 0:
self.module.warn("No secrets were parsed")
return total_secrets

for s in secrets:
total_secrets += 1
counter = 0 # This counter is to use kv put on first secret and kv patch on latter
Expand Down Expand Up @@ -322,8 +327,9 @@ def _validate_field(self, f):
def _validate_secrets(self):
backing_store = self._get_backingstore()
secrets = self._get_secrets()
if len(secrets) == 0:
self.module.fail_json("No secrets found")
if secrets == 'None' or len(secrets) == 0:
self.module.warn("No secrets found")
return (True, "")

names = []
for s in secrets:
Expand Down

0 comments on commit 630a7f8

Please sign in to comment.