Skip to content

Commit

Permalink
vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruce.wu committed Sep 27, 2024
1 parent 0e4646e commit 886ad55
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
16 changes: 6 additions & 10 deletions ops/api/nacos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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"])
Expand Down
8 changes: 4 additions & 4 deletions ops/changelog/nacos_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def fetch_multi(
nacos_id: str,
count: int = 0,
contexts: str = None,
vairables: dict = {},
vars: dict = {},
):
"""
获取多个当前需要执行的changeset
Expand Down Expand Up @@ -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"]

Expand Down

0 comments on commit 886ad55

Please sign in to comment.