qontract-development-cli 0.15.8__tar.gz → 0.16.0__tar.gz

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.
Files changed (31) hide show
  1. qontract_development_cli-0.16.0/PKG-INFO +363 -0
  2. qontract_development_cli-0.16.0/README.md +342 -0
  3. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/pyproject.toml +9 -3
  4. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/commands/profile.py +20 -4
  5. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/models.py +80 -7
  6. qontract_development_cli-0.16.0/qontract_development_cli/templates/api.yml.j2 +32 -0
  7. qontract_development_cli-0.16.0/qontract_development_cli/templates/cache.yml.j2 +21 -0
  8. qontract_development_cli-0.16.0/qontract_development_cli/templates/compose.override.yml.j2 +113 -0
  9. qontract_development_cli-0.16.0/qontract_development_cli/templates/compose.yml.j2 +14 -0
  10. qontract_development_cli-0.16.0/qontract_development_cli/templates/internal-redhat-ca.yml.j2 +12 -0
  11. qontract_development_cli-0.16.0/qontract_development_cli/templates/reconcile.yml.j2 +65 -0
  12. qontract_development_cli-0.16.0/qontract_development_cli/templates/server.yml.j2 +24 -0
  13. qontract_development_cli-0.16.0/qontract_development_cli/templates/vault.yml.j2 +12 -0
  14. qontract_development_cli-0.16.0/qontract_development_cli/templates/worker.yml.j2 +32 -0
  15. qontract_development_cli-0.15.8/PKG-INFO +0 -290
  16. qontract_development_cli-0.15.8/README.md +0 -269
  17. qontract_development_cli-0.15.8/qontract_development_cli/templates/compose.override.yml.j2 +0 -7
  18. qontract_development_cli-0.15.8/qontract_development_cli/templates/compose.yml.j2 +0 -148
  19. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/__init__.py +0 -0
  20. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/__main__.py +0 -0
  21. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/cli.py +0 -0
  22. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/commands/__init__.py +0 -0
  23. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/commands/config.py +0 -0
  24. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/commands/env.py +0 -0
  25. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/completions.py +0 -0
  26. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/config.py +0 -0
  27. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/shell.py +0 -0
  28. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/templates/prep-worktree.sh.j2 +0 -0
  29. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/templates.py +0 -0
  30. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/utils.py +0 -0
  31. {qontract_development_cli-0.15.8 → qontract_development_cli-0.16.0}/qontract_development_cli/watchdog.py +0 -0
