Ensure that imagePushedAt fields from ECR is timezone aware (#4501)

This commit is contained in:
Boris Bera 2021-10-30 06:00:40 -04:00 committed by GitHub
parent 56866e0ef5
commit b0c22c6ac1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -3,7 +3,7 @@ import json
import re
import uuid
from collections import namedtuple
from datetime import datetime
from datetime import datetime, timezone
from random import random
from typing import Dict, List
@ -235,7 +235,7 @@ class Image(BaseObject):
self.repository = repository
self.registry_id = registry_id
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
def _create_digest(self):

View File

@ -361,7 +361,7 @@ def test_put_image_with_push_date():
_ = client.create_repository(repositoryName="test_repository")
with freeze_time("2018-08-28 00:00:00"):
image1_date = datetime.now()
image1_date = datetime.now(tzlocal())
_ = client.put_image(
repositoryName="test_repository",
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"):
image2_date = datetime.now()
image2_date = datetime.now(tzlocal())
_ = client.put_image(
repositoryName="test_repository",
imageManifest=json.dumps(_create_image_manifest()),