Skip to content

Commit 02ec69f

Browse files
authored
Update changelog schema etag (#2818)
1 parent c98d662 commit 02ec69f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/ansiblelint/schemas/__store__.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/arg_specs.json"
1313
},
1414
"changelog": {
15+
"etag": "3749b3e00288947d6aa204710e536d8b0f7abe12bb5c370b4aae526b88a44310",
1516
"url": "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/changelog.json"
1617
},
1718
"execution-environment": {

src/ansiblelint/schemas/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,20 @@ def refresh_schemas(min_age_seconds: int = 3600 * 24) -> int:
106106
try:
107107
with urllib.request.urlopen(request) as response:
108108
if response.status == 200:
109-
content = response.read().decode("utf-8")
109+
content = response.read().decode("utf-8").rstrip()
110110
etag = response.headers["etag"].strip('"')
111111
if etag != data.get("etag", ""):
112112
JSON_SCHEMAS[kind]["etag"] = etag
113113
changed += 1
114114
with open(f"{path}", "w", encoding="utf-8") as f_out:
115115
_logger.info("Schema %s was updated", kind)
116116
f_out.write(content)
117+
f_out.write("\n") # prettier/editors
117118
f_out.truncate()
118119
os.fsync(f_out.fileno())
119120
# unload possibly loaded schema
120-
del _schema_cache[kind]
121+
if kind in _schema_cache:
122+
del _schema_cache[kind]
121123
except (ConnectionError, OSError) as exc:
122124
if (
123125
isinstance(exc, urllib.error.HTTPError)
@@ -132,6 +134,7 @@ def refresh_schemas(min_age_seconds: int = 3600 * 24) -> int:
132134
with open(store_file, "w", encoding="utf-8") as f_out:
133135
# formatting should match our .prettierrc.yaml
134136
json.dump(JSON_SCHEMAS, f_out, indent=2, sort_keys=True)
137+
f_out.write("\n") # prettier and editors in general
135138
# clear schema cache
136139
get_schema.cache_clear()
137140
else:

0 commit comments

Comments
 (0)