Skip to content

Commit

Permalink
Add support to check if Gitlab is down
Browse files Browse the repository at this point in the history
Add method to check Gitlab's status.

Closes #5
  • Loading branch information
kx-chen committed Nov 5, 2018
1 parent 96eb2fc commit fea8003
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions org_status/org_hosts/gitlab.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import json

import requests
from IGitt.GitLab.GitLab import GitLabPrivateToken
from IGitt.GitLab.GitLabOrganization import GitLabOrganization

Expand All @@ -9,6 +12,9 @@ class GitLabOrg(OrgHost):
HostName = 'gitlab'
StatusProvider = GitLabCIStatus

HOST_STATUS_URL = ('https://api.status.io/1.0/status'
'/5b36dc6502d06804c08349f7')

def __init__(self, token, group, **kargs):
super().__init__(**kargs)

Expand All @@ -18,6 +24,12 @@ def __init__(self, token, group, **kargs):

self._status_provider = self.StatusProvider(self._group)

@classmethod
def get_host_status(cls):
status = requests.get(cls.HOST_STATUS_URL)
status = json.loads(status.text)
return status['result']['status_overall']['status'] == 'Operational'

def process_repository(self, repo, branch='master'):
self.print_status(repo.web_url)

Expand Down

0 comments on commit fea8003

Please sign in to comment.