spaceforge 0.0.10__py3-none-any.whl → 0.0.13__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.
- spaceforge/_version_scm.py +2 -2
- spaceforge/cls.py +5 -2
- spaceforge/plugin.py +59 -5
- spaceforge/schema.json +12 -5
- {spaceforge-0.0.10.dist-info → spaceforge-0.0.13.dist-info}/METADATA +1 -1
- {spaceforge-0.0.10.dist-info → spaceforge-0.0.13.dist-info}/RECORD +10 -10
- {spaceforge-0.0.10.dist-info → spaceforge-0.0.13.dist-info}/WHEEL +0 -0
- {spaceforge-0.0.10.dist-info → spaceforge-0.0.13.dist-info}/entry_points.txt +0 -0
- {spaceforge-0.0.10.dist-info → spaceforge-0.0.13.dist-info}/licenses/LICENSE +0 -0
- {spaceforge-0.0.10.dist-info → spaceforge-0.0.13.dist-info}/top_level.txt +0 -0
spaceforge/_version_scm.py
CHANGED
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.0.
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 0,
|
|
31
|
+
__version__ = version = '0.0.13'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 0, 13)
|
|
33
33
|
|
|
34
34
|
__commit_id__ = commit_id = None
|
spaceforge/cls.py
CHANGED
|
@@ -145,7 +145,7 @@ class Webhook:
|
|
|
145
145
|
|
|
146
146
|
name_prefix: str
|
|
147
147
|
endpoint: str
|
|
148
|
-
secretFromParameter: str
|
|
148
|
+
secretFromParameter: Optional[str] = optional_field
|
|
149
149
|
labels: Optional[List[str]] = optional_field
|
|
150
150
|
|
|
151
151
|
|
|
@@ -202,4 +202,7 @@ if __name__ == "__main__":
|
|
|
202
202
|
|
|
203
203
|
from pydantic import TypeAdapter
|
|
204
204
|
|
|
205
|
-
|
|
205
|
+
schema = TypeAdapter(PluginManifest).json_schema()
|
|
206
|
+
schema["$schema"] = "http://json-schema.org/draft-07/schema#"
|
|
207
|
+
|
|
208
|
+
print(json.dumps(schema, indent=2))
|
spaceforge/plugin.py
CHANGED
|
@@ -9,7 +9,7 @@ import os
|
|
|
9
9
|
import subprocess
|
|
10
10
|
import urllib.request
|
|
11
11
|
from abc import ABC
|
|
12
|
-
from typing import Any, Dict, List, Optional, Tuple
|
|
12
|
+
from typing import Any, Callable, Dict, List, Optional, Tuple
|
|
13
13
|
from urllib.error import HTTPError
|
|
14
14
|
|
|
15
15
|
|
|
@@ -109,6 +109,60 @@ class SpaceforgePlugin(ABC):
|
|
|
109
109
|
|
|
110
110
|
return logger
|
|
111
111
|
|
|
112
|
+
def use_user_token(
|
|
113
|
+
self, id: str, token: str, api_query: Callable[[str, None], Dict[str, Any]]
|
|
114
|
+
) -> None:
|
|
115
|
+
headers = {
|
|
116
|
+
"Content-Type": "application/json",
|
|
117
|
+
"Authorization": f"Bearer {self._api_token}",
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
query = """
|
|
121
|
+
mutation requestApiKey($id: ID!, $secret: String!){
|
|
122
|
+
apiKeyUser(id: $id, secret: $secret){
|
|
123
|
+
jwt
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
data: Dict[str, Any] = {
|
|
129
|
+
"query": query,
|
|
130
|
+
"variables": {"id": id, "secret": token},
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
req = urllib.request.Request(
|
|
134
|
+
self.spacelift_domain, # type: ignore[arg-type]
|
|
135
|
+
json.dumps(data).encode("utf-8"),
|
|
136
|
+
headers,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
self.logger.debug(f"Sending request to url: {self.spacelift_domain}")
|
|
140
|
+
try:
|
|
141
|
+
with urllib.request.urlopen(req) as response:
|
|
142
|
+
resp: Dict[str, Any] = json.loads(response.read().decode("utf-8"))
|
|
143
|
+
except urllib.error.HTTPError as e:
|
|
144
|
+
if hasattr(e, "read"):
|
|
145
|
+
resp = json.loads(e.read().decode("utf-8"))
|
|
146
|
+
else:
|
|
147
|
+
# We should not get here, but if we do re-raise the exception
|
|
148
|
+
self.logger.error(f"HTTP error occurred: ({e.code}) {e.reason} {e.msg}")
|
|
149
|
+
raise e
|
|
150
|
+
|
|
151
|
+
if "errors" in resp:
|
|
152
|
+
self.logger.error(f"Error: {resp['errors']}")
|
|
153
|
+
return
|
|
154
|
+
|
|
155
|
+
if (
|
|
156
|
+
"data" in resp
|
|
157
|
+
and "apiKeyUser" in resp["data"]
|
|
158
|
+
and "jwt" in resp["data"]["apiKeyUser"]
|
|
159
|
+
):
|
|
160
|
+
self._api_token = resp["data"]["apiKeyUser"]["jwt"]
|
|
161
|
+
self._api_enabled = True
|
|
162
|
+
self.logger.debug("Successfully set user token for API calls.")
|
|
163
|
+
else:
|
|
164
|
+
self.logger.error(f"API call returned no data: {resp}")
|
|
165
|
+
|
|
112
166
|
def get_available_hooks(self) -> List[str]:
|
|
113
167
|
"""
|
|
114
168
|
Get list of hook methods available in this plugin.
|
|
@@ -145,9 +199,7 @@ class SpaceforgePlugin(ABC):
|
|
|
145
199
|
Run a CLI command with the given arguments.
|
|
146
200
|
|
|
147
201
|
Args:
|
|
148
|
-
command: The command to run
|
|
149
|
-
*args: Positional arguments for the command
|
|
150
|
-
**kwargs: Keyword arguments for the command
|
|
202
|
+
*command: The command to run
|
|
151
203
|
expect_code: Expected return code
|
|
152
204
|
print_output: Whether to print the output to the logger
|
|
153
205
|
"""
|
|
@@ -277,7 +329,9 @@ class SpaceforgePlugin(ABC):
|
|
|
277
329
|
method="POST",
|
|
278
330
|
)
|
|
279
331
|
|
|
280
|
-
self.logger.debug(
|
|
332
|
+
self.logger.debug(
|
|
333
|
+
f"Sending request to url: {self._spacelift_markdown_endpoint}"
|
|
334
|
+
)
|
|
281
335
|
try:
|
|
282
336
|
with urllib.request.urlopen(req) as response:
|
|
283
337
|
if response.status != 200:
|
spaceforge/schema.json
CHANGED
|
@@ -260,8 +260,15 @@
|
|
|
260
260
|
"type": "string"
|
|
261
261
|
},
|
|
262
262
|
"secretFromParameter": {
|
|
263
|
-
"
|
|
264
|
-
|
|
263
|
+
"anyOf": [
|
|
264
|
+
{
|
|
265
|
+
"type": "string"
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
"type": "null"
|
|
269
|
+
}
|
|
270
|
+
],
|
|
271
|
+
"title": "Secretfromparameter"
|
|
265
272
|
},
|
|
266
273
|
"labels": {
|
|
267
274
|
"anyOf": [
|
|
@@ -280,8 +287,7 @@
|
|
|
280
287
|
},
|
|
281
288
|
"required": [
|
|
282
289
|
"name_prefix",
|
|
283
|
-
"endpoint"
|
|
284
|
-
"secretFromParameter"
|
|
290
|
+
"endpoint"
|
|
285
291
|
],
|
|
286
292
|
"title": "Webhook",
|
|
287
293
|
"type": "object"
|
|
@@ -383,5 +389,6 @@
|
|
|
383
389
|
"author"
|
|
384
390
|
],
|
|
385
391
|
"title": "PluginManifest",
|
|
386
|
-
"type": "object"
|
|
392
|
+
"type": "object",
|
|
393
|
+
"$schema": "http://json-schema.org/draft-07/schema#"
|
|
387
394
|
}
|
|
@@ -2,13 +2,13 @@ spaceforge/README.md,sha256=8o1Nuyasb4OxX3E7ZycyducOrR4J19bZcHrLvFeoFNg,7730
|
|
|
2
2
|
spaceforge/__init__.py,sha256=TU-vvm15dK1ucixNW0V42eTT72x3_hmKSyxP4MC1Occ,589
|
|
3
3
|
spaceforge/__main__.py,sha256=c3nAw4WBnHXIcfMlRV6Ja7r87pEhSeK-SAqiSYIasIY,643
|
|
4
4
|
spaceforge/_version.py,sha256=RP_LfUd4ODnrfwn9nam8wB6bR3lM4VwmoRxK08Tkiiw,2155
|
|
5
|
-
spaceforge/_version_scm.py,sha256=
|
|
6
|
-
spaceforge/cls.py,sha256=
|
|
5
|
+
spaceforge/_version_scm.py,sha256=zL2ebKl28AIxVDJJ-NA0JydSncoMv-eXaYp14mDVF3Y,706
|
|
6
|
+
spaceforge/cls.py,sha256=8jZ0noS-kIBQWHp7pWHOX6yzs5N30gIEm6-slWgBaKI,6182
|
|
7
7
|
spaceforge/conftest.py,sha256=U-xCavCsgRAQXqflIIOMeq9pcGbeqRviUNkEXgZol8g,2141
|
|
8
8
|
spaceforge/generator.py,sha256=7tt0zpqrD2pZsoVxQa0BfzBH1ZtGr6o3r_LmpBjrOJk,16739
|
|
9
|
-
spaceforge/plugin.py,sha256=
|
|
9
|
+
spaceforge/plugin.py,sha256=Uk-OrzbGzVXR-3hmzwln2bK69mLWc1KSbABuzU5DEV8,15957
|
|
10
10
|
spaceforge/runner.py,sha256=aBQQLG8MFVrqCzM0X8HgERYbhLKbmlOHUPKjV7-xvpA,3163
|
|
11
|
-
spaceforge/schema.json,sha256=
|
|
11
|
+
spaceforge/schema.json,sha256=F0STokM3YYT0xzcNdtnELZJJgpyi49mwk9Oj8ueD39s,10631
|
|
12
12
|
spaceforge/test_cls.py,sha256=nXAgbnFnGdFxrtA7vNXiePjNUASuoYW-lEuQGx9WMGs,468
|
|
13
13
|
spaceforge/test_generator.py,sha256=Nst3YVu_iZbFopH6ajjxCfqYrZvybteGbwMfZzjBFnI,32615
|
|
14
14
|
spaceforge/test_generator_binaries.py,sha256=X_7pPLGE45eQt-Kv9_ku__LsyLgOvViHc_BvVpSCMp0,7263
|
|
@@ -25,9 +25,9 @@ spaceforge/test_runner_core.py,sha256=eNR9YOwJwv7LsMtNQ4WXXMPIW6RE_A7hUp4bCpzz1R
|
|
|
25
25
|
spaceforge/test_runner_execution.py,sha256=BRlOApCmlpjE9YYvqHc8creSRu2vyPubzOCVXv-on0w,5335
|
|
26
26
|
spaceforge/templates/binary_install.sh.j2,sha256=UjP_kAdvkkATKds2nqk4ouqLhuIfCgM_x0WQIl1hbIo,477
|
|
27
27
|
spaceforge/templates/ensure_spaceforge_and_run.sh.j2,sha256=g5BldIEve0IkZ-mCzTXfB_rFvyWqUJqymRRaaMrpp0s,550
|
|
28
|
-
spaceforge-0.0.
|
|
29
|
-
spaceforge-0.0.
|
|
30
|
-
spaceforge-0.0.
|
|
31
|
-
spaceforge-0.0.
|
|
32
|
-
spaceforge-0.0.
|
|
33
|
-
spaceforge-0.0.
|
|
28
|
+
spaceforge-0.0.13.dist-info/licenses/LICENSE,sha256=wyljRrfnWY2ggQKkSCg3Nw2hxwPMmupopaKs9Kpgys8,1065
|
|
29
|
+
spaceforge-0.0.13.dist-info/METADATA,sha256=vga1DNTQuQo8_RFEbpJXN31qsIcjpm3rcd6nXLm0Fzc,16804
|
|
30
|
+
spaceforge-0.0.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
31
|
+
spaceforge-0.0.13.dist-info/entry_points.txt,sha256=qawuuKBSNTGg-njnQnhxxFldFvXYAPej6bF_f3iyQ48,56
|
|
32
|
+
spaceforge-0.0.13.dist-info/top_level.txt,sha256=eVw-Lw4Th0oHM8Gx1Y8YetyNgbNbMBU00yWs-kwGeSs,11
|
|
33
|
+
spaceforge-0.0.13.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|