diff --git a/posit-bakery/posit_bakery/config/config.py b/posit-bakery/posit_bakery/config/config.py index 9ade6d1c..c61835a8 100644 --- a/posit-bakery/posit_bakery/config/config.py +++ b/posit-bakery/posit_bakery/config/config.py @@ -897,9 +897,7 @@ def build_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 cf343bc5..2c08afe7 100644 --- a/posit-bakery/posit_bakery/image/bake/bake.py +++ b/posit-bakery/posit_bakery/image/bake/bake.py @@ -202,6 +202,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, @@ -228,6 +246,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: