Skip to content

Commit 78cd361

Browse files
committed
Run pre-commit
1 parent 20b9c08 commit 78cd361

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

unpack-api/unpack_api/main.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23
from typing import Annotated
34

@@ -10,8 +11,6 @@
1011
from fastapi import HTTPException
1112
from fastapi.security import HTTPBearer
1213

13-
import json
14-
1514

1615
load_dotenv()
1716

@@ -30,15 +29,13 @@
3029
# <<<
3130

3231

33-
3432
def get_expose_api_map():
3533
expose_api = {
3634
'gitlab': False,
3735
'github': False,
3836
'secret': False,
3937
}
4038

41-
4239
if None not in (
4340
GITLAB_SERVER,
4441
GITLAB_TARGET_REPOSITORY_ID,
@@ -53,12 +50,12 @@ def get_expose_api_map():
5350
):
5451
expose_api['github'] = True
5552

56-
5753
if SECRET_TOKEN is not None:
5854
expose_api['secret'] = True
5955

6056
return expose_api
6157

58+
6259
def get_jwt_keys():
6360
gitlab_server_url = f'{GITLAB_SERVER}/oauth/discovery/keys'
6461

@@ -89,6 +86,7 @@ def request_gitlab_sync(image):
8986
detail=f'Token server error: {request.text}',
9087
)
9188

89+
9290
def request_github_sync(image):
9391
"""
9492
https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event
@@ -100,14 +98,14 @@ def request_github_sync(image):
10098
data=json.dumps({
10199
'ref': 'action-testing',
102100
'inputs': {
103-
'image': image
104-
}
101+
'image': image,
102+
},
105103
}),
106104
headers={
107-
'Accept': "application/vnd.github+json",
105+
'Accept': 'application/vnd.github+json',
108106
'Authorization': f'Bearer {GITHUB_TOKEN}',
109107
'X-GitHub-Api-Version': '2022-11-28',
110-
}
108+
},
111109
)
112110

113111
from pprint import pprint
@@ -133,11 +131,6 @@ def check_authorization(
133131
)
134132

135133

136-
137-
138-
139-
140-
141134
app = FastAPI()
142135

143136
expose_api = get_expose_api_map()
@@ -184,7 +177,6 @@ def sync_jwt(
184177
request_gitlab_sync(image)
185178

186179

187-
188180
if expose_api['secret'] and expose_api['gitlab']:
189181
@app.post('/api/gitlab/sync/secret')
190182
def sync_secret(
@@ -203,8 +195,6 @@ def sync_secret(
203195
request_gitlab_sync(image)
204196

205197

206-
207-
208198
if expose_api['secret'] and expose_api['github']:
209199
@app.post('/api/github/sync/secret')
210200
def sync_secret(

0 commit comments

Comments
 (0)