qontract-reconcile 0.10.2.dev254__py3-none-any.whl → 0.10.2.dev255__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {qontract_reconcile-0.10.2.dev254.dist-info → qontract_reconcile-0.10.2.dev255.dist-info}/METADATA +1 -1
- {qontract_reconcile-0.10.2.dev254.dist-info → qontract_reconcile-0.10.2.dev255.dist-info}/RECORD +5 -5
- reconcile/utils/gql.py +36 -26
- {qontract_reconcile-0.10.2.dev254.dist-info → qontract_reconcile-0.10.2.dev255.dist-info}/WHEEL +0 -0
- {qontract_reconcile-0.10.2.dev254.dist-info → qontract_reconcile-0.10.2.dev255.dist-info}/entry_points.txt +0 -0
{qontract_reconcile-0.10.2.dev254.dist-info → qontract_reconcile-0.10.2.dev255.dist-info}/METADATA
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: qontract-reconcile
|
3
|
-
Version: 0.10.2.
|
3
|
+
Version: 0.10.2.dev255
|
4
4
|
Summary: Collection of tools to reconcile services with their desired state as defined in the app-interface DB.
|
5
5
|
Project-URL: homepage, https://github.com/app-sre/qontract-reconcile
|
6
6
|
Project-URL: repository, https://github.com/app-sre/qontract-reconcile
|
{qontract_reconcile-0.10.2.dev254.dist-info → qontract_reconcile-0.10.2.dev255.dist-info}/RECORD
RENAMED
@@ -608,7 +608,7 @@ reconcile/utils/git.py,sha256=o4p9m8jlzCJDcutl2HErvGLhL6sZ1NB4Aw3zGcQIzso,2427
|
|
608
608
|
reconcile/utils/github_api.py,sha256=S1vO-hvYPzm5BIychVIHSYibMns0HBmLgS78MkPfunE,3402
|
609
609
|
reconcile/utils/gitlab_api.py,sha256=0wJObojbXXk8Cgh8ymNWlwD1CdENmpsMo1zDSTddnoE,28335
|
610
610
|
reconcile/utils/gpg.py,sha256=EKG7_fdMv8BMlV5yUdPiqoTx-KrzmVSEAl2sLkaKwWI,1123
|
611
|
-
reconcile/utils/gql.py,sha256=
|
611
|
+
reconcile/utils/gql.py,sha256=a1SXvhqqfmFpf9dNwGxnp_6ryvhOwm_kIaFwzJmQQDQ,14683
|
612
612
|
reconcile/utils/grouping.py,sha256=vr9SFHZ7bqmHYrvYcEZt-Er3-yQYfAAdq5sHLZVmXPY,456
|
613
613
|
reconcile/utils/helm.py,sha256=wC1h0GylhDFeZ6hZEtYy2giAGIIQroaQhkAtURoSlI8,3893
|
614
614
|
reconcile/utils/helpers.py,sha256=koyAtYnxsUVx-HIn6GpedcUE-ekz_VtoYDkiZ0iv8ik,1795
|
@@ -796,7 +796,7 @@ tools/saas_promotion_state/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
|
|
796
796
|
tools/saas_promotion_state/saas_promotion_state.py,sha256=UfwwRLS5Ya4_Nh1w5n1dvoYtchQvYE9yj1VANt2IKqI,3925
|
797
797
|
tools/sre_checkpoints/__init__.py,sha256=CDaDaywJnmRCLyl_NCcvxi-Zc0hTi_3OdwKiFOyS39I,145
|
798
798
|
tools/sre_checkpoints/util.py,sha256=zEDbGr18ZeHNQwW8pUsr2JRjuXIPz--WAGJxZo9sv_Y,894
|
799
|
-
qontract_reconcile-0.10.2.
|
800
|
-
qontract_reconcile-0.10.2.
|
801
|
-
qontract_reconcile-0.10.2.
|
802
|
-
qontract_reconcile-0.10.2.
|
799
|
+
qontract_reconcile-0.10.2.dev255.dist-info/METADATA,sha256=o_zpsOZUysndjUn1lN3Sv7LKSNdPT0CVKbWcdLPy6gY,23820
|
800
|
+
qontract_reconcile-0.10.2.dev255.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
801
|
+
qontract_reconcile-0.10.2.dev255.dist-info/entry_points.txt,sha256=5i9l54La3vQrDLAdwDKQWC0iG4sV9RRfOb1BpvzOWLc,698
|
802
|
+
qontract_reconcile-0.10.2.dev255.dist-info/RECORD,,
|
reconcile/utils/gql.py
CHANGED
@@ -7,7 +7,7 @@ from datetime import (
|
|
7
7
|
datetime,
|
8
8
|
)
|
9
9
|
from typing import Any
|
10
|
-
from urllib.parse import urlparse
|
10
|
+
from urllib.parse import ParseResult, urlparse
|
11
11
|
|
12
12
|
import requests
|
13
13
|
from gql import (
|
@@ -38,7 +38,7 @@ INTEGRATIONS_QUERY = """
|
|
38
38
|
requests_logger.setLevel(logging.WARNING)
|
39
39
|
|
40
40
|
|
41
|
-
def capture_and_forget(error):
|
41
|
+
def capture_and_forget(error: BaseException) -> None:
|
42
42
|
"""fire-and-forget an exception to sentry
|
43
43
|
|
44
44
|
:param error: exception to be captured and sent to sentry
|
@@ -54,7 +54,7 @@ class GqlApiError(Exception):
|
|
54
54
|
|
55
55
|
|
56
56
|
class GqlApiIntegrationNotFound(Exception):
|
57
|
-
def __init__(self, integration):
|
57
|
+
def __init__(self, integration: str):
|
58
58
|
msg = f"""
|
59
59
|
Integration not found: {integration}
|
60
60
|
|
@@ -65,7 +65,7 @@ class GqlApiIntegrationNotFound(Exception):
|
|
65
65
|
|
66
66
|
|
67
67
|
class GqlApiErrorForbiddenSchema(Exception):
|
68
|
-
def __init__(self, schemas):
|
68
|
+
def __init__(self, schemas: list):
|
69
69
|
msg = f"""
|
70
70
|
Forbidden schemas: {schemas}
|
71
71
|
|
@@ -76,7 +76,7 @@ class GqlApiErrorForbiddenSchema(Exception):
|
|
76
76
|
|
77
77
|
|
78
78
|
class GqlGetResourceError(Exception):
|
79
|
-
def __init__(self, path, msg):
|
79
|
+
def __init__(self, path: str, msg: str):
|
80
80
|
super().__init__(f"Error getting resource from path {path}: {msg!s}")
|
81
81
|
|
82
82
|
|
@@ -88,8 +88,8 @@ class GqlApi:
|
|
88
88
|
self,
|
89
89
|
url: str,
|
90
90
|
token: str | None = None,
|
91
|
-
int_name=None,
|
92
|
-
validate_schemas=False,
|
91
|
+
int_name: str | None = None,
|
92
|
+
validate_schemas: bool = False,
|
93
93
|
commit: str | None = None,
|
94
94
|
commit_timestamp: str | None = None,
|
95
95
|
) -> None:
|
@@ -127,14 +127,21 @@ class GqlApi:
|
|
127
127
|
)
|
128
128
|
return Client(transport=transport)
|
129
129
|
|
130
|
-
def close(self):
|
130
|
+
def close(self) -> None:
|
131
131
|
logging.debug("Closing GqlApi client")
|
132
|
-
if
|
132
|
+
if (
|
133
|
+
self.client.transport is not None
|
134
|
+
and hasattr(self.client.transport, "session")
|
135
|
+
and self.client.transport.session
|
136
|
+
):
|
133
137
|
self.client.transport.session.close()
|
134
138
|
|
135
139
|
@retry(exceptions=GqlApiError, max_attempts=5, hook=capture_and_forget)
|
136
140
|
def query(
|
137
|
-
self,
|
141
|
+
self,
|
142
|
+
query: str,
|
143
|
+
variables: dict[str, Any] | None = None,
|
144
|
+
skip_validation: bool = False,
|
138
145
|
) -> dict[str, Any] | None:
|
139
146
|
try:
|
140
147
|
result = self.client.execute(
|
@@ -237,7 +244,7 @@ class GqlApi:
|
|
237
244
|
resources = self.query(query, {"schema": schema}, skip_validation=True)
|
238
245
|
return resources["resources"]
|
239
246
|
|
240
|
-
def get_queried_schemas(self):
|
247
|
+
def get_queried_schemas(self) -> list:
|
241
248
|
return list(self._queried_schemas)
|
242
249
|
|
243
250
|
@property
|
@@ -252,7 +259,7 @@ class GqlApiSingleton:
|
|
252
259
|
gqlapi_lock = threading.Lock()
|
253
260
|
|
254
261
|
@classmethod
|
255
|
-
def create(cls, *args, **kwargs) -> GqlApi:
|
262
|
+
def create(cls, *args: Any, **kwargs: Any) -> GqlApi:
|
256
263
|
with cls.gqlapi_lock:
|
257
264
|
if cls.gql_api:
|
258
265
|
logging.debug("Resestting GqlApi instance")
|
@@ -261,8 +268,9 @@ class GqlApiSingleton:
|
|
261
268
|
return cls.gql_api
|
262
269
|
|
263
270
|
@classmethod
|
264
|
-
def close_gqlapi(cls):
|
265
|
-
cls.gql_api
|
271
|
+
def close_gqlapi(cls) -> None:
|
272
|
+
if cls.gql_api is not None:
|
273
|
+
cls.gql_api.close()
|
266
274
|
|
267
275
|
@classmethod
|
268
276
|
def instance(cls) -> GqlApi:
|
@@ -281,11 +289,11 @@ class GqlApiSingleton:
|
|
281
289
|
def init(
|
282
290
|
url: str,
|
283
291
|
token: str | None = None,
|
284
|
-
integration=None,
|
285
|
-
validate_schemas=False,
|
292
|
+
integration: str | None = None,
|
293
|
+
validate_schemas: bool = False,
|
286
294
|
commit: str | None = None,
|
287
295
|
commit_timestamp: str | None = None,
|
288
|
-
):
|
296
|
+
) -> GqlApi:
|
289
297
|
return GqlApiSingleton.create(
|
290
298
|
url,
|
291
299
|
token,
|
@@ -336,7 +344,7 @@ class PersistentRequestsHTTPTransport(RequestsHTTPTransport):
|
|
336
344
|
# can't directly assign, due to mypy type checking
|
337
345
|
self.session = session # type: ignore
|
338
346
|
|
339
|
-
def connect(self):
|
347
|
+
def connect(self) -> None:
|
340
348
|
pass
|
341
349
|
|
342
350
|
def close(self) -> None:
|
@@ -344,7 +352,7 @@ class PersistentRequestsHTTPTransport(RequestsHTTPTransport):
|
|
344
352
|
|
345
353
|
|
346
354
|
@retry(exceptions=requests.exceptions.HTTPError, max_attempts=5)
|
347
|
-
def get_sha(server, token=None):
|
355
|
+
def get_sha(server: ParseResult, token: str | None = None) -> str:
|
348
356
|
sha_endpoint = server._replace(path="/sha256")
|
349
357
|
headers = {"Authorization": token} if token else None
|
350
358
|
response = requests.get(sha_endpoint.geturl(), headers=headers, timeout=60)
|
@@ -354,7 +362,9 @@ def get_sha(server, token=None):
|
|
354
362
|
|
355
363
|
|
356
364
|
@retry(exceptions=requests.exceptions.HTTPError, max_attempts=5)
|
357
|
-
def get_git_commit_info(
|
365
|
+
def get_git_commit_info(
|
366
|
+
sha: str, server: ParseResult, token: str | None = None
|
367
|
+
) -> dict:
|
358
368
|
git_commit_info_endpoint = server._replace(path=f"/git-commit-info/{sha}")
|
359
369
|
headers = {"Authorization": token} if token else None
|
360
370
|
response = requests.get(
|
@@ -367,12 +377,12 @@ def get_git_commit_info(sha, server, token=None):
|
|
367
377
|
|
368
378
|
@retry(exceptions=requests.exceptions.ConnectionError, max_attempts=5)
|
369
379
|
def init_from_config(
|
370
|
-
autodetect_sha=True,
|
371
|
-
sha=None,
|
372
|
-
integration=None,
|
373
|
-
validate_schemas=False,
|
374
|
-
print_url=True,
|
375
|
-
):
|
380
|
+
autodetect_sha: bool = True,
|
381
|
+
sha: str | None = None,
|
382
|
+
integration: str | None = None,
|
383
|
+
validate_schemas: bool = False,
|
384
|
+
print_url: bool = True,
|
385
|
+
) -> GqlApi:
|
376
386
|
server, token, commit, timestamp = _get_gql_server_and_token(
|
377
387
|
autodetect_sha=autodetect_sha, sha=sha
|
378
388
|
)
|
{qontract_reconcile-0.10.2.dev254.dist-info → qontract_reconcile-0.10.2.dev255.dist-info}/WHEEL
RENAMED
File without changes
|
File without changes
|