From 7e0ff17457c7585f8c97a15094cd9b43301fc230 Mon Sep 17 00:00:00 2001 From: synkd Date: Wed, 11 Sep 2024 13:12:23 -0400 Subject: [PATCH] Accept offline token option for CLI delete command This PR makes a similar change to the change made in https://github.com/SatelliteQE/manifester/pull/45 but for the `manifester delete` subcommand. This is to support a CI usecase of the manifester CLI. The PR also reformats the `commands.py` module with Ruff. --- manifester/commands.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/manifester/commands.py b/manifester/commands.py index 28d87b9..04569a1 100644 --- a/manifester/commands.py +++ b/manifester/commands.py @@ -51,14 +51,15 @@ def get_manifest(manifest_category, allocation_name, requester): default=False, help="Delete local manifest files in addition to upstream subscription allocations", ) -def delete(allocations, all_, remove_manifest_file): +@click.option("--offline-token", type=str, default=None) +def delete(allocations, all_, remove_manifest_file, offline_token): """Delete subscription allocations in inventory and optionally delete local manifest files.""" inv = helpers.load_inventory_file(Path(settings.inventory_path)) for num, allocation in enumerate(inv): if str(num) in allocations or allocation.get("name") in allocations or all_: - Manifester(minimal_init=True).delete_subscription_allocation( - uuid=allocation.get("uuid") - ) + Manifester( + minimal_init=True, offline_token=offline_token + ).delete_subscription_allocation(uuid=allocation.get("uuid")) if remove_manifest_file: manifester_directory = ( Path(os.environ["MANIFESTER_DIRECTORY"]).resolve() @@ -78,7 +79,9 @@ def inventory(details, sync, offline_token): """Display the local inventory file's contents.""" border = "-" * 38 if sync: - helpers.update_inventory(Manifester(minimal_init=True, offline_token=offline_token).subscription_allocations) + helpers.update_inventory( + Manifester(minimal_init=True, offline_token=offline_token).subscription_allocations + ) inv = helpers.load_inventory_file(Path(settings.inventory_path)) if not details: logger.info("Displaying local inventory data")