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

Method hasGithubEntity

database/sql/util.go:735–760  ·  view source on GitHub ↗
(tx *gorm.DB, entityType params.ForgeEntityType, entityID string)

Source from the content-addressed store, hash-verified

733}
734
735func (s *sqlDatabase) hasGithubEntity(tx *gorm.DB, entityType params.ForgeEntityType, entityID string) error {
736 u, err := uuid.Parse(entityID)
737 if err != nil {
738 return fmt.Errorf("error parsing id: %w", runnerErrors.ErrBadRequest)
739 }
740 var q *gorm.DB
741 switch entityType {
742 case params.ForgeEntityTypeRepository:
743 q = tx.Model(&Repository{}).Where("id = ?", u)
744 case params.ForgeEntityTypeOrganization:
745 q = tx.Model(&Organization{}).Where("id = ?", u)
746 case params.ForgeEntityTypeEnterprise:
747 q = tx.Model(&Enterprise{}).Where("id = ?", u)
748 default:
749 return fmt.Errorf("error invalid entity type: %w", runnerErrors.ErrBadRequest)
750 }
751
752 var entity interface{}
753 if err := q.First(entity).Error; err != nil {
754 if errors.Is(err, gorm.ErrRecordNotFound) {
755 return fmt.Errorf("error entity not found: %w", runnerErrors.ErrNotFound)
756 }
757 return fmt.Errorf("error fetching entity from database: %w", err)
758 }
759 return nil
760}
761
762func (s *sqlDatabase) marshalAndSeal(data interface{}) ([]byte, error) {
763 enc, err := json.Marshal(data)

Callers 4

listEntityPoolsMethod · 0.95
CreateEntityPoolMethod · 0.95
CreateEntityScaleSetMethod · 0.95
listEntityScaleSetsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected