qontract-development-cli 0.14.2__tar.gz → 0.14.4__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 (21) hide show
  1. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/PKG-INFO +1 -1
  2. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/pyproject.toml +5 -3
  3. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/commands/profile.py +15 -12
  4. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/models.py +5 -8
  5. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/templates/compose.yml.j2 +4 -0
  6. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/templates.py +4 -1
  7. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/watchdog.py +4 -10
  8. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/setup.py +1 -1
  9. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/README.md +0 -0
  10. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/__init__.py +0 -0
  11. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/__main__.py +0 -0
  12. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/cli.py +0 -0
  13. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/commands/__init__.py +0 -0
  14. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/commands/config.py +0 -0
  15. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/commands/env.py +0 -0
  16. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/completions.py +0 -0
  17. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/config.py +0 -0
  18. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/shell.py +0 -0
  19. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/templates/compose.override.yml.j2 +0 -0
  20. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/templates/prep-worktree.sh.j2 +0 -0
  21. {qontract_development_cli-0.14.2 → qontract_development_cli-0.14.4}/qontract_development_cli/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: qontract-development-cli
3
- Version: 0.14.2
3
+ Version: 0.14.4
4
4
  Summary: Helper tool for qontract-reconcile development
5
5
  Home-page: http://github.com/chassing/qontract-development-cli
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "qontract-development-cli"
3
- version = "0.14.2"
3
+ version = "0.14.4"
4
4
  description = "Helper tool for qontract-reconcile development"
5
5
  authors = ["Christian Assing <cassing@redhat.com>"]
6
6
  license = "MIT"
@@ -26,7 +26,7 @@ types-PyYAML = "^6.0.12"
26
26
  pytest = "^8.0.0"
27
27
  mypy = "^1.8.0"
28
28
  types-pyyaml = "^6.0.12.11"
29
- ruff = "^0.2.1"
29
+ ruff = "^0.4.8"
30
30
 
31
31
  [build-system]
32
32
  requires = ["poetry-core>=1.0.0"]
@@ -61,7 +61,7 @@ tag_format = "v$version"
61
61
  [tool.ruff]
62
62
  line-length = 88
63
63
  target-version = 'py311'
64
- required-version = "0.2.1"
64
+ required-version = "0.4.8"
65
65
  src = ["qontract_development_cli"]
66
66
  extend-exclude = [".local", ".cache"]
67
67
  fix = true
@@ -78,6 +78,8 @@ extend-select = [
78
78
  "I",
79
79
  # pylint
80
80
  "PL",
81
+ # pyupgrade
82
+ "UP",
81
83
  ]
82
84
 
83
85
  [tool.ruff.format]
@@ -40,13 +40,18 @@ from ..utils import console
40
40
  app = typer.Typer()
41
41
  log = logging.getLogger(__name__)
42
42
 
43
+ # see https://github.com/tiangolo/typer/issues/533
44
+ OptionalStr = Optional[str] # noqa: UP007
45
+ OptionalInt = Optional[int] # noqa: UP007
46
+ OptionalPath = Optional[Path] # noqa: UP007
47
+
43
48
 
44
49
  @app.command()
