-
Notifications
You must be signed in to change notification settings - Fork 21
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
base: main
Are you sure you want to change the base?
Conversation
[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 |
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.
Few minor comments.
Do we need some unit test coverage on the new repoimpl stuff? Not sure if it's covered currently.
fb2dcf4
to
fc9b7b4
Compare
yes, I'll do the unit tests in a later PR. |
@liamfallon: The following test failed, say
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. |
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:pkg/repoimpl
package is introduced, this package contains a factory for creating implementations of theRepository
type that store packages that are source or target packages for Porch (such as git and oci), that isRepository
implementations that are not Porch internal cachespkg/git' package is moved to
pkg/repoimpl/git`pkg/oci' package is moved to
pkg/repoimpl/oci`repoimpl
factory are inpkg/repoimpl/types
(to avoid circular imports)RepoImplFactory
interface is introduced to create instances of repos (git or oci today)CreateRepoImpl
function inpkg/repoimpl/repoimpl.go
creates an instance of a repo based on the incoming configuration, calling the factory in either git or ociRepoImplOptions
struct containing the options that theRepoImpl
implementations use but the cache does not useCacheFactory
interface is introduced for creating cache implementations, where the implementation of the cache is behind the factory interlaceCacheFactory
implementation is added to the memory cache.