Skip to content

Commit

Permalink
Merge pull request #7 from rossumai/qiq-recover-from-empty-manifest
Browse files Browse the repository at this point in the history
Recover from empty manifest (e.g. only comments)
  • Loading branch information
bauerji authored Sep 14, 2021
2 parents f9ddcbe + 5c5cbee commit efadb1e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion chart_updater/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _auto_updates_enabled(self) -> bool:
if self._chart_version_pattern_key not in annotations:
return False
return True
except KeyError:
except (KeyError, TypeError):
return False

def _update_chart(self, new_version: str) -> bool:
Expand Down
22 changes: 22 additions & 0 deletions tests/test_chart_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,13 @@
version: 1.2.3
"""


MANIFEST_EMPTY = """# HelmRelease
# rossum.ai/
---
"""


INITIAL_COMMIT_RE = re.compile(r"Init")
CHART_RELEASE_COMMIT_RE = re.compile(
r"Release of hello-world 1.2.4.*\+\s+version:\s+1.2.4", flags=re.DOTALL
Expand Down Expand Up @@ -414,6 +421,21 @@ def test_does_not_crash_for_multidoc(empty_git_repo, requests_mock):
assert re.search(SINGLE_IMAGE_RELEASE_COMMIT_RE, _last_commit())


def test_does_not_crash_for_empty_annotation(empty_git_repo, requests_mock):
_add_manifest(MANIFEST_EMPTY, path="1-empty.yaml")
_add_manifest(MANIFEST_WITH_SINGLE_IMAGE, path="2-helmrelease.yaml")
_init_commit()
requests_mock.get(HELM_REPO_INDEX, text=CHART_REPO_INDEX_WITH_NEW_CHARTS)

updater = Updater(Git(empty_git_repo), HelmRepo(HELM_REPO_URL))
updater.update_loop(one_shot=True)

assert _get_manifest("1-empty.yaml") == MANIFEST_EMPTY
assert _get_manifest("2-helmrelease.yaml") == UPDATED_MANIFEST_WITH_SINGLE_IMAGE

assert re.search(SINGLE_IMAGE_RELEASE_COMMIT_RE, _last_commit())


def _add_manifest(content: str, path: str = MANIFEST_PATH) -> None:
with open(path, "w") as f:
f.write(content)
Expand Down

0 comments on commit efadb1e

Please sign in to comment.