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.
- gcp_radar-0.1.0/LICENSE +23 -0
- gcp_radar-0.1.0/MANIFEST.in +3 -0
- gcp_radar-0.1.0/PKG-INFO +159 -0
- gcp_radar-0.1.0/README.md +119 -0
- gcp_radar-0.1.0/pyproject.toml +69 -0
- gcp_radar-0.1.0/setup.cfg +4 -0
- gcp_radar-0.1.0/src/gcp_radar/__init__.py +10 -0
- gcp_radar-0.1.0/src/gcp_radar/__main__.py +82 -0
- gcp_radar-0.1.0/src/gcp_radar/drawio.py +235 -0
- gcp_radar-0.1.0/src/gcp_radar/inventory.py +432 -0
- gcp_radar-0.1.0/src/gcp_radar.egg-info/PKG-INFO +159 -0
- gcp_radar-0.1.0/src/gcp_radar.egg-info/SOURCES.txt +15 -0
- gcp_radar-0.1.0/src/gcp_radar.egg-info/dependency_links.txt +1 -0
- gcp_radar-0.1.0/src/gcp_radar.egg-info/entry_points.txt +2 -0
- gcp_radar-0.1.0/src/gcp_radar.egg-info/requires.txt +16 -0
- gcp_radar-0.1.0/src/gcp_radar.egg-info/top_level.txt +1 -0
- gcp_radar-0.1.0/tests/test_gcp_radar.py +92 -0
gcp_radar-0.1.0/LICENSE
ADDED
|
@@ -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.
|
gcp_radar-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: gcp-radar
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: GCP resource inventory scanner and draw.io architecture diagram generator
|
|
5
|
+
Author-email: Your Name <you@example.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/yourname/gcp-radar
|
|
8
|
+
Project-URL: Repository, https://github.com/yourname/gcp-radar
|
|
9
|
+
Project-URL: Issues, https://github.com/yourname/gcp-radar/issues
|
|
10
|
+
Keywords: gcp,google-cloud,inventory,architecture,drawio,diagrams
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: System Administrators
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: System :: Systems Administration
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: google-cloud-compute>=1.14.0
|
|
25
|
+
Requires-Dist: google-cloud-sql>=0.4.0
|
|
26
|
+
Requires-Dist: google-cloud-functions>=1.5.0
|
|
27
|
+
Requires-Dist: google-cloud-container>=2.35.0
|
|
28
|
+
Requires-Dist: google-cloud-storage>=2.14.0
|
|
29
|
+
Requires-Dist: google-cloud-run>=0.10.0
|
|
30
|
+
Requires-Dist: google-cloud-firestore>=2.14.0
|
|
31
|
+
Requires-Dist: google-cloud-pubsub>=2.20.0
|
|
32
|
+
Requires-Dist: google-cloud-monitoring>=2.17.0
|
|
33
|
+
Requires-Dist: rich>=13.0.0
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
37
|
+
Requires-Dist: build; extra == "dev"
|
|
38
|
+
Requires-Dist: twine; extra == "dev"
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
|
|
41
|
+
# GCP Radar
|
|
42
|
+
|
|
43
|
+
**GCP Resource Inventory Scanner & Architecture Diagram Generator**
|
|
44
|
+
|
|
45
|
+
A Python CLI tool that inventories all your GCP resources and generates beautiful draw.io architecture diagrams.
|
|
46
|
+
|
|
47
|
+
## Features
|
|
48
|
+
|
|
49
|
+
- 🔍 **Inventory Scanning**: Scans Compute Engine, Cloud SQL, Cloud Functions, GKE, Cloud Storage, Cloud Run, Firestore, Pub/Sub, and more
|
|
50
|
+
- 📊 **CSV Export**: Export complete inventory to CSV for further analysis
|
|
51
|
+
- 🏗️ **Architecture Diagrams**: Auto-generate draw.io `.drawio` files with logical service connections
|
|
52
|
+
- ☁️ **Multi-Project Support**: Scan multiple GCP projects in one go
|
|
53
|
+
- 🔐 **Service Account Auth**: Use gcloud default credentials or specify service account key
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install gcp-radar
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Or from source:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
git clone https://github.com/yourname/gcp-radar.git
|
|
65
|
+
cd gcp-radar
|
|
66
|
+
pip install -e .
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Quick Start
|
|
70
|
+
|
|
71
|
+
### 1. Inventory Your GCP Resources
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# Scan default project
|
|
75
|
+
gcp-radar inventory --export inventory.csv
|
|
76
|
+
|
|
77
|
+
# Scan specific project
|
|
78
|
+
gcp-radar inventory --project my-project --export inventory.csv
|
|
79
|
+
|
|
80
|
+
# Export to specific region
|
|
81
|
+
gcp-radar inventory --region us-central1 --export inventory.csv
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### 2. Generate Architecture Diagram
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
gcp-radar diagram --input inventory.csv --output architecture.drawio
|
|
88
|
+
|
|
89
|
+
# Then open architecture.drawio in app.diagrams.net or the desktop app
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### 3. One-Shot: Scan + Diagram
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
gcp-radar run --project my-project \
|
|
96
|
+
--output-csv inventory.csv \
|
|
97
|
+
--output-diagram architecture.drawio
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Supported GCP Services
|
|
101
|
+
|
|
102
|
+
| Service | Collected | Diagram |
|
|
103
|
+
|---------|-----------|---------|
|
|
104
|
+
| Compute Engine | ✓ | ✓ |
|
|
105
|
+
| Cloud SQL | ✓ | ✓ |
|
|
106
|
+
| Cloud Functions | ✓ | ✓ |
|
|
107
|
+
| GKE (Kubernetes Engine) | ✓ | ✓ |
|
|
108
|
+
| Cloud Storage | ✓ | ✓ |
|
|
109
|
+
| Cloud Run | ✓ | ✓ |
|
|
110
|
+
| Firestore | ✓ | ✓ |
|
|
111
|
+
| Pub/Sub | ✓ | ✓ |
|
|
112
|
+
|
|
113
|
+
## Requirements
|
|
114
|
+
|
|
115
|
+
- Python 3.9+
|
|
116
|
+
- GCP credentials (via `gcloud auth` or service account key)
|
|
117
|
+
- Permissions: `compute:Read`, `sql:Read`, `container:Read`, `storage:Read`, `pubsub:Read`, `firestore:Read`, etc.
|
|
118
|
+
|
|
119
|
+
## Output Format
|
|
120
|
+
|
|
121
|
+
### CSV Inventory
|
|
122
|
+
|
|
123
|
+
| ProjectID | Service | Name | ID | Type/Size | Status | Region | Extra |
|
|
124
|
+
|-----------|---------|------|----|-----------|---------|---------|----|
|
|
125
|
+
| my-project | Compute Engine | web-01 | abc123 | n1-standard-2 | RUNNING | us-central1 | ... |
|
|
126
|
+
|
|
127
|
+
### Architecture Diagram
|
|
128
|
+
|
|
129
|
+
Auto-generated `.drawio` file with:
|
|
130
|
+
- **Swim lanes** by service category (Compute, Database, Storage, Messaging)
|
|
131
|
+
- **Icons** for each resource
|
|
132
|
+
- **Logical connections** between services
|
|
133
|
+
|
|
134
|
+
## Configuration
|
|
135
|
+
|
|
136
|
+
Create a `.env` file to override defaults:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
export GCP_PROJECT=my-project
|
|
140
|
+
export GCP_REGION=us-central1
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Or pass flags:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
gcp-radar inventory --project my-project --region us-central1
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
MIT
|
|
152
|
+
|
|
153
|
+
## Contributing
|
|
154
|
+
|
|
155
|
+
Pull requests welcome! Please open an issue first to discuss changes.
|
|
156
|
+
|
|
157
|
+
## Support
|
|
158
|
+
|
|
159
|
+
GitHub Issues: https://github.com/yourname/gcp-radar/issues
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# GCP Radar
|
|
2
|
+
|
|
3
|
+
**GCP Resource Inventory Scanner & Architecture Diagram Generator**
|
|
4
|
+
|
|
5
|
+
A Python CLI tool that inventories all your GCP resources and generates beautiful draw.io architecture diagrams.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 🔍 **Inventory Scanning**: Scans Compute Engine, Cloud SQL, Cloud Functions, GKE, Cloud Storage, Cloud Run, Firestore, Pub/Sub, and more
|
|
10
|
+
- 📊 **CSV Export**: Export complete inventory to CSV for further analysis
|
|
11
|
+
- 🏗️ **Architecture Diagrams**: Auto-generate draw.io `.drawio` files with logical service connections
|
|
12
|
+
- ☁️ **Multi-Project Support**: Scan multiple GCP projects in one go
|
|
13
|
+
- 🔐 **Service Account Auth**: Use gcloud default credentials or specify service account key
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install gcp-radar
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or from source:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
git clone https://github.com/yourname/gcp-radar.git
|
|
25
|
+
cd gcp-radar
|
|
26
|
+
pip install -e .
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### 1. Inventory Your GCP Resources
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Scan default project
|
|
35
|
+
gcp-radar inventory --export inventory.csv
|
|
36
|
+
|
|
37
|
+
# Scan specific project
|
|
38
|
+
gcp-radar inventory --project my-project --export inventory.csv
|
|
39
|
+
|
|
40
|
+
# Export to specific region
|
|
41
|
+
gcp-radar inventory --region us-central1 --export inventory.csv
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 2. Generate Architecture Diagram
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
gcp-radar diagram --input inventory.csv --output architecture.drawio
|
|
48
|
+
|
|
49
|
+
# Then open architecture.drawio in app.diagrams.net or the desktop app
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 3. One-Shot: Scan + Diagram
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
gcp-radar run --project my-project \
|
|
56
|
+
--output-csv inventory.csv \
|
|
57
|
+
--output-diagram architecture.drawio
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Supported GCP Services
|
|
61
|
+
|
|
62
|
+
| Service | Collected | Diagram |
|
|
63
|
+
|---------|-----------|---------|
|
|
64
|
+
| Compute Engine | ✓ | ✓ |
|
|
65
|
+
| Cloud SQL | ✓ | ✓ |
|
|
66
|
+
| Cloud Functions | ✓ | ✓ |
|
|
67
|
+
| GKE (Kubernetes Engine) | ✓ | ✓ |
|
|
68
|
+
| Cloud Storage | ✓ | ✓ |
|
|
69
|
+
| Cloud Run | ✓ | ✓ |
|
|
70
|
+
| Firestore | ✓ | ✓ |
|
|
71
|
+
| Pub/Sub | ✓ | ✓ |
|
|
72
|
+
|
|
73
|
+
## Requirements
|
|
74
|
+
|
|
75
|
+
- Python 3.9+
|
|
76
|
+
- GCP credentials (via `gcloud auth` or service account key)
|
|
77
|
+
- Permissions: `compute:Read`, `sql:Read`, `container:Read`, `storage:Read`, `pubsub:Read`, `firestore:Read`, etc.
|
|
78
|
+
|
|
79
|
+
## Output Format
|
|
80
|
+
|
|
81
|
+
### CSV Inventory
|
|
82
|
+
|
|
83
|
+
| ProjectID | Service | Name | ID | Type/Size | Status | Region | Extra |
|
|
84
|
+
|-----------|---------|------|----|-----------|---------|---------|----|
|
|
85
|
+
| my-project | Compute Engine | web-01 | abc123 | n1-standard-2 | RUNNING | us-central1 | ... |
|
|
86
|
+
|
|
87
|
+
### Architecture Diagram
|
|
88
|
+
|
|
89
|
+
Auto-generated `.drawio` file with:
|
|
90
|
+
- **Swim lanes** by service category (Compute, Database, Storage, Messaging)
|
|
91
|
+
- **Icons** for each resource
|
|
92
|
+
- **Logical connections** between services
|
|
93
|
+
|
|
94
|
+
## Configuration
|
|
95
|
+
|
|
96
|
+
Create a `.env` file to override defaults:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
export GCP_PROJECT=my-project
|
|
100
|
+
export GCP_REGION=us-central1
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Or pass flags:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
gcp-radar inventory --project my-project --region us-central1
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
MIT
|
|
112
|
+
|
|
113
|
+
## Contributing
|
|
114
|
+
|
|
115
|
+
Pull requests welcome! Please open an issue first to discuss changes.
|
|
116
|
+
|
|
117
|
+
## Support
|
|
118
|
+
|
|
119
|
+
GitHub Issues: https://github.com/yourname/gcp-radar/issues
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "gcp-radar"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "GCP resource inventory scanner and draw.io architecture diagram generator"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Your Name", email = "you@example.com" }
|
|
14
|
+
]
|
|
15
|
+
keywords = ["gcp", "google-cloud", "inventory", "architecture", "drawio", "diagrams"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"Intended Audience :: System Administrators",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Topic :: System :: Systems Administration",
|
|
26
|
+
"Topic :: Utilities",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"google-cloud-compute>=1.14.0",
|
|
30
|
+
"google-cloud-sql>=0.4.0",
|
|
31
|
+
"google-cloud-functions>=1.5.0",
|
|
32
|
+
"google-cloud-container>=2.35.0",
|
|
33
|
+
"google-cloud-storage>=2.14.0",
|
|
34
|
+
"google-cloud-run>=0.10.0",
|
|
35
|
+
"google-cloud-firestore>=2.14.0",
|
|
36
|
+
"google-cloud-pubsub>=2.20.0",
|
|
37
|
+
"google-cloud-monitoring>=2.17.0",
|
|
38
|
+
"rich>=13.0.0",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
[project.optional-dependencies]
|
|
42
|
+
dev = [
|
|
43
|
+
"pytest>=7.0",
|
|
44
|
+
"pytest-cov",
|
|
45
|
+
"build",
|
|
46
|
+
"twine",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.urls]
|
|
50
|
+
Homepage = "https://github.com/yourname/gcp-radar"
|
|
51
|
+
Repository = "https://github.com/yourname/gcp-radar"
|
|
52
|
+
Issues = "https://github.com/yourname/gcp-radar/issues"
|
|
53
|
+
|
|
54
|
+
[project.scripts]
|
|
55
|
+
gcp-radar = "gcp_radar.__main__:main"
|
|
56
|
+
|
|
57
|
+
[tool.setuptools.packages.find]
|
|
58
|
+
where = ["src"]
|
|
59
|
+
|
|
60
|
+
[tool.setuptools.package-dir]
|
|
61
|
+
"" = "src"
|
|
62
|
+
|
|
63
|
+
[tool.pytest.ini_options]
|
|
64
|
+
testpaths = ["tests"]
|
|
65
|
+
addopts = "-v --tb=short"
|
|
66
|
+
|
|
67
|
+
[tool.coverage.run]
|
|
68
|
+
source = ["gcp_radar"]
|
|
69
|
+
omit = ["tests/*"]
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Main entry point for gcp-radar CLI.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import sys
|
|
8
|
+
from gcp_radar.inventory import run_inventory
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def main():
|
|
12
|
+
parser = argparse.ArgumentParser(
|
|
13
|
+
prog="gcp-radar",
|
|
14
|
+
description="GCP Resource Inventory Scanner and Architecture Diagram Generator"
|
|
15
|
+
)
|
|
16
|
+
subparsers = parser.add_subparsers(dest="command", help="Available commands")
|
|
17
|
+
|
|
18
|
+
# Inventory command
|
|
19
|
+
inv_parser = subparsers.add_parser("inventory", help="Scan GCP resources")
|
|
20
|
+
inv_parser.add_argument("--project", help="GCP project ID (uses default if not specified)")
|
|
21
|
+
inv_parser.add_argument("--all-projects", action="store_true", help="Scan all accessible projects")
|
|
22
|
+
inv_parser.add_argument("--region", help="Specific region (e.g., us-central1)")
|
|
23
|
+
inv_parser.add_argument("--export", help="Export inventory to CSV file")
|
|
24
|
+
|
|
25
|
+
# Diagram command
|
|
26
|
+
dia_parser = subparsers.add_parser("diagram", help="Generate architecture diagram")
|
|
27
|
+
dia_parser.add_argument("--input", required=True, help="Input CSV file from inventory scan")
|
|
28
|
+
dia_parser.add_argument("--output", required=True, help="Output .drawio file")
|
|
29
|
+
|
|
30
|
+
# Run command
|
|
31
|
+
run_parser = subparsers.add_parser("run", help="One-shot: inventory + diagram")
|
|
32
|
+
run_parser.add_argument("--project", help="GCP project ID")
|
|
33
|
+
run_parser.add_argument("--output-csv", required=True, help="Output CSV inventory file")
|
|
34
|
+
run_parser.add_argument("--output-diagram", required=True, help="Output .drawio file")
|
|
35
|
+
|
|
36
|
+
args = parser.parse_args()
|
|
37
|
+
|
|
38
|
+
if args.command == "inventory":
|
|
39
|
+
from gcp_radar.inventory import run_inventory
|
|
40
|
+
projects = [args.project] if args.project else []
|
|
41
|
+
if not projects:
|
|
42
|
+
import subprocess
|
|
43
|
+
try:
|
|
44
|
+
result = subprocess.run(["gcloud", "config", "get-value", "project"],
|
|
45
|
+
capture_output=True, text=True, check=True)
|
|
46
|
+
projects = [result.stdout.strip()]
|
|
47
|
+
except Exception as e:
|
|
48
|
+
print(f" [!] Could not determine GCP project: {e}")
|
|
49
|
+
sys.exit(1)
|
|
50
|
+
run_inventory(projects, export_path=args.export)
|
|
51
|
+
|
|
52
|
+
elif args.command == "diagram":
|
|
53
|
+
from gcp_radar.drawio import read_csv, build_drawio, export_drawio
|
|
54
|
+
rows = read_csv(args.input)
|
|
55
|
+
mxfile = build_drawio(rows)
|
|
56
|
+
export_drawio(mxfile, args.output)
|
|
57
|
+
|
|
58
|
+
elif args.command == "run":
|
|
59
|
+
from gcp_radar.inventory import run_inventory
|
|
60
|
+
from gcp_radar.drawio import build_drawio, export_drawio
|
|
61
|
+
|
|
62
|
+
projects = [args.project] if args.project else []
|
|
63
|
+
if not projects:
|
|
64
|
+
import subprocess
|
|
65
|
+
try:
|
|
66
|
+
result = subprocess.run(["gcloud", "config", "get-value", "project"],
|
|
67
|
+
capture_output=True, text=True, check=True)
|
|
68
|
+
projects = [result.stdout.strip()]
|
|
69
|
+
except Exception as e:
|
|
70
|
+
print(f" [!] Could not determine GCP project: {e}")
|
|
71
|
+
sys.exit(1)
|
|
72
|
+
|
|
73
|
+
rows = run_inventory(projects, export_path=args.output_csv)
|
|
74
|
+
mxfile = build_drawio(rows, project_id=projects[0])
|
|
75
|
+
export_drawio(mxfile, args.output_diagram)
|
|
76
|
+
|
|
77
|
+
else:
|
|
78
|
+
parser.print_help()
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
if __name__ == "__main__":
|
|
82
|
+
main()
|