Skip to content

Commit 506fbcb

Browse files
updated the upload config
1 parent 028456f commit 506fbcb

File tree

2 files changed

+30
-10
lines changed

2 files changed

+30
-10
lines changed

infra/scripts/upload_team_config.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ def check_team_exists(backend_url, team_id, user_principal_id):
1010
Args:
1111
backend_url: The backend endpoint URL
1212
team_id: The team ID to check
13-
user_principal_id: User principal ID for authentication
13+
user_principal_id: User principal ID for authentication (None if no auth)
1414
1515
Returns:
1616
exists: bool
1717
"""
1818
check_endpoint = backend_url.rstrip('/') + f'/api/v3/team_configs/{team_id}'
19-
headers = {
20-
'x-ms-client-principal-id': user_principal_id
21-
}
19+
headers = {}
20+
if user_principal_id is not None:
21+
headers['x-ms-client-principal-id'] = user_principal_id
2222

2323
try:
2424
response = requests.get(check_endpoint, headers=headers)
@@ -39,12 +39,19 @@ def check_team_exists(backend_url, team_id, user_principal_id):
3939

4040
backend_url = sys.argv[1]
4141
directory_path = sys.argv[2]
42-
user_principal_id = sys.argv[3] if len(sys.argv) > 3 else "00000000-0000-0000-0000-000000000000"
42+
user_principal_id = sys.argv[3] if len(sys.argv) > 3 else None
4343

4444
# Convert to absolute path if provided as relative
4545
directory_path = os.path.abspath(directory_path)
4646
print(f"Scanning directory: {directory_path}")
4747

48+
# Determine if we should use authentication headers
49+
use_auth_headers = user_principal_id is not None
50+
if use_auth_headers:
51+
print(f"Using authentication with user ID: {user_principal_id}")
52+
else:
53+
print("No authentication - backend will use development mode")
54+
4855
files_to_process = [
4956
("hr.json", "00000000-0000-0000-0000-000000000001"),
5057
("marketing.json", "00000000-0000-0000-0000-000000000002"),
@@ -77,9 +84,10 @@ def check_team_exists(backend_url, team_id, user_principal_id):
7784
files = {
7885
'file': (filename, file_data, 'application/json')
7986
}
80-
headers = {
81-
'x-ms-client-principal-id': user_principal_id
82-
}
87+
headers = {}
88+
if use_auth_headers:
89+
headers['x-ms-client-principal-id'] = user_principal_id
90+
8391
params = {
8492
'team_id': team_id
8593
}

infra/scripts/upload_team_config.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,15 @@ else
7575
az account set --subscription "$currentSubscriptionId"
7676
fi
7777

78-
userPrincipalId=$(az ad signed-in-user show --query id -o tsv)
78+
# Only get user principal ID if we have azSubscriptionId (indicating authentication is needed)
79+
if [ -n "$azSubscriptionId" ]; then
80+
echo "Getting user principal ID for authentication..."
81+
userPrincipalId=$(az ad signed-in-user show --query id -o tsv)
82+
echo "Using authenticated mode with user ID: $userPrincipalId"
83+
else
84+
echo "No subscription ID provided - using development mode (no authentication)"
85+
userPrincipalId=""
86+
fi
7987

8088
# Determine the correct Python command
8189
if command -v python && python --version &> /dev/null; then
@@ -112,7 +120,11 @@ pip install --quiet -r infra/scripts/requirements.txt
112120
echo "Requirements installed"
113121

114122
echo "Running the python script to upload team configuration"
115-
$PYTHON_CMD infra/scripts/upload_team_config.py "$backendUrl" "$directoryPath" "$userPrincipalId"
123+
if [ -n "$userPrincipalId" ]; then
124+
$PYTHON_CMD infra/scripts/upload_team_config.py "$backendUrl" "$directoryPath" "$userPrincipalId"
125+
else
126+
$PYTHON_CMD infra/scripts/upload_team_config.py "$backendUrl" "$directoryPath"
127+
fi
116128
if [ $? -ne 0 ]; then
117129
echo "Error: Team configuration upload failed."
118130
exit 1

0 commit comments

Comments
 (0)