Fix for spulec/moto#1698 - ECR list_images missing RepositoryNotFoundException
This commit is contained in:
parent
bb6da93891
commit
e32a640861
@ -200,15 +200,20 @@ class ECRBackend(BaseBackend):
|
|||||||
"""
|
"""
|
||||||
maxResults and filtering not implemented
|
maxResults and filtering not implemented
|
||||||
"""
|
"""
|
||||||
images = []
|
repository = None
|
||||||
for repository in self.repositories.values():
|
found = False
|
||||||
if repository_name:
|
if repository_name in self.repositories:
|
||||||
if repository.name != repository_name:
|
repository = self.repositories[repository_name]
|
||||||
continue
|
|
||||||
if registry_id:
|
if registry_id:
|
||||||
if repository.registry_id != registry_id:
|
if repository.registry_id == registry_id:
|
||||||
continue
|
found = True
|
||||||
|
else:
|
||||||
|
found = True
|
||||||
|
|
||||||
|
if not found:
|
||||||
|
raise RepositoryNotFoundException(repository_name, registry_id or DEFAULT_REGISTRY_ID)
|
||||||
|
|
||||||
|
images = []
|
||||||
for image in repository.images:
|
for image in repository.images:
|
||||||
images.append(image)
|
images.append(image)
|
||||||
return images
|
return images
|
||||||
|
@ -247,9 +247,31 @@ def test_list_images():
|
|||||||
len(response['imageIds']).should.be(1)
|
len(response['imageIds']).should.be(1)
|
||||||
response['imageIds'][0]['imageTag'].should.equal('oldest')
|
response['imageIds'][0]['imageTag'].should.equal('oldest')
|
||||||
|
|
||||||
response = client.list_images(repositoryName='test_repository_2', registryId='109876543210')
|
|
||||||
type(response['imageIds']).should.be(list)
|
@mock_ecr
|
||||||
len(response['imageIds']).should.be(0)
|
def test_list_images_from_repository_that_doesnt_exist():
|
||||||
|
client = boto3.client('ecr', region_name='us-east-1')
|
||||||
|
_ = client.create_repository(
|
||||||
|
repositoryName='test_repository_1'
|
||||||
|
)
|
||||||
|
|
||||||
|
# non existing repo
|
||||||
|
error_msg = re.compile(
|
||||||
|
r".*The repository with name 'repo-that-doesnt-exist' does not exist in the registry with id '123'.*",
|
||||||
|
re.MULTILINE)
|
||||||
|
client.list_images.when.called_with(
|
||||||
|
repositoryName='repo-that-doesnt-exist',
|
||||||
|
registryId='123',
|
||||||
|
).should.throw(Exception, error_msg)
|
||||||
|
|
||||||
|
# repo does not exist in specified registry
|
||||||
|
error_msg = re.compile(
|
||||||
|
r".*The repository with name 'test_repository_1' does not exist in the registry with id '222'.*",
|
||||||
|
re.MULTILINE)
|
||||||
|
client.list_images.when.called_with(
|
||||||
|
repositoryName='test_repository_1',
|
||||||
|
registryId='222',
|
||||||
|
).should.throw(Exception, error_msg)
|
||||||
|
|
||||||
|
|
||||||
@mock_ecr
|
@mock_ecr
|
||||||
|
Loading…
Reference in New Issue
Block a user