Skip to content

Commit

Permalink
Allow options for the stack methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bra-fsn committed Jul 26, 2024
1 parent a372762 commit 92f6bac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "sparecores-runner"
version = "0.0.20"
version = "0.0.21"
requires-python = ">= 3.9"
dependencies = [
"click",
Expand Down
14 changes: 7 additions & 7 deletions src/sc_runner/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def pulumi_stack(
return stack


def create(vendor, pulumi_opts, resource_opts):
def create(vendor, pulumi_opts, resource_opts, stack_opts=dict(on_output=print)):
resource_f = getattr(resources, f"{resources.PREFIX}{vendor}")
if not pulumi_opts.get("stack_name"):
pulumi_opts["stack_name"] = get_stack_name(vendor, resource_f, resource_opts)
Expand All @@ -55,24 +55,24 @@ def pulumi_program():
return resource_f(**resource_opts)

stack = pulumi_stack(pulumi_program, **pulumi_opts)
stack.up(on_output=print)
stack.up(**stack_opts)


def destroy(vendor, pulumi_opts, resource_opts):
def destroy(vendor, pulumi_opts, resource_opts, stack_opts=dict(on_output=print)):
resource_f = getattr(resources, f"{resources.PREFIX}{vendor}")
if not pulumi_opts.get("stack_name"):
pulumi_opts["stack_name"] = get_stack_name(vendor, resource_f, resource_opts)
stack = pulumi_stack(lambda: None, **pulumi_opts)
stack.up(on_output=print)
stack.up(**stack_opts)


def destroy_stack(vendor, pulumi_opts, resource_opts):
def destroy_stack(vendor, pulumi_opts, resource_opts, stack_opts=dict(on_output=print)):
resource_f = getattr(resources, f"{resources.PREFIX}{vendor}")
if not pulumi_opts.get("stack_name"):
pulumi_opts["stack_name"] = get_stack_name(vendor, resource_f, resource_opts)
stack = pulumi_stack(lambda: None, **pulumi_opts)
stack.refresh(on_output=print)
stack.destroy(on_output=print)
stack.refresh(**stack_opts)
stack.destroy(**stack_opts)
stack.workspace.remove_stack(stack.name)


Expand Down

0 comments on commit 92f6bac

Please sign in to comment.