From 2dc73773d74e3fb6623d3ffd1fc0c07f574ba05c Mon Sep 17 00:00:00 2001 From: HUANG SIZHE Date: Wed, 28 Jul 2021 22:26:45 +0800 Subject: [PATCH] update --- CHANGELOG.md | 6 ++++++ portainer_deploy_tool/create_or_update_stack.py | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9020039..3196151 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 0.0.4 + +## bug修复 + ++ 修复`createorupdatestack`在没有stack时无法部署的问题 + # 0.0.3 ## 接口修改 diff --git a/portainer_deploy_tool/create_or_update_stack.py b/portainer_deploy_tool/create_or_update_stack.py index 0c7f073..53d90b8 100644 --- a/portainer_deploy_tool/create_or_update_stack.py +++ b/portainer_deploy_tool/create_or_update_stack.py @@ -248,12 +248,14 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: def find_compose(self, cwd: Path, suffix: str, root: Path) -> None: for p in cwd.iterdir(): if p.is_file: + log.info("find file", file_name=p.name) if p.name.endswith(suffix): rp = p.relative_to(root) stack_name = p.name.replace(suffix, "") if stack_name in [i.stack_name for i in self.compose_infos]: log.error("stack name repetition", stack_name=stack_name) raise AttributeError("stack name repetition") + log.debug("find stack", stack_name=stack_name) ci = ComposeInfo(stack_name=stack_name, path=str(rp)) self.compose_infos.append(ci) elif p.is_dir(): @@ -300,7 +302,7 @@ def do_main(self) -> None: self.find_compose(cwd=cwdp, suffix=suffix, root=root) # 处理excepts endpoints_stacks = self.handdler_excepts(excepts) - log.debug("deal with excepts ok", endpoints_stacks=endpoints_stacks) + log.debug("deal with excepts ok", endpoints_stacks=endpoints_stacks, compose_infos=self.compose_infos) # 获取jwt jwt = get_jwt(rq, base_url=base_url, username=username, password=password) log.debug("deal with jwt ok", jwt=jwt) @@ -317,9 +319,7 @@ def do_main(self) -> None: except Exception as e: raise e log.debug("deal with swarmID ok", swarmID=swarmID, endpoint=endpoint) - exist_stacks = endpoint_stack_info.get(endpoint) - if exist_stacks is None: - continue + exist_stacks = endpoint_stack_info.get(endpoint, {}) preparing_stacks = endpoints_stacks[endpoint] for _stack in preparing_stacks: stack = exist_stacks.get(_stack.stack_name)