-
Notifications
You must be signed in to change notification settings - Fork 30
Place repositories (git/oci) behind the Repository interface and use a Factory to create instances of implementations #171
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
Conversation
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. |
87268b9
to
e878caf
Compare
Looks great Liam. |
e878caf
to
c090209
Compare
a1523e1
to
7d30c94
Compare
bb2ed66
to
5130c1f
Compare
/test presubmit-nephio-go-test |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: efiacor, 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 |
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
externalrepo
package is introduced as a package that contains "external" repository implementations. The following list details the refactors:pkg/externalrepo
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/externalrepo/git`pkg/oci' package is moved to
pkg/externalrepo/oci`repoimpl
factory are inpkg/externalrepo/types
(to avoid circular imports)ExternalRepoFactory
interface is introduced to create instances of repos (git or oci today)CreateExternalRepo
function inpkg/externalrepo/externalrepo.go
creates an instance of a repo based on the incoming configuration, calling the factory in either git or ociExternalRepoOptions
struct containing the options that theExternalRepo
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 CR cache cache.