-
Notifications
You must be signed in to change notification settings - Fork 119
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
feat: add GetEnvironments method to DBus register #3462
Conversation
f438b2e
to
3c6b79b
Compare
tested using this script, a modified example from: https://github.com/jirihnidek/rhsm-dbus-examples/tree/main
|
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.
Thanks for this PR, and sorry for the wait.
I added a couple of notes of things I noticed so far; will give a better try later on.
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.
Thanks for the PR. I have few requests.
@@ -181,6 +181,32 @@ def get_organizations(self, options: dict) -> List[dict]: | |||
owners: List[dict] = uep.getOwnerList(options["username"]) | |||
return owners | |||
|
|||
def get_environments(self, options: dict) -> List[dict]: |
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.
This method should not be in rhsmlib.dbus.objects.register
module. This module should contain only methods related to D-Bus. This proposed method should be in new rhsmlib.services.environment
module, because you can see that subscription-manager CLI already has environments
sub-command. Thus, there will be potential to share new code.
This method should have optional argument uep
(basic auth connection to candlepin) to be able to pass existing connection instance to this method.
I this method had another argument typed_environments: bool = True
, then we could list not only typed environments. If typed_environments is False
, then we could skip detection for that capability on server.
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.
My understanding of the card is that the GetEnvironments() method is intended to be a DBus method. With that said, I moved the actual list call to candlepin to a newly created EnvironmentService class. I then instantiated that in the DBus method and used it to call to candlepin. Is that okay?
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.
If I'm misunderstanding your request, I'm happy to make more changes :)
"type": "content-template" | ||
} | ||
] | ||
""" |
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.
Please add more environments to this list. You will see that new unit test will start to fail.
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 added more environments to this list (10 more), but I don't see an issue. If you're seeing something else, what else can I do to reproduce?
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.
If the old code was used, then the unit test would fail.
6926ca2
to
af0d114
Compare
Thank you guys for the reviews! I addressed most of the feedback, and left some questions where I'm not sure. My team usually squashes commits before merging, so I just added a new commit for the feedback. Please let me know if I should organize my commits differently :) I also still need to work on the tests a bit and fix the linting |
updated, thanks for the review! |
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.
Thanks for the updates! It seems to work fine, so I'm leaving a last round of miscellaneous minor changes to do the final polishing to this from my POV.
updated, thanks! |
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.
Thanks for the changes! The code now LGTM, and it works well too.
Since @jirihnidek had notes/reviews, I'll approve leaving it to him for an additional review.
One small last thing from me (a forgotten previous comment from you, sorry):
My team usually squashes commits before merging, so I just added a new commit for the feedback. Please let me know if I should organize my commits differently :)
We generally don't squash commits on merging; would you please squash them in this PR, and provide a commit message that explains the changes done?
* Card-ID: CCT-764 * Method lists environments of the given org and returns a subset of the fields from candlepin * Provides a way to get the names of environments before registering in support of content templates
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.
LGTM, Thanks for updates
Card-ID: CCT-764
This implements the functionality requested in the card, but I would like to get guidance on how to architect the implementation. Perhaps I should be implementing an environments class? The
get_environments
method I created makes multiple calls to the candlepin API, which I don't see precedence for looking at the other DBus methods.