Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for component in changed_components:
validate_component(formula, repodir, component)
# Check to see if the removed components are used
removal_errors = []
for component in removed_components:
blueprint_hosts = component.blueprinthostformulacomponent_set.all()
if len(blueprint_hosts) is 0:
component.delete()
else:
removal_errors.append(component.sls_path)
if len(removal_errors) is not 0:
errors = ', '.join(removal_errors)
formula.set_status(
Formula.COMPLETE,
'Formula could not be updated. The following components '
'are used in blueprints: {0}. '
'Your formula was left unchanged.'.format(errors))
return False
# Add the new components
for component in added_components:
title = component['title']
description = component.get('description', '')
sls_path = component['sls_path']
formula.components.create(title=title,
sls_path=sls_path,
description=description)
# Update the other components
for component in changed_components: