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

Method getOrgByID

database/sql/organizations.go:258–280  ·  view source on GitHub ↗
(_ context.Context, db *gorm.DB, id string, preload ...string)

Source from the content-addressed store, hash-verified

256}
257
258func (s *sqlDatabase) getOrgByID(_ context.Context, db *gorm.DB, id string, preload ...string) (Organization, error) {
259 u, err := uuid.Parse(id)
260 if err != nil {
261 return Organization{}, fmt.Errorf("error parsing id: %w", runnerErrors.ErrBadRequest)
262 }
263 var org Organization
264
265 q := db
266 if len(preload) > 0 {
267 for _, field := range preload {
268 q = q.Preload(field)
269 }
270 }
271 q = q.Where("id = ?", u).First(&org)
272
273 if q.Error != nil {
274 if errors.Is(q.Error, gorm.ErrRecordNotFound) {
275 return Organization{}, runnerErrors.ErrNotFound
276 }
277 return Organization{}, fmt.Errorf("error fetching org from database: %w", q.Error)
278 }
279 return org, nil
280}
281
282func (s *sqlDatabase) getOrg(_ context.Context, name, endpointName string) (Organization, error) {
283 var org Organization

Callers 4

addOrgEventMethod · 0.95
DeleteOrganizationMethod · 0.95
UpdateOrganizationMethod · 0.95
GetOrganizationByIDMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected