spaceforge 0.1.0.dev0__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/schema.json ADDED
@@ -0,0 +1,371 @@
1
+ {
2
+ "$defs": {
3
+ "Context": {
4
+ "description": "A class to represent a context for a plugin.\n\nAttributes:\n name_prefix (str): The name of the context, will be appended with a unique ID.\n description (str): A description of the context.\n labels (dict): Labels associated with the context.\n env (list): List of variables associated with the context.\n hooks (dict): Hooks associated with the context.",
5
+ "properties": {
6
+ "name_prefix": {
7
+ "title": "Name Prefix",
8
+ "type": "string"
9
+ },
10
+ "description": {
11
+ "title": "Description",
12
+ "type": "string"
13
+ },
14
+ "env": {
15
+ "anyOf": [
16
+ {
17
+ "items": {
18
+ "$ref": "#/$defs/Variable"
19
+ },
20
+ "type": "array"
21
+ },
22
+ {
23
+ "type": "null"
24
+ }
25
+ ],
26
+ "title": "Env"
27
+ },
28
+ "mounted_files": {
29
+ "anyOf": [
30
+ {
31
+ "items": {
32
+ "$ref": "#/$defs/MountedFile"
33
+ },
34
+ "type": "array"
35
+ },
36
+ {
37
+ "type": "null"
38
+ }
39
+ ],
40
+ "title": "Mounted Files"
41
+ },
42
+ "hooks": {
43
+ "anyOf": [
44
+ {
45
+ "additionalProperties": {
46
+ "items": {
47
+ "type": "string"
48
+ },
49
+ "type": "array"
50
+ },
51
+ "propertyNames": {
52
+ "enum": [
53
+ "before_init",
54
+ "after_init",
55
+ "before_plan",
56
+ "after_plan",
57
+ "before_apply",
58
+ "after_apply",
59
+ "before_perform",
60
+ "after_perform",
61
+ "before_destroy",
62
+ "after_destroy",
63
+ "after_run"
64
+ ]
65
+ },
66
+ "type": "object"
67
+ },
68
+ {
69
+ "type": "null"
70
+ }
71
+ ],
72
+ "title": "Hooks"
73
+ },
74
+ "labels": {
75
+ "anyOf": [
76
+ {
77
+ "additionalProperties": {
78
+ "type": "string"
79
+ },
80
+ "type": "object"
81
+ },
82
+ {
83
+ "type": "null"
84
+ }
85
+ ],
86
+ "title": "Labels"
87
+ }
88
+ },
89
+ "required": [
90
+ "name_prefix",
91
+ "description"
92
+ ],
93
+ "title": "Context",
94
+ "type": "object"
95
+ },
96
+ "MountedFile": {
97
+ "description": "A class to represent a mounted file.\n\nAttributes:\n path (str): The path of the mounted file.\n content (str): The content of the mounted file.\n sensitive (bool): Whether the content of the file is sensitive.",
98
+ "properties": {
99
+ "path": {
100
+ "title": "Path",
101
+ "type": "string"
102
+ },
103
+ "content": {
104
+ "title": "Content",
105
+ "type": "string"
106
+ },
107
+ "sensitive": {
108
+ "default": false,
109
+ "title": "Sensitive",
110
+ "type": "boolean"
111
+ }
112
+ },
113
+ "required": [
114
+ "path",
115
+ "content"
116
+ ],
117
+ "title": "MountedFile",
118
+ "type": "object"
119
+ },
120
+ "Parameter": {
121
+ "description": "A class to represent a parameter with a name and value.\n\nAttributes:\n name (str): The name of the parameter.\n description (str): A description of the parameter.\n sensitive (bool): Whether the parameter contains sensitive information.\n required (bool): Whether the parameter is required.\n default (Optional[str]): The default value of the parameter, if any. (required if sensitive is False)",
122
+ "properties": {
123
+ "name": {
124
+ "title": "Name",
125
+ "type": "string"
126
+ },
127
+ "description": {
128
+ "title": "Description",
129
+ "type": "string"
130
+ },
131
+ "sensitive": {
132
+ "default": false,
133
+ "title": "Sensitive",
134
+ "type": "boolean"
135
+ },
136
+ "required": {
137
+ "default": false,
138
+ "title": "Required",
139
+ "type": "boolean"
140
+ },
141
+ "default": {
142
+ "anyOf": [
143
+ {
144
+ "type": "string"
145
+ },
146
+ {
147
+ "type": "null"
148
+ }
149
+ ],
150
+ "default": null,
151
+ "title": "Default"
152
+ }
153
+ },
154
+ "required": [
155
+ "name",
156
+ "description"
157
+ ],
158
+ "title": "Parameter",
159
+ "type": "object"
160
+ },
161
+ "Policy": {
162
+ "description": "A class to represent a policy configuration.\n\nAttributes:\n name_prefix (str): The name of the policy, will be appended with a unique ID.\n type (str): The type of the policy (e.g., \"terraform\", \"kubernetes\").\n body (str): The body of the policy, typically a configuration or script.\n labels (Optional[dict[str, str]]): Labels associated with the policy.",
163
+ "properties": {
164
+ "name_prefix": {
165
+ "title": "Name Prefix",
166
+ "type": "string"
167
+ },
168
+ "type": {
169
+ "title": "Type",
170
+ "type": "string"
171
+ },
172
+ "body": {
173
+ "title": "Body",
174
+ "type": "string"
175
+ },
176
+ "labels": {
177
+ "anyOf": [
178
+ {
179
+ "additionalProperties": {
180
+ "type": "string"
181
+ },
182
+ "type": "object"
183
+ },
184
+ {
185
+ "type": "null"
186
+ }
187
+ ],
188
+ "title": "Labels"
189
+ }
190
+ },
191
+ "required": [
192
+ "name_prefix",
193
+ "type",
194
+ "body"
195
+ ],
196
+ "title": "Policy",
197
+ "type": "object"
198
+ },
199
+ "Variable": {
200
+ "description": "A class to represent an environment variable.\n\nAttributes:\n key (str): The key of the environment variable.\n value (Optional[str]): The value of the environment variable, if set.\n value_from_parameter (Optional[str]): The name of the plugin variable to use as the value.\n sensitive (bool): Whether the environment variable is sensitive.",
201
+ "properties": {
202
+ "key": {
203
+ "title": "Key",
204
+ "type": "string"
205
+ },
206
+ "value": {
207
+ "anyOf": [
208
+ {
209
+ "type": "string"
210
+ },
211
+ {
212
+ "type": "null"
213
+ }
214
+ ],
215
+ "title": "Value"
216
+ },
217
+ "value_from_parameter": {
218
+ "anyOf": [
219
+ {
220
+ "type": "string"
221
+ },
222
+ {
223
+ "type": "null"
224
+ }
225
+ ],
226
+ "title": "Value From Parameter"
227
+ },
228
+ "sensitive": {
229
+ "default": false,
230
+ "title": "Sensitive",
231
+ "type": "boolean"
232
+ }
233
+ },
234
+ "required": [
235
+ "key"
236
+ ],
237
+ "title": "Variable",
238
+ "type": "object"
239
+ },
240
+ "Webhook": {
241
+ "description": "A class to represent a webhook configuration.\n\nAttributes:\n name_prefix (str): The name of the webhook, will be appended with a unique ID.\n endpoint (str): The URL endpoint for the webhook.\n labels (Optional[dict]): Labels associated with the webhook.\n secrets (Optional[list[Variable]]): List of secrets associated with the webhook.",
242
+ "properties": {
243
+ "name_prefix": {
244
+ "title": "Name Prefix",
245
+ "type": "string"
246
+ },
247
+ "endpoint": {
248
+ "title": "Endpoint",
249
+ "type": "string"
250
+ },
251
+ "labels": {
252
+ "anyOf": [
253
+ {
254
+ "additionalProperties": {
255
+ "type": "string"
256
+ },
257
+ "type": "object"
258
+ },
259
+ {
260
+ "type": "null"
261
+ }
262
+ ],
263
+ "title": "Labels"
264
+ },
265
+ "secrets": {
266
+ "anyOf": [
267
+ {
268
+ "items": {
269
+ "$ref": "#/$defs/Variable"
270
+ },
271
+ "type": "array"
272
+ },
273
+ {
274
+ "type": "null"
275
+ }
276
+ ],
277
+ "title": "Secrets"
278
+ }
279
+ },
280
+ "required": [
281
+ "name_prefix",
282
+ "endpoint"
283
+ ],
284
+ "title": "Webhook",
285
+ "type": "object"
286
+ }
287
+ },
288
+ "description": "A class to represent the manifest of a Spacelift plugin.\n\nAttributes:\n name_prefix (str): The name of the plugin, will be appended with a unique ID.\n description (str): A description of the plugin.\n author (str): The author of the plugin.\n parameters (list[Parameter]): List of parameters for the plugin.\n contexts (list[Context]): List of contexts for the plugin.\n webhooks (list[Webhook]): List of webhooks for the plugin.\n policies (list[Policy]): List of policies for the plugin.",
289
+ "properties": {
290
+ "name_prefix": {
291
+ "title": "Name Prefix",
292
+ "type": "string"
293
+ },
294
+ "version": {
295
+ "title": "Version",
296
+ "type": "string"
297
+ },
298
+ "description": {
299
+ "title": "Description",
300
+ "type": "string"
301
+ },
302
+ "author": {
303
+ "title": "Author",
304
+ "type": "string"
305
+ },
306
+ "parameters": {
307
+ "anyOf": [
308
+ {
309
+ "items": {
310
+ "$ref": "#/$defs/Parameter"
311
+ },
312
+ "type": "array"
313
+ },
314
+ {
315
+ "type": "null"
316
+ }
317
+ ],
318
+ "title": "Parameters"
319
+ },
320
+ "contexts": {
321
+ "anyOf": [
322
+ {
323
+ "items": {
324
+ "$ref": "#/$defs/Context"
325
+ },
326
+ "type": "array"
327
+ },
328
+ {
329
+ "type": "null"
330
+ }
331
+ ],
332
+ "title": "Contexts"
333
+ },
334
+ "webhooks": {
335
+ "anyOf": [
336
+ {
337
+ "items": {
338
+ "$ref": "#/$defs/Webhook"
339
+ },
340
+ "type": "array"
341
+ },
342
+ {
343
+ "type": "null"
344
+ }
345
+ ],
346
+ "title": "Webhooks"
347
+ },
348
+ "policies": {
349
+ "anyOf": [
350
+ {
351
+ "items": {
352
+ "$ref": "#/$defs/Policy"
353
+ },
354
+ "type": "array"
355
+ },
356
+ {
357
+ "type": "null"
358
+ }
359
+ ],
360
+ "title": "Policies"
361
+ }
362
+ },
363
+ "required": [
364
+ "name_prefix",
365
+ "version",
366
+ "description",
367
+ "author"
368
+ ],
369
+ "title": "PluginManifest",
370
+ "type": "object"
371
+ }
@@ -0,0 +1,163 @@
1
+ Metadata-Version: 2.4
2
+ Name: spaceforge
3
+ Version: 0.1.0.dev0
4
+ Summary: A Python framework for building Spacelift plugins
5
+ Home-page: https://github.com/spacelift-io/plugins
6
+ Author: Spacelift
7
+ Author-email: Spacelift <support@spacelift.io>
8
+ Maintainer-email: Spacelift <support@spacelift.io>
9
+ License: MIT
10
+ Project-URL: Homepage, https://github.com/spacelift-io/plugins
11
+ Project-URL: Documentation, https://github.com/spacelift-io/plugins#readme
12
+ Project-URL: Repository, https://github.com/spacelift-io/plugins
13
+ Project-URL: Bug Reports, https://github.com/spacelift-io/plugins/issues
14
+ Keywords: spacelift,plugin,framework,infrastructure,devops,spaceforge
15
+ Classifier: Development Status :: 3 - Alpha
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Topic :: System :: Systems Administration
25
+ Requires-Python: >=3.9
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: PyYAML>=6.0
29
+ Requires-Dist: click>=8.0.0
30
+ Requires-Dist: pydantic>=2.11.7
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest>=6.0; extra == "dev"
33
+ Requires-Dist: pytest-cov; extra == "dev"
34
+ Requires-Dist: black; extra == "dev"
35
+ Requires-Dist: isort; extra == "dev"
36
+ Requires-Dist: mypy; extra == "dev"
37
+ Requires-Dist: types-PyYAML; extra == "dev"
38
+ Requires-Dist: setuptools-scm[toml]>=6.2; extra == "dev"
39
+ Dynamic: author
40
+ Dynamic: home-page
41
+ Dynamic: license-file
42
+ Dynamic: requires-python
43
+
44
+ # Spacelift Plugins
45
+
46
+ A monorepo for Spacelift plugins built with the **spaceforge** framework.
47
+
48
+ ## Overview
49
+
50
+ This repository contains:
51
+ - **spaceforge/** - The core Python framework for building Spacelift plugins
52
+ - **plugins/wiz/** - Wiz security scanning plugin
53
+ - Plugin management and generation tools
54
+
55
+ ## Quick Start
56
+
57
+ ### Installation
58
+
59
+ ```bash
60
+ # Install the spaceforge framework
61
+ pip install -e .
62
+ ```
63
+
64
+ ### Creating a Plugin
65
+
66
+ 1. Create a new directory for your plugin
67
+ 2. Implement your plugin by inheriting from `SpacepyPlugin`:
68
+
69
+ ```python
70
+ from spaceforge import SpaceforgePlugin, Parameter, Variable, Context
71
+
72
+ class MyPlugin(SpaceforgePlugin):
73
+ __plugin_name__ = "my-plugin"
74
+ __version__ = "1.0.0"
75
+ __author__ = "Your Name"
76
+
77
+ # Define parameters using pydantic dataclasses
78
+ __parameters__ = [
79
+ Parameter(
80
+ name="api_key",
81
+ description="API key for authentication",
82
+ required=True,
83
+ sensitive=True
84
+ )
85
+ ]
86
+
87
+ # Define contexts using pydantic dataclasses
88
+ __contexts__ = [
89
+ Context(
90
+ name="main",
91
+ description="Main plugin context",
92
+ env=[
93
+ Variable(
94
+ key="API_KEY",
95
+ value_from_parameter="api_key",
96
+ sensitive=True
97
+ )
98
+ ]
99
+ )
100
+ ]
101
+
102
+ def after_plan(self):
103
+ self.logger.info("Running after plan hook")
104
+ ```
105
+
106
+ 3. Generate the plugin YAML:
107
+
108
+ ```bash
109
+ python -m spaceforge generate my_plugin.py
110
+ ```
111
+
112
+ ### Testing Plugins
113
+
114
+ ```bash
115
+ # Set plugin parameters
116
+ export SPACEFORGE_PARAM_NAME="value"
117
+
118
+ # Test specific hooks
119
+ python -m spaceforge runner after_plan
120
+ ```
121
+
122
+ ## Architecture
123
+
124
+ The spaceforge framework uses a hook-based architecture where plugins:
125
+ - Inherit from `SpaceforgePlugin` base class
126
+ - Override hook methods (`after_plan`, `before_apply`, etc.)
127
+ - Define parameters, contexts, webhooks, and policies using pydantic dataclasses
128
+ - Include automatic validation of data structures (e.g., Variables must have either `value` or `value_from_parameter`)
129
+ - Are automatically converted to Spacelift plugin YAML format with JSON schema validation
130
+
131
+ ## Available Plugins
132
+
133
+ - **wiz** - Security scanning plugin for infrastructure as code
134
+
135
+ ## Development
136
+
137
+ ### Commands
138
+
139
+ ```bash
140
+ # Generate plugin YAML
141
+ python -m spaceforge generate [plugin_file.py] [-o output.yaml]
142
+
143
+ # Test plugin execution
144
+ python -m spaceforge runner [--plugin-file plugin.py] hook_name
145
+
146
+ # Get help
147
+ python -m spaceforge --help
148
+ ```
149
+
150
+ ### Framework Documentation
151
+
152
+ See [spaceforge/README.md](spaceforge/README.md) for detailed framework documentation.
153
+
154
+ ## Contributing
155
+
156
+ 1. Create your plugin in a new directory
157
+ 2. Follow the plugin development patterns shown in existing plugins
158
+ 3. Generate and test your plugin YAML
159
+ 4. Submit a pull request
160
+
161
+ ## License
162
+
163
+ MIT License
@@ -0,0 +1,19 @@
1
+ spaceforge/README.md,sha256=8o1Nuyasb4OxX3E7ZycyducOrR4J19bZcHrLvFeoFNg,7730
2
+ spaceforge/__init__.py,sha256=jsfbVuAa-7QX5XCu-d1rGc2qP9Iw1zQOu9ARJM9sm1k,516
3
+ spaceforge/__main__.py,sha256=gqj_EAEshdkwcXfERLnyAWveGDoXYJPwPa17BDMSMSA,613
4
+ spaceforge/_version.py,sha256=KLlA-mMwGoc8dP7BQAzLprWKT_n6k13anGYGEvf47GA,2166
5
+ spaceforge/cls.py,sha256=-oNXg75ddexgU3eo0MtO_1Nv3QiAPEHLqB_r8WJQ7tw,5791
6
+ spaceforge/cls_test.py,sha256=nXAgbnFnGdFxrtA7vNXiePjNUASuoYW-lEuQGx9WMGs,468
7
+ spaceforge/generator.py,sha256=myAn8C-15S3KKiYUDfaT1UeMdtFBkFA9jKXGV2Ux4l0,13672
8
+ spaceforge/generator_test.py,sha256=CGQOD0WrBbbbg6tgiEKo_KZp5nT6GpZdThWRv2VAhsU,23068
9
+ spaceforge/plugin.py,sha256=NHCQg01OTWvnUMOpBQAq4rkJQ61coLE-xrG1zV8Hjn8,9549
10
+ spaceforge/plugin_test.py,sha256=eTCIVU9VGx0j_rt_L-9HjB0rR6K0Fw-8uQ86pZjNna8,23003
11
+ spaceforge/runner.py,sha256=JSABlCiq_qs9knWEq6eUpEE_ZR-r0KcDQLzxErd324Y,3457
12
+ spaceforge/runner_test.py,sha256=fws8RaWbZLLek7CQJ-PJjGLsgAMdPXgnHxIYBTRRm4Q,19702
13
+ spaceforge/schema.json,sha256=h3G0K5AYXC5p0YCpf8NWlvhzxuvy-SvL4zWWHOUkTpU,10134
14
+ spaceforge-0.1.0.dev0.dist-info/licenses/LICENSE,sha256=wyljRrfnWY2ggQKkSCg3Nw2hxwPMmupopaKs9Kpgys8,1065
15
+ spaceforge-0.1.0.dev0.dist-info/METADATA,sha256=vmdK_0BZNPhPVsx_9UkgEUR0V8Fked_dnWPFxUlxyMQ,4588
16
+ spaceforge-0.1.0.dev0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
17
+ spaceforge-0.1.0.dev0.dist-info/entry_points.txt,sha256=qawuuKBSNTGg-njnQnhxxFldFvXYAPej6bF_f3iyQ48,56
18
+ spaceforge-0.1.0.dev0.dist-info/top_level.txt,sha256=eVw-Lw4Th0oHM8Gx1Y8YetyNgbNbMBU00yWs-kwGeSs,11
19
+ spaceforge-0.1.0.dev0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ spaceforge = spaceforge.__main__:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Spacelift
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ spaceforge