Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update changelog schema etag #2818

Merged
merged 1 commit into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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