Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add offline token argument to inventory command #45

Merged

Conversation

synkd
Copy link
Collaborator

@synkd synkd commented Jul 30, 2024

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.

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.
@synkd synkd requested review from jyejare and JacobCallahan July 30, 2024 17:01
Comment on lines 36 to 39
if kwargs.get("offline_token") is not None:
self.offline_token = kwargs.get("offline_token")
else:
self.offline_token = settings.get("offline_token")
Copy link
Member

@ogajduse ogajduse Jul 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, with validators disabled, we might bump into self.offline_token being none if none of kwargs and settings contain the offline token. Should we raise an exception in that case?

Suggested change
if kwargs.get("offline_token") is not None:
self.offline_token = kwargs.get("offline_token")
else:
self.offline_token = settings.get("offline_token")
if not self.offline_token := kwargs.get("offline_token", settings.get("offline_token")):
raise Exception("Offline token was not set") # to be replaced with less general exception type

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, good idea. I will make this change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ogajduse It turns out that := can't be used to set instance attributes. Doing so throws SyntaxError: cannot use assignment expressions with attribute. But I've added another condition to catch this. I also added an exception that prints the error text when generating an access token fails, which should provide more visibility into failures at that stage.

@synkd synkd force-pushed the accept_offline_token_arg_for_inventory_command branch from 4afd1ae to 94a9f71 Compare July 31, 2024 20:07
@synkd synkd merged commit 8cb287c into SatelliteQE:master Aug 1, 2024
4 checks passed
synkd added a commit to synkd/manifester that referenced this pull request Sep 11, 2024
This PR makes a similar change to the change made in SatelliteQE#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants