Skip to content

Commit

Permalink
Updated memorycache name to etcdcache to btter reflect the implementa…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
liamfallon committed Feb 11, 2025
1 parent f065923 commit 081bdb8
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package cache
import (
"context"

memorycache "github.com/nephio-project/porch/pkg/cache/memorycache"
etcdcache "github.com/nephio-project/porch/pkg/cache/etcdcache"
cachetypes "github.com/nephio-project/porch/pkg/cache/types"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"
Expand All @@ -29,6 +29,6 @@ func CreateCacheImpl(ctx context.Context, options cachetypes.CacheOptions) (cach
ctx, span := tracer.Start(ctx, "Repository::RepositoryFactory", trace.WithAttributes())
defer span.End()

var cacheFactory = new(memorycache.MemoryCacheFactory)
var cacheFactory = new(etcdcache.EtcdCacheFactory)
return cacheFactory.NewCache(ctx, options)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package memorycache
package etcdcache

import (
"context"
Expand All @@ -27,7 +27,7 @@ import (
"go.opentelemetry.io/otel/trace"
)

var tracer = otel.Tracer("memorycache")
var tracer = otel.Tracer("etcdcache")

// Cache allows us to keep state for repositories, rather than querying them every time.
//
Expand All @@ -38,7 +38,7 @@ var tracer = otel.Tracer("memorycache")
// * Caches oci images with further hierarchy underneath
// * We Cache image layers in <cacheDir>/oci/layers/ (this might be obsolete with the flattened Cache)
// * We Cache flattened tar files in <cacheDir>/oci/ (so we don't need to pull to read resources)
// * We poll the repositories periodically (configurable) and cache the discovered images in memory.
// * We poll the repositories periodically (configurable) and cache the discovered images in etcd.
type Cache struct {
mutex sync.Mutex
repositories map[string]*cachedRepository
Expand Down Expand Up @@ -80,7 +80,7 @@ func (c *Cache) OpenRepository(ctx context.Context, repositorySpec *configapi.Re
}

func (c *Cache) UpdateRepository(ctx context.Context, repositorySpec *configapi.Repository) error {
return errors.New("update on memory cached repositories is not supported")
return errors.New("update on etcd cached repositories is not supported")
}

func (c *Cache) CloseRepository(ctx context.Context, repositorySpec *configapi.Repository, allRepos []configapi.Repository) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package memorycache
package etcdcache

import (
"context"
Expand Down Expand Up @@ -225,7 +225,7 @@ func openRepositoryFromArchive(t *testing.T, ctx context.Context, testPath, name
_, address := git.ServeGitRepository(t, tarfile, tempdir)
metadataStore := createMetadataStoreFromArchive(t, fmt.Sprintf("%s-metadata.yaml", name), name)

cache, _ := new(MemoryCacheFactory).NewCache(ctx, cachetypes.CacheOptions{
cache, _ := new(EtcdCacheFactory).NewCache(ctx, cachetypes.CacheOptions{
ExternalRepoOptions: externalrepotypes.ExternalRepoOptions{
LocalDirectory: t.TempDir(),
UseUserDefinedCaBundle: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package memorycache
package etcdcache

import (
"context"

cachetypes "github.com/nephio-project/porch/pkg/cache/types"
)

var _ cachetypes.CacheFactory = &MemoryCacheFactory{}
var _ cachetypes.CacheFactory = &EtcdCacheFactory{}

type MemoryCacheFactory struct {
type EtcdCacheFactory struct {
}

func (f *MemoryCacheFactory) NewCache(_ context.Context, options cachetypes.CacheOptions) (cachetypes.Cache, error) {
func (f *EtcdCacheFactory) NewCache(_ context.Context, options cachetypes.CacheOptions) (cachetypes.Cache, error) {
return &Cache{
repositories: make(map[string]*cachedRepository),
options: options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package memorycache
package etcdcache

import (
"github.com/nephio-project/porch/pkg/repository"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package memorycache
package etcdcache

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package memorycache
package etcdcache

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package memorycache
package etcdcache

import (
"context"
Expand Down

0 comments on commit 081bdb8

Please sign in to comment.