8000 Add lambda config to ignore architecture by joe4dev · Pull Request #7890 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

Add lambda config to ignore architecture #7890

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add typed LS Arch class
Use standardized LocalStack `get_arch` to match Linux platform.
  • Loading branch information
joe4dev committed Mar 20, 2023
commit 19463cf875958209f442cf5a3e39b2f0ae6011d8
5 changes: 0 additions & 5 deletions localstack/testing/aws/lambda_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import os
import platform
from typing import Literal

from localstack.utils.common import to_str
Expand Down Expand Up @@ -127,7 +126,3 @@ def is_new_provider():
return os.environ.get("TEST_TARGET") != "AWS_CLOUD" and os.environ.get(
"PROVIDER_OVERRIDE_LAMBDA"
) in ["asf", "v2"]


def is_arm_compatible():
return platform.machine() == "arm64"
16 changes: 14 additions & 2 deletions localstack/utils/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@ def is_redhat() -> bool:
return "rhel" in load_file("/etc/os-release", "")


class Arch(str):
"""LocalStack standardised machine architecture names"""

amd64 = "amd64"
arm64 = "arm64"


def standardized_arch(arch: str):
"""
Returns LocalStack standardised machine architecture name.
"""
if arch == "x86_64":
return "amd64"
return Arch.amd64
if arch == "aarch64":
return "arm64"
return Arch.arm64
return arch


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


def is_arm_compatible() -> bool:
"""Returns true if the current machine is compatible with ARM instructions and false otherwise."""
return get_arch() == Arch.arm64


def get_os() -> str:
if is_mac_os():
return "osx"
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/awslambda/test_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from localstack.testing.aws.lambda_utils import (
concurrency_update_done,
get_invoke_init_type,
is_arm_compatible,
is_old_provider,
update_done,
)
Expand All @@ -27,7 +26,7 @@
from localstack.utils import files, platform, testutil
from localstack.utils.files import load_file
from localstack.utils.http import safe_requests
from localstack.utils.platform import standardized_arch
from localstack.utils.platform import is_arm_compatible, standardized_arch
from localstack.utils.strings import short_uid, to_bytes, to_str
from localstack.utils.sync import retry, wait_until
from localstack.utils.testutil import create_lambda_archive
Expand Down
0