Skip to content

Commit

Permalink
🐛 Fix docker.buildx.list() for buildx 0.13 (#568)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldemarmiesse authored Mar 19, 2024
1 parent 1aa86ec commit 9ceeb60
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python_on_whales/components/buildx/cli_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ def list(self) -> List[Builder]:
# if the line starts by a " ", it's not a builder, it's a node
lines = list(filter(lambda x: not x.startswith(" "), lines))
builders_names = [x.split(" ")[0] for x in lines]
# in buildx 0.13.0, the "*" is added to the name, without whitespace
builders_names = [removesuffix(x, "*") for x in builders_names]
return [
Builder(self.client_config, x, is_immutable_id=True) for x in builders_names
]
Expand Down Expand Up @@ -590,6 +592,16 @@ def is_installed(self) -> bool:
return "buildx" in help_output


def removesuffix(base_string: str, suffix: str) -> str:
"""Backport of removesuffix for python <3.9.
TODO: Remove this when we drop support for python 3.8.
"""
if base_string.endswith(suffix):
return base_string[: -len(suffix)]
return base_string


def format_dict_for_buildx(options: Dict[str, str]) -> str:
return ",".join(format_dict_for_cli(options, separator="="))

Expand Down

0 comments on commit 9ceeb60

Please sign in to comment.