-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add modules metal_project_ssh_key{_info}, docs and tests #107
Conversation
@AlexBacho 👍 thanks for the PR, I'll take a look and run the tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually call the PRs based on the content, not by the issue they fix, so this could be "Add modules metal_project_ssh_key{_info}, docs and tests" instead of "Feature 65"
required_one_of=[("label", "id")], | ||
required_together=[("label", "key")], | ||
) | ||
print("!!!!!!!!!!!!!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you forgot debug prints here?
print()
usually doesn't work in Ansible modules, because Ansible is hijacking stdout <- IMO one of the worst things about developing Ansible modules. I use
https://github.com/zestyping/q
.. for debugging
requirements.txt
Outdated
@@ -1,2 +1,3 @@ | |||
equinix-metal>=0.2.2 | |||
ansible-specdoc>=0.0.13 | |||
pydantic==1.10.2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this shuold come in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all integration tests fail without this, will need to address it before merging this pr
- equinix.cloud.metal_project_ssh_key: | ||
label: "test_key" | ||
key: "ssh-dss AAAAB3NzaC1kc3MAAACBAPLEVntPO3L7VUbEwWZ2ErkQJ3KJ8o9kFXJrPcpvVfdNag4jIhQDqbtAUgUy6BclhhbfH9l5nlGTprrpEFkxm/GL91qJUX6xrPkDMjMqx2wSKa4YraReOrCOfkqqEkC3o3G/gYSuvTzLgp2rmPiflypftZyzNM4JZT8jDwFGotJhAAAAFQDPk43bayONtUxjkAcOf+6zP1qb6QAAAIBZHHH0tIlth5ot+Xa/EYuB/M4qh77EkrWUbER0Kki7suskw/ffdKQ0y/v+ZhoAHtBU7BeE3HmP98Vrha1i4cOU+A7DCqV+lK/a+5LoEpua0M2M+VzNSGluYuV4qGpAOxNh3mxUi2R7yXxheN1oks1ROJ/bqkF4BJQXU9Nv49GkZgAAAIByWcsFeOitvzyDaNJOZzEHv9fqGuj0L3maRVWb6O47HGzlMzniIy8WjL2dfgm2/ek+NxVR/yFnYTKDPr6+0uqSD/cb4eHaFbIj7v+k7H8hA1Ioz+duJ1ONAjn6KwneXxOXu15bYIR49P7Go0s9jCdSAP/r9NE5TnE3yiRiQzgEzw== tomk@node" | ||
project_id: "local.project_id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
project IDs (and any IDs in Equinix MEtal) are uuids (e.g. 7c7e9e99-71cf-4425-90d7-b9c950d25705) , so the example should also show some uuid.
Please fix this in all the docs, I won't comment on every occurrence.
README.md
Outdated
[equinix.cloud.metal_reserved_ip_block_info](./docs/modules/metal_reserved_ip_block_info.md)|Gather list of reserved IP blocks| | ||
[equinix.cloud.metal_ssh_key_info](./docs/modules/metal_ssh_key_info.md)|Gather personal SSH keys| | ||
list project SSH keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how this rogue line got here. We don't write README.md by hand. If we need to change readme, we do it in the template/README.template.md
@@ -50,6 +50,9 @@ def get_routes(mpc): | |||
('metal_ssh_key', action.GET): spec_types.Specs( | |||
equinix_metal.SSHKeysApi(mpc).find_ssh_key_by_id, | |||
), | |||
('metal_project_ssh_key', action.GET): spec_types.Specs( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as the API route for getting user ssh keys and project ssh keys by ID is the same, we could remove this particular route, and do this in metal_project_ssh_key.py
:
try:
module.params_syntax_check()
if module.params.get("id"):
tolerate_not_found = state == "absent"
# API getter is the same for user and project key
fetched = module.get_by_id("metal_ssh_key", tolerate_not_found)
else:
fetched = module.get_one_from_list(
# API listing method is different for project keys
"metal_project_ssh_key",
["key"],
)
That way there will be less code to maintain
@@ -119,6 +126,9 @@ def get_routes(mpc): | |||
('metal_ssh_key', action.DELETE): spec_types.Specs( | |||
equinix_metal.SSHKeysApi(mpc).delete_ssh_key, | |||
), | |||
('metal_project_ssh_key', action.DELETE): spec_types.Specs( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this route, and do
module.delete_by_id("metal_ssh_key")
in metal_project_ssh_key.py
@@ -174,4 +189,9 @@ def get_routes(mpc): | |||
{}, | |||
equinix_metal.SSHKeyInput, | |||
), | |||
('metal_project_ssh_key', action.UPDATE): spec_types.Specs( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this route, and do
fetched = module.update_by_id(diff, "metal_ssh_key")
in metal_project_ssh_key.py
I'm not sure how to run the integration tests here in the PR. This What do you think @displague ? |
Looks good but let's merge #108 first |
…ers, update readme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed before, so here I'm just approving
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed before (twice), so here I'm just approving
implements #65