Skip to content

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

chore: fix lint (#15623)

Danny Xuc0d921a41567
diff --git a/backend/api/auth/auth.go b/backend/api/auth/auth.go
index c669a23b05..95b7d7cb21 100644
--- a/backend/api/auth/auth.go
+++ b/backend/api/auth/auth.go
@@ -208,7 +208,7 @@ func (in *APIAuthInterceptor) getPrincipalID(ctx context.Context, accessTokenStr
}
// Only update for authorized request.
- in.profile.LastActiveTs = time.Now().Unix()
+ in.profile.LastActiveTS = time.Now().Unix()
return principalID, nil
}
diff --git a/backend/api/v1/actuator_service.go b/backend/api/v1/actuator_service.go
index 8058abedc9..8c34042e98 100644
--- a/backend/api/v1/actuator_service.go
+++ b/backend/api/v1/actuator_service.go
@@ -126,7 +126,7 @@ func (s *ActuatorService) getServerInfo(ctx context.Context) (*v1pb.ActuatorInfo
ExternalUrl: setting.ExternalUrl,
DisallowSignup: setting.DisallowSignup,
Require_2Fa: setting.Require_2Fa,
- LastActiveTime: timestamppb.New(time.Unix(s.profile.LastActiveTs, 0)),
+ LastActiveTime: timestamppb.New(time.Unix(s.profile.LastActiveTS, 0)),
WorkspaceId: workspaceID,
Debug: s.profile.RuntimeDebug.Load(),
Docker: s.profile.IsDocker,
diff --git a/backend/api/v1/auth_service.go b/backend/api/v1/auth_service.go
index 88a6c7daa7..c73184bd34 100644
--- a/backend/api/v1/auth_service.go
+++ b/backend/api/v1/auth_service.go
@@ -157,19 +157,20 @@ func (s *AuthService) Login(ctx context.Context, request *v1pb.LoginRequest) (*v
}, nil
}
- if loginUser.Type == api.EndUser {
+ switch loginUser.Type {
+ case api.EndUser:
token, err := auth.GenerateAccessToken(loginUser.Name, loginUser.ID, s.profile.Mode, s.secret, tokenDuration)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to generate API access token")
}
response.Token = token
- } else if loginUser.Type == api.ServiceAccount {
+ case api.ServiceAccount:
token, err := auth.GenerateAPIToken(loginUser.Name, loginUser.ID, s.profile.Mode, s.secret)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to generate API access token")
}
response.Token = token
- } else {
+ default:
return nil, status.Errorf(codes.Unauthenticated, "user type %s cannot login", loginUser.Type)
}
@@ -312,7 +313,8 @@ func (s *AuthService) getOrCreateUserWithIDP(ctx context.Context, request *v1pb.
}
var userInfo *storepb.IdentityProviderUserInfo
- if idp.Type == storepb.IdentityProviderType_OAUTH2 {
+ switch idp.Type {
+ case storepb.IdentityProviderType_OAUTH2:
oauth2Context := request.IdpContext.GetOauth2Context()
if oauth2Context == nil {
return nil, status.Errorf(codes.InvalidArgument, "missing OAuth2 context")
@@ -330,7 +332,7 @@ func (s *AuthService) getOrCreateUserWithIDP(ctx context.Context, request *v1pb.
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get user info: %v", err)
}
- } else if idp.Type == storepb.IdentityProviderType_OIDC {
+ case storepb.IdentityProviderType_OIDC:
oauth2Context := request.IdpContext.GetOauth2Context()
if oauth2Context == nil {
return nil, status.Errorf(codes.InvalidArgument, "missing OAuth2 context")
@@ -362,7 +364,7 @@ func (s *AuthService) getOrCreateUserWithIDP(ctx context.Context, request *v1pb.
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get user info: %v", err)
}
- } else if idp.Type == storepb.IdentityProviderType_LDAP {
+ case storepb.IdentityProviderType_LDAP:
idpConfig := idp.Config.GetLdapConfig()
ldapIDP, err := ldap.NewIdentityProvider(
ldap.IdentityProviderConfig{
@@ -385,7 +387,7 @@ func (s *AuthService) getOrCreateUserWithIDP(ctx context.Context, request *v1pb.
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get user info: %v", err)
}
- } else {
+ default:
return nil, status.Errorf(codes.InvalidArgument, "identity provider type %s not supported", idp.Type.String())
}
if userInfo == nil {
diff --git a/backend/api/v1/plan_service.go b/backend/api/v1/plan_service.go
index cd3af571b2..9560302fbe 100644
--- a/backend/api/v1/plan_service.go
+++ b/backend/api/v1/plan_service.go
@@ -468,12 +468,12 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
}
specEarliest := spec.EarliestAllowedTime.GetSeconds()
if specEarliest != taskEarliest {
- taskPatch.UpdateEarliestAllowedTs = true
+ taskPatch.UpdateEarliestAllowedTS = true
if specEarliest == 0 {
- taskPatch.EarliestAllowedTs = nil
+ taskPatch.EarliestAllowedTS = nil
} else {
v := spec.EarliestAllowedTime.AsTime()
- taskPatch.EarliestAllowedTs = &v
+ taskPatch.EarliestAllowedTS = &v
}
doUpdate = true
@@ -687,7 +687,7 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
}
for _, taskPatch := range taskPatchList {
- if taskPatch.SheetID != nil || taskPatch.EarliestAllowedTs != nil {
+ if taskPatch.SheetID != nil || taskPatch.EarliestAllowedTS != nil {
task := tasksMap[taskPatch.ID]
if task.LatestTaskRunStatus == api.TaskRunPending || task.LatestTaskRunStatus == api.TaskRunRunning || task.LatestTaskRunStatus == api.TaskRunSkipped || task.LatestTaskRunStatus == api.TaskRunDone {
return nil, status.Errorf(codes.FailedPrecondition, "cannot update plan because task %v is %s", task.ID, task.LatestTaskRunStatus)
diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.go
index 469eb0a4a1..7dbfefe7a8 100644
--- a/backend/api/v1/project_service.go
+++ b/backend/api/v1/project_service.go
@@ -938,7 +938,7 @@ func (s *ProjectService) TestWebhook(ctx context.Context, request *v1pb.TestWebh
ActorID: api.SystemBotID,
ActorName: "Bytebase",
ActorEmail: s.store.GetSystemBotUser(ctx).Email,
- CreatedTs: time.Now().Unix(),
+ CreatedTS: time.Now().Unix(),
Issue: &webhookplugin.Issue{
ID: 1,
Name: "Test issue",
diff --git a/backend/bin/server/cmd/profile.go b/backend/bin/server/cmd/profile.go
index be32f4cd28..930dfb7b0f 100644
--- a/backend/bin/server/cmd/profile.go
+++ b/backend/bin/server/cmd/profile.go
@@ -34,7 +34,7 @@ func getBaseProfile(dataDir string) *config.Profile {
GitCommit: gitcommit,
PgURL: flags.pgURL,
DeployID: uuid.NewString()[:8],
- LastActiveTs: time.Now().Unix(),
+ LastActiveTS: time.Now().Unix(),
}
}
diff --git a/backend/common/error.go b/backend/common/error.go
index fe89da0a13..391f196b9f 100644
--- a/backend/common/error.go
+++ b/backend/common/error.go
@@ -22,8 +22,8 @@ const (
SizeExceeded Code = 7
// 101 ~ 199 db error.
- DbConnectionFailure Code = 101
- DbExecutionError Code = 102
+ DBConnectionFailure Code = 101
+ DBExecutionError Code = 102
// 201 db migration error
// Db migration is a core feature, so we separate it from the db error.
@@ -119,5 +119,5 @@ func Wrap(err error, code Code) *Error {
// FormatDBErrorEmptyRowWithQuery formats database error that query returns empty row.
func FormatDBErrorEmptyRowWithQuery(query string) error {
- return Errorf(DbExecutionError, "query %q returned empty row", query)
+ return Errorf(DBExecutionError, "query %q returned empty row", query)
}
diff --git a/backend/component/config/profile.go b/backend/component/config/profile.go
index d6a4d5884a..635122c1c5 100644
--- a/backend/component/config/profile.go
+++ b/backend/component/config/profile.go
@@ -47,8 +47,8 @@ type Profile struct {
// MetricConnectionKey is the connection key for metric.
MetricConnectionKey string
- // LastActiveTs is the service last active timestamp, any API calls will refresh this value.
- LastActiveTs int64
+ // LastActiveTS is the service last active timestamp, any API calls will refresh this value.
+ LastActiveTS int64
// Unique ID per Bytebase instance run.
DeployID string
// Whether the server is running in a docker container.
diff --git a/backend/component/masker/masker.go b/backend/component/masker/masker.go
index 74fcda9d64..b748b80eb6 100644
--- a/backend/component/masker/masker.go
+++ b/backend/component/masker/masker.go
@@ -629,11 +629,12 @@ func maskProtoValue(m Masker, value *structpb.Value) *structpb.Value {
func NewInnerOuterMasker(storeMaskerType storepb.Algorithm_InnerOuterMask_MaskType, prefixLen, suffixLen int32, substitution string) *InnerOuterMasker {
var maskerType int32
- if storeMaskerType == storepb.Algorithm_InnerOuterMask_INNER {
+ switch storeMaskerType {
+ case storepb.Algorithm_InnerOuterMask_INNER:
maskerType = InnerOuterMaskerTypeInner
- } else if storeMaskerType == storepb.Algorithm_InnerOuterMask_OUTER {
+ case storepb.Algorithm_InnerOuterMask_OUTER:
maskerType = InnerOuterMaskerTypeOuter
- } else {
+ default:
return nil
}
diff --git a/backend/component/webhook/manager.go b/backend/component/webhook/manager.go
index fb4e9cb963..80e3d952af 100644
--- a/backend/component/webhook/manager.go
+++ b/backend/component/webhook/manager.go
@@ -384,7 +384,7 @@ func (m *Manager) postWebhookList(ctx context.Context, webhookCtx *webhook.Conte
for _, hook := range webhookList {
webhookCtx := *webhookCtx
webhookCtx.URL = hook.URL
- webhookCtx.CreatedTs = time.Now().Unix()
+ webhookCtx.CreatedTS = time.Now().Unix()
webhookCtx.DirectMessage = hook.Payload.GetDirectMessage()
go func(webhookCtx *webhook.Context, hook *store.ProjectWebhookMessage) {
if err := common.Retry(ctx, func() error {
diff --git a/backend/plugin/advisor/catalog/walk_through_for_pg.go b/backend/plugin/advisor/catalog/walk_through_for_pg.go
index 0ecca71e7d..3a9064ab13 100644
--- a/backend/plugin/advisor/catalog/walk_through_for_pg.go
+++ b/backend/plugin/advisor/catalog/walk_through_for_pg.go
@@ -1017,7 +1017,7 @@ func (s *SchemaState) pgGenerateIndexName(createIndex *ast.CreateIndexStmt) (str
return "", err
}
if expressionID != 0 {
- if _, err := buf.WriteString(fmt.Sprintf("%d", expressionID)); err != nil {
+ if _, err := fmt.Fprintf(buf, "%d", expressionID); err != nil {
return "", err
}
}
diff --git a/backend/plugin/db/databricks/dump.go b/backend/plugin/db/databricks/dump.go
index 43dafd9b28..3cdc20052f 100644
--- a/backend/plugin/db/databricks/dump.go
+++ b/backend/plugin/db/databricks/dump.go
@@ -37,7 +37,7 @@ func (d *Driver) Dump(ctx context.Context, writer io.Writer, _ *storepb.Database
if catalogName == sysCatalog {
continue
}
- if _, err := writer.Write([]byte(fmt.Sprintf("CREATE CATALOG %s\n", catalogName))); err != nil {
+ if _, err := fmt.Fprintf(writer, "CREATE CATALOG %s\n", catalogName); err != nil {
return err
}
@@ -46,8 +46,7 @@ func (d *Driver) Dump(ctx context.Context, writer io.Writer, _ *storepb.Database
continue
}
if schemaName != dftSchema {
- _, err := writer.Write([]byte(fmt.Sprintf("CREATE SCHEMA `%s`.`%s`\n", catalogName, schemaName)))
- if err != nil {
+ if _, err := fmt.Fprintf(writer, "CREATE SCHEMA `%s`.`%s`\n", catalogName, schemaName); err != nil {
return err
}
}
diff --git a/backend/plugin/db/hive/dump.go b/backend/plugin/db/hive/dump.go
index 4e49f6b0a9..f31648f6af 100644
--- a/backend/plugin/db/hive/dump.go
+++ b/backend/plugin/db/hive/dump.go
@@ -328,7 +328,7 @@ func genMaterializedViewDDL(opts *MaterializedViewDDLOptions) (string, error) {
func formatColumn(builder *strings.Builder, columnNames []string) {
_, _ = builder.WriteString("(\n")
for idx, colName := range columnNames {
- _, _ = builder.WriteString(fmt.Sprintf(" `%s`", colName))
+ _, _ = fmt.Fprintf(builder, " `%s`", colName)
if idx != len(columnNames)-1 {
_, _ = builder.WriteString(",\n")
}
@@ -341,7 +341,7 @@ func formatKVPair(builder *strings.Builder, kvMap map[string]string) {
count := 0
for key, value := range kvMap {
count++
- _, _ = builder.WriteString(fmt.Sprintf(" '%s' = '%s'", key, value))
+ _, _ = fmt.Fprintf(builder, " '%s' = '%s'", key, value)
if count != len(kvMap) {
_, _ = builder.WriteString(",\n")
}
diff --git a/backend/plugin/db/obo/dump.go b/backend/plugin/db/obo/dump.go
index a7f3c57030..a0171b2e0d 100644
--- a/backend/plugin/db/obo/dump.go
+++ b/backend/plugin/db/obo/dump.go
@@ -144,13 +144,13 @@ func (t *tableSchema) assembleStatement(out io.Writer) error {
}
if t.meta.PctFree.Valid {
- if _, err := out.Write([]byte(fmt.Sprintf("\nPCTFREE %d", t.meta.PctFree.Int64))); err != nil {
+ if _, err := fmt.Fprintf(out, "\nPCTFREE %d", t.meta.PctFree.Int64); err != nil {
return err
}
}
if t.meta.IniTrans.Valid {
- if _, err := out.Write([]byte(fmt.Sprintf("\nINITRANS %d", t.meta.IniTrans.Int64))); err != nil {
+ if _, err := fmt.Fprintf(out, "\nINITRANS %d", t.meta.IniTrans.Int64); err != nil {
return err
}
}
@@ -177,7 +177,7 @@ func (t *tableSchema) assembleStatement(out io.Writer) error {
return err
}
} else {
- if _, err := out.Write([]byte(fmt.Sprintf("\nPARALLEL %s", t.meta.Degree.String))); err != nil {
+ if _, err := fmt.Fprintf(out, "\nPARALLEL %s", t.meta.Degree.String); err != nil {
return err
}
}
@@ -227,35 +227,35 @@ func (t *tableSchema) assembleStorage(out io.Writer) error {
switch {
case t.meta.InitialExtent.Valid:
- if _, err := out.Write([]byte(fmt.Sprintf("\n INITIAL %d", t.meta.InitialExtent.Int64))); err != nil {
+ if _, err := fmt.Fprintf(out, "\n INITIAL %d", t.meta.InitialExtent.Int64); err != nil {
return err
}
case t.meta.NextExtent.Valid:
- if _, err := out.Write([]byte(fmt.Sprintf("\n NEXT %d", t.meta.NextExtent.Int64))); err != nil {
+ if _, err := fmt.Fprintf(out, "\n NEXT %d", t.meta.NextExtent.Int64); err != nil {
return err
}
case t.meta.MinExtents.Valid:
- if _, err := out.Write([]byte(fmt.Sprintf("\n MINEXTENTS %d", t.meta.MinExtents.Int64))); err != nil {
+ if _, err := fmt.Fprintf(out, "\n MINEXTENTS %d", t.meta.MinExtents.Int64); err != nil {
return err
}
case t.meta.MaxExtents.Valid:
- if _, err := out.Write([]byte(fmt.Sprintf("\n MAXEXTENTS %d", t.meta.MaxExtents.Int64))); err != nil {
+ if _, err := fmt.Fprintf(out, "\n MAXEXTENTS %d", t.meta.MaxExtents.Int64); err != nil {
return err
}
case t.meta.PctIncrease.Valid:
- if _, err := out.Write([]byte(fmt.Sprintf("\n PCTINCREASE %d", t.meta.PctIncrease.Int64))); err != nil {
+ if _, err := fmt.Fprintf(out, "\n PCTINCREASE %d", t.meta.PctIncrease.Int64); err != nil {
return err
}
case t.meta.FreeLists.Valid:
- if _, err := out.Write([]byte(fmt.Sprintf("\n FREELISTS %d", t.meta.FreeLists.Int64))); err != nil {
+ if _, err := fmt.Fprintf(out, "\n FREELISTS %d", t.meta.FreeLists.Int64); err != nil {
return err
}
case t.meta.FreeListGroups.Valid:
- if _, err := out.Write([]byte(fmt.Sprintf("\n FREELIST GROUPS %d", t.meta.FreeListGroups.Int64))); err != nil {
+ if _, err := fmt.Fprintf(out, "\n FREELIST GROUPS %d", t.meta.FreeListGroups.Int64); err != nil {
return err
}
case t.meta.BufferPool.Valid && t.meta.BufferPool.String != "NULL":
- if _, err := out.Write([]byte(fmt.Sprintf("\n BUFFER_POOL %s", t.meta.BufferPool.String))); err != nil {
+ if _, err := fmt.Fprintf(out, "\n BUFFER_POOL %s", t.meta.BufferPool.String); err != nil {
return err
}
}
@@ -454,11 +454,11 @@ func (f *fieldMeta) assembleType(out io.Writer) error {
}
switch f.DataType.String {
case "VARCHAR2", "CHAR":
- if _, err := out.Write([]byte(fmt.Sprintf("(%d BYTE)", f.DataLength.Int64))); err != nil {
+ if _, err := fmt.Fprintf(out, "(%d BYTE)", f.DataLength.Int64); err != nil {
return err
}
case "NVARCHAR2", "RAW", "UROWID", "NCHAR":
- if _, err := out.Write([]byte(fmt.Sprintf("(%d)", f.DataLength.Int64))); err != nil {
+ if _, err := fmt.Fprintf(out, "(%d)", f.DataLength.Int64); err != nil {
return err
}
case "NUMBER":
@@ -466,7 +466,7 @@ func (f *fieldMeta) assembleType(out io.Writer) error {
case !f.DataPrecision.Valid || f.DataPrecision.Int64 == 0:
// do nothing
case f.DataPrecision.Valid && f.DataPrecision.Int64 > 0 && (!f.DataScale.Valid || f.DataScale.Int64 == 0):
- if _, err := out.Write([]byte(fmt.Sprintf("(%d)", f.DataPrecision.Int64))); err != nil {
+ if _, err := fmt.Fprintf(out, "(%d)", f.DataPrecision.Int64); err != nil {
return err
}
case f.DataPrecision.Valid && f.DataPrecision.Int64 > 0 && f.DataScale.Valid && f.DataScale.Int64 > 0:
@@ -479,7 +479,7 @@ func (f *fieldMeta) assembleType(out io.Writer) error {
case !f.DataPrecision.Valid || f.DataPrecision.Int64 == 0:
// do nothing
case f.DataPrecision.Valid && f.DataPrecision.Int64 > 0:
- if _, err := out.Write([]byte(fmt.Sprintf("(%d)", f.DataPrecision.Int64))); err != nil {
+ if _, err := fmt.Fprintf(out, "(%d)", f.DataPrecision.Int64); err != nil {
return err
}
}
diff --git a/backend/plugin/parser/mysql/differ.go b/backend/plugin/parser/mysql/differ.go
index cf4173c32b..d415f1f5fd 100644
--- a/backend/plugin/parser/mysql/differ.go
+++ b/backend/plugin/parser/mysql/differ.go
@@ -872,7 +872,7 @@ func sortAndWriteDropCheckConstraintList(buf *strings.Builder, checks []*checkDe
}
func writeDropCheckConstraintStatement(buf *strings.Builder, check *checkDef) error {
- if _, err := buf.WriteString(fmt.Sprintf("ALTER TABLE `%s` DROP CHECK `%s`;\n\n", check.tableName, check.name)); err != nil {
+ if _, err := fmt.Fprintf(buf, "ALTER TABLE `%s` DROP CHECK `%s`;\n\n", check.tableName, check.name); err != nil {
return err
}
return nil
@@ -894,7 +894,7 @@ func sortAndWriteAddCheckConstraintList(buf *strings.Builder, checks []*checkDef
}
func writeAddCheckConstraintStatement(buf *strings.Builder, check *checkDef) error {
- if _, err := buf.WriteString(fmt.Sprintf("ALTER TABLE `%s` ADD ", check.tableName)); err != nil {
+ if _, err := fmt.Fprintf(buf, "ALTER TABLE `%s` ADD ", check.tableName); err != nil {
return err
}
if _, err := buf.WriteString(check.ctx.GetParser().GetTokenStream().GetTextFromRuleContext(check.ctx.GetRuleContext())); err != nil {
diff --git a/backend/plugin/parser/sql/engine/pg/deparse.go b/backend/plugin/parser/sql/engine/pg/deparse.go
index 08fd01a265..07eac96583 100644
--- a/backend/plugin/parser/sql/engine/pg/deparse.go
+++ b/backend/plugin/parser/sql/engine/pg/deparse.go
@@ -1073,7 +1073,7 @@ func deparseColumnConstraint(_ DeparseContext, in *ast.ConstraintDef, buf *strin
return err
}
case ast.ConstraintTypeGenerated:
- if _, err := buf.WriteString(fmt.Sprintf("GENERATED ALWAYS AS (%s) STORED", in.Expression.Text())); err != nil {
+ if _, err := fmt.Fprintf(buf, "GENERATED ALWAYS AS (%s) STORED", in.Expression.Text()); err != nil {
return err
}
default:
@@ -1240,7 +1240,7 @@ func deparseAlterSequence(ctx DeparseContext, in *ast.AlterSequenceStmt, buf *st
return err
}
- if _, err := buf.WriteString(fmt.Sprintf("INCREMENT BY %d", *in.IncrementBy)); err != nil {
+ if _, err := fmt.Fprintf(buf, "INCREMENT BY %d", *in.IncrementBy); err != nil {
return err
}
}
@@ -1264,7 +1264,7 @@ func deparseAlterSequence(ctx DeparseContext, in *ast.AlterSequenceStmt, buf *st
return err
}
- if _, err := buf.WriteString(fmt.Sprintf("MINVALUE %d", *in.MinValue)); err != nil {
+ if _, err := fmt.Fprintf(buf, "MINVALUE %d", *in.MinValue); err != nil {
return err
}
}
@@ -1288,7 +1288,7 @@ func deparseAlterSequence(ctx DeparseContext, in *ast.AlterSequenceStmt, buf *st
return err
}
- if _, err := buf.WriteString(fmt.Sprintf("MAXVALUE %d", *in.MaxValue)); err != nil {
+ if _, err := fmt.Fprintf(buf, "MAXVALUE %d", *in.MaxValue); err != nil {
return err
}
}
@@ -1301,7 +1301,7 @@ func deparseAlterSequence(ctx DeparseContext, in *ast.AlterSequenceStmt, buf *st
return err
}
- if _, err := buf.WriteString(fmt.Sprintf("START WITH %d", *in.StartWith)); err != nil {
+ if _, err := fmt.Fprintf(buf, "START WITH %d", *in.StartWith); err != nil {
return err
}
}
@@ -1314,7 +1314,7 @@ func deparseAlterSequence(ctx DeparseContext, in *ast.AlterSequenceStmt, buf *st
return err
}
- if _, err := buf.WriteString(fmt.Sprintf("RESTART WITH %d", *in.RestartWith)); err != nil {
+ if _, err := fmt.Fprintf(buf, "RESTART WITH %d", *in.RestartWith); err != nil {
return err
}
}
@@ -1327,7 +1327,7 @@ func deparseAlterSequence(ctx DeparseContext, in *ast.AlterSequenceStmt, buf *st
return err
}
- if _, err := buf.WriteString(fmt.Sprintf("CACHE %d", *in.Cache)); err != nil {
+ if _, err := fmt.Fprintf(buf, "CACHE %d", *in.Cache); err != nil {
return err
}
}
@@ -1630,7 +1630,7 @@ func depraseSequenceDef(ctx DeparseContext, in *ast.SequenceDef, buf *strings.Bu
if err := ctx.WriteIndent(buf, deparseIndentString); err != nil {
return err
}
- if _, err := buf.WriteString(fmt.Sprintf("INCREMENT BY %d", *in.IncrementBy)); err != nil {
+ if _, err := fmt.Fprintf(buf, "INCREMENT BY %d", *in.IncrementBy); err != nil {
return err
}
}
@@ -1641,7 +1641,7 @@ func depraseSequenceDef(ctx DeparseContext, in *ast.SequenceDef, buf *strings.Bu
if err := ctx.WriteIndent(buf, deparseIndentString); err != nil {
return err
}
- if _, err := buf.WriteString(fmt.Sprintf("MINVALUE %d", *in.MinValue)); err != nil {
+ if _, err := fmt.Fprintf(buf, "MINVALUE %d", *in.MinValue); err != nil {
return err
}
} else {
diff --git a/backend/plugin/schema/clickhouse/state.go b/backend/plugin/schema/clickhouse/state.go
index 649368240c..97bcf6b65c 100644
--- a/backend/plugin/schema/clickhouse/state.go
+++ b/backend/plugin/schema/clickhouse/state.go
@@ -66,7 +66,7 @@ type tableState struct {
}
func (t *tableState) toString(buf *strings.Builder) error {
- if _, err := buf.WriteString(fmt.Sprintf("CREATE TABLE %s (\n ", t.name)); err != nil {
+ if _, err := fmt.Fprintf(buf, "CREATE TABLE %s (\n ", t.name); err != nil {
return err
}
columns := []*columnState{}
@@ -78,7 +78,7 @@ func (t *tableState) toString(buf *strings.Builder) error {
})
for i, column := range columns {
if i > 0 {
- if _, err := buf.WriteString(",\n "); err != nil {
+ if _, err := fmt.Fprintf(buf, ",\n "); err != nil {
return err
}
}
@@ -90,12 +90,12 @@ func (t *tableState) toString(buf *strings.Builder) error {
return err
}
if t.engine != "" {
- if _, err := buf.WriteString(fmt.Sprintf("\nENGINE = %s", t.engine)); err != nil {
+ if _, err := fmt.Fprintf(buf, "\nENGINE = %s", t.engine); err != nil {
return err
}
}
if len(t.sortingKeys) > 0 {
- if _, err := buf.WriteString(fmt.Sprintf("\nORDER BY (%s)", strings.Join(t.sortingKeys, ", "))); err != nil {
+ if _, err := fmt.Fprintf(buf, "\nORDER BY (%s)", strings.Join(t.sortingKeys, ", ")); err != nil {
return err
}
} else {
@@ -109,12 +109,12 @@ func (t *tableState) toString(buf *strings.Builder) error {
}
}
if len(t.primaryKeys) > 0 {
- if _, err := buf.WriteString(fmt.Sprintf("\nPRIMARY KEY (%s)", strings.Join(t.primaryKeys, ", "))); err != nil {
+ if _, err := fmt.Fprintf(buf, "\nPRIMARY KEY (%s)", strings.Join(t.primaryKeys, ", ")); err != nil {
return err
}
}
if t.comment != "" {
- if _, err := buf.WriteString(fmt.Sprintf("\nCOMMENT '%s'", t.comment)); err != nil {
+ if _, err := fmt.Fprintf(buf, "\nCOMMENT '%s'", t.comment); err != nil {
return err
}
}
@@ -198,12 +198,12 @@ func (c *columnState) toString(buf *strings.Builder) error {
}
}
if c.defaultValue != nil {
- if _, err := buf.WriteString(fmt.Sprintf(" DEFAULT %s", c.defaultValue.toString())); err != nil {
+ if _, err := fmt.Fprintf(buf, " DEFAULT %s", c.defaultValue.toString()); err != nil {
return err
}
}
if c.comment != "" {
- if _, err := buf.WriteString(fmt.Sprintf(" COMMENT '%s'", c.comment)); err != nil {
+ if _, err := fmt.Fprintf(buf, " COMMENT '%s'", c.comment); err != nil {
return err
}
}
diff --git a/backend/plugin/schema/redshift/get_database_definition.go b/backend/plugin/schema/redshift/get_database_definition.go
index 31ccad03b1..6b0238209e 100644
--- a/backend/plugin/schema/redshift/get_database_definition.go
+++ b/backend/plugin/schema/redshift/get_database_definition.go
@@ -99,13 +99,13 @@ func writeTables(w io.StringWriter, to *storepb.DatabaseSchemaMetadata, state *d
}
// Generate comment for table and columns.
if table.comment != "" {
- if _, err := buf.WriteString(fmt.Sprintf("COMMENT ON TABLE %s IS '%s';\n", table.name, table.comment)); err != nil {
+ if _, err := fmt.Fprintf(buf, "COMMENT ON TABLE %s IS '%s';\n", table.name, table.comment); err != nil {
return err
}
}
for _, column := range table.columns {
if column.comment != "" {
- if _, err := buf.WriteString(fmt.Sprintf("COMMENT ON COLUMN %s.%s IS '%s';\n", table.name, column.name, column.comment)); err != nil {
+ if _, err := fmt.Fprintf(buf, "COMMENT ON COLUMN %s.%s IS '%s';\n", table.name, column.name, column.comment); err != nil {
return err
}
}
@@ -142,7 +142,7 @@ func writeViews(w io.StringWriter, to *storepb.DatabaseSchemaMetadata, state *da
}
// Generate comment for view.
if view.comment != "" {
- if _, err := buf.WriteString(fmt.Sprintf("COMMENT ON VIEW %s IS '%s';\n", view.name, view.comment)); err != nil {
+ if _, err := fmt.Fprintf(buf, "COMMENT ON VIEW %s IS '%s';\n", view.name, view.comment); err != nil {
return err
}
}
diff --git a/backend/plugin/schema/redshift/state.go b/backend/plugin/schema/redshift/state.go
index e0bf87ea8d..b0110a82bf 100644
--- a/backend/plugin/schema/redshift/state.go
+++ b/backend/plugin/schema/redshift/state.go
@@ -64,7 +64,7 @@ type tableState struct {
}
func (t *tableState) toString(buf *strings.Builder) error {
- if _, err := buf.WriteString(fmt.Sprintf("CREATE TABLE %s (\n ", t.name)); err != nil {
+ if _, err := fmt.Fprintf(buf, "CREATE TABLE %s (\n ", t.name); err != nil {
return err
}
columns := []*columnState{}
@@ -190,7 +190,7 @@ func (f *foreignKeyState) toString(buf *strings.Builder) error {
return err
}
referencedColumn := f.referencedColumns[i]
- if _, err := buf.WriteString(fmt.Sprintf("%s(%s)", f.referencedTable, referencedColumn)); err != nil {
+ if _, err := fmt.Fprintf(buf, "%s(%s)", f.referencedTable, referencedColumn); err != nil {
return err
}
}
@@ -307,7 +307,7 @@ func (c *columnState) toString(buf *strings.Builder) error {
}
}
if c.defaultValue != nil {
- if _, err := buf.WriteString(fmt.Sprintf(" DEFAULT %s", c.defaultValue.toString())); err != nil {
+ if _, err := fmt.Fprintf(buf, " DEFAULT %s", c.defaultValue.toString()); err != nil {
return err
}
}
diff --git a/backend/plugin/schema/tidb/state.go b/backend/plugin/schema/tidb/state.go
index ee350c6969..290e7b6c20 100644
--- a/backend/plugin/schema/tidb/state.go
+++ b/backend/plugin/schema/tidb/state.go
@@ -76,7 +76,7 @@ type tableState struct {
}
func (t *tableState) toString(buf *strings.Builder) error {
- if _, err := buf.WriteString(fmt.Sprintf("CREATE TABLE `%s` (\n ", t.name)); err != nil {
+ if _, err := fmt.Fprintf(buf, "CREATE TABLE `%s` (\n ", t.name); err != nil {
return err
}
columns := []*columnState{}
@@ -146,19 +146,19 @@ func (t *tableState) toString(buf *strings.Builder) error {
}
if t.engine != "" {
- if _, err := buf.WriteString(fmt.Sprintf(" ENGINE=%s", t.engine)); err != nil {
+ if _, err := fmt.Fprintf(buf, " ENGINE=%s", t.engine); err != nil {
return err
}
}
if t.collation != "" {
- if _, err := buf.WriteString(fmt.Sprintf(" COLLATE=%s", t.collation)); err != nil {
+ if _, err := fmt.Fprintf(buf, " COLLATE=%s", t.collation); err != nil {
return err
}
}
if t.comment != "" {
- if _, err := buf.WriteString(fmt.Sprintf(" COMMENT '%s'", t.comment)); err != nil {
+ if _, err := fmt.Fprintf(buf, " COMMENT '%s'", t.comment); err != nil {
return err
}
}
@@ -311,7 +311,7 @@ func (i *indexState) toString(buf *strings.Builder) error {
return err
}
}
- if _, err := buf.WriteString(fmt.Sprintf("`%s`", key)); err != nil {
+ if _, err := fmt.Fprintf(buf, "`%s`", key); err != nil {
return err
}
}
@@ -941,7 +941,7 @@ func (c *columnState) toString(buf *strings.Builder) error {
return err
}
} else {
- if _, err := buf.WriteString(fmt.Sprintf(" DEFAULT %s", c.defaultValue.toString())); err != nil {
+ if _, err := fmt.Fprintf(buf, " DEFAULT %s", c.defaultValue.toString()); err != nil {
return err
}
}
diff --git a/backend/plugin/webhook/webhook.go b/backend/plugin/webhook/webhook.go
index e9c87e6e2c..e6a4e5ab0f 100644
--- a/backend/plugin/webhook/webhook.go
+++ b/backend/plugin/webhook/webhook.go
@@ -88,7 +88,7 @@ type Context struct {
ActorID int
ActorName string
ActorEmail string
- CreatedTs int64
+ CreatedTS int64
Issue *Issue
Rollout *Rollout
Stage *Stage
diff --git a/backend/runner/metricreport/reporter.go b/backend/runner/metricreport/reporter.go
index 768ab9d148..65609a9120 100644
--- a/backend/runner/metricreport/reporter.go
+++ b/backend/runner/metricreport/reporter.go
@@ -196,7 +196,7 @@ func (m *Reporter) identify(ctx context.Context) (string, error) {
identifyTraitForOrgID: orgID,
identifyTraitForOrgName: orgName,
identifyTraitForMode: mode,
- identifyTraitForLastActiveTime: time.Unix(m.profile.LastActiveTs, 0).String(),
+ identifyTraitForLastActiveTime: time.Unix(m.profile.LastActiveTS, 0).String(),
identifyTraitForSubscriptionStartDate: subscriptionStartDate,
identifyTraitForSubscriptionEndDate: subscriptionEndDate,
},
diff --git a/backend/runner/plancheck/database_connect_executor.go b/backend/runner/plancheck/database_connect_executor.go
index e4493becfa..e7b50be96c 100644
--- a/backend/runner/plancheck/database_connect_executor.go
+++ b/backend/runner/plancheck/database_connect_executor.go
@@ -62,7 +62,7 @@ func (e *DatabaseConnectExecutor) checkDatabaseConnection(ctx context.Context, i
if err != nil {
return &storepb.PlanCheckRunResult_Result{
Status: storepb.PlanCheckRunResult_Result_ERROR,
- Code: common.DbConnectionFailure.Int32(),
+ Code: common.DBConnectionFailure.Int32(),
Title: fmt.Sprintf("Failed to connect %q", database.DatabaseName),
Content: err.Error(),
}
diff --git a/backend/server/server.go b/backend/server/server.go
index cfcccc6593..79f85e5c30 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -185,7 +185,7 @@ func NewServer(ctx context.Context, profile *config.Profile) (*Server, error) {
return nil, err
}
- if err := s.store.BackfillIssueTsVector(ctx); err != nil {
+ if err := s.store.BackfillIssueTSVector(ctx); err != nil {
slog.Warn("failed to backfill issue ts vector", log.BBError(err))
}
diff --git a/backend/store/idp.go b/backend/store/idp.go
index 0b893cc66a..b874756e40 100644
--- a/backend/store/idp.go
+++ b/backend/store/idp.go
@@ -286,19 +286,22 @@ func (*Store) listIdentityProvidersImpl(ctx context.Context, txn *sql.Tx, find *
}
func convertIdentityProviderType(identityProviderType string) storepb.IdentityProviderType {
- if identityProviderType == "OAUTH2" {
+ switch identityProviderType {
+ case "OAUTH2":
return storepb.IdentityProviderType_OAUTH2
- } else if identityProviderType == "OIDC" {
+ case "OIDC":
return storepb.IdentityProviderType_OIDC
- } else if identityProviderType == "LDAP" {
+ case "LDAP":
return storepb.IdentityProviderType_LDAP
+ default:
+ return storepb.IdentityProviderType_IDENTITY_PROVIDER_TYPE_UNSPECIFIED
}
- return storepb.IdentityProviderType_IDENTITY_PROVIDER_TYPE_UNSPECIFIED
}
func convertIdentityProviderConfigString(identityProviderType storepb.IdentityProviderType, config string) *storepb.IdentityProviderConfig {
identityProviderConfig := &storepb.IdentityProviderConfig{}
- if identityProviderType == storepb.IdentityProviderType_OAUTH2 {
+ switch identityProviderType {
+ case storepb.IdentityProviderType_OAUTH2:
var formattedConfig storepb.OAuth2IdentityProviderConfig
if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(config), &formattedConfig); err != nil {
return nil
@@ -306,7 +309,7 @@ func convertIdentityProviderConfigString(identityProviderType storepb.IdentityPr
identityProviderConfig.Config = &storepb.IdentityProviderConfig_Oauth2Config{
Oauth2Config: &formattedConfig,
}
- } else if identityProviderType == storepb.IdentityProviderType_OIDC {
+ case storepb.IdentityProviderType_OIDC:
var formattedConfig storepb.OIDCIdentityProviderConfig
if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(config), &formattedConfig); err != nil {
return nil
@@ -314,7 +317,7 @@ func convertIdentityProviderConfigString(identityProviderType storepb.IdentityPr
identityProviderConfig.Config = &storepb.IdentityProviderConfig_OidcConfig{
OidcConfig: &formattedConfig,
}
- } else if identityProviderType == storepb.IdentityProviderType_LDAP {
+ case storepb.IdentityProviderType_LDAP:
var formattedConfig storepb.LDAPIdentityProviderConfig
if err := common.ProtojsonUnmarshaler.Unmarshal([]byte(config), &formattedConfig); err != nil {
return nil
diff --git a/backend/store/issue.go b/backend/store/issue.go
index 424e72dc8a..c5d587b0a1 100644
--- a/backend/store/issue.go
+++ b/backend/store/issue.go
@@ -148,7 +148,7 @@ func (s *Store) CreateIssueV2(ctx context.Context, create *IssueMessage, creator
return nil, err
}
- tsVector := getTsVector(fmt.Sprintf("%s %s", create.Title, create.Description))
+ tsVector := getTSVector(fmt.Sprintf("%s %s", create.Title, create.Description))
query := `
INSERT INTO issue (
creator_id,
@@ -246,7 +246,7 @@ func (s *Store) UpdateIssueV2(ctx context.Context, uid int, patch *UpdateIssueMe
description = *patch.Description
}
- tsVector := getTsVector(fmt.Sprintf("%s %s", title, description))
+ tsVector := getTSVector(fmt.Sprintf("%s %s", title, description))
set = append(set, fmt.Sprintf("ts_vector = $%d", len(args)+1))
args = append(args, tsVector)
}
@@ -400,7 +400,7 @@ func (s *Store) ListIssueV2(ctx context.Context, find *FindIssueMessage) ([]*Iss
args = append(args, *v)
}
if v := find.Query; v != nil && *v != "" {
- if tsQuery := getTsQuery(*v); tsQuery != "" {
+ if tsQuery := getTSQuery(*v); tsQuery != "" {
from += fmt.Sprintf(` LEFT JOIN CAST($%d AS tsquery) AS query ON TRUE`, len(args)+1)
args = append(args, tsQuery)
where = append(where, "issue.ts_vector @@ query")
@@ -620,7 +620,7 @@ func (s *Store) BatchUpdateIssueStatuses(ctx context.Context, issueUIDs []int, s
return nil
}
-func getTsVector(text string) string {
+func getTSVector(text string) string {
seg := getSegmenter()
parts := seg.CutTrim(text)
var tsVector strings.Builder
@@ -633,7 +633,7 @@ func getTsVector(text string) string {
return tsVector.String()
}
-func getTsQuery(text string) string {
+func getTSQuery(text string) string {
seg := getSegmenter()
parts := seg.Trim(seg.CutSearch(text))
// CutSearch returns empty for a single word.
@@ -653,7 +653,7 @@ func getTsQuery(text string) string {
return tsQuery.String()
}
-func (s *Store) BackfillIssueTsVector(ctx context.Context) error {
+func (s *Store) BackfillIssueTSVector(ctx context.Context) error {
chunkSize := 50
offset := 0
selectQuery := `
@@ -705,7 +705,7 @@ func (s *Store) BackfillIssueTsVector(ctx context.Context) error {
offset += len(issues)
for _, issue := range issues {
- tsVector := getTsVector(fmt.Sprintf("%s %s", issue.Title, issue.Description))
+ tsVector := getTSVector(fmt.Sprintf("%s %s", issue.Title, issue.Description))
if _, err := tx.ExecContext(ctx, updateStatement, tsVector, issue.UID); err != nil {
return errors.Wrapf(err, "failed to update")
}
diff --git a/backend/store/task.go b/backend/store/task.go
index 21593c08b6..fb290ec8ab 100644
--- a/backend/store/task.go
+++ b/backend/store/task.go
@@ -75,8 +75,8 @@ type TaskPatch struct {
// Domain specific fields
DatabaseName *string
- EarliestAllowedTs *time.Time
- UpdateEarliestAllowedTs bool
+ EarliestAllowedTS *time.Time
+ UpdateEarliestAllowedTS bool
Type *api.TaskType
SheetID *int
@@ -407,11 +407,11 @@ func (s *Store) UpdateTaskV2(ctx context.Context, patch *TaskPatch) (*TaskMessag
if len(payloadSet) != 0 {
set = append(set, fmt.Sprintf(`payload = payload || %s`, strings.Join(payloadSet, "||")))
}
- if patch.UpdateEarliestAllowedTs {
- if patch.EarliestAllowedTs == nil {
+ if patch.UpdateEarliestAllowedTS {
+ if patch.EarliestAllowedTS == nil {
set = append(set, "earliest_allowed_at = null")
} else {
- set, args = append(set, fmt.Sprintf("earliest_allowed_at = $%d", len(args)+1)), append(args, *patch.EarliestAllowedTs)
+ set, args = append(set, fmt.Sprintf("earliest_allowed_at = $%d", len(args)+1)), append(args, *patch.EarliestAllowedTS)
}
}
args = append(args, patch.ID)