(ctx context.Context)
| 372 | } |
| 373 | |
| 374 | func (s *sqlDatabase) ListGithubCredentials(ctx context.Context) ([]params.ForgeCredentials, error) { |
| 375 | q := s.conn.Preload("Endpoint") |
| 376 | if !auth.IsAdmin(ctx) { |
| 377 | userID, err := getUIDFromContext(ctx) |
| 378 | if err != nil { |
| 379 | return nil, fmt.Errorf("error fetching github credentials: %w", err) |
| 380 | } |
| 381 | q = q.Where("user_id = ?", userID) |
| 382 | } |
| 383 | |
| 384 | var creds []GithubCredentials |
| 385 | err := q.Preload("Endpoint").Find(&creds).Error |
| 386 | if err != nil { |
| 387 | return nil, fmt.Errorf("error fetching github credentials: %w", err) |
| 388 | } |
| 389 | |
| 390 | var ret []params.ForgeCredentials |
| 391 | for _, c := range creds { |
| 392 | commonCreds, err := s.sqlToCommonForgeCredentials(c) |
| 393 | if err != nil { |
| 394 | return nil, fmt.Errorf("error converting github credentials: %w", err) |
| 395 | } |
| 396 | ret = append(ret, commonCreds) |
| 397 | } |
| 398 | return ret, nil |
| 399 | } |
| 400 | |
| 401 | func (s *sqlDatabase) UpdateGithubCredentials(ctx context.Context, id uint, param params.UpdateGithubCredentialsParams) (ghCreds params.ForgeCredentials, err error) { |
| 402 | var rowsAffected int64 |
nothing calls this directly
no test coverage detected