ansible-community / ansible.content_builder

A collection to scaffold Ansible plugins.
GNU General Public License v3.0
31 stars 27 forks source link

[WIP] vmware.vmware_rest: Generate action_groups #76

Closed mariolenz closed 8 months ago

mariolenz commented 9 months ago
SUMMARY

Fixes #75

Generate action_groups for vmware.vmware_rest.

edit: Tested in ansible-collections/vmware.vmware_rest#461

ISSUE TYPE
COMPONENT NAME

plugins/action/generate_cloud_modules.py

ADDITIONAL INFORMATION

Same code as for the Amazon collection in generate_amazon_cloud.

This has already been requested twice by users: ansible-collections/vmware.vmware_rest#361 ansible-collections/vmware.vmware_rest#440

mariolenz commented 9 months ago

@alinabuzachis @GomathiselviS What do you think about this?

GomathiselviS commented 8 months ago

@mariolenz Thanks for implementing this feature. It will be immensely beneficial.

It looks good.

The generator currently rewrites the files if they already exist instead of managing the differences by writing or deleting them. We aimed to address this issue, but due to other pressing priorities, it hasn't been resolved yet. Do you think it's feasible to check the contents of the runtime.yml, if it exists, and selectively apply only the differences?

mariolenz commented 8 months ago

The generator currently rewrites the files if they already exist instead of managing the differences by writing or deleting them. We aimed to address this issue, but due to other pressing priorities, it hasn't been resolved yet. Do you think it's feasible to check the contents of the runtime.yml, if it exists, and selectively apply only the differences?

After thinking this through, I would keep re-generating the file every time. If there effectively are no changes, git will ignore the file when you commit so there's no change, really.

But if you want to "manage the differences" someone has to code this. This code can be buggy and needs to be maintained. Code that doesn't exist can't contain any bugs and nobody has to maintain it ;-)

I don't see any benefit over rewriting the file every time. It's probably even more efficient in terms of CPU cycles and other resources.

mariolenz commented 8 months ago

@GomathiselviS If this OK for you I'd like to keep this WIP until #77 is merged.

GomathiselviS commented 8 months ago

@mariolenz Please add unit testcase to test the generation of action_groups.

mariolenz commented 8 months ago

Please add unit testcase to test the generation of action_groups.

@GomathiselviS I have absolutely no idea how to do this. Any help would be very much appreciated.

Maybe I can more or less copy&paste the unit test for generating action_groups in generate_amazon_cloud but I seem unable to find it :-/

GomathiselviS commented 8 months ago

Please add unit testcase to test the generation of action_groups.

@GomathiselviS I have absolutely no idea how to do this. Any help would be very much appreciated.

Maybe I can more or less copy&paste the unit test for generating action_groups in generate_amazon_cloud but I seem unable to find it :-/

Take a look at the following file: test_generator.py. It contains testcases that might serve as a reference for adding a 'generate_action_group' testcase. If you require further information, feel free to ask.

mariolenz commented 8 months ago

@GomathiselviS I've closed this accidentally. Could you please reopen it again? Or should I create a new PR?

mariolenz commented 8 months ago

@GomathiselviS I've closed this accidentally. Could you please reopen it again? Or should I create a new PR?

@GomathiselviS I've created #78