gcp-platforms-auto 0.8.1__tar.gz → 0.8.3__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_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/PKG-INFO +1 -2
- {gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/gcp_platforms_auto/iam.py +31 -53
- {gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/gcp_platforms_auto/models.py +0 -1
- {gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/gcp_platforms_auto.egg-info/PKG-INFO +1 -2
- {gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/gcp_platforms_auto.egg-info/requires.txt +0 -1
- {gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/pyproject.toml +1 -2
- {gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/README.md +0 -0
- {gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/gcp_platforms_auto/__init__.py +0 -0
- {gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/gcp_platforms_auto/db.py +0 -0
- {gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/gcp_platforms_auto/git.py +0 -0
- {gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/gcp_platforms_auto.egg-info/SOURCES.txt +0 -0
- {gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/gcp_platforms_auto.egg-info/dependency_links.txt +0 -0
- {gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/gcp_platforms_auto.egg-info/top_level.txt +0 -0
- {gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gcp_platforms_auto
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.3
|
|
4
4
|
Summary: A brief description of your package
|
|
5
5
|
Author-email: ofir4858 <ofirshasha10@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -13,7 +13,6 @@ Requires-Dist: requests
|
|
|
13
13
|
Requires-Dist: pyjwt
|
|
14
14
|
Requires-Dist: google-cloud-logging
|
|
15
15
|
Requires-Dist: google-cloud-asset
|
|
16
|
-
Requires-Dist: google-cloud-resource-manager
|
|
17
16
|
Requires-Dist: gitpython
|
|
18
17
|
Requires-Dist: sqlalchemy
|
|
19
18
|
Requires-Dist: pg8000
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"""IAM access management utilities for GCP."""
|
|
2
2
|
|
|
3
3
|
import logging
|
|
4
|
+
import os
|
|
4
5
|
import google.cloud.logging
|
|
5
|
-
from google.cloud import asset_v1
|
|
6
|
+
from google.cloud import asset_v1
|
|
6
7
|
from typing import Optional
|
|
7
8
|
|
|
8
9
|
# Initialize Google Cloud Logging
|
|
@@ -106,47 +107,39 @@ def check_user_has_role_in_project(
|
|
|
106
107
|
raise
|
|
107
108
|
|
|
108
109
|
|
|
109
|
-
def
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
logger.info(f"Found folder: {folder_name}")
|
|
130
|
-
|
|
131
|
-
# Recursively get subfolders
|
|
132
|
-
subfolders = _get_all_folders_recursive(folder_name, folders_client)
|
|
133
|
-
all_folders.extend(subfolders)
|
|
134
|
-
|
|
135
|
-
except Exception as e:
|
|
136
|
-
logger.warning(f"Error listing folders under {parent}: {e}")
|
|
137
|
-
|
|
138
|
-
return all_folders
|
|
110
|
+
def _get_all_service_projects(base_paths, prefix):
|
|
111
|
+
service_projects = []
|
|
112
|
+
|
|
113
|
+
for path in base_paths:
|
|
114
|
+
logger.info(f"[INFO] Searching for projects under: {path}")
|
|
115
|
+
|
|
116
|
+
for root, _, _ in os.walk(path):
|
|
117
|
+
if root == path:
|
|
118
|
+
continue
|
|
119
|
+
|
|
120
|
+
for _, _, projects in os.walk(root):
|
|
121
|
+
for project in projects:
|
|
122
|
+
if not project.endswith(".yaml"):
|
|
123
|
+
continue
|
|
124
|
+
if project.startswith(prefix):
|
|
125
|
+
service_projects.append(project.split('.')[0])
|
|
126
|
+
else:
|
|
127
|
+
service_projects.append(f"{prefix}-{project.split('.')[0]}")
|
|
128
|
+
|
|
129
|
+
return list(set(service_projects))
|
|
139
130
|
|
|
140
131
|
|
|
141
132
|
def get_projects_with_role(
|
|
142
133
|
user_email: str,
|
|
143
134
|
organization_id: str,
|
|
144
135
|
role: str = "roles/owner",
|
|
145
|
-
expand_groups: bool = True
|
|
136
|
+
expand_groups: bool = True,
|
|
137
|
+
project_prefix: Optional[str] = None,
|
|
138
|
+
projects_base_paths: Optional[list] = []
|
|
146
139
|
) -> list:
|
|
147
140
|
"""
|
|
148
141
|
Get all projects where a user or service account has a specific role.
|
|
149
|
-
Searches
|
|
142
|
+
Searches for all service projects in the organization.
|
|
150
143
|
|
|
151
144
|
Args:
|
|
152
145
|
user_email: Email of the user or service account to check
|
|
@@ -168,27 +161,12 @@ def get_projects_with_role(
|
|
|
168
161
|
logger.info(f"Fetching all projects in organization {organization_id} (including folders)")
|
|
169
162
|
|
|
170
163
|
try:
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
# Get all folders recursively
|
|
176
|
-
org_parent = f"organizations/{organization_id}"
|
|
177
|
-
all_folders = _get_all_folders_recursive(org_parent, folders_client)
|
|
178
|
-
logger.info(f"Found {len(all_folders)} folder(s) in organization")
|
|
179
|
-
|
|
180
|
-
# Create list of all parents to search (organization + all folders)
|
|
181
|
-
parents_to_search = [org_parent] + all_folders
|
|
182
|
-
|
|
183
|
-
# Collect all projects from all parents
|
|
184
|
-
all_projects = []
|
|
185
|
-
for parent in parents_to_search:
|
|
186
|
-
request = resourcemanager_v3.ListProjectsRequest(parent=parent)
|
|
187
|
-
projects = projects_client.list_projects(request=request)
|
|
188
|
-
for project in projects:
|
|
189
|
-
all_projects.append(project.project_id)
|
|
164
|
+
all_projects = _get_all_service_projects(
|
|
165
|
+
base_paths=projects_base_paths,
|
|
166
|
+
prefix=project_prefix
|
|
167
|
+
)
|
|
190
168
|
|
|
191
|
-
logger.info(f"Found {len(all_projects)} total project(s) across organization
|
|
169
|
+
logger.info(f"Found {len(all_projects)} total service project(s) across organization {organization_id}")
|
|
192
170
|
|
|
193
171
|
# Filter projects where user has the specified role
|
|
194
172
|
matching_projects = []
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gcp_platforms_auto
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.3
|
|
4
4
|
Summary: A brief description of your package
|
|
5
5
|
Author-email: ofir4858 <ofirshasha10@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -13,7 +13,6 @@ Requires-Dist: requests
|
|
|
13
13
|
Requires-Dist: pyjwt
|
|
14
14
|
Requires-Dist: google-cloud-logging
|
|
15
15
|
Requires-Dist: google-cloud-asset
|
|
16
|
-
Requires-Dist: google-cloud-resource-manager
|
|
17
16
|
Requires-Dist: gitpython
|
|
18
17
|
Requires-Dist: sqlalchemy
|
|
19
18
|
Requires-Dist: pg8000
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "gcp_platforms_auto"
|
|
7
|
-
version = "0.8.
|
|
7
|
+
version = "0.8.3"
|
|
8
8
|
description = "A brief description of your package"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
@@ -16,7 +16,6 @@ dependencies = [
|
|
|
16
16
|
"pyjwt",
|
|
17
17
|
"google-cloud-logging",
|
|
18
18
|
"google-cloud-asset",
|
|
19
|
-
"google-cloud-resource-manager",
|
|
20
19
|
"gitpython",
|
|
21
20
|
"sqlalchemy",
|
|
22
21
|
"pg8000",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/gcp_platforms_auto.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{gcp_platforms_auto-0.8.1 → gcp_platforms_auto-0.8.3}/gcp_platforms_auto.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|