Skip to content

Commit

Permalink
Remove catalog.Interface as we don't put it in any use (#6723)
Browse files Browse the repository at this point in the history
  • Loading branch information
nopcoder authored Oct 8, 2023
1 parent 822eb6d commit 9418352
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 200 deletions.
4 changes: 0 additions & 4 deletions cmd/lakectl/cmd/fs.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package cmd

import (
"errors"

"github.com/spf13/cobra"
)

var ErrRequestFailed = errors.New("request failed")

// fsCmd represents the fs command
var fsCmd = &cobra.Command{
Use: "fs",
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/treeverse/lakefs/pkg/catalog"
"github.com/treeverse/lakefs/pkg/cloud"
"github.com/treeverse/lakefs/pkg/config"
graveler "github.com/treeverse/lakefs/pkg/graveler"
"github.com/treeverse/lakefs/pkg/graveler"
"github.com/treeverse/lakefs/pkg/graveler/ref"
"github.com/treeverse/lakefs/pkg/httputil"
"github.com/treeverse/lakefs/pkg/kv"
Expand Down Expand Up @@ -80,7 +80,7 @@ type Migrator interface {

type Controller struct {
Config *config.Config
Catalog catalog.Interface
Catalog *catalog.Catalog
Authenticator auth.Authenticator
Auth auth.Service
BlockAdapter block.Adapter
Expand Down Expand Up @@ -4529,7 +4529,7 @@ func resolvePathList(objects, prefixes *[]string) []catalog.PathRecord {
return pathRecords
}

func NewController(cfg *config.Config, catalog catalog.Interface, authenticator auth.Authenticator, authService auth.Service, blockAdapter block.Adapter, metadataManager auth.MetadataManager, migrator Migrator, collector stats.Collector, cloudMetadataProvider cloud.MetadataProvider, actions actionsHandler, auditChecker AuditChecker, logger logging.Logger, sessionStore sessions.Store, pathProvider upload.PathProvider, otfDiffService *tablediff.Service) *Controller {
func NewController(cfg *config.Config, catalog *catalog.Catalog, authenticator auth.Authenticator, authService auth.Service, blockAdapter block.Adapter, metadataManager auth.MetadataManager, migrator Migrator, collector stats.Collector, cloudMetadataProvider cloud.MetadataProvider, actions actionsHandler, auditChecker AuditChecker, logger logging.Logger, sessionStore sessions.Store, pathProvider upload.PathProvider, otfDiffService *tablediff.Service) *Controller {
return &Controller{
Config: cfg,
Catalog: catalog,
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func TestController_GetRepoHandler(t *testing.T) {
})
}

func testCommitEntries(t *testing.T, ctx context.Context, cat catalog.Interface, deps *dependencies, params commitEntriesParams) string {
func testCommitEntries(t *testing.T, ctx context.Context, cat *catalog.Catalog, deps *dependencies, params commitEntriesParams) string {
t.Helper()
for _, p := range params.paths {
err := cat.CreateEntry(ctx, params.repo, params.branch,
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const (
extensionValidationExcludeBody = "x-validation-exclude-body"
)

func Serve(cfg *config.Config, catalog catalog.Interface, middlewareAuthenticator auth.Authenticator, authService auth.Service, blockAdapter block.Adapter, metadataManager auth.MetadataManager, migrator Migrator, collector stats.Collector, cloudMetadataProvider cloud.MetadataProvider, actions actionsHandler, auditChecker AuditChecker, logger logging.Logger, gatewayDomains []string, snippets []params.CodeSnippet, pathProvider upload.PathProvider, otfService *tablediff.Service) http.Handler {
func Serve(cfg *config.Config, catalog *catalog.Catalog, middlewareAuthenticator auth.Authenticator, authService auth.Service, blockAdapter block.Adapter, metadataManager auth.MetadataManager, migrator Migrator, collector stats.Collector, cloudMetadataProvider cloud.MetadataProvider, actions actionsHandler, auditChecker AuditChecker, logger logging.Logger, gatewayDomains []string, snippets []params.CodeSnippet, pathProvider upload.PathProvider, otfService *tablediff.Service) http.Handler {
logger.Info("initialize OpenAPI server")
swagger, err := apigen.GetSwagger()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/serve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const (

type dependencies struct {
blocks block.Adapter
catalog catalog.Interface
catalog *catalog.Catalog
authService auth.Service
collector *memCollector
server *httptest.Server
Expand Down
73 changes: 72 additions & 1 deletion pkg/catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,74 @@ const (
MetaRangeFSName = "meta-range"
)

const (
DefaultPathDelimiter = "/"
)

type DiffParams struct {
Limit int
After string
Prefix string
Delimiter string
AdditionalFields []string // db fields names that will be load in additional to Path on Difference's Entry
}

type RevertParams struct {
Reference string // the commit to revert
ParentNumber int // if reverting a merge commit, the change will be reversed relative to this parent number (1-based).
Committer string
}

type CherryPickParams struct {
Reference string // the commit to pick
ParentNumber *int // if a merge commit was picked, the change will be applied relative to this parent number (1-based).
Committer string
}

type PathRecord struct {
Path Path
IsPrefix bool
}

type LogParams struct {
PathList []PathRecord
FromReference string
Amount int
Limit bool
FirstParent bool
}

type ExpireResult struct {
Repository string
Branch string
PhysicalAddress string
InternalReference string
}

// ExpiryRows is a database iterator over ExpiryResults. Use Next to advance from row to row.
type ExpiryRows interface {
Close()
Next() bool
Err() error
// Read returns the current from ExpiryRows, or an error on failure. Call it only after
// successfully calling Next.
Read() (*ExpireResult, error)
}

// GetEntryParams configures what entries GetEntry returns.
type GetEntryParams struct {
// StageOnly when true will return entry found on stage without checking committed data
StageOnly bool
}

type WriteRangeRequest struct {
SourceURI string
Prepend string
After string
StagingToken string
ContinuationToken string
}

type Config struct {
Config *config.Config
KVStore kv.Store
Expand Down Expand Up @@ -350,7 +418,8 @@ func (c *Catalog) CreateRepository(ctx context.Context, repository string, stora
return catalogRepo, nil
}

// CreateBareRepository creates a new repository pointing to 'storageNamespace' (ex: s3://bucket1/repo) with no initial branch or commit
// CreateBareRepository create a new repository pointing to 'storageNamespace' (ex: s3://bucket1/repo) with no initial branch or commit
// defaultBranchID will point to a non-existent branch on creation, it is up to the caller to eventually create it.
func (c *Catalog) CreateBareRepository(ctx context.Context, repository string, storageNamespace string, defaultBranchID string) (*Repository, error) {
repositoryID := graveler.RepositoryID(repository)
storageNS := graveler.StorageNamespace(storageNamespace)
Expand Down Expand Up @@ -412,6 +481,7 @@ func (c *Catalog) DeleteRepository(ctx context.Context, repository string) error
return c.Store.DeleteRepository(ctx, repositoryID)
}

// GetRepositoryMetadata get repository metadata
func (c *Catalog) GetRepositoryMetadata(ctx context.Context, repository string) (graveler.RepositoryMetadata, error) {
repositoryID := graveler.RepositoryID(repository)
if err := validator.Validate([]validator.ValidateArg{
Expand Down Expand Up @@ -2267,6 +2337,7 @@ func (c *Catalog) CopyEntry(ctx context.Context, srcRepository, srcRef, srcPath,
return &dstEntry, nil
}

// SetLinkAddress to validate single use limited in time of a given physical address
func (c *Catalog) SetLinkAddress(ctx context.Context, repository, physicalAddress string) error {
repo, err := c.getRepository(ctx, repository)
if err != nil {
Expand Down
181 changes: 0 additions & 181 deletions pkg/catalog/interface.go

This file was deleted.

4 changes: 2 additions & 2 deletions pkg/gateway/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ type handler struct {
type ServerContext struct {
region string
bareDomains []string
catalog catalog.Interface
catalog *catalog.Catalog
multipartTracker multipart.Tracker
blockStore block.Adapter
authService auth.GatewayService
stats stats.Collector
pathProvider upload.PathProvider
}

func NewHandler(region string, catalog catalog.Interface, multipartTracker multipart.Tracker, blockStore block.Adapter, authService auth.GatewayService, bareDomains []string, stats stats.Collector, pathProvider upload.PathProvider, fallbackURL *url.URL, auditLogLevel string, traceRequestHeaders bool) http.Handler {
func NewHandler(region string, catalog *catalog.Catalog, multipartTracker multipart.Tracker, blockStore block.Adapter, authService auth.GatewayService, bareDomains []string, stats stats.Collector, pathProvider upload.PathProvider, fallbackURL *url.URL, auditLogLevel string, traceRequestHeaders bool) http.Handler {
var fallbackHandler http.Handler
if fallbackURL != nil {
fallbackProxy := gohttputil.NewSingleHostReverseProxy(fallbackURL)
Expand Down
6 changes: 3 additions & 3 deletions pkg/gateway/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ func DurationHandler(next http.Handler) http.Handler {
})
}

func EnrichWithRepositoryOrFallback(c catalog.Interface, authService auth.GatewayService, fallbackProxy http.Handler, next http.Handler) http.Handler {
func EnrichWithRepositoryOrFallback(c *catalog.Catalog, authService auth.GatewayService, fallbackProxy http.Handler, next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
ctx := req.Context()
repoID := ctx.Value(ContextKeyRepositoryID).(string)
user, _ := auth.GetUser(ctx)
username := user.Username
o := ctx.Value(ContextKeyOperation).(*operations.Operation)
if repoID == "" {
// action without repo
// action without a repo
next.ServeHTTP(w, req)
return
}
Expand Down Expand Up @@ -226,7 +226,7 @@ func OperationLookupHandler(next http.Handler) http.Handler {
})
}

// memberFold returns true if 'a' is equal case-folded to a member of bs.
// memberFold returns true if 'a' is an equal case-folded to a member of bs.
func memberFold(a string, bs []string) bool {
for _, b := range bs {
if strings.EqualFold(a, b) {
Expand Down
Loading

0 comments on commit 9418352

Please sign in to comment.