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

Add modules metal_project_ssh_key{_info}, docs and tests #107

Merged
merged 11 commits into from
Aug 15, 2023

Conversation

AlexBacho
Copy link
Contributor

implements #65

@t0mk
Copy link
Contributor

t0mk commented Aug 2, 2023

@AlexBacho 👍 thanks for the PR, I'll take a look and run the tests.

Copy link
Contributor

@t0mk t0mk left a 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("!!!!!!!!!!!!!")
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor Author

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"
Copy link
Contributor

@t0mk t0mk Aug 2, 2023

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
Copy link
Contributor

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(
Copy link
Contributor

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(
Copy link
Contributor

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(
Copy link
Contributor

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

@t0mk
Copy link
Contributor

t0mk commented Aug 4, 2023

I'm not sure how to run the integration tests here in the PR. This
https://github.com/equinix-labs/ansible-collection-equinix/blob/main/.github/workflows/integration-tests.yml
..should trigger but didn't, probably because Alex doesn't have a role in the repo. I think we should have a command to run the tests or PR by external people.

What do you think @displague ?

@t0mk t0mk changed the title Feature 65 "Add modules metal_project_ssh_key{_info}, docs and tests Aug 4, 2023
@t0mk t0mk changed the title "Add modules metal_project_ssh_key{_info}, docs and tests Add modules metal_project_ssh_key{_info}, docs and tests Aug 4, 2023
t0mk
t0mk previously approved these changes Aug 4, 2023
@t0mk
Copy link
Contributor

t0mk commented Aug 4, 2023

Looks good but let's merge #108 first

@t0mk t0mk temporarily deployed to external August 15, 2023 10:55 — with GitHub Actions Inactive
t0mk
t0mk previously approved these changes Aug 15, 2023
Copy link
Contributor

@t0mk t0mk left a 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

@t0mk t0mk temporarily deployed to external August 15, 2023 11:07 — with GitHub Actions Inactive
Copy link
Contributor

@t0mk t0mk left a 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

@t0mk t0mk merged commit 2a64e13 into equinix:main Aug 15, 2023
2 checks passed
This was referenced Aug 15, 2023
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