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

Fix secret parsing, when there is no secret in secret yaml file #20

Merged
merged 4 commits into from
Oct 9, 2024

Conversation

darkdoc
Copy link
Contributor

@darkdoc darkdoc commented Oct 8, 2024

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.

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.
Copy link
Collaborator

@mhjacks mhjacks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to change the None test. Should we also have tests?
Also, we should change the version in galaxy.yml. In the narrowest possible view this is backwards incompatible, but I can't imagine anyone depends on this to throw these exceptions this way, and it would seem even odder to call this 2.0.0 for this

plugins/module_utils/parse_secrets_v2.py Outdated Show resolved Hide resolved
plugins/module_utils/parse_secrets_v2.py Outdated Show resolved Hide resolved
The check for "None" is better placed inside the get_secrets function,
with this, get_secrets will always return a list, either empty list, or
the list with the secrets from the yaml. Changed checks accordingly.
Changed default get to be an empty list if the "secret" key is not
present in the secret values file.
@mhjacks
Copy link
Collaborator

mhjacks commented Oct 9, 2024

LGTM

Added check for None type as well, in case the module is used witout
from_yaml filter (like in unit tests)
@darkdoc darkdoc requested a review from mhjacks October 9, 2024 13:31
@mhjacks
Copy link
Collaborator

mhjacks commented Oct 9, 2024

Looks even better to me now with tests (LEBTMNWT). :)

@darkdoc darkdoc merged commit 4534151 into validatedpatterns:main Oct 9, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants