diff --git a/migrator.py b/migrator.py index 60a9e62..945d952 100644 --- a/migrator.py +++ b/migrator.py @@ -1,5 +1,6 @@ import binascii import click +import fnmatch import hashlib import json import requests @@ -297,6 +298,12 @@ def migrate_state(): for tf_state in fetch_tfc("state-versions", state_filters)["data"]: create_state(tf_state, workspace["data"]["id"]) + def should_migrate_workspace(workspace_name): + for workspace in workspaces: + if fnmatch.fnmatch(workspace_name, workspace): + return True + return False + def migrate_variables(): print("Migrating variables...") @@ -364,7 +371,8 @@ def migrate_variables(): for tf_workspace in tfc_workspaces["data"]: workspace_name = tf_workspace["attributes"]["name"] - if workspace_name not in workspaces and "*" not in workspaces: + if not should_migrate_workspace(workspace_name): + print(f"Skipping workspace {workspace_name}...") continue workspace_exists = fetch_scalr(