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 4 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

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