gitlab: enterprise gitlab support

This commit is contained in:
Iain Learmonth 2022-08-30 11:21:15 +01:00
parent 3163286e88
commit 63c36dccd2
3 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,27 @@
from flask import current_app
from gitlab import Gitlab
from app.terraform.block.bridge_reachability import BlockBridgeReachabilityAutomation
class BlockBridgeGitlabAutomation(BlockBridgeReachabilityAutomation):
"""
Automation task to import bridge reachability results from Gitlab.
"""
short_name = "block_bridge_gitlab"
description = "Import bridge reachability results from Gitlab"
frequency = 30
def fetch(self) -> None:
credentials = {"private_token": current_app.config['GITLAB_TOKEN']}
if "GITLAB_URL" in current_app.config:
credentials['url'] = current_app.config['GITLAB_URL']
gitlab = Gitlab(**credentials)
project = gitlab.project.get(current_app.config['GITLAB_BRIDGE_PROJECT'])
for vantage_point in current_app.config['GITHUB_BRIDGE_VANTAGE_POINTS']:
contents = project.get(
filepath=f"recentResult_{vantage_point}",
ref=current_app.config["GITLAB_BRIDGE_BRANCH"]
)
self._lines = contents.decode().splitlines()

View file

@ -1,3 +1,5 @@
from flask import current_app
from app.terraform.list import ListAutomation
@ -21,6 +23,9 @@ class ListGitlabAutomation(ListAutomation):
gitlab = {
source = "gitlabhq/gitlab"
version = "~> 3.14.0"
{% if gitlab_url %}
url = "{{ gitlab_url }}"
{% endif %}
}
}
}
@ -46,3 +51,8 @@ class ListGitlabAutomation(ListAutomation):
{% endfor %}
"""
def __init__(self):
super().__init__()
if current_app.config['GITLAB_URL']:
self.template_parameters.append("gitlab_url")

View file

@ -21,3 +21,4 @@ sqlalchemy
tldextract
wtforms
pyyaml
python-gitlab