8000 minor refactoring and adding missing path in Dockerfile · riddopic/localstack@b1dc51b · GitHub
[go: up one dir, main page]

Skip to content

Commit b1dc51b

Browse files
committed
minor refactoring and adding missing path in Dockerfile
1 parent 3d46443 commit b1dc51b

File tree

4 files changed

+18
-15
lines changed

4 files changed

+18
-15
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ RUN mkdir -p localstack/utils/kinesis/ && mkdir -p localstack/services/ && \
2929
touch localstack/__init__.py localstack/utils/__init__.py localstack/services/__init__.py localstack/utils/kinesis/__init__.py
3030
ADD localstack/constants.py localstack/config.py localstack/
3131
ADD localstack/services/install.py localstack/services/
32+
ADD localstack/services/cloudformation/deployment_utils.py localstack/services/cloudformation/deployment_utils.py
3233
ADD localstack/utils/common.py localstack/utils/bootstrap.py localstack/utils/
3334
ADD localstack/utils/aws/ localstack/utils/aws/
3435
ADD localstack/utils/kinesis/ localstack/utils/kinesis/

localstack/services/cloudformation/deployment_utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
import os
12
import json
23
from localstack.utils import common
4+
from localstack.constants import INSTALL_DIR_INFRA
5+
6+
# URL to "cfn-response" module which is required in some CF Lambdas
7+
CFN_RESPONSE_MODULE_URL = 'https://raw.githubusercontent.com/LukeMizuhashi/cfn-response/master/index.js'
38

49
# placeholders
510
PLACEHOLDER_RESOURCE_NAME = '__resource_name__'
@@ -99,3 +104,10 @@ def _convert(params, **kwargs):
99104
result = json.dumps(result)
100105
return result
101106
return _convert
107+
108+
109+
def get_cfn_response_mod_file():
110+
cfn_response_tmp_file = os.path.join(INSTALL_DIR_INFRA, 'lambda.cfn-response.js')
111+
if not os.path.exists(cfn_response_tmp_file):
112+
common.download(CFN_RESPONSE_MODULE_URL, cfn_response_tmp_file)
113+
return cfn_response_tmp_file

localstack/services/install.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ def install_lambda_java_libs():
242242

243243

244244
def install_cloudformation_libs():
245-
from localstack.utils.cloudformation import template_deployer
245+
from localstack.services.cloudformation import deployment_utils
246246
# trigger download of CF module file
247-
template_deployer.get_cfn_response_mod_file()
247+
deployment_utils.get_cfn_response_mod_file()
248248

249249

250250
def install_component(name):

localstack/utils/cloudformation/template_deployer.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313
from localstack import config
1414
from localstack.utils import common
1515
from localstack.utils.aws import aws_stack
16-
from localstack.constants import TEST_AWS_ACCOUNT_ID, FALSE_STRINGS, INSTALL_DIR_INFRA
16+
from localstack.constants import TEST_AWS_ACCOUNT_ID, FALSE_STRINGS
1717
from localstack.services.s3 import s3_listener
1818
from localstack.utils.common import (
19-
json_safe, md5, canonical_json, short_uid, to_str, to_bytes, download,
19+
json_safe, md5, canonical_json, short_uid, to_str, to_bytes,
2020
mkdir, cp_r, prevent_stack_overflow, start_worker_thread, get_all_subclasses)
2121
from localstack.utils.testutil import create_zip_file, delete_all_s3_objects
2222
from localstack.utils.cloudformation import template_preparer
2323
from localstack.services.awslambda.lambda_api import get_handler_file_from_name
2424
from localstack.services.cloudformation.service_models import GenericBaseModel, DependencyNotYetSatisfied
2525
from localstack.services.cloudformation.deployment_utils import (
26-
dump_json_params, select_parameters, param_defaults, remove_none_values,
26+
dump_json_params, select_parameters, param_defaults, remove_none_values, get_cfn_response_mod_file,
2727
lambda_keys_to_lower, PLACEHOLDER_AWS_NO_VALUE, PLACEHOLDER_RESOURCE_NAME)
2828

2929
ACTION_CREATE = 'create'
@@ -45,9 +45,6 @@
4545
# maps resource type string to model class
4646
RESOURCE_MODELS = {model.cloudformation_type(): model for model in get_all_subclasses(GenericBaseModel)}
4747

48-
# URL to "cfn-response" module which is required in some CF Lambdas
49-
CFN_RESPONSE_MODULE_URL = 'https://raw.githubusercontent.com/LukeMizuhashi/cfn-response/master/index.js'
50-
5148

5249
class NoStackUpdates(Exception):
5350
""" Exception indicating that no actions are to be performed in a stack update (which is not allowed) """
@@ -90,13 +87,6 @@ def get_lambda_code_param(params, **kwargs):
9087
return code
9188

9289

93-
def get_cfn_response_mod_file():
94-
cfn_response_tmp_file = os.path.join(INSTALL_DIR_INFRA, 'lambda.cfn-response.js')
95-
if not os.path.exists(cfn_response_tmp_file):
96-
download(CFN_RESPONSE_MODULE_URL, cfn_response_tmp_file)
97-
return cfn_response_tmp_file
98-
99-
10090
def events_put_rule_params(params, **kwargs):
10191
attrs = ['ScheduleExpression', 'EventPattern', 'State', 'Description', 'Name']
10292
result = select_parameters(*attrs)(params, **kwargs)

0 commit comments

Comments
 (0)
0