-
Notifications
You must be signed in to change notification settings - Fork 37
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
Would it make sense to document the precise format of not_valid_after
in hcloud_certificate_info
?
#91
Comments
This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs. |
@te-online Sorry for not getting back to you earlier. We use the format defined in RFC 3339, Section 5.6 ('Internet Date/Time Format', date-time in the ABNF) for producing timestamps returned by the public API with the following restrictions:
That said, there might be disparities in the API which should be considered as a bug. On the ansible collection side, I believe that we also have some inconsistency: we use either the string representation of the Python 3.11.6 (main, Oct 5 2023, 17:25:11) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime
>>> d = datetime.now()
>>> str(d)
'2023-12-21 18:54:18.762601'
>>> str(d.isoformat())
'2023-12-21T18:54:18.762601' I added this ticket to the v3 milestone, because I am not sure if I want to risk breaking user code by changing all the format to |
No worries 😊 If you've used ansible's My whole point was to have it documented, because it's a bit annoying I had to debug log the value to find what the issue with comparing the dates was. I personally think, hinting at the default format of the date in the docs would go a long way 🤓 I solved it like this, which is acceptable in my opinion (and can probably be improved anyways): - name: Try to get current certificate expiry date
ansible.builtin.set_fact:
certificate_expiry_date: "{{ certinfo.hcloud_certificate_info[0].not_valid_after }}"
when: existing_loadbalancer and (certinfo is defined)
ignore_errors: yes
- name: Calculate certificate expiry days
ansible.builtin.set_fact:
certificate_expiry_days: "{{ ((certificate_expiry_date | to_datetime('%Y-%m-%d %H:%M:%S%z')) - (ansible_date_time.iso8601 | to_datetime('%Y-%m-%dT%H:%M:%S%z'))).days }}"
when: certificate_expiry_date is defined |
##### SUMMARY Fixes #91 Always return datetime as iso-8601 formatted strings. ##### ISSUE TYPE - Bugfix Pull Request
SUMMARY
The docs state that
not_valid_after
is ISO-8601 formatted, which I think is true.It seems to be
%Y-%m-%d %H:%M:%S%z
(example:2021-06-15 13:37:08+00:00
)?However, I ran into issues, because I was comparing to
ansible_date_time.iso8601
, which is something like%Y-%m-%dT%H:%M:%SZ
(example:2021-06-15T13:37:08Z
).Note the
T
is a space in Hetzner Cloud's API response and the timezone notation is different.Would it make sense to document an example of the precise date format? Or is that just common knowledge that ISO-8601 can have slightly different representations?
ISSUE TYPE
COMPONENT NAME
hcloud_certificate_info
ANSIBLE VERSION
The text was updated successfully, but these errors were encountered: