Skip to content

Commit

Permalink
fix: pylint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
heresie committed Oct 19, 2021
1 parent 5c8a021 commit 04fc1dc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
14 changes: 8 additions & 6 deletions bin/libraries/GithubEnvironmentSecret.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

import urllib3
import os
import json
import json
import sys

from base64 import b64encode
from nacl import encoding, public


class GithubEnvironmentSecret:

__repository_id = None
Expand All @@ -31,10 +32,10 @@ def __init__(self, repository_id: int, environment: str):
f"Could not retrieve Environment {environment}"
)
sys.exit(1)

else:
self.__env_secret_key = self.__retrieve_secret_key()

def __call_github(self, endpoint: str, verb: str, body=None):
'''
Wrapper for API Calls to Github APIv3
Expand All @@ -48,7 +49,7 @@ def __call_github(self, endpoint: str, verb: str, body=None):
headers = {
'Accept': "application/vnd.github.v3+json",
'Authorization': f"Bearer {os.getenv('GITHUB_TOKEN', 'NONE')}",
'Content-Type': f"application/json"
'Content-Type': "application/json"
}

if body:
Expand All @@ -70,7 +71,7 @@ def __call_github(self, endpoint: str, verb: str, body=None):

if resp.status > 300:
raise Exception("Exception", str(response))

return response

def __retrieve_secret_key(self):
Expand All @@ -82,10 +83,11 @@ def __retrieve_secret_key(self):
try:
result = self.__call_github(
verb='get',
endpoint=
endpoint=(
f"/repositories/{self.__repository_id}"
f"/environments/{self.__environment}"
f"/secrets/public-key"
)
)

return result
Expand Down
5 changes: 4 additions & 1 deletion bin/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
parser.add_argument(
'-k', '--token',
dest='github_token',
help='Github API Token. Can be given through GITHUB_TOKEN environment variable.',
help=(
'Github API Token. Can be given through GITHUB_TOKEN '
'environment variable.'
),
required=False
)

Expand Down

0 comments on commit 04fc1dc

Please sign in to comment.