feat(ingest): add -f option to skip confirmations for automation en… (#3256)

This commit is contained in:
aseembansal-gogo 2021-09-29 11:19:34 +05:30 committed by GitHub
parent 08e18868dc
commit dd1f6fbc5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 12 deletions

View File

@ -32,6 +32,8 @@ To delete all the data related to a single entity, run
datahub delete --urn "<my urn>"
```
You can optionally add `-f` or `--force` to skip confirmations
_Note: make sure you surround your urn with quotes! If you do not include the quotes, your terminal may misinterpret the command._
## Rollback Ingestion Batch Run

View File

@ -44,10 +44,7 @@ def write_datahub_config(host: str, token: Optional[str]) -> None:
def should_skip_config() -> bool:
try:
return os.environ[ENV_SKIP_CONFIG] == "True"
except KeyError:
return False
return os.getenv(ENV_SKIP_CONFIG, False) == "True"
def ensure_datahub_config() -> None:

View File

@ -2,7 +2,7 @@ import logging
import click
from datahub.cli.cli_utils import post_delete_endpoint
from datahub.cli import cli_utils
logger = logging.getLogger(__name__)
@ -14,15 +14,22 @@ RUN_TABLE_COLUMNS = ["urn", "aspect name", "created at"]
@click.command()
@click.option("--urn", required=True, type=str)
def delete(urn: str) -> None:
@click.option("-f", "--force", required=False, type=bool, default=False)
def delete(urn: str, force: bool) -> None:
"""Delete a provided URN from datahub"""
click.confirm(
"This will permanently delete data from DataHub. Do you want to continue?",
abort=True,
)
if not force:
click.confirm(
"This will permanently delete data from DataHub. Do you want to continue?",
abort=True,
)
payload_obj = {"urn": urn}
urn, rows_affected = post_delete_endpoint(payload_obj, "/entities?action=delete")
urn, rows_affected = cli_utils.post_delete_endpoint(
payload_obj, "/entities?action=delete"
)
click.echo(f"Successfully deleted {urn}. {rows_affected} rows deleted")
if rows_affected == 0:
click.echo(f"Nothing deleted for {urn}")
else:
click.echo(f"Successfully deleted {urn}. {rows_affected} rows deleted")