45
50
  def create( # noqa: PLR0913, PLR0917
46
51
  profile_name: str = typer.Argument(..., help="Profile to create."),
47
- integration_name: Optional[str] = typer.Option(None),
48
- integration_extra_args: Optional[str] = typer.Option(None),
49
- app_interface: Optional[Path] = typer.Option(
52
+ integration_name: OptionalStr = typer.Option(None),
53
+ integration_extra_args: OptionalStr = typer.Option(None),
54
+ app_interface: OptionalPath = typer.Option(
50
55
  None,
51
56
  file_okay=False,
52
57
  dir_okay=True,
@@ -55,9 +60,9 @@ def create( # noqa: PLR0913, PLR0917
55
60
  exists=True,
56
61
  help="Path to local app-interface instance git working copy.",
57
62
  ),
58
- app_interface_pr: Optional[int] = typer.Option(None, help="PR/MR to use"),
63
+ app_interface_pr: OptionalInt = typer.Option(None, help="PR/MR to use"),
59
64
  app_interface_upstream: str = typer.Option("upstream", help="Upstream remote name"),
60
- qontract_schemas: Optional[Path] = typer.Option(
65
+ qontract_schemas: OptionalPath = typer.Option(
61
66
  None,
62
67
  file_okay=False,
63
68
  dir_okay=True,
@@ -66,11 +71,11 @@ def create( # noqa: PLR0913, PLR0917
66
71
  exists=True,
67
72
  help="Path to local qontract-schemas git working copy.",
68
73
  ),
69
- qontract_schemas_pr: Optional[int] = typer.Option(None, help="PR/MR to use"),
74
+ qontract_schemas_pr: OptionalInt = typer.Option(None, help="PR/MR to use"),
70
75
  qontract_schemas_upstream: str = typer.Option(
71
76
  "upstream", help="Upstream remote name"
72
77
  ),
73
- qontract_reconcile: Optional[Path] = typer.Option(
78
+ qontract_reconcile: OptionalPath = typer.Option(
74
79
  None,
75
80
  file_okay=False,
76
81
  dir_okay=True,
@@ -79,7 +84,7 @@ def create( # noqa: PLR0913, PLR0917
79
84
  exists=True,
80
85
  help="Path to local qontract-reconcile git working copy.",
81
86
  ),
82
- qontract_reconcile_pr: Optional[int] = typer.Option(None, help="PR/MR to use"),
87
+ qontract_reconcile_pr: OptionalInt = typer.Option(None, help="PR/MR to use"),
83
88
  qontract_reconcile_upstream: str = typer.Option(
84
89
  "upstream", help="Upstream remote name"
85
90
  ),
@@ -278,7 +283,7 @@ def run( # noqa: PLR0912, PLR0917, PLR0913, PLR0915
278
283
  extensions=qontract_reconcile_monitor_file_extensions.split(" "),
279
284
  action=container_restart,
280
285
  action_args=(
281
- f"qontract-reconcile-{ profile.settings.integration_name }",
286
+ f"qontract-reconcile-{profile.settings.integration_name}",
282
287
  ),
283
288
  ),
284
289
  )
@@ -317,9 +322,7 @@ def run( # noqa: PLR0912, PLR0917, PLR0913, PLR0915
317
322
  key = "q"
318
323
 
319
324
  if key.lower() == "r":
320
- container_restart(
321
- f"qontract-reconcile-{ profile.settings.integration_name }"
322
- )
325
+ container_restart(f"qontract-reconcile-{profile.settings.integration_name}")
323
326
  elif key.lower() == "b":
324
327
  if not env.settings.run_qontract_server:
325
328
  console.print(
@@ -1,10 +1,7 @@
1
1
  import copy
2
2
  import os
3
3
  from pathlib import Path
4
- from typing import (
5
- Any,
6
- Optional,
7
- )
4
+ from typing import Any
8
5
 
9
6
  from pydantic import (
10
7
  BaseModel,
@@ -35,19 +32,19 @@ class ProfileSettings(BaseModel):
35
32
  integration_extra_args: str = ""
36
33
  integration_name: str = ""
37
34
  log_level: str = "INFO"
38
- app_interface_path: Optional[Path] = None
39
- app_interface_pr: Optional[int] = None
35
+ app_interface_path: Path | None = None
36
+ app_interface_pr: int | None = None
40
37
  app_interface_upstream: str = "upstream"
41
38
  qontract_reconcile_build_image: bool = True
42
39
  qontract_reconcile_image: str = "quay.io/app-sre/qontract-reconcile:latest"
43
40
  qontract_reconcile_path: Path = Path("~/workspace/qontract-reconcile")
44
- qontract_reconcile_pr: Optional[int] = None
41
+ qontract_reconcile_pr: int | None = None
45
42
  qontract_reconcile_upstream: str = "upstream"
46
43
  qontract_server_build_image: bool = True
47
44
  qontract_server_image: str = "quay.io/app-sre/qontract-server:latest"
48
45
  qontract_server_path: Path = Path("~/workspace/qontract-server")
49
46
  qontract_schemas_path: Path = Path("~/workspace/qontract-schemas")
50
- qontract_schemas_pr: Optional[int] = None
47
+ qontract_schemas_pr: int | None = None
51
48
  qontract_schemas_upstream: str = "upstream"
52
49
  run_once: bool = True
53
50
  sleep_duration_secs: int = 10
@@ -6,6 +6,7 @@ services:
6
6
  internal-certificates:
7
7
  image: quay.io/app-sre/internal-redhat-ca:latest
8
8
  container_name: internal-certificates
9
+ platform: linux/amd64
9
10
  command: |
10
11
  sh -c 'cp -r /etc/pki/. /tmp/'
11
12
  volumes:
@@ -14,6 +15,7 @@ services:
14
15
  {% if env.settings.run_qontract_reconcile %}
15
16
  qontract-reconcile:
16
17
  container_name: qontract-reconcile-{{ profile.settings.integration_name }}
18
+ platform: linux/amd64
17
19
  stop_grace_period: 1s
18
20
  stop_signal: SIGKILL
19
21
  tty: true
@@ -99,6 +101,7 @@ services:
99
101
  image: {{ profile.settings.qontract_server_image }}
100
102
  {% endif %}
101
103
  container_name: qontract-server
104
+ platform: linux/amd64
102
105
  stop_grace_period: 1s
103
106
  stop_signal: SIGKILL
104
107
  volumes:
@@ -116,6 +119,7 @@ services:
116
119
  {% if env.settings.run_vault %}
117
120
  vault:
118
121
  container_name: vault
122
+ platform: linux/amd64
119
123
  image: "vault:1.5.4"
120
124
  environment:
121
125
  - VAULT_ADDR=http://127.0.0.1:8200
@@ -7,7 +7,10 @@ from jinja2 import (
7
7
  )
8
8
 
9
9
  environment = Environment(
10
- loader=FileSystemLoader(str(Path(__file__).parent / "templates"))
10
+ loader=FileSystemLoader(str(Path(__file__).parent / "templates")),
11
+ trim_blocks=True,
12
+ lstrip_blocks=True,
13
+ keep_trailing_newline=True,
11
14
  )
12
15
 
13
16
 
@@ -1,13 +1,7 @@
1
1
  import logging
2
+ from collections.abc import Callable, Sequence
2
3
  from multiprocessing import Process
3
4
  from pathlib import Path
4
- from typing import (
5
- Callable,
6
- Optional,
7
- Sequence,
8
- Tuple,
9
- Union,
10
- )
11
5
 
12
6
  from rich.logging import RichHandler
13
7
  from watchfiles import (
@@ -24,7 +18,7 @@ class ExtensionFilter(DefaultFilter):
24
18
  self,
25
19
  *,
26
20
  extensions: Sequence[str],
27
- ignore_paths: Optional[Sequence[Union[str, Path]]] = None,
21
+ ignore_paths: Sequence[str | Path] | None = None,
28
22
  ) -> None:
29
23
  self.extensions = tuple(extensions)
30
24
  super().__init__(ignore_paths=ignore_paths)
@@ -34,7 +28,7 @@ class ExtensionFilter(DefaultFilter):
34
28
 
35
29
 
36
30
  def _watcher(
37
- path: Path, extensions: Sequence[str], action: Callable, action_args: Tuple
31
+ path: Path, extensions: Sequence[str], action: Callable, action_args: tuple
38
32
  ) -> None:
39
33
  # logger must be setup in child process
40
34
  logging.basicConfig(
@@ -50,7 +44,7 @@ def _watcher(
50
44
 
51
45
 
52
46
  def watch_files(
53
- path: Path, extensions: Sequence[str], action: Callable, action_args: Tuple
47
+ path: Path, extensions: Sequence[str], action: Callable, action_args: tuple
54
48
  ) -> Process:
55
49
  p = Process(target=_watcher, args=(path, extensions, action, action_args))
56
50
  p.start()
@@ -22,7 +22,7 @@ entry_points = \
22
22
 
23
23
  setup_kwargs = {
24
24
  'name': 'qontract-development-cli',
25
- 'version': '0.14.2',
25
+ 'version': '0.14.4',
26
26
  'description': 'Helper tool for qontract-reconcile development',
27
27
  'long_description': "# Qontract Development CLI\n\n[![PyPI](https://img.shields.io/pypi/v/qontract-development-cli)][pypi-link]\n[![PyPI platforms][pypi-platforms]][pypi-link]\n![PyPI - License](https://img.shields.io/pypi/l/qontract-development-cli)\n\nQontract Development CLI supports your daily [qontract-reconcile][qontract-reconcile] development work.\n\n[toc]\n\n## Installation\n\nYou can install this library from [PyPI][pypi-link] with `pip`:\n\n```shell\npython3 -m pip install qontract-development-cli\n```\n\nOr install it with `pipx`:\n\n```shell\npipx install qontract-development-cli\n```\n\nYou can also use `pipx` to run the library without installing it:\n\n```shell\npipx run qontract-development-cli\n```\n\n## Quickstart\n\n* Create initial configuration\n\n ```shell\n qd config init\n ```\n\n ![qd init](/demo/qd_config_init.gif)\n\n* Create a profile `sql-query` to run the `sql-query` integration\n\n ```shell\n qd profile create sql-query\n ```\n\n ![qd profile create](/demo/qd_profile_create.gif)\n\n* Run `sql-query` profile\n\n ```shell\n qd profile run dev sql-query\n ```\n\n ![qd sql_query](/images/profile_run_sql_query.svg)\n\n## Features\n\nQontract Development CLI currently provides the following features (get help with `-h` or `--help`):\n\n* Run `qontract-reconcile` and `qontract-server` as docker containers on your local machine\n* Support for different App-Interface environments (dev, prod, ...) via the `env` command\n* Configure your [qontract-reconcile integration][qontract-reconcile] with the `profile` command\n* Support pull request reviews (see `profile create`)\n* Bootstrap your initial configurations with the `config` command\n* Shell auto-completion (see `qd --help`)\n* Automatically restart `qontract-reconcile` container when files change\n* Automatically rebuild the App-Interface bundle and restart the `qontract-server` container when files change\n\n## Examples\n\nTake a look at the [examples](examples) directory for different profile examples.\n\n## Usage\n\nThe following sections describe all available commands and their options.\n\n### Config\n\nManage global qontract-development-cli configuration.\n\n`qd config [sub-cmd] --help`\n\n* **edit**: open the configuration file in your favorite editor\n* **init**: create a default configuration\n\n#### Global Settings\n\n| **Key** | **Description** | **Default** |\n| --------------------------- | ------------------------------------- | ------------------------------------ |\n| debug | Enable/disable debug mode | false |\n| defaults_profile | Name of defaults profile | defaults |\n| docker_compose_project_name | Docker compose project name | qontract-development |\n| editor | Your favorite editor | $EDITOR or vim |\n| environments_dir | Directory to store environment files | User config directory / environments |\n| profiles_dir | Directory to store profile files | User config directory / profiles |\n| worktrees_dir | Directory to store git repo worktrees | User cache directory / worktrees |\n\n### Environments\n\nAn environment specifies app-interface instance settings, e.g., **dev** vs. **prod** config and path to the actual app-interface instance.\n\n`qd env [sub-cmd] --help`\n\n* **edit**: Create/edit an environment file in your editor.\n* **ls**: List all available environments.\n* **rm**: Remove environment.\n* **show**: Display environment.\n\n#### Environment Settings\n\n| **Key** | **Description** | **Default** |\n| ---------------------------------- | ------------------------------------ | ---------------------------------------------- |\n| **app_interface_path** | Path to local app-interface instance | ~/workspace/app-interface |\n| app_interface_state_bucket | S3 bucket | empty |\n| app_interface_state_bucket_account | AWS S3 account | empty |\n| **config** | app-interface config | ~/workspace/qontract-reconcile/config.dev.toml |\n| gitlab_pr_submitter_queue_url | Gitlab pr submitter queue url | |\n| run_qontract_reconcile | Run qontract-reconcile container | true |\n| run_qontract_server | Run qontract-server container | true |\n| run_vault | Run vault container | false |\n\n> :point_right: **Bold keys** are mandatory or should be customized.\n\n### Profiles\n\nA profile specifies all settings to run a qontract-reconcile integration (e.g., *sql-query*).\n\n`qd profile [sub-cmd] --help`\n\n* **create**: Create a new profile to run an integration.\n\n Supports the creation of a new profile from an open PR/MR. See `$ qd profile create --help` for all available options.\n\n* **edit**: Edit a profile in your editor.\n* **ls**: List all available profiles.\n* **rm**: Remove profile.\n* **run**: Run a profile.\n* **show**: Display profile.\n\n#### --no-dry-run\n\nBy default, `qd` runs integrations in `dry-run` mode if not explicitly specified differently in the profile config.\nThere is also a `--no-dry-run` flag which lets you disable `dry-run` mode from the command line.\n\n```shell\nqd profile run dev my-integration --no-dry-run\n```\n\nThe command line flag takes precedence over any configuration you might have in the profile settings.\n\n#### Profile Settings\n\n| **Key** | **Description** | **Default** |\n| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |\n| additional_environment | Dictionary of additional environment variables to pass to the qontract-reconcile container | `{}` |\n| container_uid | Change ownership of /recconcile files in container to this user id | current UID |\n| command | Command to run in the qontract-reconcile container. | `dockerfiles/hack/run-integration.py` |\n| command_extra_args | Additional arguments to pass to the command. | |\n| debugger | Python debugger | `debugpy` |\n| dry_run | Run --dry-run mode | `true` |\n| 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. | `[]` |\n| **integration_name** | Intergration name | |\n| **integration_extra_args** | Intergration extra arguments | |\n| **internal_redhat_ca** | Inject Red Hat internal CAs and `REQUESTS_CA_BUNDLE` environment variable | `false` |\n| log_level | Log level | `info` |\n| app_interface_path | App-interface instance path. (Overrides *env.app_interface_path*) | |\n| app_interface_pr | App-interface PR/MR number | |\n| app_interface_upstream | Upstream remote name | `upstream` |\n| qontract_reconcile_build_image | Build qontract-reconcile image | `true` |\n| qontract_reconcile_image | Qontract-reconcile image | `quay.io/app-sre/qontract-reconcile:latest` |\n| qontract_reconcile_path | Qontract-reconcile path | `~/workspace/qontract-reconcile` |\n| qontract_reconcile_pr | Qontract-reconcile PR/MR number | |\n| qontract_reconcile_upstream | Upstream remote name | `upstream` |\n| qontract_server_build_image | Build qontract-server image | `true` |\n| qontract_server_image | Qontract-server image | `quay.io/app-sre/qontract-server:lates`t |\n| qontract_server_path | Qontract-server path | `~/workspace/qontract-server` |\n| qontract_schemas_path | Qontract-schemas path | `~/workspace/qontract-schemas` |\n| qontract_schemas_pr | Qontract-schemas PR/MR number | |\n| qontract_schemas_upstream | Upstream remote name | `upstream` |\n| run_once | If 'true', execute the integration once and exit | `true` |\n| sleep_duration_secs | If not *run_once*, sleep duration until integration runs again | `10` |\n| localstack | Run localstack container and set AWS related environment variables | `false` |\n| localstack_compose_file | Path to your Localstack docker-compose file | `qontract_server_path` / `dev/localstack/docker-compose.yml` |\n| skip_initial_make_bundle | Skip initial make bundle step | `false` |\n\n> :point_right: **Bold keys** are mandatory or should be customized.\n\n### PR/MR support\n\nIt's a pretty handy feature to create a profile from a pull request (merge request). E.g.:\n\n```shell\nqd 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\n```\n\nWhich results in this profile:\n\n```shell\n$ qd profile show glitchtip-pr-check\n---\napp_interface_path: PATH_TO_YOUR_LOCAL/app-interface-dev-data\napp_interface_pr: NUMBER\nintegration_name: glitchtip\nqontract_reconcile_pr: NUMBER\nqontract_schemas_pr: NUMBER\n```\n\nRunning this profile will:\n\n* Create new git worktrees (see `config.worktrees_dir`) for app-interface-dev-data, qontract-schema, and qontract-reconcile PRs\n* Start the containers with the adapted path to these worktrees\n* Restarting the profile will fetch PR updates\n\n> :point_right: A git worktree cleanup isn't implemented yet\n\n## Development\n\n[![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)\n[![Checked with mypy](https://www.mypy-lang.org/static/mypy_badge.svg)](https://mypy-lang.org/)\n\n### Release\n\n* Bump the version in `pyproject.toml`\n* Update the `CHANGELOG.md`\n* Commit the changes\n\n[pypi-link]: https://pypi.org/project/qontract-development-cli/\n[pypi-platforms]: https://img.shields.io/pypi/pyversions/qontract-development-cli\n[qontract-reconcile]: https://github.com/app-sre/qontract-reconcile\n",
28
28
  'author': 'Christian Assing',