Skip to content

Commit

Permalink
Merge pull request salt-formulas#35 from deepmind/compiled-dir-bug
Browse files Browse the repository at this point in the history
Creating compiled directory if it doesn't exist
  • Loading branch information
ramaro authored Mar 22, 2018
2 parents 6a5c3ad + d427b54 commit 58d5d63
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions kapitan/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,23 @@ def compile_targets(inventory_path, search_path, output_path, parallel, targets,
raise KapitanError("Error: no targets found")
pool.map(worker, target_objs)

if os.path.exists(compile_path):
# if '-t' is set on compile, only override selected targets
if targets:
for target in targets:
compile_path_target = os.path.join(compile_path, target)
temp_path_target = os.path.join(temp_path, target)

shutil.rmtree(compile_path_target)
shutil.copytree(temp_path_target, compile_path_target)
logger.debug("Copied %s into %s", temp_path_target, compile_path_target)
# otherwise override all targets
else:
shutil.rmtree(compile_path)
shutil.copytree(temp_path, compile_path)
logger.debug("Copied %s into %s", temp_path, compile_path)
if not os.path.exists(compile_path):
os.makedirs(compile_path)

# if '-t' is set on compile, only override selected targets
if targets:
for target in targets:
compile_path_target = os.path.join(compile_path, target)
temp_path_target = os.path.join(temp_path, target)

shutil.rmtree(compile_path_target)
shutil.copytree(temp_path_target, compile_path_target)
logger.debug("Copied %s into %s", temp_path_target, compile_path_target)
# otherwise override all targets
else:
shutil.rmtree(compile_path)
shutil.copytree(temp_path, compile_path)
logger.debug("Copied %s into %s", temp_path, compile_path)

except Exception as e:
# if compile worker fails, terminate immediately
Expand Down

0 comments on commit 58d5d63

Please sign in to comment.