File tree Expand file tree Collapse file tree 4 files changed +34
-27
lines changed
time_tracker_cli/data_target Expand file tree Collapse file tree 4 files changed +34
-27
lines changed Original file line number Diff line number Diff line change 22COMMAND=$@
33API_CONTAINER_NAME=" time-tracker-backend_api"
44TIME_TRACKER_CLI_URL=" cosmosdb_emulator/time_tracker_cli"
5- TIME_TRACKER_CLI=" python3 $COMMAND "
6- DEFAULT_SCRIPT_NAME=' main.py'
5+ DEFAULT_SCRIPT_NAME=" main.py"
76FIRST_ARG=$1
87
9- if [ " $FIRST_ARG " != " $DEFAULT_SCRIPT_NAME " ]; then
8+ execute (){
9+ docker exec -it $API_CONTAINER_NAME sh " cosmosdb_emulator/verify_environment.sh"
10+
11+ if [ " $FIRST_ARG " != " $DEFAULT_SCRIPT_NAME " ]; then
1012 echo " Do not forget that the file name is $DEFAULT_SCRIPT_NAME and needs to be sent as first parameter"
1113 echo " For example: ./cli.sh main.py"
1214 exit 0
13- fi
15+ fi
1416
15- DATABASE_EMULATOR_KEY=" C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
16- DATABASE_ENV_KEY=$DATABASE_MASTER_KEY
17+ TIME_TRACKER_CLI=" python3 $COMMAND "
1718
18- if [ " $DATABASE_EMULATOR_KEY " != " $DATABASE_ENV_KEY " ]; then
19- echo " You are trying to run this CLI in a non-development environment. We can not proceed with this action"
20- exit 0
21- fi
22-
23- execute (){
24- docker exec -ti $API_CONTAINER_NAME sh -c " cd $TIME_TRACKER_CLI_URL && $TIME_TRACKER_CLI "
19+ docker exec -it $API_CONTAINER_NAME sh -c " cd $TIME_TRACKER_CLI_URL && $TIME_TRACKER_CLI "
2520}
2621
2722execute
Original file line number Diff line number Diff line change @@ -5,15 +5,7 @@ until curl -ksf "${DATABASE_ACCOUNT_URI}/_explorer/emulator.pem" -o 'cosmosdb_em
55 sleep 10
66done
77
8- echo " Development environment check..."
9- DATABASE_EMULATOR_KEY=" C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
10- DATABASE_ENV_KEY=$DATABASE_MASTER_KEY
11-
12- if [ " $DATABASE_EMULATOR_KEY " != " $DATABASE_ENV_KEY " ]; then
13- echo " You are trying to build an environment different from the development, this can have negative effects."
14- exit 0
15- fi
16- echo " GREAT! You are on development environment"
8+ source cosmosdb_emulator/verify_environment.sh
179
1810echo " Container cosmosemulator started."
1911
Original file line number Diff line number Diff line change 11import os
2+ import sys
23
34from azure .cosmos import CosmosClient
4- from azure .cosmos .exceptions import CosmosResourceExistsError
5+ from azure .cosmos .exceptions import (
6+ CosmosResourceExistsError ,
7+ CosmosResourceNotFoundError ,
8+ )
59
610from cosmosdb_emulator .time_tracker_cli .data_target .data_target import (
711 DataTarget ,
@@ -79,10 +83,13 @@ def delete(self, entities: dict):
7983 )
8084 )
8185 entity_container_id = entity_container_definition .get ('id' )
82- self .database .create_container_if_not_exists (
83- ** entity_container_definition
84- )
85- self .database .delete_container (entity_container_id )
86+ try :
87+ self .database .delete_container (entity_container_id )
88+ self .database .create_container_if_not_exists (
89+ ** entity_container_definition
90+ )
91+ except CosmosResourceNotFoundError :
92+ pass
8693
8794 def save (self , entities : dict ):
8895 for entity in entities :
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ echo " We are checking the development environment..."
4+
5+ DATABASE_EMULATOR_KEY=" C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
6+ DATABASE_ENV_KEY=$DATABASE_MASTER_KEY
7+
8+ if [ " $DATABASE_EMULATOR_KEY " != " $DATABASE_ENV_KEY " ]; then
9+ echo " You are trying to run this CLI in a non-development environment. We can not proceed with this action"
10+ exit 0
11+ fi
12+
13+ echo " GREAT! You are on development environment"
You can’t perform that action at this time.
0 commit comments