passbolt / lab-passbolt-ansible-collection

Source repository for https://galaxy.ansible.com/anatomicjc/passbolt
MIT No Attribution
9 stars 10 forks source link

Add exception if resource is not available #1

Closed FSchwehla closed 1 year ago

FSchwehla commented 1 year ago

To prevent that an empty password will be provided by the ansible lookup, I added an exception so that in case that the resource is not available and the create_new_resource parameter is set to false, the lookup will throw an error.

CLAassistant commented 1 year ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


FSchwehla seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

AnatomicJC commented 1 year ago

Hi @FSchwehla 👋

Thank you for the suggestion 👍, nice to see this ansible collection is used and yes, we should trigger an exception for this case :)

I would suggest an update on your PR. Instead of adding the resourcenotfound variable and additional if / else nightmare, maybe could we just replace on line 294:

ret.append(self._format_result(dict(), dict()))

With:

raise Exception("resource {} not found".format(terms[0]))

What do you think? Can you update your PR with only this change?

Best regards,

AnatomicJC commented 1 year ago

Cool! thank you for your contribution! Don't hesitate if you have other optimizations or questions 😃

AnatomicJC commented 1 year ago

I will create a new release soon with your change.

FSchwehla commented 1 year ago

Hi @AnatomicJC,

my pleasure and thank you for the incredibly fast response! 👍

Best Regards

AnatomicJC commented 1 year ago

@FSchwehla I just pushed the new release with your merged PR to https://galaxy.ansible.com/anatomicjc/passbolt

Have a nice day / weekend