-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add offline token argument to inventory command #45
Conversation
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.
manifester/manifester.py
Outdated
if kwargs.get("offline_token") is not None: | ||
self.offline_token = kwargs.get("offline_token") | ||
else: | ||
self.offline_token = settings.get("offline_token") |
There was a problem hiding this comment.
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?
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
4afd1ae
to
94a9f71
Compare
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.
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.