Skip to content

Commit 5cc0c7e

Browse files
committed
fix validation
1 parent 60de1e5 commit 5cc0c7e

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

metadata-ingestion/src/datahub/cli/delete_cli.py

+8-12
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ def by_filter(
382382
platform=platform,
383383
env=env,
384384
query=query,
385-
recursive=recursive,
386385
)
387386
soft_delete_filter = _validate_user_soft_delete_flags(
388387
soft=soft, aspect=aspect, only_soft_deleted=only_soft_deleted
@@ -432,6 +431,7 @@ def by_filter(
432431
)
433432
)
434433
if recursive:
434+
_validate_recursive_delete(urns)
435435
for urn in urns:
436436
# Add children urns to the list.
437437
if guess_entity_type(urn) == "dataPlatformInstance":
@@ -553,7 +553,6 @@ def _validate_user_urn_and_filters(
553553
platform: Optional[str],
554554
env: Optional[str],
555555
query: Optional[str],
556-
recursive: bool,
557556
) -> None:
558557
# Check urn / filters options.
559558
if urn:
@@ -574,20 +573,17 @@ def _validate_user_urn_and_filters(
574573
f"Using --env without other filters will delete all metadata in the {env} environment. Please use with caution."
575574
)
576575

577-
# Check recursive flag.
578-
if recursive:
579-
if not urn:
580-
raise click.UsageError(
581-
"The --recursive flag can only be used with a single urn."
576+
577+
def _validate_recursive_delete(urns: List[str]) -> None:
578+
for urn in urns:
579+
if guess_entity_type(urn) in _RECURSIVE_DELETE_TYPES:
580+
logger.warning(
581+
f"This will only delete {urn}. Use --recursive to delete all contained entities."
582582
)
583-
elif guess_entity_type(urn) not in _RECURSIVE_DELETE_TYPES:
583+
else:
584584
raise click.UsageError(
585585
f"The --recursive flag can only be used with these entity types: {_RECURSIVE_DELETE_TYPES}."
586586
)
587-
elif urn and guess_entity_type(urn) in _RECURSIVE_DELETE_TYPES:
588-
logger.warning(
589-
f"This will only delete {urn}. Use --recursive to delete all contained entities."
590-
)
591587

592588

593589
def _validate_user_soft_delete_flags(

0 commit comments

Comments
 (0)