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

feat: add deprecation field to hcloud_iso_info #357

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/add-deprecation-field-to-iso-info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- hcloud_iso_info - Add deprecation field
31 changes: 30 additions & 1 deletion plugins/modules/hcloud_iso_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,33 @@
description: >
ISO 8601 timestamp of deprecation, None if ISO is still available.
After the deprecation time it will no longer be possible to attach the
ISO to servers.
ISO to servers. This field is deprecated. Use `deprecation` instead.
returned: always
type: str
sample: "2024-12-01T00:00:00+00:00"
deprecation:
description: >
Describes if, when & how the resources was deprecated. If this field is
set to None the resource is not deprecated. If it has a value, it is
considered deprecated.
returned: if the resource is deprecated
type: dict
contains:
announced:
description: Date of when the deprecation was announced.
returned: always
type: str
sample: "2021-11-01T00:00:00+00:00"
unavailable_after:
description: >
After the time in this field, the resource will not be available
from the general listing endpoint of the resource type, and it can
not be used in new resources. For example, if this is an image,
you can not create new servers with this image after the mentioned
date.
returned: always
type: str
sample: "2021-12-01T00:00:00+00:00"
"""

from typing import List, Optional
Expand Down Expand Up @@ -126,6 +149,12 @@ def _prepare_result(self):
"type": iso_info.type,
"architecture": iso_info.architecture,
"deprecated": iso_info.deprecated,
"deprecation": {
"announced": iso_info.deprecation.announced.isoformat(),
"unavailable_after": iso_info.deprecation.unavailable_after.isoformat(),
}
if iso_info.deprecation is not None
else None,
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ hcloud_iso_id: 551
hcloud_iso_name: systemrescuecd-x86-5.2.2.iso
hcloud_iso_type: public
hcloud_iso_architecture: x86

hcloud_iso_deprecated_id: 10433
hcloud_iso_deprecated_name: vyos-1.4-rolling-202111150317-amd64.iso
hcloud_iso_deprecated_announced: "2023-10-05T08:27:01+00:00"
hcloud_iso_deprecated_unavailable_after: "2023-11-05T08:27:01+00:00"
13 changes: 13 additions & 0 deletions tests/integration/targets/hcloud_iso_info/tasks/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,16 @@
- result.hcloud_iso_info | list | count > 2
- result.hcloud_iso_info | selectattr('architecture', 'equalto', 'x86') | list | count == 0
- result.hcloud_iso_info | selectattr('architecture', 'equalto', 'arm') | list | count > 2

- name: Gather hcloud_iso_info with deprecation
hetzner.hcloud.hcloud_iso_info:
id: "{{ hcloud_iso_deprecated_id }}"
register: result
- name: Verify hcloud_iso_info with correct id
ansible.builtin.assert:
that:
- result.hcloud_iso_info | list | count == 1
- result.hcloud_iso_info[0].id == "{{ hcloud_iso_deprecated_id }}"
- result.hcloud_iso_info[0].name == "{{ hcloud_iso_deprecated_name }}"
- result.hcloud_iso_info[0].deprecation.announced == "{{ hcloud_iso_deprecated_announced }}"
- result.hcloud_iso_info[0].deprecation.unavailable_after == "{{ hcloud_iso_deprecated_unavailable_after }}"
jooola marked this conversation as resolved.
Show resolved Hide resolved