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 helper functions for bundle image #765

Merged
merged 2 commits into from
Jan 8, 2025
Merged

Add helper functions for bundle image #765

merged 2 commits into from
Jan 8, 2025

Conversation

Allda
Copy link
Contributor

@Allda Allda commented Jan 7, 2025

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

  • Development is done in feature branches
  • Code changes are submitted as pull request into a primary branch [Provide reason for non-primary branch submissions]
  • Code changes are covered with unit and integration tests.
  • Code passes all automated code tests:
    • Linting
    • Code formatter - Black
    • Security scanners
    • Unit tests
    • Integration tests
  • Code is reviewed by at least 1 team member
  • Pull request is tagged with "risk/good-to-go" label for minor changes

Allda added 2 commits January 7, 2025 10:06
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>
@Allda Allda changed the title Add helper functions for bunlde image Add helper functions for budle image Jan 7, 2025
@Allda Allda changed the title Add helper functions for budle image Add helper functions for bundle image Jan 7, 2025
@Allda Allda requested review from mavaras and ezopezo January 7, 2025 09:20
"""
return f"BundleImage({self.image_pullspec})"

def __del__(self) -> None:
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough.

@Allda Allda merged commit cbfd812 into main Jan 8, 2025
3 checks passed
@Allda Allda deleted the ISV-5280 branch January 8, 2025 15:16
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