MCPcopy Create free account
hub / github.com/cloudbase/garm / getRepoByID

Method getRepoByID

database/sql/repositories.go:282–304  ·  view source on GitHub ↗
(_ context.Context, tx *gorm.DB, id string, preload ...string)

Source from the content-addressed store, hash-verified

280}
281
282func (s *sqlDatabase) getRepoByID(_ context.Context, tx *gorm.DB, id string, preload ...string) (Repository, error) {
283 u, err := uuid.Parse(id)
284 if err != nil {
285 return Repository{}, runnerErrors.NewBadRequestError("error parsing id: %s", err)
286 }
287 var repo Repository
288
289 q := tx
290 if len(preload) > 0 {
291 for _, field := range preload {
292 q = q.Preload(field)
293 }
294 }
295 q = q.Where("id = ?", u).First(&repo)
296
297 if q.Error != nil {
298 if errors.Is(q.Error, gorm.ErrRecordNotFound) {
299 return Repository{}, runnerErrors.ErrNotFound
300 }
301 return Repository{}, fmt.Errorf("error fetching repository from database: %w", q.Error)
302 }
303 return repo, nil
304}

Callers 4

DeleteRepositoryMethod · 0.95
UpdateRepositoryMethod · 0.95
GetRepositoryByIDMethod · 0.95
addRepositoryEventMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected