mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-05 15:59:09 -07:00
[PR #8222/524d5883 backport][stable-8] Avoid deprecated utcnow() (#8243)
Avoid deprecated utcnow() (#8222)
Avoid deprecated utcnow().
(cherry picked from commit 524d5883b8
)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
83738f21a3
commit
4832100d76
19 changed files with 142 additions and 64 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue