Skip to content

Commit

Permalink
Accept offline token option for CLI delete command
Browse files Browse the repository at this point in the history
This PR makes a similar change to the change made in #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.
  • Loading branch information
synkd committed Sep 11, 2024
1 parent b53f403 commit 7e0ff17
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions manifester/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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")
Expand Down

0 comments on commit 7e0ff17

Please sign in to comment.