Skip to content

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

refactor: modernize pointer construction for Go 1.26 (#19745)

p0ny7d81e51c3fba
diff --git a/action/command/api.go b/action/command/api.go
index 1fbbed7370..57bc5afd2a 100644
--- a/action/command/api.go
+++ b/action/command/api.go
@@ -120,7 +120,7 @@ func createClient(url, accessToken, serviceAccount, serviceAccountSecret string,
unifiedInt := newUnifiedInterceptor(opts.RetryConfig, tokenRefresher)
interceptors := connect.WithInterceptors(unifiedInt)
- c := Client{
+ return &Client{
httpClient: httpClient,
url: url,
serviceAccount: serviceAccount,
@@ -130,9 +130,7 @@ func createClient(url, accessToken, serviceAccount, serviceAccountSecret string,
planClient: v1connect.NewPlanServiceClient(httpClient, url, interceptors),
rolloutClient: v1connect.NewRolloutServiceClient(httpClient, url, interceptors),
actuatorClient: v1connect.NewActuatorServiceClient(httpClient, url, interceptors),
- }
-
- return &c, nil
+ }, nil
}
func getTokenRefresher(httpClient connect.HTTPClient, email, password, url string) func(ctx context.Context) (string, error) {
@@ -234,10 +232,9 @@ func (c *Client) ListTaskRuns(ctx context.Context, r *v1pb.ListTaskRunsRequest)
}
func (c *Client) ListAllTaskRuns(ctx context.Context, rolloutName string) (*v1pb.ListTaskRunsResponse, error) {
- request := &v1pb.ListTaskRunsRequest{
+ return c.ListTaskRuns(ctx, &v1pb.ListTaskRunsRequest{
Parent: rolloutName + "/stages/-/tasks/-",
- }
- return c.ListTaskRuns(ctx, request)
+ })
}
func (c *Client) BatchCancelTaskRuns(ctx context.Context, r *v1pb.BatchCancelTaskRunsRequest) (*v1pb.BatchCancelTaskRunsResponse, error) {
diff --git a/backend/api/directory-sync/webhook.go b/backend/api/directory-sync/webhook.go
index ac79cf7744..d4c4a5e832 100644
--- a/backend/api/directory-sync/webhook.go
+++ b/backend/api/directory-sync/webhook.go
@@ -268,9 +268,8 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
})
}
- deleteUser := true
if _, err := s.store.UpdateUser(ctx, user, &store.UpdateUserMessage{
- Delete: &deleteUser,
+ Delete: new(true),
}); err != nil {
return c.String(http.StatusInternalServerError, fmt.Sprintf("failed to delete user, error %v", err))
}
@@ -387,8 +386,7 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
slog.Warn("unsupport value, expect bool or string", slog.String("operation", op.OP), slog.String("path", op.Path), slog.Any("value", op.Value))
continue
}
- isDelete := !active
- updateUser.Delete = &isDelete
+ updateUser.Delete = new(!active)
case "":
// Empty path with replace operation - Okta sends full resource attributes.
// Per RFC 7644 Section 3.5.2.3: If path is omitted, the value must be a complex
@@ -411,8 +409,7 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
}
}
if active, ok := parseBoolValue(valueMap["active"]); ok {
- isDelete := !active
- updateUser.Delete = &isDelete
+ updateUser.Delete = new(!active)
}
// Handle nested name object (name.givenName, name.familyName)
if nameObj, ok := valueMap["name"].(map[string]any); ok {
@@ -424,8 +421,7 @@ func (s *Service) RegisterDirectorySyncRoutes(g *echo.Group) {
nameParts = append(nameParts, familyName)
}
if len(nameParts) > 0 {
- fullName := strings.Join(nameParts, " ")
- updateUser.Name = &fullName
+ updateUser.Name = new(strings.Join(nameParts, " "))
}
}
default:
@@ -929,9 +925,8 @@ func (s *Service) updateUserFromSCIM(ctx context.Context, user *store.UserMessag
if !common.IsValidEmail(normalizedEmail) {
return nil, errors.Errorf("email %q contains non-ASCII characters", scimUser.UserName)
}
- deleted := !scimUser.Active
patch := &store.UpdateUserMessage{
- Delete: &deleted,
+ Delete: new(!scimUser.Active),
Name: &scimUser.DisplayName,
Email: &normalizedEmail,
Profile: user.Profile,
diff --git a/backend/api/lsp/handler.go b/backend/api/lsp/handler.go
index 95a361e827..0f715fff8d 100644
--- a/backend/api/lsp/handler.go
+++ b/backend/api/lsp/handler.go
@@ -108,8 +108,7 @@ func (h *Handler) ShutDown() {
func (h *Handler) setMetadata(arg SetMetadataCommandArguments) {
h.mu.Lock()
defer h.mu.Unlock()
- tmp := arg
- h.metadata = &tmp
+ h.metadata = new(arg)
}
func (h *Handler) getDefaultDatabase() string {
diff --git a/backend/api/v1/access_grant_service.go b/backend/api/v1/access_grant_service.go
index d06c634441..9db2564652 100644
--- a/backend/api/v1/access_grant_service.go
+++ b/backend/api/v1/access_grant_service.go
@@ -182,8 +182,7 @@ func (s *AccessGrantService) CreateAccessGrant(ctx context.Context, request *con
if exp.ExpireTime == nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("expire_time is required"))
}
- t := exp.ExpireTime.AsTime()
- expireTime = &t
+ expireTime = new(exp.ExpireTime.AsTime())
case *v1pb.AccessGrant_Ttl:
if exp.Ttl == nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.New("ttl is required"))
@@ -296,15 +295,13 @@ func activateAccessGrant(ctx context.Context, stores *store.Store, accessGrantNa
return nil, connect.NewError(connect.CodeNotFound, errors.Errorf("access grant %q not found", accessGrantName))
}
- status := storepb.AccessGrant_ACTIVE
update := &store.UpdateAccessGrantMessage{
- Status: &status,
+ Status: new(storepb.AccessGrant_ACTIVE),
}
// If the grant was created with a TTL, compute expire_time at activation time.
if refreshExpireTime && grant.Payload != nil && grant.Payload.RequestedDuration != nil {
- expireTime := time.Now().Add(grant.Payload.RequestedDuration.AsDuration())
- update.ExpireTime = &expireTime
+ update.ExpireTime = new(time.Now().Add(grant.Payload.RequestedDuration.AsDuration()))
}
updated, err := stores.UpdateAccessGrant(ctx, accessGrantID, update)
@@ -341,9 +338,8 @@ func (s *AccessGrantService) RevokeAccessGrant(ctx context.Context, request *con
return nil, connect.NewError(connect.CodeFailedPrecondition, errors.Errorf("access grant %q is not in ACTIVE status", req.Name))
}
- status := storepb.AccessGrant_REVOKED
updated, err := s.store.UpdateAccessGrant(ctx, accessGrantID, &store.UpdateAccessGrantMessage{
- Status: &status,
+ Status: new(storepb.AccessGrant_REVOKED),
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to revoke access grant"))
diff --git a/backend/api/v1/ai_service.go b/backend/api/v1/ai_service.go
index 62609f1f60..22216f8fef 100644
--- a/backend/api/v1/ai_service.go
+++ b/backend/api/v1/ai_service.go
@@ -158,8 +158,7 @@ func buildChatToolCallMetadata(rawOpenAIToolCall json.RawMessage, geminiThoughtS
if err != nil {
return nil, err
}
- metadataString := string(metadataBytes)
- return &metadataString, nil
+ return new(string(metadataBytes)), nil
}
func openAIToolCallFromMetadata(raw string) json.RawMessage {
diff --git a/backend/api/v1/database_service.go b/backend/api/v1/database_service.go
index 917ec191d1..3309712963 100644
--- a/backend/api/v1/database_service.go
+++ b/backend/api/v1/database_service.go
@@ -84,7 +84,7 @@ func (s *DatabaseService) BatchGetDatabases(ctx context.Context, req *connect.Re
if err != nil {
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("invalid parent %q", req.Msg.Parent))
}
- projectIDFilter = &projectID
+ projectIDFilter = new(projectID)
}
// For instances/{instance} or "-" (wildcard), no project filter is applied.
databases := make([]*v1pb.Database, 0, len(req.Msg.Names))
@@ -346,8 +346,7 @@ func (s *DatabaseService) UpdateDatabase(ctx context.Context, req *connect.Reque
}
patch.EnvironmentID = &environmentID
} else {
- unsetEnvironment := ""
- patch.EnvironmentID = &unsetEnvironment
+ patch.EnvironmentID = new("")
}
case "drifted":
// Create a new base schema.
@@ -509,8 +508,7 @@ func getDatabaseMetadataFilter(filter string) (*metadataFilter, error) {
}
switch variable {
case "schema":
- lowerValue := strings.ToLower(strValue)
- metaFilter.schema = &lowerValue
+ metaFilter.schema = new(strings.ToLower(strValue))
case "table":
metaFilter.table = &tableMetadataFilter{
name: strings.ToLower(strValue),
@@ -1006,12 +1004,10 @@ func (s *DatabaseService) convertToDatabase(ctx context.Context, database *store
var environment, effectiveEnvironment *string
if database.EnvironmentID != nil && *database.EnvironmentID != "" {
- env := common.FormatEnvironment(*database.EnvironmentID)
- environment = &env
+ environment = new(common.FormatEnvironment(*database.EnvironmentID))
}
if database.EffectiveEnvironmentID != nil && *database.EffectiveEnvironmentID != "" {
- effEnv := common.FormatEnvironment(*database.EffectiveEnvironmentID)
- effectiveEnvironment = &effEnv
+ effectiveEnvironment = new(common.FormatEnvironment(*database.EffectiveEnvironmentID))
}
instanceResource := convertToV1InstanceResource(instance)
return &v1pb.Database{
diff --git a/backend/api/v1/instance_service.go b/backend/api/v1/instance_service.go
index 3cedb5f08b..eedd0b860f 100644
--- a/backend/api/v1/instance_service.go
+++ b/backend/api/v1/instance_service.go
@@ -352,8 +352,7 @@ func (s *InstanceService) UpdateInstance(ctx context.Context, req *connect.Reque
case "environment":
if req.Msg.Instance.Environment == nil || *req.Msg.Instance.Environment == "" {
// Clear the environment if null or empty string is provided
- emptyStr := ""
- patch.EnvironmentID = &emptyStr
+ patch.EnvironmentID = new("")
} else {
envID, err := common.GetEnvironmentID(*req.Msg.Instance.Environment)
if err != nil {
diff --git a/backend/api/v1/issue_hook.go b/backend/api/v1/issue_hook.go
index b994542cf9..bf64ea7fa0 100644
--- a/backend/api/v1/issue_hook.go
+++ b/backend/api/v1/issue_hook.go
@@ -109,8 +109,7 @@ func completeAccessRequestIssue(ctx context.Context, stores *store.Store, userEm
return issue, nil
}
- newStatus := storepb.Issue_DONE
- updatedIssue, err := stores.UpdateIssue(ctx, issue.ProjectID, issue.UID, &store.UpdateIssueMessage{Status: &newStatus})
+ updatedIssue, err := stores.UpdateIssue(ctx, issue.ProjectID, issue.UID, &store.UpdateIssueMessage{Status: new(storepb.Issue_DONE)})
if err != nil {
return nil, errors.Wrapf(err, "failed to update issue %q's status", issue.Title)
}
diff --git a/backend/api/v1/issue_service.go b/backend/api/v1/issue_service.go
index 68a2fcba60..acd3bde840 100644
--- a/backend/api/v1/issue_service.go
+++ b/backend/api/v1/issue_service.go
@@ -134,8 +134,7 @@ func (s *IssueService) getIssueFind(
if !ok {
return "", connect.NewError(connect.CodeInvalidArgument, errors.Errorf(`invalid approval_status %q`, value))
}
- approvalStatus := v1pb.Issue_ApprovalStatus(approvalStatusValue)
- filterIssue.ApprovalStatus = &approvalStatus
+ filterIssue.ApprovalStatus = new(v1pb.Issue_ApprovalStatus(approvalStatusValue))
case "current_approver", "creator":
user, err := s.getUserByIdentifier(ctx, value.(string))
if err != nil {
@@ -187,7 +186,7 @@ func (s *IssueService) getIssueFind(
issueFind.StatusList = append(issueFind.StatusList, newStatus)
}
case "type":
- types := []storepb.Issue_Type{}
+ var types []storepb.Issue_Type
for _, raw := range rawList {
issueType, err := convertToAPIIssueType(v1pb.Issue_Type(v1pb.Issue_Type_value[raw.(string)]))
if err != nil {
@@ -1029,7 +1028,6 @@ func (s *IssueService) BatchUpdateIssuesStatus(ctx context.Context, req *connect
// Batch create issue comments.
issueComments := make([]*store.IssueCommentMessage, 0, len(issueUIDs))
for _, issueUID := range issueUIDs {
- oldStatus := oldIssueStatuses[issueUID]
issueComments = append(issueComments, &store.IssueCommentMessage{
ProjectID: projectID,
IssueUID: issueUID,
@@ -1037,7 +1035,7 @@ func (s *IssueService) BatchUpdateIssuesStatus(ctx context.Context, req *connect
Comment: req.Msg.Reason,
Event: &storepb.IssueCommentPayload_IssueUpdate_{
IssueUpdate: &storepb.IssueCommentPayload_IssueUpdate{
- FromStatus: &oldStatus,
+ FromStatus: new(oldIssueStatuses[issueUID]),
ToStatus: &newStatus,
},
},
diff --git a/backend/api/v1/masking_evaluator_test.go b/backend/api/v1/masking_evaluator_test.go
index bfc1eacdfb..1164772404 100644
--- a/backend/api/v1/masking_evaluator_test.go
+++ b/backend/api/v1/masking_evaluator_test.go
@@ -38,10 +38,7 @@ func TestEvalMaskingLevelOfColumn(t *testing.T) {
"1-1-1": {
Id: "1-1-1",
Title: "personal",
- Level: func() *int32 {
- a := int32(2)
- return &a
- }(),
+ Level: new(int32(2)),
},
},
},
diff --git a/backend/api/v1/plan_service.go b/backend/api/v1/plan_service.go
index b074d90da0..a5c91c9fa9 100644
--- a/backend/api/v1/plan_service.go
+++ b/backend/api/v1/plan_service.go
@@ -294,14 +294,11 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *connect.Request[v
for _, path := range req.UpdateMask.Paths {
switch path {
case "title":
- title := req.Plan.Title
- planUpdate.Name = &title
+ planUpdate.Name = new(req.Plan.Title)
case "description":
- description := req.Plan.Description
- planUpdate.Description = &description
+ planUpdate.Description = new(req.Plan.Description)
case "state":
- deleted := req.Plan.State == v1pb.State_DELETED
- planUpdate.Deleted = &deleted
+ planUpdate.Deleted = new(req.Plan.State == v1pb.State_DELETED)
case "specs":
// Block all spec changes if plan has a rollout (pipeline).
// Block all spec changes if plan has a rollout (pipeline).
diff --git a/backend/api/v1/project_service_converter.go b/backend/api/v1/project_service_converter.go
index a2ffef6d7d..f549178532 100644
--- a/backend/api/v1/project_service_converter.go
+++ b/backend/api/v1/project_service_converter.go
@@ -19,12 +19,11 @@ import (
func convertToProtoAny(i any) (*anypb.Any, error) {
switch deltas := i.(type) {
case []*v1pb.BindingDelta:
- auditData := v1pb.AuditData{
+ return anypb.New(&v1pb.AuditData{
PolicyDelta: &v1pb.PolicyDelta{
BindingDeltas: deltas,
},
- }
- return anypb.New(&auditData)
+ })
default:
return &anypb.Any{}, nil
}
@@ -319,23 +318,22 @@ func convertToStoreExecutionRetryPolicy(policy *v1pb.Project_ExecutionRetryPolic
}
func convertToProjectMessage(resourceID string, project *v1pb.Project) *store.ProjectMessage {
- setting := &storepb.Project{
- EnforceIssueTitle: project.EnforceIssueTitle,
- PostgresDatabaseTenantMode: project.PostgresDatabaseTenantMode,
- AllowSelfApproval: project.AllowSelfApproval,
- CiSamplingSize: project.CiSamplingSize,
- ParallelTasksPerRollout: project.ParallelTasksPerRollout,
- Labels: project.Labels,
- EnforceSqlReview: project.EnforceSqlReview,
- RequireIssueApproval: project.RequireIssueApproval,
- RequirePlanCheckNoError: project.RequirePlanCheckNoError,
- AllowRequestRole: project.AllowRequestRole,
- AllowJustInTimeAccess: project.AllowJustInTimeAccess,
- DataClassificationConfigId: project.DataClassificationConfigId,
- }
return &store.ProjectMessage{
ResourceID: resourceID,
Title: project.Title,
- Setting: setting,
+ Setting: &storepb.Project{
+ EnforceIssueTitle: project.EnforceIssueTitle,
+ PostgresDatabaseTenantMode: project.PostgresDatabaseTenantMode,
+ AllowSelfApproval: project.AllowSelfApproval,
+ CiSamplingSize: project.CiSamplingSize,
+ ParallelTasksPerRollout: project.ParallelTasksPerRollout,
+ Labels: project.Labels,
+ EnforceSqlReview: project.EnforceSqlReview,
+ RequireIssueApproval: project.RequireIssueApproval,
+ RequirePlanCheckNoError: project.RequirePlanCheckNoError,
+ AllowRequestRole: project.AllowRequestRole,
+ AllowJustInTimeAccess: project.AllowJustInTimeAccess,
+ DataClassificationConfigId: project.DataClassificationConfigId,
+ },
}
}
diff --git a/backend/api/v1/release_service_check.go b/backend/api/v1/release_service_check.go
index 01166691f4..7fb60f8557 100644
--- a/backend/api/v1/release_service_check.go
+++ b/backend/api/v1/release_service_check.go
@@ -193,7 +193,7 @@ loop:
revisions, err := s.store.ListRevisions(ctx, &store.FindRevisionMessage{
InstanceID: database.InstanceID,
DatabaseName: &database.DatabaseName,
- Type: common.NewP(storepb.SchemaChangeType_VERSIONED),
+ Type: new(storepb.SchemaChangeType_VERSIONED),
Versions: &releaseFileVersions,
ShowDeleted: false,
})
@@ -371,8 +371,8 @@ func (s *ReleaseService) checkReleaseDeclarative(ctx context.Context, files []*v
revisions, err := s.store.ListRevisions(ctx, &store.FindRevisionMessage{
InstanceID: database.InstanceID,
DatabaseName: &database.DatabaseName,
- Type: common.NewP(storepb.SchemaChangeType_DECLARATIVE),
- Limit: common.NewP(1),
+ Type: new(storepb.SchemaChangeType_DECLARATIVE),
+ Limit: new(1),
ShowDeleted: false,
})
if err != nil {
diff --git a/backend/api/v1/review_config_service.go b/backend/api/v1/review_config_service.go
index d46828935e..e10ff4a1ca 100644
--- a/backend/api/v1/review_config_service.go
+++ b/backend/api/v1/review_config_service.go
@@ -191,12 +191,11 @@ func (s *ReviewConfigService) DeleteReviewConfig(ctx context.Context, req *conne
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to marshal tag policy"))
}
- patch := string(payloadBytes)
if _, err := s.store.UpdatePolicy(ctx, &store.UpdatePolicyMessage{
ResourceType: policy.ResourceType,
Resource: policy.Resource,
Workspace: policy.Workspace,
- Payload: &patch,
+ Payload: new(string(payloadBytes)),
}); err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrap(err, "failed to update tag policy"))
}
diff --git a/backend/api/v1/rollout_service_converter.go b/backend/api/v1/rollout_service_converter.go
index 1a64de4e11..d4eaaf2226 100644
--- a/backend/api/v1/rollout_service_converter.go
+++ b/backend/api/v1/rollout_service_converter.go
@@ -312,11 +312,6 @@ func convertToTaskFromDatabaseDataExport(project *store.ProjectMessage, task *st
targetDatabaseName := fmt.Sprintf("%s%s/%s%s", common.InstanceNamePrefix, task.InstanceID, common.DatabaseIDPrefix, *(task.DatabaseName))
sheet := common.FormatSheet(project.ResourceID, task.Payload.GetSheetSha256())
- v1pbTaskPayload := v1pb.Task_DatabaseDataExport_{
- DatabaseDataExport: &v1pb.Task_DatabaseDataExport{
- Sheet: sheet,
- },
- }
stageID := common.FormatStageID(task.Environment)
v1pbTask := &v1pb.Task{
Name: common.FormatTask(project.ResourceID, task.PlanID, stageID, task.ID),
@@ -325,7 +320,11 @@ func convertToTaskFromDatabaseDataExport(project *store.ProjectMessage, task *st
Status: convertToTaskStatus(task.LatestTaskRunStatus, task.Payload.GetSkipped()),
SkippedReason: task.Payload.GetSkippedReason(),
Target: targetDatabaseName,
- Payload: &v1pbTaskPayload,
+ Payload: &v1pb.Task_DatabaseDataExport_{
+ DatabaseDataExport: &v1pb.Task_DatabaseDataExport{
+ Sheet: sheet,
+ },
+ },
}
if task.UpdatedAt != nil {
v1pbTask.UpdateTime = timestamppb.New(*task.UpdatedAt)
@@ -386,15 +385,14 @@ func convertToTaskRunLogEntries(logs []*store.TaskRunLog) []*v1pb.TaskRunLogEntr
for _, l := range logs {
switch l.Payload.Type {
case storepb.TaskRunLog_SCHEMA_DUMP_START:
- e := &v1pb.TaskRunLogEntry{
+ entries = append(entries, &v1pb.TaskRunLogEntry{
Type: v1pb.TaskRunLogEntry_SCHEMA_DUMP,
LogTime: timestamppb.New(l.T),
ReplicaId: l.Payload.ReplicaId,
SchemaDump: &v1pb.TaskRunLogEntry_SchemaDump{
StartTime: timestamppb.New(l.T),
},
- }
- entries = append(entries, e)
+ })
case storepb.TaskRunLog_SCHEMA_DUMP_END:
if len(entries) == 0 {
@@ -408,7 +406,7 @@ func convertToTaskRunLogEntries(logs []*store.TaskRunLog) []*v1pb.TaskRunLogEntr
prev.SchemaDump.Error = l.Payload.SchemaDumpEnd.Error
case storepb.TaskRunLog_COMMAND_EXECUTE:
- e := &v1pb.TaskRunLogEntry{
+ entries = append(entries, &v1pb.TaskRunLogEntry{
Type: v1pb.TaskRunLogEntry_COMMAND_EXECUTE,
LogTime: timestamppb.New(l.T),
ReplicaId: l.Payload.ReplicaId,
@@ -417,8 +415,7 @@ func convertToTaskRunLogEntries(logs []*store.TaskRunLog) []*v1pb.TaskRunLogEntr
Range: convertToRange(l.Payload.CommandExecute.Range),
Statement: l.Payload.CommandExecute.Statement,
},
- }
- entries = append(entries, e)
+ })
case storepb.TaskRunLog_COMMAND_RESPONSE:
if len(entries) == 0 {
@@ -436,15 +433,14 @@ func convertToTaskRunLogEntries(logs []*store.TaskRunLog) []*v1pb.TaskRunLogEntr
}
case storepb.TaskRunLog_DATABASE_SYNC_START:
- e := &v1pb.TaskRunLogEntry{
+ entries = append(entries, &v1pb.TaskRunLogEntry{
Type: v1pb.TaskRunLogEntry_DATABASE_SYNC,
LogTime: timestamppb.New(l.T),
ReplicaId: l.Payload.ReplicaId,
DatabaseSync: &v1pb.TaskRunLogEntry_DatabaseSync{
StartTime: timestamppb.New(l.T),
},
- }
- entries = append(entries, e)
+ })
case storepb.TaskRunLog_DATABASE_SYNC_END:
if len(entries) == 0 {
@@ -458,7 +454,7 @@ func convertToTaskRunLogEntries(logs []*store.TaskRunLog) []*v1pb.TaskRunLogEntr
prev.DatabaseSync.Error = l.Payload.DatabaseSyncEnd.Error
case storepb.TaskRunLog_TRANSACTION_CONTROL:
- e := &v1pb.TaskRunLogEntry{
+ entries = append(entries, &v1pb.TaskRunLogEntry{
Type: v1pb.TaskRunLogEntry_TRANSACTION_CONTROL,
LogTime: timestamppb.New(l.T),
ReplicaId: l.Payload.ReplicaId,
@@ -466,19 +462,17 @@ func convertToTaskRunLogEntries(logs []*store.TaskRunLog) []*v1pb.TaskRunLogEntr
Type: convertTaskRunLogTransactionControlType(l.Payload.TransactionControl.Type),
Error: l.Payload.TransactionControl.Error,
},
- }
- entries = append(entries, e)
+ })
case storepb.TaskRunLog_PRIOR_BACKUP_START:
- e := &v1pb.TaskRunLogEntry{
+ entries = append(entries, &v1pb.TaskRunLogEntry{
Type: v1pb.TaskRunLogEntry_PRIOR_BACKUP,
LogTime: timestamppb.New(l.T),
ReplicaId: l.Payload.ReplicaId,
PriorBackup: &v1pb.TaskRunLogEntry_PriorBackup{
StartTime: timestamppb.New(l.T),
},
- }
- entries = append(entries, e)
+ })
case storepb.TaskRunLog_PRIOR_BACKUP_END:
if len(entries) == 0 {
@@ -493,15 +487,14 @@ func convertToTaskRunLogEntries(logs []*store.TaskRunLog) []*v1pb.TaskRunLogEntr
prev.PriorBackup.PriorBackupDetail = convertToTaskRunLogPriorBackupDetail(l.Payload.PriorBackupEnd.PriorBackupDetail)
case storepb.TaskRunLog_COMPUTE_DIFF_START:
- e := &v1pb.TaskRunLogEntry{
+ entries = append(entries, &v1pb.TaskRunLogEntry{
Type: v1pb.TaskRunLogEntry_COMPUTE_DIFF,
LogTime: timestamppb.New(l.T),
ReplicaId: l.Payload.ReplicaId,
ComputeDiff: &v1pb.TaskRunLogEntry_ComputeDiff{
StartTime: timestamppb.New(l.T),
},
- }
- entries = append(entries, e)
+ })
case storepb.TaskRunLog_COMPUTE_DIFF_END:
if len(entries) == 0 {
@@ -515,7 +508,7 @@ func convertToTaskRunLogEntries(logs []*store.TaskRunLog) []*v1pb.TaskRunLogEntr
prev.ComputeDiff.Error = l.Payload.ComputeDiffEnd.Error
case storepb.TaskRunLog_RETRY_INFO:
- e := &v1pb.TaskRunLogEntry{
+ entries = append(entries, &v1pb.TaskRunLogEntry{
Type: v1pb.TaskRunLogEntry_RETRY_INFO,
LogTime: timestamppb.New(l.T),
ReplicaId: l.Payload.ReplicaId,
@@ -524,11 +517,10 @@ func convertToTaskRunLogEntries(logs []*store.TaskRunLog) []*v1pb.TaskRunLogEntr
MaximumRetries: l.Payload.RetryInfo.MaximumRetries,
Error: l.Payload.RetryInfo.Error,
},
- }
- entries = append(entries, e)
+ })
case storepb.TaskRunLog_RELEASE_FILE_EXECUTE:
- e := &v1pb.TaskRunLogEntry{
+ entries = append(entries, &v1pb.TaskRunLogEntry{
Type: v1pb.TaskRunLogEntry_RELEASE_FILE_EXECUTE,
LogTime: timestamppb.New(l.T),
ReplicaId: l.Payload.ReplicaId,
@@ -536,8 +528,7 @@ func convertToTaskRunLogEntries(logs []*store.TaskRunLog) []*v1pb.TaskRunLogEntr
Version: l.Payload.ReleaseFileExecute.Version,
FilePath: l.Payload.ReleaseFileExecute.FilePath,
},
- }
- entries = append(entries, e)
+ })
default:
}
}
diff --git a/backend/api/v1/service_account_service.go b/backend/api/v1/service_account_service.go
index 402bc00428..1e5e7ce731 100644
--- a/backend/api/v1/service_account_service.go
+++ b/backend/api/v1/service_account_service.go
@@ -150,8 +150,7 @@ func (s *ServiceAccountService) ListServiceAccounts(ctx context.Context, request
case strings.HasPrefix(parent, common.WorkspacePrefix):
// workspace-level list: parent = "workspaces/{id}"
// use empty string to filter workspace-level SAs
- emptyProjectID := ""
- projectID = &emptyProjectID
+ projectID = new("")
default:
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("invalid parent format %q, expected projects/{project} or workspaces/{id}", parent))
}
@@ -246,8 +245,7 @@ func (s *ServiceAccountService) UpdateServiceAccount(ctx context.Context, reques
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to hash service key"))
}
- passwordHashStr := string(passwordHash)
- patch.ServiceKeyHash = &passwordHashStr
+ patch.ServiceKeyHash = new(string(passwordHash))
default:
// Ignore unknown fields
}
diff --git a/backend/api/v1/sql_service.go b/backend/api/v1/sql_service.go
index 4000f5d0f5..0bf75e9298 100644
--- a/backend/api/v1/sql_service.go
+++ b/backend/api/v1/sql_service.go
@@ -923,7 +923,6 @@ func (s *SQLService) doExportFromIssue(ctx context.Context, requestName string)
}
pendingEncrypts := []*encryptContent{}
- targetTaskRunStatus := []storepb.TaskRun_Status{storepb.TaskRun_DONE}
for _, task := range tasks {
// Skip tasks that are marked as skipped (they don't have archives)
@@ -935,7 +934,7 @@ func (s *SQLService) doExportFromIssue(ctx context.Context, requestName string)
Workspace: common.GetWorkspaceIDFromContext(ctx),
ProjectID: projectID,
TaskUID: &task.ID,
- Status: &targetTaskRunStatus,
+ Status: &[]storepb.TaskRun_Status{storepb.TaskRun_DONE},
})
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Errorf("failed to get task run: %v", err))
@@ -1241,8 +1240,7 @@ func (s *SQLService) createQueryHistory(database *store.DatabaseMessage, queryTy
},
}
if queryErr != nil {
- queryErrString := queryErr.Error()
- qh.Payload.Error = &queryErrString
+ qh.Payload.Error = new(queryErr.Error())
}
// Use a fresh context with timeout for creating query history
diff --git a/backend/api/v1/user_service.go b/backend/api/v1/user_service.go
index 420c1f8612..639fd5501e 100644
--- a/backend/api/v1/user_service.go
+++ b/backend/api/v1/user_service.go
@@ -426,8 +426,7 @@ func (s *UserService) UpdateUser(ctx context.Context, request *connect.Request[v
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to generate password hash"))
}
- passwordHashStr := string(passwordHash)
- patch.PasswordHash = &passwordHashStr
+ patch.PasswordHash = new(string(passwordHash))
// Revoke all refresh tokens for this user (including current session)
// User must re-login after password change for security
diff --git a/backend/api/v1/workload_identity_service.go b/backend/api/v1/workload_identity_service.go
index cae2bacdce..d31fe4baf0 100644
--- a/backend/api/v1/workload_identity_service.go
+++ b/backend/api/v1/workload_identity_service.go
@@ -139,8 +139,7 @@ func (s *WorkloadIdentityService) ListWorkloadIdentities(ctx context.Context, re
case strings.HasPrefix(parent, common.WorkspacePrefix):
// workspace-level list: parent = "workspaces/{id}"
// use empty string to filter workspace-level WIs
- emptyProjectID := ""
- projectID = &emptyProjectID
+ projectID = new("")
default:
return nil, connect.NewError(connect.CodeInvalidArgument, errors.Errorf("invalid parent format %q, expected projects/{project} or workspaces/{id}", parent))
}
diff --git a/backend/api/v1/workspace_service.go b/backend/api/v1/workspace_service.go
index bce6c8269c..4ea35598ed 100644
--- a/backend/api/v1/workspace_service.go
+++ b/backend/api/v1/workspace_service.go
@@ -231,13 +231,12 @@ func (s *WorkspaceService) SetIamPolicy(ctx context.Context, req *connect.Reques
if err != nil {
return nil, connect.NewError(connect.CodeInternal, errors.Wrapf(err, "failed to marshal iam policy"))
}
- payloadStr := string(payloadBytes)
patch := &store.UpdatePolicyMessage{
ResourceType: storepb.Policy_WORKSPACE,
Resource: request.Resource,
Type: storepb.Policy_IAM,
Workspace: workspaceID,
- Payload: &payloadStr,
+ Payload: new(string(payloadBytes)),
}
if _, err := s.store.UpdatePolicy(ctx, patch); err != nil {
diff --git a/backend/common/util.go b/backend/common/util.go
index 02dacbd602..e06795c2cf 100644
--- a/backend/common/util.go
+++ b/backend/common/util.go
@@ -243,10 +243,6 @@ func IsNil(val any) bool {
return false
}
-func NewP[T any](x T) *T {
- return &x
-}
-
// Uniq returns a new slice with duplicate elements removed, preserving order.
func Uniq[T comparable](array []T) []T {
res := make([]T, 0, len(array))
diff --git a/backend/component/sampleinstance/manager.go b/backend/component/sampleinstance/manager.go
index 56336c7fde..b22ef4c728 100644
--- a/backend/component/sampleinstance/manager.go
+++ b/backend/component/sampleinstance/manager.go
@@ -176,12 +176,10 @@ func (m *Manager) GenerateOnboardingData(ctx context.Context, workspaceID string
project = sampleProject
}
- testEnvID := common.DefaultTestEnvironmentID
- prodEnvID := common.DefaultProdEnvironmentID
instanceMessages := []*store.InstanceMessage{
{
ResourceID: "test-sample-instance",
- EnvironmentID: &testEnvID,
+ EnvironmentID: new(common.DefaultTestEnvironmentID),
Workspace: workspaceID,
Metadata: &storepb.Instance{
Title: "Test Sample Instance",
@@ -195,7 +193,7 @@ func (m *Manager) GenerateOnboardingData(ctx context.Context, workspaceID string
},
{
ResourceID: "prod-sample-instance",
- EnvironmentID: &prodEnvID,
+ EnvironmentID: new(common.DefaultProdEnvironmentID),
Workspace: workspaceID,
Metadata: &storepb.Instance{
Title: "Prod Sample Instance",
diff --git a/backend/enterprise/license.go b/backend/enterprise/license.go
index 41a7b8c1d7..2c5bd1d275 100644
--- a/backend/enterprise/license.go
+++ b/backend/enterprise/license.go
@@ -448,8 +448,7 @@ func (s *LicenseService) GetAuditLogRetentionCutoff(ctx context.Context, workspa
if days <= 0 {
return nil // Either no access (0) or unlimited (-1)
}
- cutoff := time.Now().AddDate(0, 0, -days)
- return &cutoff
+ return new(time.Now().AddDate(0, 0, -days))
}
// CountActiveReplicas returns the count of active replicas.
diff --git a/backend/plugin/db/cassandra/cassandra_test.go b/backend/plugin/db/cassandra/cassandra_test.go
index 7741e385c9..72b47f5988 100644
--- a/backend/plugin/db/cassandra/cassandra_test.go
+++ b/backend/plugin/db/cassandra/cassandra_test.go
@@ -78,11 +78,8 @@ func TestConvertRowValuePrimitives(t *testing.T) {
expected *v1pb.RowValue
}{
{
- name: "string pointer",
- value: func() *string {
- s := "hello"
- return &s
- }(),
+ name: "string pointer",
+ value: new("hello"),
expected: &v1pb.RowValue{Kind: &v1pb.RowValue_StringValue{StringValue: "hello"}},
},
{
@@ -93,43 +90,28 @@ func TestConvertRowValuePrimitives(t *testing.T) {
expected: util.NullRowValue,
},
{
- name: "int64 pointer",
- value: func() *int64 {
- i := int64(42)
- return &i
- }(),
+ name: "int64 pointer",
+ value: new(int64(42)),
expected: &v1pb.RowValue{Kind: &v1pb.RowValue_Int64Value{Int64Value: 42}},
},
{
- name: "bool pointer true",
- value: func() *bool {
- b := true
- return &b
- }(),
+ name: "bool pointer true",
+ value: new(true),
expected: &v1pb.RowValue{Kind: &v1pb.RowValue_BoolValue{BoolValue: true}},
},
{
- name: "bool pointer false",
- value: func() *bool {
- b := false
- return &b
- }(),
+ name: "bool pointer false",
+ value: new(false),
expected: &v1pb.RowValue{Kind: &v1pb.RowValue_BoolValue{BoolValue: false}},
},
{
- name: "float64 pointer",
- value: func() *float64 {
- f := 3.14159
- return &f
- }(),
+ name: "float64 pointer",
+ value: new(3.14159),
expected: &v1pb.RowValue{Kind: &v1pb.RowValue_DoubleValue{DoubleValue: 3.14159}},
},
{
- name: "bytes pointer",
- value: func() *[]byte {
- b := []byte("hello")
- return &b
- }(),
+ name: "bytes pointer",
+ value: new([]byte("hello")),
expected: &v1pb.RowValue{Kind: &v1pb.RowValue_BytesValue{BytesValue: []byte("hello")}},
},
}
diff --git a/backend/plugin/db/dynamodb/dynamodb.go b/backend/plugin/db/dynamodb/dynamodb.go
index 43096d381f..87bc1c01a0 100644
--- a/backend/plugin/db/dynamodb/dynamodb.go
+++ b/backend/plugin/db/dynamodb/dynamodb.go
@@ -67,9 +67,8 @@ func (*Driver) Close(_ context.Context) error {
func (d *Driver) Ping(ctx context.Context) error {
// DynamoDB does not support ping method, we list tables instead. To avoid network overhead,
// we set the limit to 1.
- var limit int32 = 1
_, err := d.client.ListTables(ctx, &dynamodb.ListTablesInput{
- Limit: &limit,
+ Limit: new(int32(1)),
})
if err != nil {
return errors.Wrapf(err, "failed to list dynamodb tables")
@@ -171,8 +170,7 @@ func (d *Driver) querySinglePartiQL(ctx context.Context, statement string, query
Statement: &statement,
}
if queryContext.Limit > 0 {
- limit := int32(queryContext.Limit)
- input.Limit = &limit
+ input.Limit = new(int32(queryContext.Limit))
}
var nextToken *string
diff --git a/backend/plugin/db/dynamodb/sync.go b/backend/plugin/db/dynamodb/sync.go
index 526b9f6b3b..51e8132fc8 100644
--- a/backend/plugin/db/dynamodb/sync.go
+++ b/backend/plugin/db/dynamodb/sync.go
@@ -140,11 +140,10 @@ func (d *Driver) syncTable(ctx context.Context, tableName string) (*storepb.Tabl
func (d *Driver) listAllTables(ctx context.Context) ([]string, error) {
var result []string
- var limit int32 = 100
var exclusiveStartTableName *string
for {
out, err := d.client.ListTables(ctx, &dynamodb.ListTablesInput{
- Limit: &limit,
+ Limit: new(int32(100)),
ExclusiveStartTableName: exclusiveStartTableName,
})
if err != nil {
diff --git a/backend/runner/approval/runner.go b/backend/runner/approval/runner.go
index 2885e35f01..3c336e9a39 100644
--- a/backend/runner/approval/runner.go
+++ b/backend/runner/approval/runner.go
@@ -466,12 +466,11 @@ func unfoldSpecTargets(ctx context.Context, stores *store.Store, specs []*storep
}
// For CREATE_DATABASE, create a synthetic database message
// since the database doesn't exist yet
- envID := config.CreateDatabaseConfig.Environment
targets = append(targets, specTarget{
database: &store.DatabaseMessage{
InstanceID: instanceID,
DatabaseName: config.CreateDatabaseConfig.Database,
- EffectiveEnvironmentID: &envID,
+ EffectiveEnvironmentID: new(config.CreateDatabaseConfig.Environment),
},
sheetSha256: "",
})
diff --git a/backend/runner/schemasync/syncer.go b/backend/runner/schemasync/syncer.go
index 167660a0a1..039ae46173 100644
--- a/backend/runner/schemasync/syncer.go
+++ b/backend/runner/schemasync/syncer.go
@@ -356,11 +356,10 @@ func (s *Syncer) SyncInstance(ctx context.Context, instance *store.InstanceMessa
for _, database := range databases {
idx := slices.IndexFunc(filteredDatabaseMetadatas, func(db *storepb.DatabaseSchemaMetadata) bool { return db.Name == database.DatabaseName })
if idx < 0 {
- d := true
if _, err := s.store.UpdateDatabase(ctx, &store.UpdateDatabaseMessage{
InstanceID: instance.ResourceID,
DatabaseName: database.DatabaseName,
- Deleted: &d,
+ Deleted: new(true),
}); err != nil {
return nil, nil, nil, errors.Errorf("failed to update database %q for instance %q", database.DatabaseName, instance.ResourceID)
}
@@ -427,7 +426,7 @@ func (s *Syncer) doSyncDatabaseSchema(ctx context.Context, database *store.Datab
if _, err := s.store.UpdateDatabase(ctx, &store.UpdateDatabaseMessage{
InstanceID: database.InstanceID,
DatabaseName: database.DatabaseName,
- Deleted: proto.Bool(false),
+ Deleted: new(false),
MetadataUpdates: metadataUpdates,
}); err != nil {
return "", errors.Wrapf(err, "failed to update database %q for instance %q", database.DatabaseName, database.InstanceID)
diff --git a/backend/runner/taskrun/database_migrate_executor.go b/backend/runner/taskrun/database_migrate_executor.go
index 38c204a781..015f729a8f 100644
--- a/backend/runner/taskrun/database_migrate_executor.go
+++ b/backend/runner/taskrun/database_migrate_executor.go
@@ -129,11 +129,10 @@ func (exec *DatabaseMigrateExecutor) RunOnce(ctx context.Context, driverCtx cont
// ensureBaselineChangelog creates a baseline changelog if this is the first migration for the database.
func (exec *DatabaseMigrateExecutor) ensureBaselineChangelog(ctx context.Context, database *store.DatabaseMessage, _ *store.InstanceMessage) error {
// Check if this database has any existing changelogs
- limit := 1
existingChangelogs, err := exec.store.ListChangelogs(ctx, &store.FindChangelogMessage{
InstanceID: database.InstanceID,
DatabaseName: &database.DatabaseName,
- Limit: &limit,
+ Limit: new(1),
})
if err != nil {
return errors.Wrapf(err, "failed to check for existing changelogs")
@@ -275,11 +274,9 @@ func (exec *DatabaseMigrateExecutor) runStandardMigration(ctx context.Context, d
}
}
if migrationErr == nil {
- status := store.ChangelogStatusDone
- update.Status = &status
+ update.Status = new(store.ChangelogStatusDone)
} else {
- status := store.ChangelogStatusFailed
- update.Status = &status
+ update.Status = new(store.ChangelogStatusFailed)
}
if err := exec.store.UpdateChangelog(ctx, update); err != nil {
slog.Error("failed to update changelog", log.BBError(err))
@@ -426,11 +423,9 @@ func (exec *DatabaseMigrateExecutor) runGhostMigration(ctx context.Context, driv
update.SyncHistory = &syncHistory
}
if migrationErr == nil {
- status := store.ChangelogStatusDone
- update.Status = &status
+ update.Status = new(store.ChangelogStatusDone)
} else {
- status := store.ChangelogStatusFailed
- update.Status = &status
+ update.Status = new(store.ChangelogStatusFailed)
}
if err := exec.store.UpdateChangelog(ctx, update); err != nil {
slog.Error("failed to update changelog", log.BBError(err))
@@ -582,11 +577,9 @@ func (exec *DatabaseMigrateExecutor) runVersionedRelease(ctx context.Context, dr
update.SyncHistory = &syncHistory
}
if migrationErr == nil {
- status := store.ChangelogStatusDone
- update.Status = &status
+ update.Status = new(store.ChangelogStatusDone)
} else {
- status := store.ChangelogStatusFailed
- update.Status = &status
+ update.Status = new(store.ChangelogStatusFailed)
}
if err := exec.store.UpdateChangelog(ctx, update); err != nil {
slog.Error("failed to update changelog", log.BBError(err))
@@ -713,11 +706,9 @@ func (exec *DatabaseMigrateExecutor) runDeclarativeRelease(ctx context.Context,
update.SyncHistory = &syncHistory
}
if migrationErr == nil {
- status := store.ChangelogStatusDone
- update.Status = &status
+ update.Status = new(store.ChangelogStatusDone)
} else {
- status := store.ChangelogStatusFailed
- update.Status = &status
+ update.Status = new(store.ChangelogStatusFailed)
}
if err := exec.store.UpdateChangelog(ctx, update); err != nil {
slog.Error("failed to update changelog", log.BBError(err))
diff --git a/backend/runner/taskrun/scheduler.go b/backend/runner/taskrun/scheduler.go
index fb92ec6d4d..048bf44b94 100644
--- a/backend/runner/taskrun/scheduler.go
+++ b/backend/runner/taskrun/scheduler.go
@@ -203,8 +203,7 @@ func (s *Scheduler) autoResolveIssue(ctx context.Context, projectID string, plan
return
}
- newStatus := storepb.Issue_DONE
- if _, err := s.store.UpdateIssue(ctx, issue.ProjectID, issue.UID, &store.UpdateIssueMessage{Status: &newStatus}); err != nil {
+ if _, err := s.store.UpdateIssue(ctx, issue.ProjectID, issue.UID, &store.UpdateIssueMessage{Status: new(storepb.Issue_DONE)}); err != nil {
slog.Error("failed to auto-resolve issue", slog.String("project", projectID), slog.Int64("issueUID", issue.UID), log.BBError(err))
return
}
diff --git a/backend/store/policy.go b/backend/store/policy.go
index b276024bcd..43c6e387c5 100644
--- a/backend/store/policy.go
+++ b/backend/store/policy.go
@@ -33,12 +33,10 @@ func generateEtag(t time.Time) string {
}
func (s *Store) GetWorkspaceIamPolicy(ctx context.Context, workspaceID string) (*IamPolicyMessage, error) {
- workspaceResource := common.FormatWorkspace(workspaceID)
- resourceType := storepb.Policy_WORKSPACE
return s.getIamPolicy(ctx, &FindPolicyMessage{
Workspace: workspaceID,
- ResourceType: &resourceType,
- Resource: &workspaceResource,
+ ResourceType: new(storepb.Policy_WORKSPACE),
+ Resource: new(common.FormatWorkspace(workspaceID)),
})
}
@@ -111,12 +109,10 @@ func (s *Store) PatchWorkspaceIamPolicy(ctx context.Context, patch *PatchIamPoli
}
func (s *Store) GetProjectIamPolicy(ctx context.Context, workspaceID string, projectID string) (*IamPolicyMessage, error) {
- resource := common.FormatProject(projectID)
- resourceType := storepb.Policy_PROJECT
return s.getIamPolicy(ctx, &FindPolicyMessage{
Workspace: workspaceID,
- ResourceType: &resourceType,
- Resource: &resource,
+ ResourceType: new(storepb.Policy_PROJECT),
+ Resource: new(common.FormatProject(projectID)),
})
}
@@ -138,8 +134,7 @@ func (s *Store) GetProjectIamPolicySnapshot(ctx context.Context, workspaceID str
}
func (s *Store) getIamPolicy(ctx context.Context, find *FindPolicyMessage) (*IamPolicyMessage, error) {
- pType := storepb.Policy_IAM
- find.Type = &pType
+ find.Type = new(storepb.Policy_IAM)
policy, err := s.GetPolicy(ctx, find)
if err != nil {
return nil, err
@@ -176,14 +171,11 @@ func GetDefaultRolloutPolicy() *storepb.RolloutPolicy {
}
func (s *Store) GetRolloutPolicy(ctx context.Context, workspaceID string, environment string) (*storepb.RolloutPolicy, error) {
- resource := common.FormatEnvironment(environment)
- resourceType := storepb.Policy_ENVIRONMENT
- pType := storepb.Policy_ROLLOUT
policy, err := s.GetPolicy(ctx, &FindPolicyMessage{
Workspace: workspaceID,
- ResourceType: &resourceType,
- Resource: &resource,
- Type: &pType,
+ ResourceType: new(storepb.Policy_ENVIRONMENT),
+ Resource: new(common.FormatEnvironment(environment)),
+ Type: new(storepb.Policy_ROLLOUT),
})
if err != nil {
return nil, errors.Wrapf(err, "failed to get policy")
@@ -262,12 +254,11 @@ func (s *Store) getQueryDataPolicy(ctx context.Context, workspaceID string, reso
if err != nil {
return nil, err
}
- pType := storepb.Policy_QUERY_DATA
policy, err := s.GetPolicy(ctx, &FindPolicyMessage{
Workspace: workspaceID,
ResourceType: &resourceType,
Resource: &resource,
- Type: &pType,
+ Type: new(storepb.Policy_QUERY_DATA),
})
if err != nil {
return nil, errors.Wrapf(err, "failed to get policy")
@@ -318,13 +309,11 @@ func (s *Store) GetReviewConfigForDatabase(ctx context.Context, workspaceID stri
}
func (s *Store) getReviewConfigByResource(ctx context.Context, workspaceID string, resourceType storepb.Policy_Resource, resource string) (*storepb.ReviewConfigPayload, error) {
- pType := storepb.Policy_TAG
-
policy, err := s.GetPolicy(ctx, &FindPolicyMessage{
Workspace: workspaceID,
ResourceType: &resourceType,
Resource: &resource,
- Type: &pType,
+ Type: new(storepb.Policy_TAG),
})
if err != nil {
return nil, err
@@ -366,14 +355,11 @@ func (s *Store) getReviewConfigByResource(ctx context.Context, workspaceID strin
// GetMaskingRulePolicy will get the masking rule policy.
func (s *Store) GetMaskingRulePolicy(ctx context.Context, workspaceID string) (*storepb.MaskingRulePolicy, error) {
- workspaceResource := common.FormatWorkspace(workspaceID)
- resourceType := storepb.Policy_WORKSPACE
- pType := storepb.Policy_MASKING_RULE
policy, err := s.GetPolicy(ctx, &FindPolicyMessage{
Workspace: workspaceID,
- ResourceType: &resourceType,
- Resource: &workspaceResource,
- Type: &pType,
+ ResourceType: new(storepb.Policy_WORKSPACE),
+ Resource: new(common.FormatWorkspace(workspaceID)),
+ Type: new(storepb.Policy_MASKING_RULE),
})
if err != nil {
return nil, err
@@ -393,14 +379,11 @@ func (s *Store) GetMaskingRulePolicy(ctx context.Context, workspaceID string) (*
// GetMaskingExemptionPolicyByProject gets the masking exemption policy for a project.
func (s *Store) GetMaskingExemptionPolicyByProject(ctx context.Context, workspaceID string, projectID string) (*storepb.MaskingExemptionPolicy, error) {
- resourceType := storepb.Policy_PROJECT
- resource := common.FormatProject(projectID)
- pType := storepb.Policy_MASKING_EXEMPTION
policy, err := s.GetPolicy(ctx, &FindPolicyMessage{
Workspace: workspaceID,
- ResourceType: &resourceType,
- Resource: &resource,
- Type: &pType,
+ ResourceType: new(storepb.Policy_PROJECT),
+ Resource: new(common.FormatProject(projectID)),
+ Type: new(storepb.Policy_MASKING_EXEMPTION),
})
if err != nil {
return nil, err
diff --git a/backend/store/project.go b/backend/store/project.go
index 50ece15dda..fe0c6e3db8 100644
--- a/backend/store/project.go
+++ b/backend/store/project.go
@@ -60,8 +60,7 @@ type UpdateProjectMessage struct {
// Checks for new format ("default-{workspaceID}") first, falls back to legacy ("default").
func (s *Store) GetDefaultProjectID(ctx context.Context, workspace string) (string, error) {
newID := common.DefaultProjectID(workspace)
- resourceID := newID
- project, err := s.GetProject(ctx, &FindProjectMessage{Workspace: workspace, ResourceID: &resourceID})
+ project, err := s.GetProject(ctx, &FindProjectMessage{Workspace: workspace, ResourceID: new(newID)})
if err != nil {
return "", err
}
@@ -298,8 +297,7 @@ func (s *Store) UpdateProjects(ctx context.Context, patches ...*UpdateProjectMes
if err != nil {
return err
}
- s := string(payload)
- settings[i] = &s
+ settings[i] = new(string(payload))
}
}
diff --git a/backend/store/service_account.go b/backend/store/service_account.go
index 9012bdfb61..8126129e67 100644
--- a/backend/store/service_account.go
+++ b/backend/store/service_account.go
@@ -255,13 +255,11 @@ func (s *Store) UpdateServiceAccount(ctx context.Context, sa *ServiceAccountMess
// DeleteServiceAccount soft-deletes a service account.
func (s *Store) DeleteServiceAccount(ctx context.Context, sa *ServiceAccountMessage) error {
- deleted := true
- _, err := s.UpdateServiceAccount(ctx, sa, &UpdateServiceAccountMessage{Delete: &deleted})
+ _, err := s.UpdateServiceAccount(ctx, sa, &UpdateServiceAccountMessage{Delete: new(true)})
return err
}
// UndeleteServiceAccount restores a soft-deleted service account.
func (s *Store) UndeleteServiceAccount(ctx context.Context, sa *ServiceAccountMessage) (*ServiceAccountMessage, error) {
- deleted := false
- return s.UpdateServiceAccount(ctx, sa, &UpdateServiceAccountMessage{Delete: &deleted})
+ return s.UpdateServiceAccount(ctx, sa, &UpdateServiceAccountMessage{Delete: new(false)})
}
diff --git a/backend/store/workload_identity.go b/backend/store/workload_identity.go
index 56caa2ab0b..7ef6aeac0d 100644
--- a/backend/store/workload_identity.go
+++ b/backend/store/workload_identity.go
@@ -286,13 +286,11 @@ func (s *Store) UpdateWorkloadIdentity(ctx context.Context, wi *WorkloadIdentity
// DeleteWorkloadIdentity soft-deletes a workload identity.
func (s *Store) DeleteWorkloadIdentity(ctx context.Context, wi *WorkloadIdentityMessage) error {
- deleted := true
- _, err := s.UpdateWorkloadIdentity(ctx, wi, &UpdateWorkloadIdentityMessage{Delete: &deleted})
+ _, err := s.UpdateWorkloadIdentity(ctx, wi, &UpdateWorkloadIdentityMessage{Delete: new(true)})
return err
}
// UndeleteWorkloadIdentity restores a soft-deleted workload identity.
func (s *Store) UndeleteWorkloadIdentity(ctx context.Context, wi *WorkloadIdentityMessage) (*WorkloadIdentityMessage, error) {
- deleted := false
- return s.UpdateWorkloadIdentity(ctx, wi, &UpdateWorkloadIdentityMessage{Delete: &deleted})
+ return s.UpdateWorkloadIdentity(ctx, wi, &UpdateWorkloadIdentityMessage{Delete: new(false)})
}
diff --git a/backend/tests/action_test.go b/backend/tests/action_test.go
index e90a351677..39697f31b9 100644
--- a/backend/tests/action_test.go
+++ b/backend/tests/action_test.go
@@ -544,7 +544,7 @@ func (ctl *controller) createTestDatabase(ctx context.Context, t *testing.T) *v1
Instance: &v1pb.Instance{
Title: "Test Instance",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{
Type: v1pb.DataSourceType_ADMIN,
@@ -583,7 +583,7 @@ func (ctl *controller) createTestMySQLDatabase(ctx context.Context, t *testing.T
Instance: &v1pb.Instance{
Title: "Test MySQL Instance",
Engine: v1pb.Engine_MYSQL,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{
Type: v1pb.DataSourceType_ADMIN,
@@ -625,7 +625,7 @@ func (ctl *controller) createTestPostgreSQLDatabase(ctx context.Context, t *test
Instance: &v1pb.Instance{
Title: "Test PostgreSQL Instance",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{
Type: v1pb.DataSourceType_ADMIN,
diff --git a/backend/tests/approval_test.go b/backend/tests/approval_test.go
index 09357700c6..e49e0a4332 100644
--- a/backend/tests/approval_test.go
+++ b/backend/tests/approval_test.go
@@ -35,7 +35,7 @@ func TestDirectApprovalRuleMatching(t *testing.T) {
Instance: &v1pb.Instance{
Title: "Prod Instance",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{
Type: v1pb.DataSourceType_ADMIN,
@@ -169,7 +169,7 @@ func TestApprovalRuleFirstMatchWins(t *testing.T) {
Instance: &v1pb.Instance{
Title: "Prod Instance",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{
Type: v1pb.DataSourceType_ADMIN,
@@ -314,7 +314,7 @@ func TestApprovalRuleNoMatch(t *testing.T) {
Instance: &v1pb.Instance{
Title: "Test Instance",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/test"),
+ Environment: new("environments/test"),
Activation: true,
DataSources: []*v1pb.DataSource{{
Type: v1pb.DataSourceType_ADMIN,
@@ -515,7 +515,7 @@ func TestFallbackRuleMatchesWhenSourceSpecificDoesNot(t *testing.T) {
Instance: &v1pb.Instance{
Title: "Test Instance",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/test"),
+ Environment: new("environments/test"),
Activation: true,
DataSources: []*v1pb.DataSource{{
Type: v1pb.DataSourceType_ADMIN,
@@ -654,7 +654,7 @@ func TestSourceSpecificRuleTakesPriorityOverFallback(t *testing.T) {
Instance: &v1pb.Instance{
Title: "Prod Instance",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{
Type: v1pb.DataSourceType_ADMIN,
@@ -805,7 +805,7 @@ func TestSelfApprovalBlocked(t *testing.T) {
Instance: &v1pb.Instance{
Title: "Prod Instance",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{
Type: v1pb.DataSourceType_ADMIN,
diff --git a/backend/tests/common.go b/backend/tests/common.go
index 3abe9561d8..58c1f3ff8b 100644
--- a/backend/tests/common.go
+++ b/backend/tests/common.go
@@ -9,8 +9,3 @@ import (
func generateRandomString(prefix string) string {
return fmt.Sprintf("%s-%s", prefix, uuid.New().String()[:10])
}
-
-// stringPtr returns a pointer to the string value.
-func stringPtr(s string) *string {
- return &s
-}
diff --git a/backend/tests/data_source_test.go b/backend/tests/data_source_test.go
index e216f493a1..64deeb079a 100644
--- a/backend/tests/data_source_test.go
+++ b/backend/tests/data_source_test.go
@@ -29,7 +29,7 @@ func TestDataSource(t *testing.T) {
Instance: &v1pb.Instance{
Title: "test",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Id: "admin-ds", Host: instanceDir}},
},
diff --git a/backend/tests/environment_test.go b/backend/tests/environment_test.go
index 7878efb77d..23f92231b3 100644
--- a/backend/tests/environment_test.go
+++ b/backend/tests/environment_test.go
@@ -35,7 +35,7 @@ func TestDatabaseEnvironment(t *testing.T) {
Instance: &v1pb.Instance{
Title: "test",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr(prodEnvironment.Name),
+ Environment: new(prodEnvironment.Name),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Id: "admin-ds", Host: instanceDir}},
},
@@ -81,7 +81,7 @@ func TestDatabaseEnvironment(t *testing.T) {
db2Resp, err = ctl.databaseServiceClient.UpdateDatabase(ctx, connect.NewRequest(&v1pb.UpdateDatabaseRequest{
Database: &v1pb.Database{
Name: db2.Name,
- Environment: stringPtr(testEnvironment.Name),
+ Environment: new(testEnvironment.Name),
},
UpdateMask: &fieldmaskpb.FieldMask{
Paths: []string{"environment"},
@@ -98,7 +98,7 @@ func TestDatabaseEnvironment(t *testing.T) {
db2Resp, err = ctl.databaseServiceClient.UpdateDatabase(ctx, connect.NewRequest(&v1pb.UpdateDatabaseRequest{
Database: &v1pb.Database{
Name: db2.Name,
- Environment: stringPtr(""),
+ Environment: new(""),
},
UpdateMask: &fieldmaskpb.FieldMask{
Paths: []string{"environment"},
diff --git a/backend/tests/ghost_test.go b/backend/tests/ghost_test.go
index d93afbd65b..ec260dc595 100644
--- a/backend/tests/ghost_test.go
+++ b/backend/tests/ghost_test.go
@@ -71,7 +71,7 @@ func TestGhostSchemaUpdate(t *testing.T) {
Instance: &v1pb.Instance{
Title: "mysqlInstance",
Engine: v1pb.Engine_MYSQL,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: mysqlContainer.host, Port: mysqlContainer.port, Username: "bytebase", Password: "bytebase", Id: "admin"}},
},
diff --git a/backend/tests/gitops_test.go b/backend/tests/gitops_test.go
index a89913b370..d9cc033521 100644
--- a/backend/tests/gitops_test.go
+++ b/backend/tests/gitops_test.go
@@ -52,7 +52,7 @@ func TestGitOpsCheck(t *testing.T) {
Instance: &v1pb.Instance{
Title: "gitops-check-test",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/test"),
+ Environment: new("environments/test"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: testInstanceDir, Id: "admin"}},
},
@@ -65,7 +65,7 @@ func TestGitOpsCheck(t *testing.T) {
Instance: &v1pb.Instance{
Title: "gitops-check-prod",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: prodInstanceDir, Id: "admin"}},
},
@@ -183,7 +183,7 @@ func TestGitOpsRollout(t *testing.T) {
Instance: &v1pb.Instance{
Title: "gitops-rollout-test",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/test"),
+ Environment: new("environments/test"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: testInstanceDir, Id: "admin"}},
},
@@ -354,7 +354,7 @@ func TestGitOpsRolloutGhostDirective(t *testing.T) {
Instance: &v1pb.Instance{
Title: "gitops-rollout-ghost",
Engine: v1pb.Engine_MYSQL,
- Environment: stringPtr("environments/test"),
+ Environment: new("environments/test"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: mysqlContainer.host, Port: mysqlContainer.port, Username: "bytebase", Password: "bytebase", Id: "admin"}},
},
@@ -490,7 +490,7 @@ func TestGitOpsRolloutMultiTarget(t *testing.T) {
Instance: &v1pb.Instance{
Title: "gitops-multi-test",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/test"),
+ Environment: new("environments/test"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: testInstanceDir, Id: "admin"}},
},
@@ -503,7 +503,7 @@ func TestGitOpsRolloutMultiTarget(t *testing.T) {
Instance: &v1pb.Instance{
Title: "gitops-multi-prod",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: prodInstanceDir, Id: "admin"}},
},
@@ -734,7 +734,7 @@ func TestGitOpsCheckAppliedButChanged(t *testing.T) {
Instance: &v1pb.Instance{
Title: "gitops-changed-test",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/test"),
+ Environment: new("environments/test"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: testInstanceDir, Id: "admin"}},
},
@@ -940,7 +940,7 @@ func TestGitOpsCheckDeclarative(t *testing.T) {
Instance: &v1pb.Instance{
Title: "gitops-decl-pg",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/test"),
+ Environment: new("environments/test"),
Activation: true,
DataSources: []*v1pb.DataSource{{
Type: v1pb.DataSourceType_ADMIN,
@@ -1081,7 +1081,7 @@ ALTER TABLE public.users ADD COLUMN name VARCHAR(255);`,
Instance: &v1pb.Instance{
Title: "gitops-disallow-pg",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/test"),
+ Environment: new("environments/test"),
Activation: true,
DataSources: []*v1pb.DataSource{{
Type: v1pb.DataSourceType_ADMIN,
@@ -1263,7 +1263,7 @@ func TestGitOpsCheckVersionedDependency(t *testing.T) {
Instance: &v1pb.Instance{
Title: "gitops-dep-pg",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/test"),
+ Environment: new("environments/test"),
Activation: true,
DataSources: []*v1pb.DataSource{{
Type: v1pb.DataSourceType_ADMIN,
@@ -1361,7 +1361,7 @@ func TestGitOpsCheckDeclarativeMultipleFiles(t *testing.T) {
Instance: &v1pb.Instance{
Title: "gitops-multi-decl-pg",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/test"),
+ Environment: new("environments/test"),
Activation: true,
DataSources: []*v1pb.DataSource{{
Type: v1pb.DataSourceType_ADMIN,
diff --git a/backend/tests/grouping_change_test.go b/backend/tests/grouping_change_test.go
index 67e68d4d0e..f6c4855f51 100644
--- a/backend/tests/grouping_change_test.go
+++ b/backend/tests/grouping_change_test.go
@@ -128,7 +128,7 @@ func TestCreateDatabaseGroup(t *testing.T) {
Instance: &v1pb.Instance{
Title: prepareInstance.instanceTitle,
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: instanceDir, Id: "admin"}},
Activation: true,
},
diff --git a/backend/tests/pg_sdl_rollout_test.go b/backend/tests/pg_sdl_rollout_test.go
index 83246810a0..51843704cd 100644
--- a/backend/tests/pg_sdl_rollout_test.go
+++ b/backend/tests/pg_sdl_rollout_test.go
@@ -44,7 +44,7 @@ func TestPgSDLRollout(t *testing.T) {
Instance: &v1pb.Instance{
Title: "SDL Test Instance",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{
Type: v1pb.DataSourceType_ADMIN,
diff --git a/backend/tests/project_test.go b/backend/tests/project_test.go
index 02f6ed307c..b6afa31bb1 100644
--- a/backend/tests/project_test.go
+++ b/backend/tests/project_test.go
@@ -30,7 +30,7 @@ func TestArchiveProject(t *testing.T) {
Instance: &v1pb.Instance{
Title: "test",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: instanceDir, Id: "admin"}},
},
diff --git a/backend/tests/schema_update_test.go b/backend/tests/schema_update_test.go
index 2e1e734192..afd5883bd1 100644
--- a/backend/tests/schema_update_test.go
+++ b/backend/tests/schema_update_test.go
@@ -36,7 +36,7 @@ func TestSchemaAndDataUpdate(t *testing.T) {
Instance: &v1pb.Instance{
Title: instanceName,
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: instanceDir, Id: "admin"}},
},
@@ -251,7 +251,7 @@ CREATE TABLE "public"."book" (
Instance: &v1pb.Instance{
Title: test.name,
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr(environment.Name),
+ Environment: new(environment.Name),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: pgContainer.host, Port: pgContainer.port, Username: "postgres", Password: "root-password", Id: "admin"}},
},
@@ -270,7 +270,7 @@ CREATE TABLE "public"."book" (
Instance: &v1pb.Instance{
Title: "mysqlInstance",
Engine: v1pb.Engine_MYSQL,
- Environment: stringPtr(environment.Name),
+ Environment: new(environment.Name),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: mysqlContainer.host, Port: mysqlContainer.port, Username: "root", Password: "root-password", Id: "admin"}},
},
@@ -341,7 +341,7 @@ func TestMarkTaskAsDone(t *testing.T) {
Instance: &v1pb.Instance{
Title: instanceName,
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: instanceDir, Id: "admin"}},
},
diff --git a/backend/tests/sensitive_data_test.go b/backend/tests/sensitive_data_test.go
index eda54ae080..ff8eb44057 100644
--- a/backend/tests/sensitive_data_test.go
+++ b/backend/tests/sensitive_data_test.go
@@ -154,7 +154,7 @@ func TestSensitiveData(t *testing.T) {
Instance: &v1pb.Instance{
Title: "mysqlInstance",
Engine: v1pb.Engine_MYSQL,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: mysqlContainer.host, Port: mysqlContainer.port, Username: "bytebase", Password: "bytebase", Id: "admin"}},
},
diff --git a/backend/tests/sql_editor_test.go b/backend/tests/sql_editor_test.go
index 15e701a940..900192a423 100644
--- a/backend/tests/sql_editor_test.go
+++ b/backend/tests/sql_editor_test.go
@@ -148,7 +148,7 @@ func TestAdminQueryAffectedRows(t *testing.T) {
Instance: &v1pb.Instance{
Title: "mysqlInstance",
Engine: v1pb.Engine_MYSQL,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: mysqlContainer.host, Port: mysqlContainer.port, Username: "root", Password: "root-password", Id: "admin"}},
},
@@ -161,7 +161,7 @@ func TestAdminQueryAffectedRows(t *testing.T) {
Instance: &v1pb.Instance{
Title: "pgInstance",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: pgContainer.host, Port: pgContainer.port, Username: "postgres", Password: "root-password", Id: "admin"}},
},
diff --git a/backend/tests/sql_export_test.go b/backend/tests/sql_export_test.go
index 5538da5c55..90df699ecd 100644
--- a/backend/tests/sql_export_test.go
+++ b/backend/tests/sql_export_test.go
@@ -168,7 +168,7 @@ func TestSQLExport(t *testing.T) {
Instance: &v1pb.Instance{
Title: "mysqlInstance",
Engine: v1pb.Engine_MYSQL,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: mysqlContainer.host, Port: mysqlContainer.port, Username: "root", Password: "root-password", Id: "admin"}},
},
@@ -181,7 +181,7 @@ func TestSQLExport(t *testing.T) {
Instance: &v1pb.Instance{
Title: "pgInstance",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: pgContainer.host, Port: pgContainer.port, Username: "postgres", Password: "root-password", Id: "admin"}},
},
diff --git a/backend/tests/sql_query_test.go b/backend/tests/sql_query_test.go
index 7738d4d67c..12f1b37d45 100644
--- a/backend/tests/sql_query_test.go
+++ b/backend/tests/sql_query_test.go
@@ -123,7 +123,7 @@ func TestSQLAdminQuery(t *testing.T) {
Instance: &v1pb.Instance{
Title: "mysqlInstance",
Engine: v1pb.Engine_MYSQL,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: mysqlContainer.host, Port: mysqlContainer.port, Username: "root", Password: "root-password", Id: "admin"}},
},
@@ -136,7 +136,7 @@ func TestSQLAdminQuery(t *testing.T) {
Instance: &v1pb.Instance{
Title: "pgInstance",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: pgContainer.host, Port: pgContainer.port, Username: "postgres", Password: "root-password", Id: "admin"}},
},
diff --git a/backend/tests/sql_review_test.go b/backend/tests/sql_review_test.go
index 7e9862dace..f9bd05e8cf 100644
--- a/backend/tests/sql_review_test.go
+++ b/backend/tests/sql_review_test.go
@@ -145,7 +145,7 @@ func TestSQLReviewForPostgreSQL(t *testing.T) {
Instance: &v1pb.Instance{
Title: "pgInstance",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: pgContainer.host, Port: pgContainer.port, Username: "bytebase", Password: "bytebase", Id: "admin"}},
},
@@ -312,7 +312,7 @@ func TestSQLReviewForMySQL(t *testing.T) {
Instance: &v1pb.Instance{
Title: "mysqlInstance",
Engine: v1pb.Engine_MYSQL,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: mysqlContainer.host, Port: mysqlContainer.port, Username: "bytebase", Password: "bytebase", Id: "admin"}},
},
diff --git a/backend/tests/sql_stop_on_error_test.go b/backend/tests/sql_stop_on_error_test.go
index 8e57236932..f1ca2edeaf 100644
--- a/backend/tests/sql_stop_on_error_test.go
+++ b/backend/tests/sql_stop_on_error_test.go
@@ -117,7 +117,7 @@ func TestSQLQueryStopOnError(t *testing.T) {
Instance: &v1pb.Instance{
Title: "mysqlInstance",
Engine: v1pb.Engine_MYSQL,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: mysqlContainer.host, Port: mysqlContainer.port, Username: "root", Password: "root-password", Id: "admin"}},
},
@@ -130,7 +130,7 @@ func TestSQLQueryStopOnError(t *testing.T) {
Instance: &v1pb.Instance{
Title: "pgInstance",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: pgContainer.host, Port: pgContainer.port, Username: "postgres", Password: "root-password", Id: "admin"}},
},
@@ -144,7 +144,7 @@ func TestSQLQueryStopOnError(t *testing.T) {
Instance: &v1pb.Instance{
Title: "mysqlTestInstance",
Engine: v1pb.Engine_MYSQL,
- Environment: stringPtr("environments/test"),
+ Environment: new("environments/test"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: mysqlContainer.host, Port: mysqlContainer.port, Username: "root", Password: "root-password", Id: "admin"}},
},
@@ -157,7 +157,7 @@ func TestSQLQueryStopOnError(t *testing.T) {
Instance: &v1pb.Instance{
Title: "pgTestInstance",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/test"),
+ Environment: new("environments/test"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: pgContainer.host, Port: pgContainer.port, Username: "postgres", Password: "root-password", Id: "admin"}},
},
@@ -322,7 +322,7 @@ func TestSQLAdminExecuteStopOnError(t *testing.T) {
Instance: &v1pb.Instance{
Title: "mysqlInstance",
Engine: v1pb.Engine_MYSQL,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: mysqlContainer.host, Port: mysqlContainer.port, Username: "root", Password: "root-password", Id: "admin"}},
},
@@ -335,7 +335,7 @@ func TestSQLAdminExecuteStopOnError(t *testing.T) {
Instance: &v1pb.Instance{
Title: "pgInstance",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: pgContainer.host, Port: pgContainer.port, Username: "postgres", Password: "root-password", Id: "admin"}},
},
diff --git a/backend/tests/sync_schema_test.go b/backend/tests/sync_schema_test.go
index cb6c62398d..53dc7a6ddc 100644
--- a/backend/tests/sync_schema_test.go
+++ b/backend/tests/sync_schema_test.go
@@ -56,7 +56,7 @@ func TestSyncSchema(t *testing.T) {
Instance: &v1pb.Instance{
Title: "pgTestSyncSchema",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: pgContainer.host, Port: pgContainer.port, Username: "bytebase", Password: "bytebase", Id: "admin"}},
},
@@ -198,7 +198,7 @@ func TestSyncSchemaWithTempSchema(t *testing.T) {
Instance: &v1pb.Instance{
Title: "pgTestSyncSchemaWithTemp",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: pgContainer.host, Port: pgContainer.port, Username: "testuser", Password: "testpass", Id: "admin"}},
},
diff --git a/backend/tests/syncer_test.go b/backend/tests/syncer_test.go
index 88223c30a7..d9e12fbc2f 100644
--- a/backend/tests/syncer_test.go
+++ b/backend/tests/syncer_test.go
@@ -209,7 +209,7 @@ func TestSyncerForPostgreSQL(t *testing.T) {
Instance: &v1pb.Instance{
Title: "pgInstance",
Engine: v1pb.Engine_POSTGRES,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: pgContainer.host, Port: pgContainer.port, Username: "bytebase", Password: "bytebase", Id: "admin"}},
},
@@ -492,7 +492,7 @@ func TestSyncerForMySQL(t *testing.T) {
Instance: &v1pb.Instance{
Title: "mysqlInstance",
Engine: v1pb.Engine_MYSQL,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: mysqlContainer.host, Port: mysqlContainer.port, Username: "bytebase", Password: "bytebase", Id: "admin"}},
},
diff --git a/backend/tests/task_run_idempotent_test.go b/backend/tests/task_run_idempotent_test.go
index 247c80f0f9..7b37527fbc 100644
--- a/backend/tests/task_run_idempotent_test.go
+++ b/backend/tests/task_run_idempotent_test.go
@@ -33,7 +33,7 @@ func TestBatchRunTasks_Idempotent(t *testing.T) {
Instance: &v1pb.Instance{
Title: instanceName,
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: instanceDir, Id: "admin"}},
},
diff --git a/backend/tests/tenant_test.go b/backend/tests/tenant_test.go
index a9908da50c..9e5c0df660 100644
--- a/backend/tests/tenant_test.go
+++ b/backend/tests/tenant_test.go
@@ -62,7 +62,7 @@ func TestTenantBackfill(t *testing.T) {
Instance: &v1pb.Instance{
Title: "prod-instance",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: prodInstanceDir, Id: "admin"}},
},
diff --git a/backend/tests/webhook_test.go b/backend/tests/webhook_test.go
index 43b3f7ba85..05671940a0 100644
--- a/backend/tests/webhook_test.go
+++ b/backend/tests/webhook_test.go
@@ -168,7 +168,7 @@ func TestWebhookIntegration(t *testing.T) {
Instance: &v1pb.Instance{
Title: "test instance",
Engine: v1pb.Engine_SQLITE,
- Environment: stringPtr("environments/prod"),
+ Environment: new("environments/prod"),
Activation: true,
DataSources: []*v1pb.DataSource{{Type: v1pb.DataSourceType_ADMIN, Host: instanceDir, Id: "admin"}},
},