1919NG_MANAGER_DB_NAME = "ng-harness"
2020
2121STORE_TYPE_REMOTE = "REMOTE"
22+ PIPELINE = "PIPELINE"
23+ INPUTSET = "INPUTSET"
2224
2325class DBKeys (Enum ):
2426 ACCOUNT_ID = "accountId"
@@ -61,6 +63,8 @@ def get_repo_from_repo_url(repo_url):
6163 delimiter_index = repo_url .rfind ("/" )
6264 return repo_url [delimiter_index + 1 :]
6365
66+ def prepare_key (identifier , entity ):
67+ return identifier + "_" + entity
6468
6569def setup_mongo_client ():
6670 global mongo_client
@@ -88,11 +92,11 @@ def prepare_yaml_git_config_list():
8892 print (yaml_git_config_list )
8993
9094
91- def cache_pipeline_locally (record ):
92- migrated_pipelines [record .get ("_id" )] = record
95+ def cache_pipeline_locally (record , entity ):
96+ migrated_pipelines [prepare_key ( record .get (DBKeys . IDENTIFIER . value ), entity )] = record
9397
9498
95- def migrate_records (collection , yaml_git_config ):
99+ def migrate_records (collection , yaml_git_config , entity ):
96100 query = {
97101 DBKeys .ACCOUNT_ID .value : INPUT_ACCOUNT_ID ,
98102 DBKeys .ORG_IDENTIFIER .value : INPUT_ORG_ID ,
@@ -112,7 +116,7 @@ def migrate_records(collection, yaml_git_config):
112116 record [DBKeys .FILE_PATH .value ] = old_root_folder [1 :] + old_file_path
113117
114118 collection .update_one ({"_id" : record .get ("_id" )}, {"$set" : record }, upsert = False )
115- cache_pipeline_locally (record )
119+ cache_pipeline_locally (record , entity )
116120
117121 collection .update_many (query , {"$unset" : {
118122 DBKeys .ROOT_FOLDER .value : 1 ,
@@ -128,8 +132,8 @@ def migrate_records(collection, yaml_git_config):
128132def migrate_records_from_inline_to_remote ():
129133 for yaml_git_config in yaml_git_config_list :
130134 print (yaml_git_config )
131- migrate_records (pms_db .pipelinesPMS , yaml_git_config )
132- migrate_records (pms_db .inputSetsPMS , yaml_git_config )
135+ migrate_records (pms_db .pipelinesPMS , yaml_git_config , PIPELINE )
136+ migrate_records (pms_db .inputSetsPMS , yaml_git_config , INPUTSET )
133137
134138
135139def delete_non_default_pipelines_input_sets ():
@@ -230,7 +234,7 @@ def update_triggers():
230234
231235 for trigger in triggers :
232236 pipelineId = trigger .get (DBKeys .TARGET_IDENTIFIER .value )
233- pipeline = migrated_pipelines [ pipelineId ]
237+ pipeline = migrated_pipelines . get ( prepare_key ( pipelineId , PIPELINE ))
234238 if pipeline is None :
235239 continue
236240
@@ -247,7 +251,7 @@ def update_triggers():
247251 delete_yaml_git_configs ()
248252 delete_non_default_branch_entities ()
249253 enable_new_gitx ()
250- update_triggers ()
251254 migrate_records_from_inline_to_remote ()
255+ update_triggers ()
252256 cleanup_connector_entities ()
253257 # reset_git_sync_sdk_cache()
0 commit comments