-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create gitlab base class to auth the instance and return if no …
…cath erros
- Loading branch information
lpmatos
committed
Jul 28, 2020
1 parent
f1d32e9
commit 11eeca0
Showing
3 changed files
with
66 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import Text, Type, Callable | ||
from dataclasses import dataclass, field | ||
from gitlab import Gitlab, config, exceptions | ||
|
||
@dataclass | ||
class GitLabBase: | ||
url: Type[Text] = field(default="https://gitlab.com") | ||
token: Type[Text] = field(repr=False, default_factory=Text) | ||
|
||
@property | ||
def client(self) -> Gitlab: | ||
try: | ||
instance = Gitlab( | ||
self.url, | ||
private_token=self.token | ||
) | ||
instance.auth() | ||
except exceptions.GitlabAuthenticationError as error: | ||
print(f"GitLab authenticantion error - {error}") | ||
exit() | ||
else: | ||
return instance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters