Skip to content

Commit

Permalink
rename method
Browse files Browse the repository at this point in the history
  • Loading branch information
N-o-Z committed Feb 25, 2025
1 parent 1fc7c7d commit 94f2895
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/api/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,7 @@ func (c *Controller) ListRepositories(w http.ResponseWriter, r *http.Request, pa
creationDate := repo.CreationDate.Unix()
r := apigen.Repository{
Id: repo.Name,
StorageId: swag.String(c.getRepoStorageID(repo.StorageID)),
StorageId: swag.String(c.getActualStorageID(repo.StorageID)),
StorageNamespace: repo.StorageNamespace,
CreationDate: creationDate,
DefaultBranch: repo.DefaultBranch,
Expand Down Expand Up @@ -2026,7 +2026,7 @@ func (c *Controller) CreateRepository(w http.ResponseWriter, r *http.Request, bo
}

// Validate storage ID exists
storageID = c.getRepoStorageID(storageID) // This returns the actual storageID for the repository
storageID = c.getActualStorageID(storageID)
if !slices.Contains(c.Config.StorageConfig().GetStorageIDs(), storageID) {
c.handleAPIError(ctx, w, r, graveler.ErrInvalidStorageID)
return
Expand Down Expand Up @@ -2227,7 +2227,8 @@ func (c *Controller) DeleteRepository(w http.ResponseWriter, r *http.Request, re
writeResponse(w, r, http.StatusNoContent, nil)
}

func (c *Controller) getRepoStorageID(storageID string) string {
// getActualStorageID - This returns the actual storageID of the storage
func (c *Controller) getActualStorageID(storageID string) string {
if storageID == config.SingleBlockstoreID {
if storage := c.Config.StorageConfig().GetStorageByID(config.SingleBlockstoreID); storage != nil {
return storage.ID() // Will return the real actual ID
Expand All @@ -2254,7 +2255,7 @@ func (c *Controller) GetRepository(w http.ResponseWriter, r *http.Request, repos
CreationDate: repo.CreationDate.Unix(),
DefaultBranch: repo.DefaultBranch,
Id: repo.Name,
StorageId: swag.String(c.getRepoStorageID(repo.StorageID)),
StorageId: swag.String(c.getActualStorageID(repo.StorageID)),
StorageNamespace: repo.StorageNamespace,
ReadOnly: swag.Bool(repo.ReadOnly),
}
Expand Down

0 comments on commit 94f2895

Please sign in to comment.