pump-gcp-radar 0.1.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.
@@ -0,0 +1,23 @@
1
+ LICENSE
2
+
3
+ MIT License
4
+
5
+ Copyright (c) 2026 Your Name
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.4
2
+ Name: pump-gcp-radar
3
+ Version: 0.1.0
4
+ Summary: Extra commands for gcp-radar, added through its plugin hook
5
+ Author: Mor Michaeli
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: gcp-radar<2,>=1.3.0
11
+ Provides-Extra: dev
12
+ Requires-Dist: pytest; extra == "dev"
13
+ Requires-Dist: build; extra == "dev"
14
+ Requires-Dist: twine; extra == "dev"
15
+ Dynamic: license-file
16
+
17
+ # pump-gcp-radar
18
+
19
+ Extra commands for [gcp-radar](https://pypi.org/project/gcp-radar/), added through
20
+ its plugin hook (`gcp_radar.commands` entry points, gcp-radar 1.3.0+).
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ pip install pump-gcp-radar
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ `pump-gcp-radar` runs the normal gcp-radar CLI with this package's commands added:
31
+
32
+ ```bash
33
+ pump-gcp-radar --help # built-in and pump commands together
34
+ pump-gcp-radar run --project my-proj # gcp-radar built-in
35
+ pump-gcp-radar pump-report --project my-proj # example command from this package
36
+ ```
37
+
38
+ ## Adding a command
39
+
40
+ 1. Add a `register(subparsers)` function in `src/pump_gcp_radar/commands.py`
41
+ (add a subparser and `set_defaults(func=handler)`).
42
+ 2. Register it in `pyproject.toml`:
43
+
44
+ ```toml
45
+ [project.entry-points."gcp_radar.commands"]
46
+ my-command = "pump_gcp_radar.commands:register_my_command"
47
+ ```
48
+ 3. Reinstall (`pip install -e .`) so the entry point is picked up.
49
+
50
+ Command names can't clash with gcp-radar's built-ins (`inventory`, `commitments`,
51
+ `billing`, `diagram`, `run`); clashing plugins are skipped with a warning.
52
+
53
+ ## Development
54
+
55
+ ```bash
56
+ pip install -e ".[dev]"
57
+ pytest
58
+ ```
@@ -0,0 +1,42 @@
1
+ # pump-gcp-radar
2
+
3
+ Extra commands for [gcp-radar](https://pypi.org/project/gcp-radar/), added through
4
+ its plugin hook (`gcp_radar.commands` entry points, gcp-radar 1.3.0+).
5
+
6
+ ## Install
7
+
8
+ ```bash
9
+ pip install pump-gcp-radar
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ `pump-gcp-radar` runs the normal gcp-radar CLI with this package's commands added:
15
+
16
+ ```bash
17
+ pump-gcp-radar --help # built-in and pump commands together
18
+ pump-gcp-radar run --project my-proj # gcp-radar built-in
19
+ pump-gcp-radar pump-report --project my-proj # example command from this package
20
+ ```
21
+
22
+ ## Adding a command
23
+
24
+ 1. Add a `register(subparsers)` function in `src/pump_gcp_radar/commands.py`
25
+ (add a subparser and `set_defaults(func=handler)`).
26
+ 2. Register it in `pyproject.toml`:
27
+
28
+ ```toml
29
+ [project.entry-points."gcp_radar.commands"]
30
+ my-command = "pump_gcp_radar.commands:register_my_command"
31
+ ```
32
+ 3. Reinstall (`pip install -e .`) so the entry point is picked up.
33
+
34
+ Command names can't clash with gcp-radar's built-ins (`inventory`, `commitments`,
35
+ `billing`, `diagram`, `run`); clashing plugins are skipped with a warning.
36
+
37
+ ## Development
38
+
39
+ ```bash
40
+ pip install -e ".[dev]"
41
+ pytest
42
+ ```
@@ -0,0 +1,29 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pump-gcp-radar"
7
+ version = "0.1.0"
8
+ description = "Extra commands for gcp-radar, added through its plugin hook"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.9"
12
+ authors = [{name = "Mor Michaeli"}]
13
+ dependencies = ["gcp-radar>=1.3.0,<2"]
14
+
15
+ [project.optional-dependencies]
16
+ dev = ["pytest", "build", "twine"]
17
+
18
+ # Runs gcp-radar's own CLI; the plugin below adds the extra commands to it.
19
+ [project.scripts]
20
+ pump-gcp-radar = "gcp_radar.__main__:main"
21
+
22
+ [project.entry-points."gcp_radar.commands"]
23
+ pump-report = "pump_gcp_radar.commands:register"
24
+
25
+ [tool.setuptools.packages.find]
26
+ where = ["src"]
27
+
28
+ [tool.pytest.ini_options]
29
+ testpaths = ["tests"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ """pump-gcp-radar: extra commands for gcp-radar."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,27 @@
1
+ """Subcommands added to gcp-radar through the ``gcp_radar.commands`` entry-point group.
2
+
3
+ Each ``register(subparsers)`` adds one subparser and sets ``func=<handler>``.
4
+ gcp-radar calls ``handler(args)`` when that subcommand is run.
5
+ """
6
+
7
+ from collections import Counter
8
+
9
+
10
+ def register(subparsers):
11
+ p = subparsers.add_parser(
12
+ "pump-report", help="Example: count scanned resources per service")
13
+ p.add_argument("--project", required=True, help="GCP project ID")
14
+ p.set_defaults(func=run_pump_report)
15
+
16
+
17
+ def run_pump_report(args):
18
+ # Imported here so `--help` stays fast and doesn't need GCP credentials.
19
+ from gcp_radar.inventory import run_inventory
20
+
21
+ rows = run_inventory([args.project], export_path=None)
22
+ counts = Counter(r["Service"] for r in rows)
23
+ print(f"\nResources in {args.project}:")
24
+ for service, n in counts.most_common():
25
+ print(f" {service:<20} {n}")
26
+ print(f" {'Total':<20} {sum(counts.values())}")
27
+ return counts
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.4
2
+ Name: pump-gcp-radar
3
+ Version: 0.1.0
4
+ Summary: Extra commands for gcp-radar, added through its plugin hook
5
+ Author: Mor Michaeli
6
+ License-Expression: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: gcp-radar<2,>=1.3.0
11
+ Provides-Extra: dev
12
+ Requires-Dist: pytest; extra == "dev"
13
+ Requires-Dist: build; extra == "dev"
14
+ Requires-Dist: twine; extra == "dev"
15
+ Dynamic: license-file
16
+
17
+ # pump-gcp-radar
18
+
19
+ Extra commands for [gcp-radar](https://pypi.org/project/gcp-radar/), added through
20
+ its plugin hook (`gcp_radar.commands` entry points, gcp-radar 1.3.0+).
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ pip install pump-gcp-radar
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ `pump-gcp-radar` runs the normal gcp-radar CLI with this package's commands added:
31
+
32
+ ```bash
33
+ pump-gcp-radar --help # built-in and pump commands together
34
+ pump-gcp-radar run --project my-proj # gcp-radar built-in
35
+ pump-gcp-radar pump-report --project my-proj # example command from this package
36
+ ```
37
+
38
+ ## Adding a command
39
+
40
+ 1. Add a `register(subparsers)` function in `src/pump_gcp_radar/commands.py`
41
+ (add a subparser and `set_defaults(func=handler)`).
42
+ 2. Register it in `pyproject.toml`:
43
+
44
+ ```toml
45
+ [project.entry-points."gcp_radar.commands"]
46
+ my-command = "pump_gcp_radar.commands:register_my_command"
47
+ ```
48
+ 3. Reinstall (`pip install -e .`) so the entry point is picked up.
49
+
50
+ Command names can't clash with gcp-radar's built-ins (`inventory`, `commitments`,
51
+ `billing`, `diagram`, `run`); clashing plugins are skipped with a warning.
52
+
53
+ ## Development
54
+
55
+ ```bash
56
+ pip install -e ".[dev]"
57
+ pytest
58
+ ```
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/pump_gcp_radar/__init__.py
5
+ src/pump_gcp_radar/commands.py
6
+ src/pump_gcp_radar.egg-info/PKG-INFO
7
+ src/pump_gcp_radar.egg-info/SOURCES.txt
8
+ src/pump_gcp_radar.egg-info/dependency_links.txt
9
+ src/pump_gcp_radar.egg-info/entry_points.txt
10
+ src/pump_gcp_radar.egg-info/requires.txt
11
+ src/pump_gcp_radar.egg-info/top_level.txt
12
+ tests/test_commands.py
@@ -0,0 +1,5 @@
1
+ [console_scripts]
2
+ pump-gcp-radar = gcp_radar.__main__:main
3
+
4
+ [gcp_radar.commands]
5
+ pump-report = pump_gcp_radar.commands:register
@@ -0,0 +1,6 @@
1
+ gcp-radar<2,>=1.3.0
2
+
3
+ [dev]
4
+ pytest
5
+ build
6
+ twine
@@ -0,0 +1 @@
1
+ pump_gcp_radar
@@ -0,0 +1,26 @@
1
+ import argparse
2
+
3
+ from pump_gcp_radar import commands
4
+
5
+
6
+ def _parser():
7
+ parser = argparse.ArgumentParser()
8
+ commands.register(parser.add_subparsers(dest="command"))
9
+ return parser
10
+
11
+
12
+ def test_register_adds_subcommand():
13
+ args = _parser().parse_args(["pump-report", "--project", "p"])
14
+ assert args.command == "pump-report"
15
+ assert args.project == "p"
16
+ assert args.func is commands.run_pump_report
17
+
18
+
19
+ def test_pump_report_counts_by_service(monkeypatch, capsys):
20
+ rows = [{"Service": "Compute Engine"}, {"Service": "Compute Engine"},
21
+ {"Service": "Cloud SQL"}]
22
+ monkeypatch.setattr("gcp_radar.inventory.run_inventory",
23
+ lambda projects, export_path=None: rows)
24
+ counts = commands.run_pump_report(argparse.Namespace(project="p"))
25
+ assert counts == {"Compute Engine": 2, "Cloud SQL": 1}
26
+ assert "Total" in capsys.readouterr().out