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

Function GetMatchedDatabasesInDatabaseGroup

backend/utils/utils.go:155–170  ·  view source on GitHub ↗

GetMatchedDatabasesInDatabaseGroup returns the matched databases in the given database group.

(ctx context.Context, databaseGroup *store.DatabaseGroupMessage, allDatabases []*store.DatabaseMessage)

Source from the content-addressed store, hash-verified

153
154// GetMatchedDatabasesInDatabaseGroup returns the matched databases in the given database group.
155func GetMatchedDatabasesInDatabaseGroup(ctx context.Context, databaseGroup *store.DatabaseGroupMessage, allDatabases []*store.DatabaseMessage) ([]*store.DatabaseMessage, error) {
156 var matches []*store.DatabaseMessage
157
158 // DONOT check bb.feature.database-grouping for instance. The API here is read-only in the frontend, we need to show if the instance is matched but missing required license.
159 // The feature guard will works during issue creation.
160 for _, database := range allDatabases {
161 matched, err := CheckDatabaseGroupMatch(ctx, databaseGroup.Expression.Expression, database)
162 if err != nil {
163 return nil, err
164 }
165 if matched {
166 matches = append(matches, database)
167 }
168 }
169 return matches, nil
170}
171
172func CheckDatabaseGroupMatch(ctx context.Context, expression string, database *store.DatabaseMessage) (bool, error) {
173 prog, err := common.ValidateGroupCELExpr(expression)

Callers 5

unfoldDatabaseTargetsFunction · 0.92
CheckReleaseMethod · 0.92

Calls 1

CheckDatabaseGroupMatchFunction · 0.85

Tested by

no test coverage detected