-
Notifications
You must be signed in to change notification settings - Fork 62
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 helper functions for bundle image #765
Conversation
A new class BundleImage is introduced that represents a bundle image. The class will be used in integration test to verify its content is as expected. The class contains a generic method to get a metadata and simplifies a way how to extract it. JIRA: ISV-5280 Signed-off-by: Ales Raszka <araszka@redhat.com>
There were few warnings coming from yamllint about incompatible linting config. This commits extends the config with recommended values and fixes a violations. Signed-off-by: Ales Raszka <araszka@redhat.com>
""" | ||
return f"BundleImage({self.image_pullspec})" | ||
|
||
def __del__(self) -> None: |
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.
Have you considered that destructors are very unsafe to use, because there is no guarantee when garbage collection invoke them (and thus in this implementation when will be the file removed)?
If you need to be sure about when file will be removed and avoid potential future inconsistencies or race conditions I strongly recommend to use rather context manager pattern (__enter__ and __exit__ methods) and use BundleImage as context manager.
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 don't care when exactly this file gets removed; I'll leave it up to Python. The important thing is that the file is available when the object is usable. Since it uses random temporary directories, it never conflicts with any other instance of the same class. I didn't want to overcomplicate the testing scenarios with a context manager if there was no specific need for it.
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.
Fair enough.
A new class BundleImage is introduced that represents a bundle image. The class will be used in integration test to verify its content is as expected. The class contains a generic method to get a metadata and simplifies a way how to extract it.
JIRA: ISV-5280
Merge Request Checklists