MCPcopy Create free account
hub / github.com/bytebase/bytebase / GetDefaultProjectID

Method GetDefaultProjectID

backend/store/project.go:61–80  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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").
61func (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
82func (s *Store) GetProject(ctx context.Context, find *FindProjectMessage) (*ProjectMessage, error) {
83 if find.ResourceID != nil {

Callers 4

DeleteProjectMethod · 0.95
SyncInstanceMethod · 0.80
getServerInfoMethod · 0.80
DeleteInstanceMethod · 0.80

Calls 2

GetProjectMethod · 0.95
DefaultProjectIDFunction · 0.92

Tested by

no test coverage detected