Skip to content

Commit ddbf38c

Browse files
committed
Add offline token argument to inventory command
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.
1 parent 4401c8a commit ddbf38c

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

manifester/commands.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ def delete(allocations, all_, remove_manifest_file):
7373
@cli.command()
7474
@click.option("--details", is_flag=True, help="Display full inventory details")
7575
@click.option("--sync", is_flag=True, help="Fetch inventory data from RHSM before displaying")
76-
def inventory(details, sync):
76+
@click.option("--offline-token", type=str, default=None)
77+
def inventory(details, sync, offline_token):
7778
"""Display the local inventory file's contents."""
7879
border = "-" * 38
7980
if sync:
80-
helpers.update_inventory(Manifester(minimal_init=True).subscription_allocations)
81+
helpers.update_inventory(Manifester(minimal_init=True, offline_token=offline_token).subscription_allocations)
8182
inv = helpers.load_inventory_file(Path(settings.inventory_path))
8283
if not details:
8384
logger.info("Displaying local inventory data")

manifester/manifester.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ def __init__(
3333
**kwargs,
3434
):
3535
if minimal_init:
36-
self.offline_token = settings.get("offline_token")
36+
if kwargs.get("offline_token") is not None:
37+
self.offline_token = kwargs.get("offline_token")
38+
else:
39+
self.offline_token = settings.get("offline_token")
3740
self.token_request_url = settings.get("url").get("token_request")
3841
self.allocations_url = settings.get("url").get("allocations")
3942
self._access_token = None

0 commit comments

Comments
 (0)