Skip to content

Commit

Permalink
Add offline token argument to inventory command
Browse files Browse the repository at this point in the history
This PR modifies the inventory CLI command to accept an offline_token
argument. This should resolve an issue with generating an access token
that I'm encountering with a CI pipeline. With this change, the job can
pass an environment variable containing the offline token to the
Manifester CLI, which mirrors how we access the same token in another CI
use case.
  • Loading branch information
synkd committed Jul 30, 2024
1 parent 4401c8a commit ddbf38c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions manifester/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ def delete(allocations, all_, remove_manifest_file):
@cli.command()
@click.option("--details", is_flag=True, help="Display full inventory details")
@click.option("--sync", is_flag=True, help="Fetch inventory data from RHSM before displaying")
def inventory(details, sync):
@click.option("--offline-token", type=str, default=None)
def inventory(details, sync, offline_token):
"""Display the local inventory file's contents."""
border = "-" * 38
if sync:
helpers.update_inventory(Manifester(minimal_init=True).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
5 changes: 4 additions & 1 deletion manifester/manifester.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ def __init__(
**kwargs,
):
if minimal_init:
self.offline_token = settings.get("offline_token")
if kwargs.get("offline_token") is not None:
self.offline_token = kwargs.get("offline_token")
else:
self.offline_token = settings.get("offline_token")
self.token_request_url = settings.get("url").get("token_request")
self.allocations_url = settings.get("url").get("allocations")
self._access_token = None
Expand Down

0 comments on commit ddbf38c

Please sign in to comment.