Skip to content

Commit

Permalink
Set up custom Flattenable type
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanjjung committed Jan 14, 2025
1 parent 32a8cf4 commit 578b512
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion tb_pulumi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
from typing import Any


type Flattenable = dict | list | ThunderbirdComponentResource | pulumi.Output | pulumi.Resource

class ThunderbirdPulumiProject:
"""A collection of related Pulumi resources upon which we can take bulk/collective actions. This class enforces some
usage conventions that help keep us organized and consistent.
Expand Down Expand Up @@ -226,7 +228,7 @@ def env_var_is_true(name: str) -> bool:
return env_var_matches(name, ['t', 'true', 'yes'], False)


def flatten(item: dict | list | ThunderbirdComponentResource | pulumi.Output | pulumi.Resource) -> set[pulumi.Resource]:
def flatten(item: Flattenable) -> set[pulumi.Resource]:
"""Recursively traverses a nested collection of Pulumi ``Resource`` s, converting them into a flat set which can be
more easily iterated over.
Expand Down
2 changes: 1 addition & 1 deletion tb_pulumi/monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(
self.supported_resources = []

def __parse_resource_item(
item: list | dict | pulumi.Output | pulumi.Resource | tb_pulumi.ThunderbirdComponentResource,
item: tb_pulumi.Flattenable,
):
"""Not all items in a project's ``resources`` dict are actually Pulumi Resources. Sometimes we build
resources downstream of a Pulumi Output, which makes those resources (as they are known to the project)
Expand Down

0 comments on commit 578b512

Please sign in to comment.