Skip to content

Commit b6438af

Browse files
committed
changes after code library build.
1 parent 45ff358 commit b6438af

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

python/example_code/ecr/ecr_getting_started.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ def run(self, role_arn: str) -> None:
132132
self.docker_image = self.docker_client.images.build(
133133
path="docker_files", tag=self.full_tag_name
134134
)[0]
135-
self.docker_image.tag(repository=repository_uri, tag=self.tag)
136135
print(f"Docker image {self.full_tag_name} successfully built.")
137136
press_enter_to_continue()
138137
print_dashes()
@@ -179,7 +178,7 @@ def run(self, role_arn: str) -> None:
179178
* Retrieve an ECR authorization token.
180179
181180
You need an authorization token to securely access and interact with the Amazon ECR registry.
182-
The `getAuthorizationToken` method of the `EcrAsyncClient` is responsible for securely accessing
181+
The `get_authorization_token` method of the `ecr` client is responsible for securely accessing
183182
and interacting with an Amazon ECR repository. This operation is responsible for obtaining a
184183
valid authorization token, which is required to authenticate your requests to the ECR service.
185184
@@ -233,9 +232,8 @@ def run(self, role_arn: str) -> None:
233232
"""
234233
* Push a docker image to the Amazon ECR Repository.
235234
236-
The method uses the authorization token to create an `AuthConfig` object, which is used to authenticate
237-
the Docker client when pushing the image. Finally, the method tags the Docker image with the specified
238-
repository name and image image_tag, and then pushes the image to the ECR repository using the Docker client.
235+
The Docker client uses the authorization token is used to authenticate the when pushing the image to the
236+
ECR repository.
239237
"""
240238
)
241239
decoded_authorization = base64.b64decode(authorization_token).decode("utf-8")

python/example_code/ecr/ecr_wrapper.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ def delete_repository(self, repository_name: str):
7474
self.ecr_client.delete_repository(
7575
repositoryName=repository_name, force=True
7676
)
77-
logger.info("Deleted repository %s.", repository_name)
77+
print(f"Deleted repository {repository_name}.")
7878
except ClientError as err:
79-
logger.exception(
79+
logger.error(
8080
"Couldn't delete repository %s.. Here's why %s",
8181
repository_name,
8282
err.response["Error"]["Message"],
@@ -97,13 +97,13 @@ def set_repository_policy(self, repository_name: str, policy_text: str):
9797
self.ecr_client.set_repository_policy(
9898
repositoryName=repository_name, policyText=policy_text
9999
)
100-
logger.info("Set repository policy for repository %s.", repository_name)
100+
print(f"Set repository policy for repository {repository_name}.")
101101
except ClientError as err:
102102
if err.response["Error"]["Code"] == "RepositoryPolicyNotFoundException":
103-
logger.info("Repository does not exist. %s.", repository_name)
103+
logger.error("Repository does not exist. %s.", repository_name)
104104
raise
105105
else:
106-
logger.exception(
106+
logger.error(
107107
"Couldn't set repository policy for repository %s. Here's why %s",
108108
repository_name,
109109
err.response["Error"]["Message"],
@@ -127,10 +127,10 @@ def get_repository_policy(self, repository_name: str) -> str:
127127
return response["policyText"]
128128
except ClientError as err:
129129
if err.response["Error"]["Code"] == "RepositoryPolicyNotFoundException":
130-
logger.info("Repository does not exist. %s.", repository_name)
130+
logger.error("Repository does not exist. %s.", repository_name)
131131
raise
132132
else:
133-
logger.exception(
133+
logger.error(
134134
"Couldn't get repository policy for repository %s. Here's why %s",
135135
repository_name,
136136
err.response["Error"]["Message"],
@@ -150,7 +150,7 @@ def get_authorization_token(self) -> str:
150150
response = self.ecr_client.get_authorization_token()
151151
return response["authorizationData"][0]["authorizationToken"]
152152
except ClientError as err:
153-
logger.exception(
153+
logger.error(
154154
"Couldn't get authorization token. Here's why %s",
155155
err.response["Error"]["Message"],
156156
)
@@ -172,7 +172,7 @@ def describe_repositories(self, repository_names: list[str]) -> list[dict]:
172172
)
173173
return response["repositories"]
174174
except ClientError as err:
175-
logger.exception(
175+
logger.error(
176176
"Couldn't describe repositories. Here's why %s",
177177
err.response["Error"]["Message"],
178178
)
@@ -193,9 +193,9 @@ def put_lifecycle_policy(self, repository_name: str, lifecycle_policy_text: str)
193193
repositoryName=repository_name,
194194
lifecyclePolicyText=lifecycle_policy_text,
195195
)
196-
logger.info("Put lifecycle policy for repository %s.", repository_name)
196+
print(f"Put lifecycle policy for repository {repository_name}.")
197197
except ClientError as err:
198-
logger.exception(
198+
logger.error(
199199
"Couldn't put lifecycle policy for repository %s. Here's why %s",
200200
repository_name,
201201
err.response["Error"]["Message"],
@@ -228,7 +228,7 @@ def describe_images(
228228
image_descriptions.extend(page["imageDetails"])
229229
return image_descriptions
230230
except ClientError as err:
231-
logger.exception(
231+
logger.error(
232232
"Couldn't describe images. Here's why %s",
233233
err.response["Error"]["Message"],
234234
)

python/example_code/ecr/test/conftest.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ def __init__(self):
3030
self.image_tag = (None,)
3131
self.path = None
3232

33-
def tag(self, repository: str, tag: str) -> None:
34-
assert repository == self.repository, "MockDockerImage.tag"
35-
assert tag == self.image_tag, "MockDockerImage.tag"
36-
3733
def build(self, path: str, tag: str) -> tuple["MockDockerImage", None]:
3834
assert path == self.path, "MockDockerImage.build"
3935
assert tag == f"{self.repository}:{self.image_tag}", "MockDockerImage.build"

0 commit comments

Comments
 (0)