Skip to content

Commit

Permalink
Add inventory_database name check (#275)
Browse files Browse the repository at this point in the history
Check that database name is a word, loop until correct.
  • Loading branch information
dmoore247 authored and zpappa committed Oct 4, 2023
1 parent d38ce51 commit fad59db
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/databricks/labs/ucx/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

TAG_STEP = "step"
TAG_APP = "App"
NUM_USER_ATTEMPTS = 10 # number of attempts user gets at answering a question

DEBUG_NOTEBOOK = """
# Databricks notebook source
Expand Down Expand Up @@ -179,7 +180,17 @@ def _configure(self):
raise err

logger.info("Please answer a couple of questions to configure Unity Catalog migration")
inventory_database = self._question("Inventory Database", default="ucx")
counter = 0
while True:
inventory_database = self._question("Inventory Database stored in hive_metastore", default="ucx")
if re.match(r"^\w+$", inventory_database):
break
else:
print(f"{inventory_database} is not a valid database name")
counter = counter + 1
if counter > NUM_USER_ATTEMPTS:
msg = "Exceeded max tries to get a valid database name, try again later."
raise SystemExit(msg)

pro_warehouses = {"[Create new PRO SQL warehouse]": "create_new"} | {
f"{_.name} ({_.id}, {_.warehouse_type.value}, {_.state.value})": _.id
Expand Down

0 comments on commit fad59db

Please sign in to comment.