Skip to content

Commit

Permalink
Merge pull request #7 from ankon/pr/support-globs-for-workspaces
Browse files Browse the repository at this point in the history
Support glob matching for `workspaces`
  • Loading branch information
emocharnik authored Aug 21, 2024
2 parents 69cc582 + 84e9369 commit 4a1729c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion migrator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import binascii
import click
import fnmatch
import hashlib
import json
import requests
Expand Down Expand Up @@ -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...")

Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 4a1729c

Please sign in to comment.