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

Method getEnterpriseByID

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

Source from the content-addressed store, hash-verified

268}
269
270func (s *sqlDatabase) getEnterpriseByID(_ context.Context, tx *gorm.DB, id string, preload ...string) (Enterprise, error) {
271 u, err := uuid.Parse(id)
272 if err != nil {
273 return Enterprise{}, fmt.Errorf("error parsing id: %w", runnerErrors.ErrBadRequest)
274 }
275 var enterprise Enterprise
276
277 q := tx
278 if len(preload) > 0 {
279 for _, field := range preload {
280 q = q.Preload(field)
281 }
282 }
283 q = q.Where("id = ?", u).First(&enterprise)
284
285 if q.Error != nil {
286 if errors.Is(q.Error, gorm.ErrRecordNotFound) {
287 return Enterprise{}, runnerErrors.ErrNotFound
288 }
289 return Enterprise{}, fmt.Errorf("error fetching enterprise from database: %w", q.Error)
290 }
291 return enterprise, nil
292}

Callers 5

addEnterpriseEventMethod · 0.95
CreateEnterpriseMethod · 0.95
GetEnterpriseByIDMethod · 0.95
DeleteEnterpriseMethod · 0.95
UpdateEnterpriseMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected