Skip to content

Commit

Permalink
fix: issues with git info in service info response
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlougheed committed Mar 6, 2023
1 parent 07052bd commit bfe6907
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bento_aggregation_service/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ServiceInfoHandler(RequestHandler):
},
}

@staticmethod
async def _git_stdout(*args) -> str:
git_proc = await asyncio.create_subprocess_exec(
"git", *args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE)
Expand All @@ -56,26 +57,26 @@ async def get(self):
self.write({**self.SERVICE_INFO, "environment": "prod"})
return

bento_info = {
service_info = {
**self.SERVICE_INFO,
"environment": "dev",
}

try:
if res_tag := await self._git_stdout("describe", "--tags", "--abbrev=0"):
# noinspection PyTypeChecker
bento_info["gitTag"] = res_tag
service_info["bento"]["gitTag"] = res_tag
if res_branch := await self._git_stdout("branch", "--show-current"):
# noinspection PyTypeChecker
bento_info["gitBranch"] = res_branch
service_info["bento"]["gitBranch"] = res_branch
if res_commit := await self._git_stdout("rev-parse", "HEAD"):
# noinspection PyTypeChecker
bento_info["gitCommit"] = res_commit
service_info["bento"]["gitCommit"] = res_commit

except Exception as e:
logger.warning(f"Could not retrieve git information: {type(e).__name__}")

self.write(bento_info)
self.write(service_info)


class Application(tornado.web.Application):
Expand Down

0 comments on commit bfe6907

Please sign in to comment.