How to use construct_changes method in localstack

Best Python code snippet using localstack_python

template_deployer.py

Source:template_deployer.py Github

copy

Full Screen

...1203 parameters.update({p["ParameterKey"]: p for p in change_set.metadata["Parameters"]})1204 # TODO: unclear/undocumented behavior in implicitly updating old_stack parameter here1205 old_stack.metadata["Parameters"] = [v for v in parameters.values() if v]1206 # TODO: fix circular import with cloudformation_api.py when importing Stack here1207 def construct_changes(1208 self,1209 existing_stack,1210 new_stack,1211 initialize=False,1212 change_set_id=None,1213 append_to_changeset=False,1214 ):1215 from localstack.services.cloudformation.cloudformation_api import StackChangeSet1216 old_resources = existing_stack.template["Resources"]1217 new_resources = new_stack.template["Resources"]1218 deletes = [val for key, val in old_resources.items() if key not in new_resources]1219 adds = [val for key, val in new_resources.items() if initialize or key not in old_resources]1220 modifies = [val for key, val in new_resources.items() if key in old_resources]1221 changes = []1222 for action, items in (("Remove", deletes), ("Add", adds), ("Modify", modifies)):1223 for item in items:1224 item["Properties"] = item.get("Properties", {})1225 change = self.get_change_config(action, item, change_set_id=change_set_id)1226 changes.append(change)1227 # append changes to change set1228 if append_to_changeset and isinstance(new_stack, StackChangeSet):1229 new_stack.changes.extend(changes)1230 return changes1231 def apply_changes(1232 self,1233 existing_stack,1234 new_stack,1235 stack_name,1236 change_set_id=None,1237 initialize=False,1238 action=None,1239 ):1240 old_resources = existing_stack.template["Resources"]1241 new_resources = new_stack.template["Resources"]1242 action = action or "CREATE"1243 self.init_resource_status(old_resources, action="UPDATE")1244 # apply parameter changes to existing stack1245 self.apply_parameter_changes(existing_stack, new_stack)1246 # construct changes1247 changes = self.construct_changes(1248 existing_stack,1249 new_stack,1250 initialize=initialize,1251 change_set_id=change_set_id,1252 )1253 # check if we have actual changes in the stack, and prepare properties1254 contains_changes = False1255 for change in changes:1256 res_action = change["ResourceChange"]["Action"]1257 resource = new_resources.get(change["ResourceChange"]["LogicalResourceId"])1258 if res_action != "Modify" or self.resource_config_differs(resource):1259 contains_changes = True1260 if res_action in ["Modify", "Add"]:1261 self.merge_properties(resource["LogicalResourceId"], existing_stack, new_stack)...

Full Screen

Full Screen

init.py

Source:init.py Github

copy

Full Screen

...415 from pocketlab.methods.config import construct_changes, construct_setup416 manifest_text = retrieve_template('models/python.manifest.in.txt')417 mkdocs_text = retrieve_template('models/mkdocs.yaml.txt')418 module_files = {419 'CHANGES.rst': construct_changes(),420 'MANIFEST.in': replace_text(manifest_text, replacement_map=replacement_map),421 'mkdocs.yml': replace_text(mkdocs_text, replacement_map=replacement_map),422 'setup.py': construct_setup(service_name, replacement_map['<org-name>'])423 }424 if module_type == 'node':425 module_files = {426 'CHANGELOG.md': construct_changes(module_type),427 '.coveralls.yml': retrieve_template('models/coveralls.yml.txt'),428 '.babelrc': retrieve_template('models/babelrc.txt')429 }430 if init_jquery:431 webpack_text = retrieve_template('models/jquery.webpack.config.js.txt')432 module_files['karma.config.js'] = retrieve_template('models/karma.config.js.txt')433 module_files['webpack.config.js'] = replace_text(434 webpack_text,435 replacement_map=replacement_map436 )437 for key, value in module_files.items():438 if not path.exists(key):439 with open(key, 'wt', encoding='utf-8') as f:440 f.write(value)...

Full Screen

Full Screen

config.py

Source:config.py Github

copy

Full Screen

...495 init_text += "__url__ = 'https://github.com/<org-name>/pocketlab'\n"496 init_text += "__description__ = '<service-description>'\n"497 498 return init_text499def construct_changes(type='python'):500# retrieve changes text501 if type == 'node':502 file_text = retrieve_template('models/changelog.md.txt')503 else:504 file_text = retrieve_template('models/changes.rst.txt')505# retrieve date506 from datetime import datetime507 new_date = datetime.utcnow()508 new_month = str(new_date.month)509 new_day = str(new_date.day)510 if len(new_month) == 1:511 new_month = '0%s' % new_month512 if len(new_day) == 1:513 new_day = '0%s' % new_day514 date_string = '%s.%s.%s' % (str(new_date.year), new_month, new_day)515# replace date516 file_text = file_text.replace('2001.01.01', date_string)517 return file_text518def construct_license(license_type='mit', replace_map=None):519# retrieve license text520 file_path = 'models/license.%s.txt' % license_type521 file_text = retrieve_template(file_path)522# retrieve date523 from datetime import datetime524 new_date = datetime.utcnow()525 new_year = str(new_date.year)526# replace terms in license527 file_text = file_text.replace('2017', new_year)528 file_text = replace_text(file_text, replacement_map=replace_map)529 return file_text530if __name__ == '__main__':531 standard_path = '../models/heroku-config.json'532 from labpack.records.settings import load_settings533 standard_schema = load_settings(standard_path)534 text = compile_yaml(standard_schema)535 # print(text)536 init_path = '../__init__.py'537 readme_path = '../../README.rst'538 setup_kwargs = inject_init(init_path, readme_path, {})539 # print(setup_kwargs)540 setup_text = open('../../setup.py').read()541 new_text = update_setup(setup_text)542 # print(new_text)543 module_name = 'newmodule'544 setup_text = construct_setup(module_name)545 # print(setup_text)546 init_text = construct_init(module_name)547 # print(init_text)548 readme_text = construct_readme(framework_type='python')549 # print(readme_text)550 service_text = construct_readme(replacement_map={'.gitignore': '.hgignore'})551 # print(service_text)552 manifest_text = construct_manifest(module_name)553 # print(manifest_text)554 changes_text = construct_changes()555 # print(changes_text)556 license_text = construct_license()557 # print(license_text)558 mkdocs_text = construct_mkdocs(module_name)559 # print(mkdocs_text)560 index_text = construct_index(module_name)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful