From e91f5cdd2dc78a38ff8b49aa5b711accb267a851 Mon Sep 17 00:00:00 2001 From: "Ian H. Pittwood" Date: Thu, 19 Feb 2026 11:46:27 -0700 Subject: [PATCH] Add method to convert set options dictionary to string format for Docker Buildx Bake --- posit-bakery/posit_bakery/config/config.py | 4 +--- posit-bakery/posit_bakery/image/bake/bake.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/posit-bakery/posit_bakery/config/config.py b/posit-bakery/posit_bakery/config/config.py index b7ec603c..d39ba68e 100644 --- a/posit-bakery/posit_bakery/config/config.py +++ b/posit-bakery/posit_bakery/config/config.py @@ -895,9 +895,7 @@ def build_targets( bake_plan = BakePlan.from_image_targets(context=self.base_path, image_targets=self.targets) set_opts = None if self.settings.temp_registry is not None and push: - set_opts = { - "*.output": [{"type": "image", "push-by-digest": True, "name-canonical": True, "push": True}] - } + set_opts = {"*.output": {"type": "image", "push-by-digest": True, "name-canonical": True, "push": True}} bake_plan.build( load=load, push=push, diff --git a/posit-bakery/posit_bakery/image/bake/bake.py b/posit-bakery/posit_bakery/image/bake/bake.py index c014d7ef..383a6c99 100644 --- a/posit-bakery/posit_bakery/image/bake/bake.py +++ b/posit-bakery/posit_bakery/image/bake/bake.py @@ -188,6 +188,24 @@ def remove(self): """Delete the bake plan file if it exists.""" self.bake_file.unlink(missing_ok=True) + @staticmethod + def _set_opts_dict_to_str(set_opts: dict[str, Any]) -> dict[str, str]: + """Convert a dictionary of set options to a comma-delimited, key=value string format for Docker Buildx Bake. + + :param set_opts: A dictionary of set options to convert. + + :return: A dictionary of set options with string values. + """ + for opt, data in set_opts.items(): + if isinstance(data, list): + set_opts[opt] = ",".join(data) + elif isinstance(data, dict): + set_opts[opt] = ",".join(f"{k}={v}" for k, v in data.items()) + else: + set_opts[opt] = str(data) + + return set_opts + def build( self, load: bool = True, @@ -214,6 +232,7 @@ def build( _set["*.cache-to"] = cache_to if set_opts: _set.update(set_opts) + _set = self._set_opts_dict_to_str(_set) python_on_whales.docker.buildx.bake(files=[self.bake_file.name], load=load, push=push, cache=cache, set=_set) if clean_bakefile: