8000 Helper changes to support `eksctl` and CDK L2 EKS construct by simonrw · Pull Request #9309 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

Helper changes to support eksctl and CDK L2 EKS construct #9309

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 4 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion localstack/services/cloudformation/resource_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"AWS::ElasticBeanstalk::Environment": "ResourceProvider",
"AWS::ElasticBeanstalk::ConfigurationTemplate": "ResourceProvider",
"AWS::CertificateManager::Certificate": "ResourceProvider",
"AWS::EKS::Nodegroup": "ResourceProvider",
}


Expand Down Expand Up @@ -758,7 +759,7 @@ def load_resource_provider(self, resource_type: str) -> ResourceProvider:
return plugin.factory()
except Exception:
LOG.warning(
"Failed to load resource type as a ResourceProvider.",
"Failed to load resource type %s as a ResourceProvider.",
resource_type,
exc_info=LOG.isEnabledFor(logging.DEBUG),
)
Expand Down
3 changes: 2 additions & 1 deletion localstack/testing/pytest/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,8 @@ def _destroy_stack():

yield _deploy

for entry in state:
# delete the stacks in the reverse order they were created in case of inter-stack dependencies
for entry in state[::-1]:
entry_stack_id = entry.get("stack_id")
try:
if entry_stack_id:
Expand Down
18 changes: 14 additions & 4 deletions localstack/utils/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Any, Callable, Dict, Generic, List, Optional, Set, Type, TypeVar, Union

from .collections import ensure_list
from .strings import first_char_to_lower
from .strings import first_char_to_lower, first_char_to_upper

ComplexType = Union[List, Dict, object]

Expand Down Expand Up @@ -155,8 +155,10 @@ def recurse_object(obj: ComplexType, func: Callable, path: str = "") -> ComplexT
return obj


def keys_to_lower(obj: ComplexType, skip_children_of: List[str] = None) -> ComplexType:
"""Recursively changes all dict keys to first character lowercase. Skip children
def keys_to(
obj: ComplexType, op: Callable[[str], str], skip_children_of: List[str] = None
) -> ComplexType:
"""Recursively changes all dict keys to apply op. Skip children
of any elements whose names are contained in skip_children_of (e.g., ['Tags'])"""
skip_children_of = ensure_list(skip_children_of or [])

Expand All @@ -166,13 +168,21 @@ def fix_keys(o, path="", **kwargs):
if isinstance(o, dict):
for k, v in dict(o).items():
o.pop(k)
o[first_char_to_lower(k)] = v
o[op(k)] = v
return o

result = recurse_object(obj, fix_keys)
return result


def keys_to_lower(obj: ComplexType, skip_children_of: List[str] = None) -> ComplexType:
return keys_to(obj, first_char_to_lower, skip_children_of)


def keys_to_upper(obj: ComplexType, skip_children_of: List[str] = None) -> ComplexType:
return keys_to(obj, first_char_to_upper, skip_children_of)


def singleton_factory(factory: Callable[[], _T]) -> Callable[[], _T]:
"""
Decorator for methods that create a particular value once and then return the same value in a thread safe way.
Expand Down
0