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

Method DeleteOrganization

database/sql/organizations.go:129–152  ·  view source on GitHub ↗
(ctx context.Context, orgID string)

Source from the content-addressed store, hash-verified

127}
128
129func (s *sqlDatabase) DeleteOrganization(ctx context.Context, orgID string) (err error) {
130 org, err := s.getOrgByID(ctx, s.conn, orgID, "Endpoint", "Credentials", "Credentials.Endpoint", "GiteaCredentials", "GiteaCredentials.Endpoint")
131 if err != nil {
132 return fmt.Errorf("error fetching org: %w", err)
133 }
134
135 defer func(org Organization) {
136 if err == nil {
137 asParam, innerErr := s.sqlToCommonOrganization(org, true)
138 if innerErr == nil {
139 s.sendNotify(common.OrganizationEntityType, common.DeleteOperation, asParam)
140 } else {
141 slog.With(slog.Any("error", innerErr)).ErrorContext(ctx, "error sending delete notification", "org", orgID)
142 }
143 }
144 }(org)
145
146 q := s.conn.Unscoped().Delete(&org)
147 if q.Error != nil && !errors.Is(q.Error, gorm.ErrRecordNotFound) {
148 return fmt.Errorf("error deleting org: %w", q.Error)
149 }
150
151 return nil
152}
153
154func (s *sqlDatabase) UpdateOrganization(ctx context.Context, orgID string, param params.UpdateEntityParams) (paramOrg params.Organization, err error) {
155 var rowsAffected int64

Callers

nothing calls this directly

Calls 4

getOrgByIDMethod · 0.95
sendNotifyMethod · 0.95
DeleteMethod · 0.65

Tested by

no test coverage detected