From 886ad559b6a1d05b1fcefa1ded77bd8234423ae0 Mon Sep 17 00:00:00 2001 From: "Bruce.wu" Date: Fri, 27 Sep 2024 16:37:42 +0800 Subject: [PATCH] vars --- ops/api/nacos.py | 16 ++++++---------- ops/changelog/nacos_change.py | 8 ++++---- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/ops/api/nacos.py b/ops/api/nacos.py index 1a2e55b..cbd33bb 100644 --- a/ops/api/nacos.py +++ b/ops/api/nacos.py @@ -52,7 +52,7 @@ class GetChangeSetSchema(Schema): changeLogFile = fields.Str(required=True) count = fields.Int(required=False) contexts = fields.Str(required=False) - vairables = fields.Dict() + vars = fields.Dict() class ApplyChangeSetSchema(Schema): @@ -319,23 +319,19 @@ def get_change_set(): ) count = data.get("count", 0) contexts = data.get("contexts") - vairables = data.get("vairables", {}) + vars = data.get("vars", {}) try: nacosChangeLog = NacosChangeLog(changelogFile=data["changeLogFile"]) - result = nacosChangeLog.fetch_multi( - client, nacos_id, count, contexts, vairables - ) + result = nacosChangeLog.fetch_multi(client, nacos_id, count, contexts, vars) keys = ["ids", "changes"] return dict(zip(keys, result)) except jsonschema.ValidationError as err: logger.error("Invalid changelog file", exc_info=True) - return make_response( - f"Invalid changelog file. {err}", 400 - ) + return make_response(f"Invalid changelog file. {err}", 400) except KeyError as err: - logger.error("Vairables missing key", exc_info=True) - return make_response(f"Vairables missing key: {err}", 400) + logger.error("Vars missing key", exc_info=True) + return make_response(f"Vars missing key: {err}", 400) @bp.route("/nacos/v1/apply_change_set", methods=["POST"]) diff --git a/ops/changelog/nacos_change.py b/ops/changelog/nacos_change.py index 7642bd1..3c379bb 100644 --- a/ops/changelog/nacos_change.py +++ b/ops/changelog/nacos_change.py @@ -240,7 +240,7 @@ def fetch_multi( nacos_id: str, count: int = 0, contexts: str = None, - vairables: dict = {}, + vars: dict = {}, ): """ 获取多个当前需要执行的changeset @@ -302,13 +302,13 @@ def fetch_multi( logger.info(f"current change: {change}") namespaceTemplate = string.Template(change["namespace"]) - namespace = namespaceTemplate.substitute(vairables) + namespace = namespaceTemplate.substitute(vars) groupTemplate = string.Template(change["group"]) - group = groupTemplate.substitute(vairables) + group = groupTemplate.substitute(vars) dataIdTemplate = string.Template(change["dataId"]) - dataId = dataIdTemplate.substitute(vairables) + dataId = dataIdTemplate.substitute(vars) format = change["format"]