8000 Add typed LS Arch class · localstack/localstack@a8bdc0e · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit a8bdc0e

Browse files
committed
Add typed LS Arch class
Use standardized LocalStack `get_arch` to match Linux platform.
1 parent 26baaec commit a8bdc0e

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

localstack/testing/aws/lambda_utils.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import json
22
import os
3-
import platform
43
from typing import Literal
54

65
from localstack.utils.common import to_str
@@ -127,7 +126,3 @@ def is_new_provider():
< 8000 code>127126
return os.environ.get("TEST_TARGET") != "AWS_CLOUD" and os.environ.get(
128127
"PROVIDER_OVERRIDE_LAMBDA"
129128
) in ["asf", "v2"]
130-
131-
132-
def is_arm_compatible():
133-
return platform.machine() == "arm64"

localstack/utils/platform.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,21 @@ def is_redhat() -> bool:
2828
return "rhel" in load_file("/etc/os-release", "")
2929

3030

31+
class Arch(str):
32+
"""LocalStack standardised machine architecture names"""
33+
34+
amd64 = "amd64"
35+
arm64 = "arm64"
36+
37+
3138
def standardized_arch(arch: str):
3239
"""
3340
Returns LocalStack standardised machine architecture name.
3441
"""
3542
if arch == "x86_64":
36-
return "amd64"
43+
return Arch.amd64
3744
if arch == "aarch64":
38-
return "arm64"
45+
return Arch.arm64
3946
return arch
4047

4148

@@ -47,6 +54,11 @@ def get_arch() -> str:
4754
return standardized_arch(arch)
4855

4956

57+
def is_arm_compatible() -> bool:
58+
"""Returns true if the current machine is compatible with ARM instructions and false otherwise."""
59+
return get_arch() == Arch.arm64
60+
61+
5062
def get_os() -> str:
5163
if is_mac_os():
5264
return "osx"

tests/integration/awslambda/test_lambda.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from localstack.testing.aws.lambda_utils import (
1717
concurrency_update_done,
1818
get_invoke_init_type,
19-
is_arm_compatible,
2019
is_old_provider,
2120
update_done,
2221
)
@@ -27,7 +26,7 @@
2726
from localstack.utils import files, platform, testutil
2827
from localstack.utils.files import load_file
2928
from localstack.utils.http import safe_requests
30-
from localstack.utils.platform import standardized_arch
29+
from localstack.utils.platform import is_arm_compatible, standardized_arch
3130
from localstack.utils.strings import short_uid, to_bytes, to_str
3231
from localstack.utils.sync import retry, wait_until
3332
from localstack.utils.testutil import create_lambda_archive

0 commit comments

Comments
 (0)
0