@@ -0,0 +1,363 @@
1
+ Metadata-Version: 2.4
2
+ Name: qontract-development-cli
3
+ Version: 0.16.0
4
+ Summary: Helper tool for qontract-reconcile development
5
+ Project-URL: homepage, http://github.com/chassing/qontract-development-cli
6
+ Project-URL: repository, http://github.com/chassing/qontract-development-cli
7
+ Project-URL: documentation, http://github.com/chassing/qontract-development-cli
8
+ Author-email: Christian Assing <cassing@redhat.com>
9
+ License: MIT
10
+ Requires-Python: >=3.11
11
+ Requires-Dist: appdirs~=1.4.4
12
+ Requires-Dist: getkey~=0.6.5
13
+ Requires-Dist: jinja2~=3.1
14
+ Requires-Dist: pydantic-settings~=2.6
15
+ Requires-Dist: pydantic~=2.9
16
+ Requires-Dist: pyyaml~=6.0.2
17
+ Requires-Dist: rich~=14.0
18
+ Requires-Dist: typer~=0.21.0
19
+ Requires-Dist: watchfiles~=1.1.0
20
+ Description-Content-Type: text/markdown
21
+
22
+ # Qontract Development CLI
23
+
24
+ [![PyPI](https://img.shields.io/pypi/v/qontract-development-cli)][pypi-link]
25
+ [![PyPI platforms][pypi-platforms]][pypi-link]
26
+ ![PyPI - License](https://img.shields.io/pypi/l/qontract-development-cli)
27
+
28
+ Qontract Development CLI supports your daily [qontract-reconcile][qontract-reconcile] development work.
29
+
30
+ [toc]
31
+
32
+ ## Recommended Installation Method
33
+
34
+ The recommended way to install `qontract-development-cli` is to use the [uv](https://docs.astral.sh/uv/) tool:
35
+
36
+ ```shell
37
+ uv tool install qontract-development-cli
38
+ ```
39
+
40
+ and upgrade an existing installation with:
41
+
42
+ ```shell
43
+ uv tool upgrade qontract-development-cli
44
+ ```
45
+
46
+ ## Alternative Installation Methods
47
+
48
+ You can install this library from [PyPI][pypi-link] with `pip`:
49
+
50
+ ```shell
51
+ python3 -m pip install qontract-development-cli
52
+ ```
53
+
54
+ or install it with `pipx`:
55
+
56
+ ```shell
57
+ pipx install qontract-development-cli
58
+ ```
59
+
60
+ and upgrade an existing installation with:
61
+
62
+ ```shell
63
+ pipx upgrade qontract-development-cli
64
+ ```
65
+
66
+ ## Quickstart
67
+
68
+ * Create initial configuration
69
+
70
+ ```shell
71
+ qd config init
72
+ ```
73
+
74
+ ![qd init](/demo/qd_config_init.gif)
75
+
76
+ * Create a profile `sql-query` to run the `sql-query` integration
77
+
78
+ ```shell
79
+ qd profile create sql-query
80
+ ```
81
+
82
+ ![qd profile create](/demo/qd_profile_create.gif)
83
+
84
+ * Run `sql-query` profile
85
+
86
+ ```shell
87
+ qd profile run dev sql-query
88
+ ```
89
+
90
+ ![qd sql_query](/images/profile_run_sql_query.svg)
91
+
92
+ ## Features
93
+
94
+ Qontract Development CLI currently provides the following features (get help with `-h` or `--help`):
95
+
96
+ * Run `qontract-reconcile` and `qontract-server` as docker containers on your local machine
97
+ * Support for different App-Interface environments (dev, prod, ...) via the `env` command
98
+ * Configure your [qontract-reconcile integration][qontract-reconcile] with the `profile` command
99
+ * Support pull request reviews (see `profile create`)
100
+ * Bootstrap your initial configurations with the `config` command
101
+ * Shell auto-completion (see `qd --help`)
102
+ * Automatically restart `qontract-reconcile` container when files change
103
+ * Automatically rebuild the App-Interface bundle and restart the `qontract-server` container when files change
104
+
105
+ ## Examples
106
+
107
+ Take a look at the [examples](examples) directory for different profile examples.
108
+
109
+ ## Usage
110
+
111
+ The following sections describe all available commands and their options.
112
+
113
+ ### Config
114
+
115
+ Manage global qontract-development-cli configuration.
116
+
117
+ `qd config [sub-cmd] --help`
118
+
119
+ * **edit**: open the configuration file in your favorite editor
120
+ * **init**: create a default configuration
121
+
122
+ #### Global Settings
123
+
124
+ | **Key** | **Description** | **Default** |
125
+ | --------------------------- | ------------------------------------- | ------------------------------------ |
126
+ | debug | Enable/disable debug mode | false |
127
+ | defaults_profile | Name of defaults profile | defaults |
128
+ | docker_compose_project_name | Docker compose project name | qontract-development |
129
+ | editor | Your favorite editor | $EDITOR or vim |
130
+ | environments_dir | Directory to store environment files | User config directory / environments |
131
+ | profiles_dir | Directory to store profile files | User config directory / profiles |
132
+ | worktrees_dir | Directory to store git repo worktrees | User cache directory / worktrees |
133
+
134
+ ### Environments
135
+
136
+ An environment specifies app-interface instance settings, e.g., **dev** vs. **prod** config and path to the actual app-interface instance.
137
+
138
+ `qd env [sub-cmd] --help`
139
+
140
+ * **edit**: Create/edit an environment file in your editor.
141
+ * **ls**: List all available environments.
142
+ * **rm**: Remove environment.
143
+ * **show**: Display environment.
144
+
145
+ #### Environment Settings
146
+
147
+ | **Key** | **Description** | **Default** |
148
+ | ---------------------------------- | ------------------------------------------------ | ---------------------------------------------- |
149
+ | **app_interface_path** | Path to local app-interface instance | ~/workspace/app-interface |
150
+ | app_interface_state_bucket | S3 bucket | empty |
151
+ | app_interface_state_bucket_account | AWS S3 account | empty |
152
+ | **config** | app-interface config | ~/workspace/qontract-reconcile/config.dev.toml |
153
+ | container_platform | Default Docker container platform for all images | linux/amd64 |
154
+ | gitlab_pr_submitter_queue_url | Gitlab pr submitter queue url | |
155
+ | run_qontract_api | Run qontract-api container | false |
156
+ | run_qontract_api_worker | Run qontract-api-worker container | false |
157
+ | run_cache | Run cache (Redis) container | false |
158
+ | run_qontract_reconcile | Run qontract-reconcile container | true |
159
+ | run_qontract_server | Run qontract-server container | true |
160
+ | run_vault | Run vault container | false |
161
+
162
+ > :point_right: **Bold keys** are mandatory or should be customized.
163
+
164
+ ### Profiles
165
+
166
+ A profile specifies all settings to run a qontract-reconcile integration (e.g., *sql-query*).
167
+
168
+ `qd profile [sub-cmd] --help`
169
+
170
+ * **create**: Create a new profile to run an integration.
171
+
172
+ Supports the creation of a new profile from an open PR/MR. See `$ qd profile create --help` for all available options.
173
+
174
+ * **edit**: Edit a profile in your editor.
175
+ * **ls**: List all available profiles.
176
+ * **rm**: Remove profile.
177
+ * **run**: Run a profile.
178
+ * **show**: Display profile.
179
+
180
+ #### --no-dry-run
181
+
182
+ By default, `qd` runs integrations in `dry-run` mode if not explicitly specified differently in the profile config.
183
+ There is also a `--no-dry-run` flag which lets you disable `dry-run` mode from the command line.
184
+
185
+ ```shell
186
+ qd profile run dev my-integration --no-dry-run
187
+ ```
188
+
189
+ The command line flag takes precedence over any configuration you might have in the profile settings.
190
+
191
+ #### Profile Settings
192
+
193
+ | **Key** | **Description** | **Default** |
194
+ | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
195
+ | additional_environment | Dictionary of additional environment variables to pass to the qontract-reconcile container | `{}` |
196
+ | container_uid | Change ownership of /recconcile files in container to this user id | current UID |
197
+ | command | Command to run in the qontract-reconcile container. | `run-integration` |
198
+ | command_extra_args | Additional arguments to pass to the command. | |
199
+ | debugger | Python debugger | `debugpy` |
200
+ | dry_run | Run --dry-run mode | `true` |
201
+ | extra_hosts | List of 'HOSTNAME:IP' mapping entries for qontract-reconcile `/etc/hosts`. See [extra_hosts](https://docs.docker.com/compose/compose-file/#extra_hosts) docker compose file. | `[]` |
202
+ | **integration_name** | Intergration name | |
203
+ | **integration_extra_args** | Intergration extra arguments | |
204
+ | **internal_redhat_ca** | Inject Red Hat internal CAs and `REQUESTS_CA_BUNDLE` environment variable | `false` |
205
+ | internal_redhat_ca_image | The Red Hat internal CA image | Internal one |
206
+ | internal_redhat_ca_container_platform | The Red Hat internal CA container platform | Default from [environment](#environment-settings) |
207
+ | log_level | Log level | `info` |
208
+ | app_interface_path | App-interface instance path. (Overrides *env.app_interface_path*) | |
209
+ | app_interface_pr | App-interface PR/MR number | |
210
+ | app_interface_upstream | Upstream remote name | `upstream` |
211
+ | cache_image | Cache (Redis) image | `redis:7-alpine` |
212
+ | cache_container_platform | Cache (Redis) container platform | Default from [environment](#environment-settings) |
213
+ | cache_compose_file | Cache docker-compose file template | `cache.yml.j2` |
214
+ | qontract_api_build_image | Build qontract-api image | `true` |
215
+ | qontract_api_image | Qontract-api image | `quay.io/redhat-services-prod/.../qontract-api-master:latest` |
216
+ | qontract_api_container_platform | Qontract-api container platform | Default from [environment](#environment-settings) |
217
+ | qontract_api_compose_file | Qontract-api docker-compose file template | `api.yml.j2` |
218
+ | qontract_api_debugger_port | Debugger port for qontract-api | `5679` |
219
+ | qontract_api_worker_build_image | Build qontract-api-worker image | `true` |
220
+ | qontract_api_worker_image | Qontract-api-worker image | `quay.io/redhat-services-prod/.../qontract-api-worker-master:latest` |
221
+ | qontract_api_worker_container_platform | Qontract-api-worker container platform | Default from [environment](#environment-settings) |
222
+ | qontract_api_worker_compose_file | Qontract-api-worker docker-compose file template | `worker.yml.j2` |
223
+ | qontract_api_worker_debugger_port | Debugger port for qontract-api-worker | `5680` |
224
+ | qontract_reconcile_build_image | Build qontract-reconcile image | `true` |
225
+ | qontract_reconcile_image | Qontract-reconcile image | `quay.io/redhat-services-prod/.../qontract-reconcile-master:latest` |
226
+ | qontract_reconcile_container_platform | Qontract-reconcile container platform | Default from [environment](#environment-settings) |
227
+ | qontract_reconcile_path | Qontract-reconcile path | `~/workspace/qontract-reconcile` |
228
+ | qontract_reconcile_pr | Qontract-reconcile PR/MR number | |
229
+ | qontract_reconcile_upstream | Upstream remote name | `upstream` |
230
+ | qontract_reconcile_compose_file | Qontract-reconcile docker-compose file template | `reconcile.yml.j2` |
231
+ | qontract_reconcile_debugger_port | Debugger port for qontract-reconcile | `5678` |
232
+ | qontract_server_build_image | Build qontract-server image | `true` |
233
+ | qontract_server_image | Qontract-server image | `quay.io/redhat-services-prod/.../qontract-server-master:latest` |
234
+ | qontract_server_container_platform | Qontract-server container platform | Default from [environment](#environment-settings) |
235
+ | qontract_server_path | Qontract-server path | `~/workspace/qontract-server` |
236
+ | qontract_server_compose_file | Qontract-server docker-compose file template | `server.yml.j2` |
237
+ | qontract_server_debugger_port | Debugger port for qontract-server | `6789` |
238
+ | qontract_schemas_path | Qontract-schemas path | `~/workspace/qontract-schemas` |
239
+ | qontract_schemas_pr | Qontract-schemas PR/MR number | |
240
+ | qontract_schemas_upstream | Upstream remote name | `upstream` |
241
+ | run_once | If 'true', execute the integration once and exit | `true` |
242
+ | sleep_duration_secs | If not *run_once*, sleep duration until integration runs again | `10` |
243
+ | localstack | Run localstack container and set AWS related environment variables | `false` |
244
+ | localstack_compose_file | Path to your Localstack docker-compose file | `qontract_reconcile_path` / `dev/localstack/docker-compose.yml` |
245
+ | skip_initial_make_bundle | Skip initial make bundle step | `false` |
246
+ | vault_image | Vault image | `vault:1.5.4` |
247
+ | vault_container_platform | Vault container platform | Default from [environment](#environment-settings) |
248
+ | vault_compose_file | Vault docker-compose file template | `vault.yml.j2` |
249
+
250
+ > :point_right: **Bold keys** are mandatory or should be customized.
251
+
252
+ ### Connecting your IDE to QR
253
+
254
+ Note that the Qontract Reconcile container will not start running until it is connected to by a debugger. You can use a config like this for VSCode:
255
+
256
+ ```json
257
+ {
258
+ "version": "0.2.0",
259
+ "configurations": [
260
+ {
261
+ "name": "Python Debugger: Reconcile",
262
+ "type": "debugpy",
263
+ "request": "attach",
264
+ "connect": { "host": "localhost", "port": 5678 },
265
+ "pathMappings": [
266
+ { "localRoot": "${workspaceFolder}", "remoteRoot": "/work" }
267
+ ],
268
+ "justMyCode": false,
269
+ "autoReload": {
270
+ "enable": true
271
+ }
272
+ },
273
+ {
274
+ "name": "Python Debugger: Api",
275
+ "type": "debugpy",
276
+ "request": "attach",
277
+ "connect": { "host": "localhost", "port": 5679 },
278
+ "pathMappings": [
279
+ { "localRoot": "${workspaceFolder}", "remoteRoot": "/opt/app-root/src" }
280
+ ],
281
+ "justMyCode": false,
282
+ "autoReload": {
283
+ "enable": true
284
+ }
285
+ },
286
+ {
287
+ "name": "Python Debugger: Worker",
288
+ "type": "debugpy",
289
+ "request": "attach",
290
+ "connect": { "host": "localhost", "port": 5680 },
291
+ "pathMappings": [
292
+ { "localRoot": "${workspaceFolder}", "remoteRoot": "/opt/app-root/src" }
293
+ ],
294
+ "justMyCode": true,
295
+ "autoReload": {
296
+ "enable": true
297
+ }
298
+ }
299
+ ],
300
+ "compounds": [
301
+ {
302
+ "name": "Debug: Reconcile + qontract-api",
303
+ "configurations": [
304
+ "Python Debugger: Reconcile",
305
+ "Python Debugger: Api",
306
+ "Python Debugger: Worker"
307
+ ],
308
+ "stopAll": true,
309
+ "presentation": {
310
+ "hidden": false,
311
+ "group": "Full Stack",
312
+ "order": 0
313
+ }
314
+ }
315
+ ]
316
+ }
317
+
318
+ ```
319
+
320
+ **Please note that development does not currently work with PyCharm as debugpy is not yet supported. [This issue is being tracked here](https://youtrack.jetbrains.com/issue/PY-63403/Support-debugpy)**
321
+
322
+ ### PR/MR support
323
+
324
+ It's a pretty handy feature to create a profile from a pull request (merge request). E.g.:
325
+
326
+ ```shell
327
+ qd profile create --app-interface PATH_TO_YOUR_LOCAL/app-interface-dev-data --app-interface-pr NUMBER --qontract-schemas-pr NUMBER --qontract-reconcile-pr NUMBER --integration-name glitchtip --integration-extra-args '' glitchtip-pr-check
328
+ ```
329
+
330
+ Which results in this profile:
331
+
332
+ ```shell
333
+ $ qd profile show glitchtip-pr-check
334
+ ---
335
+ app_interface_path: PATH_TO_YOUR_LOCAL/app-interface-dev-data
336
+ app_interface_pr: NUMBER
337
+ integration_name: glitchtip
338
+ qontract_reconcile_pr: NUMBER
339
+ qontract_schemas_pr: NUMBER
340
+ ```
341
+
342
+ Running this profile will:
343
+
344
+ * Create new git worktrees (see `config.worktrees_dir`) for app-interface-dev-data, qontract-schema, and qontract-reconcile PRs
345
+ * Start the containers with the adapted path to these worktrees
346
+ * Restarting the profile will fetch PR updates
347
+
348
+ > :point_right: A git worktree cleanup isn't implemented yet
349
+
350
+ ## Development
351
+
352
+ [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
353
+ [![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)
354
+
355
+ ### Release
356
+
357
+ * Bump the version in `pyproject.toml`
358
+ * Update the `CHANGELOG.md`
359
+ * Commit the changes
360
+
361
+ [pypi-link]: https://pypi.org/project/qontract-development-cli/
362
+ [pypi-platforms]: https://img.shields.io/pypi/pyversions/qontract-development-cli
363
+ [qontract-reconcile]: https://github.com/app-sre/qontract-reconcile