Skip to content

Instantly share code, notes, and snippets.

@punya-asapp
Created July 17, 2018 17:35
Show Gist options
  • Save punya-asapp/2ab6a19e07a3178fe9aed4cf39280edf to your computer and use it in GitHub Desktop.
Save punya-asapp/2ab6a19e07a3178fe9aed4cf39280edf to your computer and use it in GitHub Desktop.
def gather_pages(func, *args, **kwargs):
result = func(*args, **kwargs)
yield result
while 'nextToken' in result:
result = func(*args, kwargs, nextToken=result['nextToken'])
yield result
def describe_all_images(registry_id, repository_name):
client = boto3.client('ecr')
return [image
for image in resp['imageDetails']
for resp in gather_pages(client.describe_images,
registryId=registry_id,
repositoryName=repository_name,
maxResults=100)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment