Ensure that imagePushedAt fields from ECR is timezone aware (#4501)
This commit is contained in:
parent
56866e0ef5
commit
b0c22c6ac1
@ -3,7 +3,7 @@ import json
|
|||||||
import re
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
from random import random
|
from random import random
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ class Image(BaseObject):
|
|||||||
self.repository = repository
|
self.repository = repository
|
||||||
self.registry_id = registry_id
|
self.registry_id = registry_id
|
||||||
self.image_digest = digest
|
self.image_digest = digest
|
||||||
self.image_pushed_at = str(datetime.utcnow().isoformat())
|
self.image_pushed_at = str(datetime.now(timezone.utc).isoformat())
|
||||||
self.last_scan = None
|
self.last_scan = None
|
||||||
|
|
||||||
def _create_digest(self):
|
def _create_digest(self):
|
||||||
|
@ -361,7 +361,7 @@ def test_put_image_with_push_date():
|
|||||||
_ = client.create_repository(repositoryName="test_repository")
|
_ = client.create_repository(repositoryName="test_repository")
|
||||||
|
|
||||||
with freeze_time("2018-08-28 00:00:00"):
|
with freeze_time("2018-08-28 00:00:00"):
|
||||||
image1_date = datetime.now()
|
image1_date = datetime.now(tzlocal())
|
||||||
_ = client.put_image(
|
_ = client.put_image(
|
||||||
repositoryName="test_repository",
|
repositoryName="test_repository",
|
||||||
imageManifest=json.dumps(_create_image_manifest()),
|
imageManifest=json.dumps(_create_image_manifest()),
|
||||||
@ -369,7 +369,7 @@ def test_put_image_with_push_date():
|
|||||||
)
|
)
|
||||||
|
|
||||||
with freeze_time("2019-05-31 00:00:00"):
|
with freeze_time("2019-05-31 00:00:00"):
|
||||||
image2_date = datetime.now()
|
image2_date = datetime.now(tzlocal())
|
||||||
_ = client.put_image(
|
_ = client.put_image(
|
||||||
repositoryName="test_repository",
|
repositoryName="test_repository",
|
||||||
imageManifest=json.dumps(_create_image_manifest()),
|
imageManifest=json.dumps(_create_image_manifest()),
|
||||||
|
Loading…
Reference in New Issue
Block a user