Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: profile p (#12737)

p0ny5000e2bc59dc
diff --git a/backend/bin/server/cmd/profile.go b/backend/bin/server/cmd/profile.go
index 62ff376b7a..fc623367e7 100644
--- a/backend/bin/server/cmd/profile.go
+++ b/backend/bin/server/cmd/profile.go
@@ -7,14 +7,14 @@ import (
"github.com/bytebase/bytebase/backend/component/config"
)
-func getBaseProfile(dataDir string) config.Profile {
+func getBaseProfile(dataDir string) *config.Profile {
sampleDatabasePort := 0
if !flags.disableSample {
// Using flags.port + 3 as our sample database port if not disabled.
sampleDatabasePort = flags.port + 3
}
- return config.Profile{
+ return &config.Profile{
ExternalURL: flags.externalURL,
Port: flags.port, // Using flags.port as our gRPC server port.
DatastorePort: flags.port + 2, // Using flags.port + 2 as our datastore port.
diff --git a/backend/bin/server/cmd/profile_dev.go b/backend/bin/server/cmd/profile_dev.go
index 8de7eb04b1..2416f7a45a 100644
--- a/backend/bin/server/cmd/profile_dev.go
+++ b/backend/bin/server/cmd/profile_dev.go
@@ -9,7 +9,7 @@ import (
"github.com/bytebase/bytebase/backend/component/config"
)
-func activeProfile(dataDir string) config.Profile {
+func activeProfile(dataDir string) *config.Profile {
p := getBaseProfile(dataDir)
p.Mode = common.ReleaseModeDev
p.PgUser = "bbdev"
diff --git a/backend/bin/server/cmd/profile_release.go b/backend/bin/server/cmd/profile_release.go
index 60e2fd344b..0966934e4c 100644
--- a/backend/bin/server/cmd/profile_release.go
+++ b/backend/bin/server/cmd/profile_release.go
@@ -9,7 +9,7 @@ import (
"github.com/bytebase/bytebase/backend/component/config"
)
-func activeProfile(dataDir string) config.Profile {
+func activeProfile(dataDir string) *config.Profile {
p := getBaseProfile(dataDir)
p.Mode = common.ReleaseModeProd
p.PgUser = "bb"
diff --git a/backend/runner/schemasync/syncer.go b/backend/runner/schemasync/syncer.go
index 4fefb66322..84d3ef820a 100644
--- a/backend/runner/schemasync/syncer.go
+++ b/backend/runner/schemasync/syncer.go
@@ -41,7 +41,7 @@ const (
)
// NewSyncer creates a schema syncer.
-func NewSyncer(stores *store.Store, dbFactory *dbfactory.DBFactory, stateCfg *state.State, profile config.Profile, licenseService enterprise.LicenseService) *Syncer {
+func NewSyncer(stores *store.Store, dbFactory *dbfactory.DBFactory, stateCfg *state.State, profile *config.Profile, licenseService enterprise.LicenseService) *Syncer {
return &Syncer{
store: stores,
dbFactory: dbFactory,
@@ -58,7 +58,7 @@ type Syncer struct {
store *store.Store
dbFactory *dbfactory.DBFactory
stateCfg *state.State
- profile config.Profile
+ profile *config.Profile
licenseService enterprise.LicenseService
databaseSyncMap sync.Map // map[int]*store.DatabaseMessage
}
diff --git a/backend/runner/slowquerysync/syncer.go b/backend/runner/slowquerysync/syncer.go
index 9f7ac5e10b..6497efca04 100644
--- a/backend/runner/slowquerysync/syncer.go
+++ b/backend/runner/slowquerysync/syncer.go
@@ -30,7 +30,7 @@ const (
)
// NewSyncer creates a new slow query syncer.
-func NewSyncer(store *store.Store, dbFactory *dbfactory.DBFactory, stateCfg *state.State, profile config.Profile) *Syncer {
+func NewSyncer(store *store.Store, dbFactory *dbfactory.DBFactory, stateCfg *state.State, profile *config.Profile) *Syncer {
return &Syncer{
store: store,
dbFactory: dbFactory,
@@ -44,7 +44,7 @@ type Syncer struct {
store *store.Store
dbFactory *dbfactory.DBFactory
stateCfg *state.State
- profile config.Profile
+ profile *config.Profile
}
// Run will run the slow query syncer.
diff --git a/backend/runner/taskrun/data_export_executor.go b/backend/runner/taskrun/data_export_executor.go
index 7e0bc558e7..6fc6c96aa7 100644
--- a/backend/runner/taskrun/data_export_executor.go
+++ b/backend/runner/taskrun/data_export_executor.go
@@ -24,7 +24,7 @@ import (
)
// NewDataExportExecutor creates a data export task executor.
-func NewDataExportExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile config.Profile) Executor {
+func NewDataExportExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile *config.Profile) Executor {
return &DataExportExecutor{
store: store,
dbFactory: dbFactory,
@@ -42,7 +42,7 @@ type DataExportExecutor struct {
license enterprise.LicenseService
stateCfg *state.State
schemaSyncer *schemasync.Syncer
- profile config.Profile
+ profile *config.Profile
}
// RunOnce will run the data export task executor once.
diff --git a/backend/runner/taskrun/data_update_executor.go b/backend/runner/taskrun/data_update_executor.go
index 40fae17899..0efcf4e82e 100644
--- a/backend/runner/taskrun/data_update_executor.go
+++ b/backend/runner/taskrun/data_update_executor.go
@@ -29,7 +29,7 @@ import (
)
// NewDataUpdateExecutor creates a data update (DML) task executor.
-func NewDataUpdateExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile config.Profile) Executor {
+func NewDataUpdateExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile *config.Profile) Executor {
return &DataUpdateExecutor{
store: store,
dbFactory: dbFactory,
@@ -47,7 +47,7 @@ type DataUpdateExecutor struct {
license enterprise.LicenseService
stateCfg *state.State
schemaSyncer *schemasync.Syncer
- profile config.Profile
+ profile *config.Profile
}
// RunOnce will run the data update (DML) task executor once.
diff --git a/backend/runner/taskrun/database_create_executor.go b/backend/runner/taskrun/database_create_executor.go
index c0134e3035..fb0cd1a622 100644
--- a/backend/runner/taskrun/database_create_executor.go
+++ b/backend/runner/taskrun/database_create_executor.go
@@ -27,7 +27,7 @@ import (
)
// NewDatabaseCreateExecutor creates a database create task executor.
-func NewDatabaseCreateExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, schemaSyncer *schemasync.Syncer, stateCfg *state.State, profile config.Profile) Executor {
+func NewDatabaseCreateExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, schemaSyncer *schemasync.Syncer, stateCfg *state.State, profile *config.Profile) Executor {
return &DatabaseCreateExecutor{
store: store,
dbFactory: dbFactory,
@@ -43,7 +43,7 @@ type DatabaseCreateExecutor struct {
dbFactory *dbfactory.DBFactory
schemaSyncer *schemasync.Syncer
stateCfg *state.State
- profile config.Profile
+ profile *config.Profile
}
var cannotCreateDatabase = map[storepb.Engine]bool{
diff --git a/backend/runner/taskrun/executor.go b/backend/runner/taskrun/executor.go
index 94e464b2ff..8e37e0db52 100644
--- a/backend/runner/taskrun/executor.go
+++ b/backend/runner/taskrun/executor.go
@@ -56,7 +56,7 @@ func RunExecutorOnce(ctx context.Context, driverCtx context.Context, exec Execut
return exec.RunOnce(ctx, driverCtx, task, taskRunUID)
}
-func getMigrationInfo(ctx context.Context, stores *store.Store, profile config.Profile, task *store.TaskMessage, migrationType db.MigrationType, statement string, schemaVersion model.Version, sheetID *int) (*db.MigrationInfo, error) {
+func getMigrationInfo(ctx context.Context, stores *store.Store, profile *config.Profile, task *store.TaskMessage, migrationType db.MigrationType, statement string, schemaVersion model.Version, sheetID *int) (*db.MigrationInfo, error) {
if schemaVersion.Version == "" {
return nil, errors.Errorf("empty schema version")
}
@@ -184,7 +184,7 @@ func executeMigration(
stores *store.Store,
dbFactory *dbfactory.DBFactory,
stateCfg *state.State,
- profile config.Profile,
+ profile *config.Profile,
task *store.TaskMessage,
taskRunUID int,
statement string,
@@ -329,7 +329,7 @@ func postMigration(ctx context.Context, stores *store.Store, task *store.TaskMes
}, nil
}
-func runMigration(ctx context.Context, driverCtx context.Context, store *store.Store, dbFactory *dbfactory.DBFactory, stateCfg *state.State, profile config.Profile, task *store.TaskMessage, taskRunUID int, migrationType db.MigrationType, statement string, schemaVersion model.Version, sheetID *int) (terminated bool, result *storepb.TaskRunResult, err error) {
+func runMigration(ctx context.Context, driverCtx context.Context, store *store.Store, dbFactory *dbfactory.DBFactory, stateCfg *state.State, profile *config.Profile, task *store.TaskMessage, taskRunUID int, migrationType db.MigrationType, statement string, schemaVersion model.Version, sheetID *int) (terminated bool, result *storepb.TaskRunResult, err error) {
mi, err := getMigrationInfo(ctx, store, profile, task, migrationType, statement, schemaVersion, sheetID)
if err != nil {
return true, nil, err
diff --git a/backend/runner/taskrun/schema_baseline_executor.go b/backend/runner/taskrun/schema_baseline_executor.go
index 2aa24b552a..a7e49740a1 100644
--- a/backend/runner/taskrun/schema_baseline_executor.go
+++ b/backend/runner/taskrun/schema_baseline_executor.go
@@ -23,7 +23,7 @@ import (
)
// NewSchemaBaselineExecutor creates a schema baseline task executor.
-func NewSchemaBaselineExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile config.Profile) Executor {
+func NewSchemaBaselineExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile *config.Profile) Executor {
return &SchemaBaselineExecutor{
store: store,
dbFactory: dbFactory,
@@ -41,7 +41,7 @@ type SchemaBaselineExecutor struct {
license enterprise.LicenseService
stateCfg *state.State
schemaSyncer *schemasync.Syncer
- profile config.Profile
+ profile *config.Profile
}
// RunOnce will run the schema update (DDL) task executor once.
diff --git a/backend/runner/taskrun/schema_update_executor.go b/backend/runner/taskrun/schema_update_executor.go
index 2f20b26ad5..63052fdd83 100644
--- a/backend/runner/taskrun/schema_update_executor.go
+++ b/backend/runner/taskrun/schema_update_executor.go
@@ -23,7 +23,7 @@ import (
)
// NewSchemaUpdateExecutor creates a schema update (DDL) task executor.
-func NewSchemaUpdateExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile config.Profile) Executor {
+func NewSchemaUpdateExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile *config.Profile) Executor {
return &SchemaUpdateExecutor{
store: store,
dbFactory: dbFactory,
@@ -41,7 +41,7 @@ type SchemaUpdateExecutor struct {
license enterprise.LicenseService
stateCfg *state.State
schemaSyncer *schemasync.Syncer
- profile config.Profile
+ profile *config.Profile
}
// RunOnce will run the schema update (DDL) task executor once.
diff --git a/backend/runner/taskrun/schema_update_ghost_cutover_executor.go b/backend/runner/taskrun/schema_update_ghost_cutover_executor.go
index 75066816ce..596b1ebe9f 100644
--- a/backend/runner/taskrun/schema_update_ghost_cutover_executor.go
+++ b/backend/runner/taskrun/schema_update_ghost_cutover_executor.go
@@ -30,7 +30,7 @@ import (
)
// NewSchemaUpdateGhostCutoverExecutor creates a schema update (gh-ost) cutover task executor.
-func NewSchemaUpdateGhostCutoverExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile config.Profile) Executor {
+func NewSchemaUpdateGhostCutoverExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile *config.Profile) Executor {
return &SchemaUpdateGhostCutoverExecutor{
store: store,
dbFactory: dbFactory,
@@ -48,7 +48,7 @@ type SchemaUpdateGhostCutoverExecutor struct {
license enterprise.LicenseService
stateCfg *state.State
schemaSyncer *schemasync.Syncer
- profile config.Profile
+ profile *config.Profile
}
// RunOnce will run SchemaUpdateGhostCutover task once.
@@ -121,7 +121,7 @@ func (e *SchemaUpdateGhostCutoverExecutor) RunOnce(ctx context.Context, taskCont
return terminated, result, err
}
-func cutover(ctx context.Context, taskContext context.Context, stores *store.Store, dbFactory *dbfactory.DBFactory, stateCfg *state.State, profile config.Profile, task *store.TaskMessage, taskRunUID int, statement string, sheetID int, schemaVersion model.Version, postponeFilename string, migrationContext *base.MigrationContext, errCh <-chan error) (terminated bool, result *storepb.TaskRunResult, err error) {
+func cutover(ctx context.Context, taskContext context.Context, stores *store.Store, dbFactory *dbfactory.DBFactory, stateCfg *state.State, profile *config.Profile, task *store.TaskMessage, taskRunUID int, statement string, sheetID int, schemaVersion model.Version, postponeFilename string, migrationContext *base.MigrationContext, errCh <-chan error) (terminated bool, result *storepb.TaskRunResult, err error) {
statement = strings.TrimSpace(statement)
instance, err := stores.GetInstanceV2(ctx, &store.FindInstanceMessage{UID: &task.InstanceID})
if err != nil {
diff --git a/backend/runner/taskrun/schema_update_sdl_executor.go b/backend/runner/taskrun/schema_update_sdl_executor.go
index 7647f053d4..b32373b439 100644
--- a/backend/runner/taskrun/schema_update_sdl_executor.go
+++ b/backend/runner/taskrun/schema_update_sdl_executor.go
@@ -25,7 +25,7 @@ import (
)
// NewSchemaUpdateSDLExecutor creates a schema update (SDL) task executor.
-func NewSchemaUpdateSDLExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile config.Profile) Executor {
+func NewSchemaUpdateSDLExecutor(store *store.Store, dbFactory *dbfactory.DBFactory, license enterprise.LicenseService, stateCfg *state.State, schemaSyncer *schemasync.Syncer, profile *config.Profile) Executor {
return &SchemaUpdateSDLExecutor{
store: store,
dbFactory: dbFactory,
@@ -43,7 +43,7 @@ type SchemaUpdateSDLExecutor struct {
license enterprise.LicenseService
stateCfg *state.State
schemaSyncer *schemasync.Syncer
- profile config.Profile
+ profile *config.Profile
}
// RunOnce will run the schema update (SDL) task executor once.
diff --git a/backend/server/routers.go b/backend/server/routers.go
index c749625c3f..5b57fa2f95 100644
--- a/backend/server/routers.go
+++ b/backend/server/routers.go
@@ -22,7 +22,7 @@ import (
"github.com/bytebase/bytebase/backend/component/config"
)
-func configureEchoRouters(e *echo.Echo, grpcServer *grpc.Server, lspServer *lsp.Server, gitOpsServer *gitops.Service, mux *grpcruntime.ServeMux, profile config.Profile) {
+func configureEchoRouters(e *echo.Echo, grpcServer *grpc.Server, lspServer *lsp.Server, gitOpsServer *gitops.Service, mux *grpcruntime.ServeMux, profile *config.Profile) {
// Embed frontend.
embedFrontend(e)
diff --git a/backend/server/server.go b/backend/server/server.go
index 72590c1195..5e454cf97d 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -114,9 +114,9 @@ type Server struct {
}
// NewServer creates a server.
-func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {
+func NewServer(ctx context.Context, profile *config.Profile) (*Server, error) {
s := &Server{
- profile: &profile,
+ profile: profile,
startedTs: time.Now().Unix(),
errorRecordRing: api.NewErrorRecordRing(),
}
@@ -193,7 +193,7 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {
// return s so that caller can call s.Close() to shut down the postgres server if embedded.
return nil, errors.Wrap(err, "cannot open metadb")
}
- storeInstance, err := store.New(storeDB, &profile)
+ storeInstance, err := store.New(storeDB, profile)
if err != nil {
return nil, errors.Wrapf(err, "failed to new store")
}
diff --git a/backend/tests/tests.go b/backend/tests/tests.go
index a9b7ab334f..2533a84142 100644
--- a/backend/tests/tests.go
+++ b/backend/tests/tests.go
@@ -118,7 +118,7 @@ CREATE TABLE book2 (
type controller struct {
server *server.Server
- profile component.Profile
+ profile *component.Profile
client *http.Client
grpcConn *grpc.ClientConn
issueServiceClient v1pb.IssueServiceClient
@@ -308,8 +308,8 @@ func (ctl *controller) initWorkspaceProfile(ctx context.Context) error {
// GetTestProfile will return a profile for testing.
// We require port as an argument of GetTestProfile so that test can run in parallel in different ports.
-func getTestProfile(dataDir, resourceDir string, port int, readOnly bool) component.Profile {
- return component.Profile{
+func getTestProfile(dataDir, resourceDir string, port int, readOnly bool) *component.Profile {
+ return &component.Profile{
Mode: common.ReleaseModeDev,
ExternalURL: fmt.Sprintf("http://localhost:%d", port),
Port: port,
@@ -327,8 +327,8 @@ func getTestProfile(dataDir, resourceDir string, port int, readOnly bool) compon
// GetTestProfileWithExternalPg will return a profile for testing with external Postgres.
// We require port as an argument of GetTestProfile so that test can run in parallel in different ports,
// pgURL for connect to Postgres.
-func getTestProfileWithExternalPg(dataDir, resourceDir string, port int, pgUser string, pgURL string, skipOnboardingData bool) component.Profile {
- return component.Profile{
+func getTestProfileWithExternalPg(dataDir, resourceDir string, port int, pgUser string, pgURL string, skipOnboardingData bool) *component.Profile {
+ return &component.Profile{
Mode: common.ReleaseModeDev,
ExternalURL: fmt.Sprintf("http://localhost:%d", port),
Port: port,