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

Place repositories (git/oci) behind the Repository interface and use a Factory to create instances of implementations #171

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

liamfallon
Copy link
Member

This PR refactors the existing Porch code to make it easier to introduce a database cache.

It reinforces the structure of the code so that repository implementations (git/oci) are behind the interface and are only used by calling the interface. The repoimpl package is introduced as a package that contains "final" repository implementations. The following list details the refactors:

  • A new pkg/repoimpl package is introduced, this package contains a factory for creating implementations of the Repository type that store packages that are source or target packages for Porch (such as git and oci), that is Repository implementations that are not Porch internal caches
  • The pkg/git' package is moved to pkg/repoimpl/git`
  • The pkg/oci' package is moved to pkg/repoimpl/oci`
  • Types for the repoimpl factory are in pkg/repoimpl/types (to avoid circular imports)
  • The RepoImplFactory interface is introduced to create instances of repos (git or oci today)
  • The CreateRepoImpl function in pkg/repoimpl/repoimpl.go creates an instance of a repo based on the incoming configuration, calling the factory in either git or oci
  • The cache options are restructured with a contained RepoImplOptions struct containing the options that the RepoImpl implementations use but the cache does not use
  • A CacheFactory interface is introduced for creating cache implementations, where the implementation of the cache is behind the factory interlace
  • A CacheFactory implementation is added to the memory cache.

Copy link
Contributor

nephio-prow bot commented Jan 20, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: liamfallon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@liamfallon
Copy link
Member Author

Copy link
Collaborator

@efiacor efiacor left a comment

Choose a reason for hiding this comment

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

Few minor comments.
Do we need some unit test coverage on the new repoimpl stuff? Not sure if it's covered currently.

pkg/cache/memorycache/cache.go Outdated Show resolved Hide resolved
pkg/cache/memorycache/cache.go Outdated Show resolved Hide resolved
@liamfallon
Copy link
Member Author

Few minor comments. Do we need some unit test coverage on the new repoimpl stuff? Not sure if it's covered currently.

yes, I'll do the unit tests in a later PR.

Copy link
Contributor

nephio-prow bot commented Jan 23, 2025

@liamfallon: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
presubmit-nephio-go-test 87268b9 link true /test presubmit-nephio-go-test

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants