Avoid deprecated utcnow() (#8222)

Avoid deprecated utcnow().
This commit is contained in:
Felix Fontein 2024-04-20 09:26:08 +02:00 committed by GitHub
parent 1b8e6bc95b
commit 524d5883b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 142 additions and 64 deletions

View file

@ -91,12 +91,17 @@ EXAMPLES = '''
pubkey: "{{ lookup('ansible.builtin.file', '/home/foo/.ssh/id_rsa.pub') }}"
'''
import datetime
import json
import re
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.urls import fetch_url
from ansible_collections.community.general.plugins.module_utils.datetime import (
now,
)
API_BASE = 'https://api.github.com'
@ -151,14 +156,13 @@ def get_all_keys(session):
def create_key(session, name, pubkey, check_mode):
if check_mode:
from datetime import datetime
now = datetime.utcnow()
now_t = now()
return {
'id': 0,
'key': pubkey,
'title': name,
'url': 'http://example.com/CHECK_MODE_GITHUB_KEY',
'created_at': datetime.strftime(now, '%Y-%m-%dT%H:%M:%SZ'),
'created_at': datetime.strftime(now_t, '%Y-%m-%dT%H:%M:%SZ'),
'read_only': False,
'verified': False
}