fix: Improve error handling in Pulumi execute functions
This commit is contained in:
parent
e0c724c68f
commit
f1bfbd3eea
@ -201,7 +201,9 @@ def execute(cb, stack_name, function, args):
|
|||||||
|
|
||||||
for s in stacks:
|
for s in stacks:
|
||||||
if s.mode == "pulumi":
|
if s.mode == "pulumi":
|
||||||
s.execute(function, args)
|
ret = s.execute(function, args)
|
||||||
|
if ret:
|
||||||
|
raise click.Abort()
|
||||||
else:
|
else:
|
||||||
logger.info(
|
logger.info(
|
||||||
"{} uses Cloudformation, no execute feature available.".format(
|
"{} uses Cloudformation, no execute feature available.".format(
|
||||||
|
@ -894,11 +894,15 @@ class Stack(object):
|
|||||||
exec_function = f"_execute_{function}"
|
exec_function = f"_execute_{function}"
|
||||||
if exec_function in vars(self._pulumi_code):
|
if exec_function in vars(self._pulumi_code):
|
||||||
pulumi_stack = self._get_pulumi_stack()
|
pulumi_stack = self._get_pulumi_stack()
|
||||||
vars(self._pulumi_code)[exec_function](
|
|
||||||
config=pulumi_stack.get_all_config(),
|
try:
|
||||||
outputs=pulumi_stack.outputs(),
|
vars(self._pulumi_code)[exec_function](
|
||||||
args=args,
|
config=pulumi_stack.get_all_config(),
|
||||||
)
|
outputs=pulumi_stack.outputs(),
|
||||||
|
args=args,
|
||||||
|
)
|
||||||
|
except Exception as e:
|
||||||
|
return e.returncode
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.error("{} is not defined in {}".format(function, self._pulumi_code))
|
logger.error("{} is not defined in {}".format(function, self._pulumi_code))
|
||||||
|
Loading…
Reference in New Issue
Block a user