( ctx context.Context, databaseGroup *store.DatabaseGroupMessage, projectResourceID string, databases []*store.DatabaseMessage, )
| 299 | } |
| 300 | |
| 301 | func 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 | } |
no test coverage detected