Skip to content

Commit

Permalink
Merge pull request #358 from izapolsk/ec2_registry
Browse files Browse the repository at this point in the history
[RFR] adding supplementary stuff for working with internal ec2 registry
  • Loading branch information
mshriver authored Feb 22, 2019
2 parents 36af88e + dcad231 commit a78f397
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions wrapanapi/systems/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,11 @@ def __init__(self, **kwargs):
region_name=self._region_name, config=connection_config
)

self.ecr_connection = boto3client(
'ecr', aws_access_key_id=self._username, aws_secret_access_key=self._password,
region_name=self._region_name, config=connection_config
)

self.cloudformation_connection = boto3client(
'cloudformation', aws_access_key_id=self._username,
aws_secret_access_key=self._password, region_name=self._region_name,
Expand Down Expand Up @@ -1160,3 +1165,16 @@ def list_queues_with_creation_timestamps(self):
except Exception:
pass
return queue_dict

def get_registry_data(self):
# Returns dict with docker registry url and token
data = self.ecr_connection.get_authorization_token()
if data['ResponseMetadata']['HTTPStatusCode'] >= 400:
raise NotFoundError("couldn't get registry details. please check environment setup")

try:
first_registry = data['authorizationData'][0]
return {'token': first_registry['authorizationToken'],
'registry': first_registry['proxyEndpoint']}
except (IndexError, KeyError):
raise NotFoundError("couldn't get registry details. please check environment setup")

0 comments on commit a78f397

Please sign in to comment.