block/bridge: refactor into general bridge block subsystem
This commit is contained in:
parent
51092865a2
commit
ca3fc844b7
7 changed files with 148 additions and 46 deletions
25
app/terraform/block/bridge_github.py
Normal file
25
app/terraform/block/bridge_github.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
from flask import current_app
|
||||
from github import Github
|
||||
|
||||
from app.terraform.block.bridge_reachability import BlockBridgeReachabilityAutomation
|
||||
|
||||
|
||||
class BlockBridgeGitHubAutomation(BlockBridgeReachabilityAutomation):
|
||||
"""
|
||||
Automation task to import bridge reachability results from GitHub.
|
||||
"""
|
||||
|
||||
short_name = "block_bridge_github"
|
||||
description = "Import bridge reachability results from GitHub"
|
||||
frequency = 30
|
||||
|
||||
def fetch(self) -> None:
|
||||
github = Github(current_app.config['GITHUB_API_KEY'])
|
||||
repo = github.get_repo(current_app.config['GITHUB_BRIDGE_REPO'])
|
||||
for vantage_point in current_app.config['GITHUB_BRIDGE_VANTAGE_POINTS']:
|
||||
contents = repo.get_contents(f"recentResult_{vantage_point}")
|
||||
if isinstance(contents, list):
|
||||
raise RuntimeError(
|
||||
f"Expected a file at recentResult_{vantage_point}"
|
||||
" but got a directory.")
|
||||
self._lines = contents.decoded_content.decode('utf-8').splitlines()
|
Loading…
Add table
Add a link
Reference in a new issue