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

centralize argument spec #87

Conversation

mikemorency
Copy link
Collaborator

SUMMARY

This is preparing the pymomi module utils to be made public. The main change is centralizing the argument spec. This is related to the doc fragment update in #86

pyvmomi and rest both have 95% of the same args and the differences can be resolved without impacting the end user. In this change, I removed the cluster/datacenter from the common arg spec since they are re-defined in all of the modules that need them anyway. I also added the protocol arg to the spec. Since its used by the rest api but does nothing for pymomi, we can safely add it to all modules and not need to maintain two copies of this arg spec

There should be no change in functionality.

Rest API modules still use their own arg spec, but they should be updated to use this one later on

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

module_utils/_vmware

@mikemorency
Copy link
Collaborator Author

FYI, this will need to be combined with #86 before merging, but Im going to leave it as is for now so its easier to review

@mariolenz
Copy link
Collaborator

I also added the protocol arg to the spec. Since its used by the rest api but does nothing for pymomi, we can safely add it to all modules

I'm not sure that it's safe to add this to all modules. If we do, we have to document this. And if it's documented, people will assume it works for those modules. You're right, there should be no change in functionality. But it might make users expect things that are, at least ATM, not implemented ;-)

and not need to maintain two copies of this arg spec

I'm with you there. But instead of adding an argument to the pyvmomi modules that they don't use, how about dropping it from common_argument_spec() and have another function that simply re-uses it? Something like:

def vmware_rest_argument_spec():
    return {
        **common_argument_spec(), **dict(proxy_protocol=dict(
            proxy_protocol=dict(
                type='str',
                default='https',
                choices=['https', 'http'],
                aliases=['protocol']
            )

I've made this up quick'n'dirty, not sure if it works or if I made any stupid mistakes. But I hope this makes clear what I mean. I guess we could also do something similar for the docs fragments (#86).

@mikemorency
Copy link
Collaborator Author

fair enough. I did what you suggested for the arg spec and I think its works well. For the doc frags I did something similar.

Let me know your thoughts, I can try combining the two PRs if you think it looks good and well see what the build says

@mariolenz
Copy link
Collaborator

Let me know your thoughts, I can try combining the two PRs if you think it looks good and well see what the build says

I'm not really sure ATM. Maybe you're right and it would be a good idea to combine both PRs (again?) and see what happens 🤷

@mikemorency
Copy link
Collaborator Author

closing in favor of #89

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