Skip to content

Commit

Permalink
move azure check and service principal confirmation prompts to for_cl…
Browse files Browse the repository at this point in the history
…i function
  • Loading branch information
qziyuan committed Feb 21, 2024
1 parent feb3d58 commit 7dc14a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/databricks/labs/ucx/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def migrate_azure_service_principals(w: WorkspaceClient):
"""
logger.info("Running migrate_azure_service_principals command")
prompts = Prompts()
service_principal_migration = AzureServicePrincipalMigration.for_cli(w)
service_principal_migration = AzureServicePrincipalMigration.for_cli(w, prompts)
service_principal_migration.execute_migration(prompts)
return

Expand Down
23 changes: 12 additions & 11 deletions src/databricks/labs/ucx/migration/azure_credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,18 @@ def __init__(
self._action_plan = 'service_principals_for_storage_credentials.csv'

@classmethod
def for_cli(cls, ws: WorkspaceClient, product='ucx'):
def for_cli(cls, ws: WorkspaceClient, prompts: Prompts, product='ucx'):
if not ws.config.is_azure:
logger.error("Workspace is not on azure, please run this command on azure databricks workspaces.")
return

csv_confirmed = prompts.confirm(
"Have you reviewed the azure_storage_account_info.csv "
"and confirm listed service principals are allowed to be checked for migration?"
)
if csv_confirmed is not True:
return

installation = Installation.current(ws, product)
config = installation.load(WorkspaceConfig)
sql_backend = StatementExecutionBackend(ws, config.warehouse_id)
Expand Down Expand Up @@ -226,16 +237,6 @@ def _validate_storage_credential(self, storage_credential, location) -> StorageC
return StorageCredentialValidationResult.from_storage_credential_validation(storage_credential, validation)

def execute_migration(self, prompts: Prompts):
if not self._ws.config.is_azure:
logger.error("Workspace is not on azure, please run this command on azure databricks workspaces.")
return

csv_confirmed = prompts.confirm(
"Have you reviewed the azure_storage_account_info.csv "
"and confirm listed service principals are allowed to be checked for migration?"
)
if csv_confirmed is not True:
return

self._generate_migration_list()

Expand Down

0 comments on commit 7dc14a1

Please sign in to comment.