feat: store outputs for Pulumi stacks

This commit is contained in:
Stefan Reimer 2023-12-04 16:24:55 +00:00
parent 6d3bf4767c
commit ff2de9d390
2 changed files with 13 additions and 26 deletions

View File

@ -444,37 +444,22 @@ def _provision(cb, stacks):
"""Utility function to reuse code between tasks""" """Utility function to reuse code between tasks"""
for step in sort_stacks(cb, stacks): for step in sort_stacks(cb, stacks):
if step: if step:
# Pulumi is not thread safe, so for now one by one with ThreadPoolExecutor(max_workers=len(step)) as group:
if _anyPulumi(step) and False: futures = []
for stack in step: for stack in step:
if stack.mode != "pulumi": if stack.mode != "pulumi":
status = stack.get_status() status = stack.get_status()
if not status: if not status:
stack.create() futures.append(group.submit(stack.create))
else: else:
stack.update() futures.append(group.submit(stack.update))
# Pulumi only needs "up" # Pulumi only needs "up"
else: else:
stack.create() futures.append(group.submit(stack.create))
else: for future in as_completed(futures):
with ThreadPoolExecutor(max_workers=len(step)) as group: future.result()
futures = []
for stack in step:
if stack.mode != "pulumi":
status = stack.get_status()
if not status:
futures.append(group.submit(stack.create))
else:
futures.append(group.submit(stack.update))
# Pulumi only needs "up"
else:
futures.append(group.submit(stack.create))
for future in as_completed(futures):
future.result()
cli.add_command(version) cli.add_command(version)

View File

@ -613,14 +613,14 @@ class Stack(object):
self.stackname, self.stackname,
output_file) output_file)
# If secrets replace with clear values for now, display ONLY # If secrets replace with cleartext values for now, display ONLY
for k in self.outputs.keys(): for k in self.outputs.keys():
if hasattr( if hasattr(
self.outputs[k], self.outputs[k],
"secret") and self.outputs[k].secret: "secret") and self.outputs[k].secret:
self.outputs[k] = self.outputs[k].value self.outputs[k] = self.outputs[k].value
logger.info( logger.debug(
"{} {} Outputs:\n{}".format( "{} {} Outputs:\n{}".format(
self.region, self.region,
self.stackname, self.stackname,
@ -815,6 +815,7 @@ class Stack(object):
if self.mode == "pulumi": if self.mode == "pulumi":
kwargs = self._set_pulumi_args() kwargs = self._set_pulumi_args()
self._get_pulumi_stack(create=True).up(**kwargs) self._get_pulumi_stack(create=True).up(**kwargs)
status = "COMPLETE"
else: else:
# Prepare parameters # Prepare parameters
@ -846,9 +847,10 @@ class Stack(object):
) )
status = self._wait_for_completion() status = self._wait_for_completion()
self.get_outputs()
return status self.get_outputs()
return status
@exec_hooks @exec_hooks
def update(self): def update(self):