(tx *gorm.DB, entityType params.ForgeEntityType, entityID string)
| 733 | } |
| 734 | |
| 735 | func (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 | |
| 762 | func (s *sqlDatabase) marshalAndSeal(data interface{}) ([]byte, error) { |
| 763 | enc, err := json.Marshal(data) |
no outgoing calls
no test coverage detected