Skip to content

Commit 4eed08a

Browse files
committed
don't delete teams that were not manually created
1 parent 9191d12 commit 4eed08a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/shared/clients/jit.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import requests
66
from loguru import logger
7+
from src.shared.consts import MANUAL_TEAM_SOURCE
78
from src.shared.env_tools import get_jit_endpoint_base_url
89
from src.shared.models import Asset, TeamAttributes
910

@@ -89,12 +90,15 @@ def delete_teams(token, team_names):
8990

9091
for team_name in team_names:
9192
team_id = None
93+
selected_team = None
9294
for team in existing_teams:
9395
if team.name == team_name:
9496
team_id = team.id
97+
selected_team = team
9598
break
9699

97-
if team_id:
100+
# We only delete teams that are manually created
101+
if team_id and selected_team and selected_team['source'] == MANUAL_TEAM_SOURCE:
98102
url = f"{get_jit_endpoint_base_url()}/teams/{team_id}"
99103
headers = {"Authorization": f"Bearer {token}"}
100104

0 commit comments

Comments
 (0)