async def update_service(client, service_id, version, *, image=None, rollback=None, mode=None): if image is None and rollback is False: raise ValueError("You need to specify an image.") inspect_service = await client.services.inspect(service_id) spec = inspect_service["Spec"] if mode is not None: spec["Mode"] = mode if image is not None: spec["TaskTemplate"]["ContainerSpec"]["Image"] = image params = {"version": version} if rollback is True: params["rollback"] = "previous" data = json.dumps(clean_map(spec)) await client._query_json( "services/{service_id}/update".format(service_id=service_id), method="POST", data=data, params=params, ) return True
def test_clean_mapping(): dirty_dict = { "a": None, "b": {}, "c": [], "d": 1, } clean_dict = { "b": {}, "c": [], "d": 1, } result = utils.clean_map(dirty_dict) assert result == clean_dict
def test_clean_mapping(): dirty_dict = {"a": None, "b": {}, "c": [], "d": 1} clean_dict = {"b": {}, "c": [], "d": 1} result = utils.clean_map(dirty_dict) assert result == clean_dict