Skip to content

Commit

Permalink
fixup! Add image repositories to cleanup task
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-turbaszek committed Nov 5, 2024
1 parent f4b7c41 commit fd9052b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 4 additions & 5 deletions scripts/cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ def is_stale(item):


def remove_resource(resource_type: str, item, role: str):
msg = f"Deleting {resource_type} {item.name}"
fqn = f"{item.database_name}.{item.schema_name}.{item.name}"
msg = f"Deleting {resource_type} {fqn}"
try:
if is_stale(item):
session.sql(
f"GRANT OWNERSHIP ON {resource_type} {item.name} TO ROLE {role}"
)
session.sql(f'drop {resource_type} "{item.name}"').collect()
session.sql(f"GRANT OWNERSHIP ON {resource_type} {fqn} TO ROLE {role}")
session.sql(f'drop {resource_type} "{fqn}"').collect()
print("SUCCESS", msg, f"created at {item.created_on}")
except Exception as err:
print("ERROR", msg)
Expand Down
1 change: 1 addition & 0 deletions tests_integration/spcs/test_image_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,4 @@ def test_create_image_repository(runner, test_database):
assert result.json == {
"status": f"Image Repository {repo_name.upper()} successfully created."
}
runner.invoke_with_connection_json(["spcs", "image-repository", "drop", repo_name])

0 comments on commit fd9052b

Please sign in to comment.