Skip to content

Commit

Permalink
re-add the Refresh function for visibility and readability
Browse files Browse the repository at this point in the history
  • Loading branch information
kushnaidu committed Nov 27, 2024
1 parent a11c007 commit 9135e58
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/cache/memory/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ func newRepository(id string, repoSpec *configapi.Repository, repo repository.Re
return r
}

func (r *cachedRepository) Refresh(ctx context.Context) error {

_, _, err := r.refreshAllCachedPackages(ctx)

return err
}

func (r *cachedRepository) Version(ctx context.Context) (string, error) {
return r.repo.Version(ctx)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -1709,6 +1709,10 @@ func (r *gitRepository) discoverPackagesInTree(commit *object.Commit, opt Discov
return t, nil
}

func (r *gitRepository) Refresh(_ context.Context) error {
return nil
}

// See https://eli.thegreenplace.net/2021/generic-functions-on-slices-with-go-type-parameters/
// func ReverseSlice[T any](s []T) { // Ready for generics!
func reverseSlice(s []v1alpha1.Task) {
Expand Down
4 changes: 4 additions & 0 deletions pkg/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ func (r *ociRepository) buildPackageRevision(ctx context.Context, name oci.Image
return p, nil
}

func (r *ociRepository) Refresh(_ context.Context) error {
return nil
}

// ToMainPackageRevision implements repository.PackageRevision.
func (p *ociPackageRevision) ToMainPackageRevision() repository.PackageRevision {
panic("unimplemented")
Expand Down
4 changes: 4 additions & 0 deletions pkg/repository/fake/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,7 @@ func (r *Repository) CreatePackage(_ context.Context, pr *v1alpha1.PorchPackage)
func (r *Repository) DeletePackage(_ context.Context, pr repository.Package) error {
return nil
}

func (r *Repository) Refresh(_ context.Context) error {
return nil
}
3 changes: 3 additions & 0 deletions pkg/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ type Repository interface {

// Close cleans up any resources associated with the repository
Close() error

// Refresh the repository
Refresh(ctx context.Context) error
}

// The definitions below would be more appropriately located in a package usable by any Porch component.
Expand Down

0 comments on commit 9135e58

Please sign in to comment.