-
Notifications
You must be signed in to change notification settings - Fork 7
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
Refactor settings and reformat multiple files #8
Conversation
Previously, API URLs were hardcoded in the body of manifester/manifester.py, and the offline token (which is used to generate an access token, which is in turn used to authenticate API calls) was a top-level setting. This commit makes the offline_token setting a child setting of each manifest_category, and it moves the API URLs to the settings file, also as children of each manifest_category. This should enable greater flexibility by letting users associate manifests with multiple RHSM accounts (potentially in multiple environments, such as Red Hat's staging environment) in a single settings file. This commit also makes numerous formatting changes as a result of running pre-commit. Additionally, the offline_token validator in manifester/settings.py has been commented out as it fails to validate with the offline_token setting nested under the manifest categories.
subscription_data: | ||
# name should be an exact match of the subscription name as listed on the Customer Portal | ||
- name: "Software Collections and Developer Toolset" | ||
quantity: 1 | ||
- name: "Red Hat Ansible Automation Platform, Standard (100 Managed Nodes)" | ||
quantity: 1 | ||
simple_content_access: "enabled" | ||
url: | ||
token_request: "https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token" | ||
allocations: "https://api.access.redhat.com/management/v1/allocations" |
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.
Nice! People can simply generate manifest on stage using manifester!
Edit: a few minutes later, I read the PR description.
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.
Great work, I can not wait to see manifester integrated into robottelo!
It looks to me that you let black
do the black formatting magic. Would it make sense now to run black on every pull request?
self.subscription_data = manifest_data.subscription_data | ||
self.sat_version = kwargs.get("sat_version", manifest_data.sat_version) | ||
self.allocation_name = allocation_name or "".join( | ||
random.sample(string.ascii_letters, 10) |
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.
Consider adding a fauxfactory dependency for this.
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.
right now it is just a single call, but if more random data is needed later, that is a possibility. or the more performant
str(uuid4()).split("-")[-1]
manifester/manifester.py
Outdated
self.offline_token = kwargs.get( | ||
"offline_token", self.manifest_data.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.
I think it would be a good idea to modify this so the offline token could be set at the top level or overridden at the manifest level. That way someone using the same token for each doesn't need to duplicate the setting for each manifest.
self.offline_token = kwargs.get( | |
"offline_token", self.manifest_data.offline_token | |
) | |
self.offline_token = kwargs.get( | |
"offline_token", self.manifest_data.get("offline_token", settings.offline_token) | |
) |
manifester/manifester.py
Outdated
self._subscription_pools=None | ||
logger.debug( | ||
f"Received response status {add_entitlements.status_code}." | ||
f"Trying to find another pool." |
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.
f"Trying to find another pool." | |
"Trying to find another pool." |
manifester/manifester.py
Outdated
) | ||
break | ||
else: | ||
raise Exception(f"Something went wrong while adding entitlements. Received response status {add_entitlements.status_code}.") | ||
raise Exception( | ||
f"Something went wrong while adding entitlements. Received response status " |
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.
f"Something went wrong while adding entitlements. Received response status " | |
"Something went wrong while adding entitlements. Received response status " |
Access to the internal Red Hat staging environment is mediated through a proxy server. To support compatibility with this environment, this commit adds a `proxies` setting to each manifest_category and adds a `proxies` argument to each request in manifester.py. To access the production RHSM API without a proxy, the value of the dictionary in the `proxies` setting can be left as an empty string (i.e. `proxies: {"https": ""}).
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.
very nice!
Previously, API URLs were hardcoded in the body of
manifester/manifester.py, and the offline token (which is used to
generate an access token, which is in turn used to authenticate API
calls) was a top-level setting. This commit makes the offline_token
setting a child setting of each manifest_category, and it moves the API
URLs to the settings file, also as children of each manifest_category.
This should enable greater flexibility by letting users associate
manifests with multiple RHSM accounts (potentially in multiple
environments, such as Red Hat's staging environment) in a single
settings file.
This commit also makes numerous formatting changes as a result of
running pre-commit.
Additionally, the offline_token validator in manifester/settings.py has
been commented out as it fails to validate with the offline_token
setting nested under the manifest categories.