MCPcopy Index your code
hub / github.com/bytebase/bytebase / convertStoreToV1DatabaseGroup

Function convertStoreToV1DatabaseGroup

backend/api/v1/database_group_service.go:301–323  ·  view source on GitHub ↗
(
	ctx context.Context,
	databaseGroup *store.DatabaseGroupMessage,
	projectResourceID string,
	databases []*store.DatabaseMessage,
)

Source from the content-addressed store, hash-verified

299}
300
301func convertStoreToV1DatabaseGroup(
302 ctx context.Context,
303 databaseGroup *store.DatabaseGroupMessage,
304 projectResourceID string,
305 databases []*store.DatabaseMessage,
306) (*v1pb.DatabaseGroup, error) {
307 ret := &v1pb.DatabaseGroup{
308 Name: fmt.Sprintf("%s/%s%s", common.FormatProject(projectResourceID), common.DatabaseGroupNamePrefix, databaseGroup.ResourceID),
309 Title: databaseGroup.Title,
310 DatabaseExpr: databaseGroup.Expression,
311 }
312
313 matches, err := utils.GetMatchedDatabasesInDatabaseGroup(ctx, databaseGroup, databases)
314 if err != nil {
315 return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get matched databases for group %v with error: %v", ret.Name, err.Error()))
316 }
317 for _, database := range matches {
318 ret.MatchedDatabases = append(ret.MatchedDatabases, &v1pb.DatabaseGroup_Database{
319 Name: common.FormatDatabase(database.InstanceID, database.DatabaseName),
320 })
321 }
322 return ret, nil
323}

Callers 2

ListDatabaseGroupsMethod · 0.85

Calls 5

FormatProjectFunction · 0.92
FormatDatabaseFunction · 0.92
ErrorfMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected