Skip to content

Commit d296ffd

Browse files
tarilabsvsoch
andauthored
fix: auth via ECR to be an extra (#208)
* fix: auth via ECR to be an extra as intended in original PR. Signed-off-by: tarilabs <matteo.mortari@gmail.com> * linting Signed-off-by: tarilabs <matteo.mortari@gmail.com> * Update oras/auth/ecr.py Co-authored-by: Vanessasaurus <814322+vsoch@users.noreply.github.com> Signed-off-by: Matteo Mortari <matteo.mortari@gmail.com> * implement code review feedback Signed-off-by: tarilabs <matteo.mortari@gmail.com> Co-authored-by: Vanessasaurus <814322+vsoch@users.noreply.github.com> * implement review feedback by removing code comment and MD in error msg Signed-off-by: tarilabs <matteo.mortari@gmail.com> --------- Signed-off-by: tarilabs <matteo.mortari@gmail.com> Signed-off-by: Matteo Mortari <matteo.mortari@gmail.com> Co-authored-by: Vanessasaurus <814322+vsoch@users.noreply.github.com>
1 parent 1d448f2 commit d296ffd

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and **Merged pull requests**. Critical items to know are:
1414
The versions coincide with releases on pip. Only major versions will be released as tags on Github.
1515

1616
## [0.0.x](https://github.com/oras-project/oras-py/tree/main) (0.0.x)
17+
- fix 'authentication with ECR' to be an extra as intended (0.2.35)
1718
- Add support for authentication with ECR registries (0.2.34)
1819
- Add support for Docker credsStore and credHelpers
1920
- fix 'get_manifest()' method with adding 'load_configs()' calling (0.2.33)

oras/auth/ecr.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import re
66

7-
import boto3
87
import requests
98

109
import oras.auth.utils as auth_utils
@@ -54,6 +53,13 @@ def authenticate_request(
5453
logger.warning(f"realm: {h.realm} did not match expected pattern.")
5554
return super().request_token(h)
5655
region = m.group("region")
56+
try:
57+
import boto3
58+
except ImportError as e:
59+
msg = """the `boto3` dependency is required to support authentication to this registry.
60+
Make sure to install the required extra "ecr", e.g.: pip install oras[ecr].
61+
"""
62+
raise ImportError(msg) from e
5763
ecr = boto3.client("ecr", region_name=region)
5864
auth = ecr.get_authorization_token()["authorizationData"][0]
5965
token = auth.get("authorizationToken", "")

oras/decorator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def inner(*args, **kwargs):
5252
return res
5353
except oras.auth.AuthenticationException as e:
5454
raise e
55-
except requests.exceptions.SSLError:
55+
except (requests.exceptions.SSLError, ImportError):
5656
raise
5757
except Exception as e:
5858
sleep = timeout + 3**attempt

oras/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
__copyright__ = "Copyright The ORAS Authors."
33
__license__ = "Apache-2.0"
44

5-
__version__ = "0.2.34"
5+
__version__ = "0.2.35"
66
AUTHOR = "Vanessa Sochat"
77
EMAIL = "vsoch@users.noreply.github.com"
88
NAME = "oras"

0 commit comments

Comments
 (0)