Skip to content

Commit

Permalink
Update changelog schema etag (#2818)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Dec 14, 2022
1 parent c98d662 commit 02ec69f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/ansiblelint/schemas/__store__.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/arg_specs.json"
},
"changelog": {
"etag": "3749b3e00288947d6aa204710e536d8b0f7abe12bb5c370b4aae526b88a44310",
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/changelog.json"
},
"execution-environment": {
Expand Down
7 changes: 5 additions & 2 deletions src/ansiblelint/schemas/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,20 @@ def refresh_schemas(min_age_seconds: int = 3600 * 24) -> int:
try:
with urllib.request.urlopen(request) as response:
if response.status == 200:
content = response.read().decode("utf-8")
content = response.read().decode("utf-8").rstrip()
etag = response.headers["etag"].strip('"')
if etag != data.get("etag", ""):
JSON_SCHEMAS[kind]["etag"] = etag
changed += 1
with open(f"{path}", "w", encoding="utf-8") as f_out:
_logger.info("Schema %s was updated", kind)
f_out.write(content)
f_out.write("\n") # prettier/editors
f_out.truncate()
os.fsync(f_out.fileno())
# unload possibly loaded schema
del _schema_cache[kind]
if kind in _schema_cache:
del _schema_cache[kind]
except (ConnectionError, OSError) as exc:
if (
isinstance(exc, urllib.error.HTTPError)
Expand All @@ -132,6 +134,7 @@ def refresh_schemas(min_age_seconds: int = 3600 * 24) -> int:
with open(store_file, "w", encoding="utf-8") as f_out:
# formatting should match our .prettierrc.yaml
json.dump(JSON_SCHEMAS, f_out, indent=2, sort_keys=True)
f_out.write("\n") # prettier and editors in general
# clear schema cache
get_schema.cache_clear()
else:
Expand Down

0 comments on commit 02ec69f

Please sign in to comment.