|
25 | 25 |
|
26 | 26 | # Load environment variables |
27 | 27 | path_to_env = os.path.join(os.getcwd(),"scripts","migration", ".env") |
| 28 | +path_to_toml = os.path.join(os.getcwd(),"scripts","migration", "config.toml") |
28 | 29 | config = dotenv_values(dotenv_path=path_to_env) |
29 | 30 |
|
| 31 | +toml_space_ids=None |
| 32 | +toml_exclude_space_ids=None |
| 33 | +toml_users=None |
| 34 | +toml_exclude_users=None |
| 35 | +toml_exclude_dataset_ids=None |
| 36 | + |
| 37 | +# Load configuration from toml file |
| 38 | +if os.path.exists(path_to_toml): |
| 39 | + toml_config = tomllib.loads(open(path_to_toml).read()) |
| 40 | + print(f"Loaded toml config") |
| 41 | + toml_space_ids = toml_config["spaces"]["space_ids"] |
| 42 | + toml_users = toml_config["users"]["user_emails"] |
| 43 | + toml_exclude_dataset_ids = toml_config["datasets"]["exclude_dataset_ids"] |
| 44 | + |
| 45 | + |
30 | 46 | CLOWDER_V1 = config["CLOWDER_V1"] |
31 | 47 | ADMIN_KEY_V1 = config["ADMIN_KEY_V1"] |
32 | 48 | CLOWDER_V2 = config["CLOWDER_V2"] |
@@ -791,6 +807,14 @@ def process_user_and_resources(user_v1, USER_MAP, DATASET_MAP): |
791 | 807 | USER_MAP = {} |
792 | 808 | DATASET_MAP = {} |
793 | 809 | users_v1 = get_clowder_v1_users() |
| 810 | + # TODO filter if toml users |
| 811 | + if toml_users is not None and len(toml_users) > 0: |
| 812 | + print(f"Using spaces from config.toml: {toml_users}") |
| 813 | + users_v1 = [ |
| 814 | + user for user in users_v1 if user["email"] in toml_users |
| 815 | + ] |
| 816 | + else: |
| 817 | + print("No spaces specified in config.toml, migrating all users.") |
794 | 818 | for user_v1 in users_v1: |
795 | 819 | if ( |
796 | 820 | "[Local Account]" in user_v1["identityProvider"] |
|
0 commit comments