GetProject gets project by resource ID. GetDefaultProjectID returns the default project resource ID for the given workspace. Checks for new format ("default-{workspaceID}") first, falls back to legacy ("default").
(ctx context.Context, workspace string)
| 59 | // GetDefaultProjectID returns the default project resource ID for the given workspace. |
| 60 | // Checks for new format ("default-{workspaceID}") first, falls back to legacy ("default"). |
| 61 | func (s *Store) GetDefaultProjectID(ctx context.Context, workspace string) (string, error) { |
| 62 | newID := common.DefaultProjectID(workspace) |
| 63 | project, err := s.GetProject(ctx, &FindProjectMessage{Workspace: workspace, ResourceID: new(newID)}) |
| 64 | if err != nil { |
| 65 | return "", err |
| 66 | } |
| 67 | if project != nil { |
| 68 | return newID, nil |
| 69 | } |
| 70 | // Legacy fallback. |
| 71 | legacyID := "default" |
| 72 | project, err = s.GetProject(ctx, &FindProjectMessage{Workspace: workspace, ResourceID: &legacyID}) |
| 73 | if err != nil { |
| 74 | return "", err |
| 75 | } |
| 76 | if project != nil { |
| 77 | return legacyID, nil |
| 78 | } |
| 79 | return newID, nil |
| 80 | } |
| 81 | |
| 82 | func (s *Store) GetProject(ctx context.Context, find *FindProjectMessage) (*ProjectMessage, error) { |
| 83 | if find.ResourceID != nil { |
no test coverage detected