Skip to content

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

Lint fix: adding comments for publics and use CamelCases for constants. (#93)

spinningbotee14707fad78
diff --git a/api/environment.go b/api/environment.go
index 4468358964..2692c66d5f 100644
--- a/api/environment.go
+++ b/api/environment.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
)
+// Environment is the API message for an environment.
type Environment struct {
ID int `jsonapi:"primary,environment"`
@@ -22,6 +23,7 @@ type Environment struct {
Order int `jsonapi:"attr,order"`
}
+// EnvironmentCreate is the API message for creating an environment.
type EnvironmentCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -31,6 +33,7 @@ type EnvironmentCreate struct {
Name string `jsonapi:"attr,name"`
}
+// EnvironmentFind is the API message for finding environments.
type EnvironmentFind struct {
ID *int
@@ -46,6 +49,7 @@ func (find *EnvironmentFind) String() string {
return string(str)
}
+// EnvironmentPatch is the API message for patching an environment.
type EnvironmentPatch struct {
ID int `jsonapi:"primary,environmentPatch"`
@@ -59,6 +63,7 @@ type EnvironmentPatch struct {
Order *int `jsonapi:"attr,order"`
}
+// EnvironmentDelete is the API message for deleting an environment.
type EnvironmentDelete struct {
ID int
@@ -67,6 +72,7 @@ type EnvironmentDelete struct {
DeleterID int
}
+// EnvironmentService is the service for environments.
type EnvironmentService interface {
CreateEnvironment(ctx context.Context, create *EnvironmentCreate) (*Environment, error)
FindEnvironmentList(ctx context.Context, find *EnvironmentFind) ([]*Environment, error)
diff --git a/api/inbox.go b/api/inbox.go
index e404707cff..449e97c1ea 100644
--- a/api/inbox.go
+++ b/api/inbox.go
@@ -5,23 +5,27 @@ import (
"encoding/json"
)
+// InboxStatus is the status for inboxes.
type InboxStatus string
const (
- UNREAD InboxStatus = "UNREAD"
- READ InboxStatus = "READ"
+ // Unread is the inbox status for UNREAD.
+ Unread InboxStatus = "UNREAD"
+ // Read is the inbox status for READ.
+ Read InboxStatus = "READ"
)
func (e InboxStatus) String() string {
switch e {
- case UNREAD:
+ case Unread:
return "UNREAD"
- case READ:
+ case Read:
return "READ"
}
return "UNKNOWN"
}
+// Inbox is the API message for an inbox.
type Inbox struct {
ID int `jsonapi:"primary,inbox"`
@@ -31,12 +35,14 @@ type Inbox struct {
Status InboxStatus `jsonapi:"attr,status"`
}
+// InboxCreate is the API message for creating an inbox.
type InboxCreate struct {
// Domain specific fields
ReceiverID int
ActivityID int
}
+// InboxFind is the API message for finding inboxes.
type InboxFind struct {
ID *int
@@ -54,6 +60,7 @@ func (find *InboxFind) String() string {
return string(str)
}
+// InboxPatch is the API message for patching an inbox.
type InboxPatch struct {
ID int
@@ -61,7 +68,7 @@ type InboxPatch struct {
Status InboxStatus `jsonapi:"attr,status"`
}
-// Contains the inbox summary info.
+// InboxSummary is the API message for inbox summary info.
// This is used by the frontend to render the inbox sidebar item without fetching the actual inbox items.
// This returns json instead of jsonapi since it't not dealing with a particular resource.
type InboxSummary struct {
@@ -69,6 +76,7 @@ type InboxSummary struct {
HasUnreadError bool `json:"hasUnreadError"`
}
+// InboxService is the service for inboxes.
type InboxService interface {
CreateInbox(ctx context.Context, create *InboxCreate) (*Inbox, error)
// Find the inbox list and return most recent created item first.
diff --git a/api/instance.go b/api/instance.go
index 389aedd422..8166a6f7bf 100644
--- a/api/instance.go
+++ b/api/instance.go
@@ -7,6 +7,7 @@ import (
"github.com/bytebase/bytebase/plugin/db"
)
+// Instance is the API message for an instance.
type Instance struct {
ID int `jsonapi:"primary,instance"`
@@ -37,6 +38,7 @@ type Instance struct {
Password string
}
+// InstanceCreate is the API message for creating an instance.
type InstanceCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -55,6 +57,7 @@ type InstanceCreate struct {
Password string `jsonapi:"attr,password"`
}
+// InstanceFind is the API message for finding instances.
type InstanceFind struct {
ID *int
@@ -70,6 +73,7 @@ func (find *InstanceFind) String() string {
return string(str)
}
+// InstancePatch is the API message for patching an instance.
type InstancePatch struct {
ID int `jsonapi:"primary,instancePatch"`
@@ -89,12 +93,15 @@ type InstancePatch struct {
UseEmptyPassword bool `jsonapi:"attr,useEmptyPassword"`
}
-// Instance migration schema status
+// InstanceMigrationSchemaStatus is the schema status for instance migration.
type InstanceMigrationSchemaStatus string
const (
- InstanceMigrationSchemaUnknown InstanceMigrationSchemaStatus = "UNKNOWN"
- InstanceMigrationSchemaOK InstanceMigrationSchemaStatus = "OK"
+ // InstanceMigrationSchemaUnknown is the UNKNOWN InstanceMigrationSchemaStatus.
+ InstanceMigrationSchemaUnknown InstanceMigrationSchemaStatus = "UNKNOWN"
+ // InstanceMigrationSchemaOK is the OK InstanceMigrationSchemaStatus.
+ InstanceMigrationSchemaOK InstanceMigrationSchemaStatus = "OK"
+ // InstanceMigrationSchemaNotExist is the NOT_EXIST InstanceMigrationSchemaStatus.
InstanceMigrationSchemaNotExist InstanceMigrationSchemaStatus = "NOT_EXIST"
)
@@ -110,6 +117,7 @@ func (e InstanceMigrationSchemaStatus) String() string {
return "UNKNOWN"
}
+// InstanceMigration is the API message for instance migration.
type InstanceMigration struct {
Status InstanceMigrationSchemaStatus `jsonapi:"attr,status"`
Error string `jsonapi:"attr,error"`
@@ -143,6 +151,7 @@ type MigrationHistory struct {
Payload string `jsonapi:"attr,payload"`
}
+// InstanceService is the service for instances.
type InstanceService interface {
// CreateInstance should also create the * database and the admin data source.
CreateInstance(ctx context.Context, create *InstanceCreate) (*Instance, error)
diff --git a/api/instance_user.go b/api/instance_user.go
index dc88602d73..24bfae5fe8 100644
--- a/api/instance_user.go
+++ b/api/instance_user.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
)
+// InstanceUser is the API message for instance user.
type InstanceUser struct {
ID int `jsonapi:"primary,instanceUser"`
@@ -16,6 +17,7 @@ type InstanceUser struct {
Grant string `jsonapi:"attr,grant"`
}
+// InstanceUserUpsert is the API message for upserting an instance user.
type InstanceUserUpsert struct {
// Standard fields
CreatorID int
@@ -28,6 +30,7 @@ type InstanceUserUpsert struct {
Grant string `jsonapi:"attr,grant"`
}
+// InstanceUserFind is the API message for finding instance users.
type InstanceUserFind struct {
InstanceID int
}
@@ -40,10 +43,12 @@ func (find *InstanceUserFind) String() string {
return string(str)
}
+// InstanceUserDelete is the API message for deleting an instance user.
type InstanceUserDelete struct {
ID int
}
+// InstanceUserService is the service for instance users.
type InstanceUserService interface {
// UpsertInstanceUser would update the existing user if name matches.
UpsertInstanceUser(ctx context.Context, upsert *InstanceUserUpsert) (*InstanceUser, error)
diff --git a/api/issue.go b/api/issue.go
index ebfc41b868..5f70f165e7 100644
--- a/api/issue.go
+++ b/api/issue.go
@@ -2,71 +2,60 @@ package api
import (
"context"
- "encoding/json"
)
-// Issue status
+// IssueStatus is the status of an issue.
type IssueStatus string
const (
- Issue_Open IssueStatus = "OPEN"
- Issue_Done IssueStatus = "DONE"
- Issue_Canceled IssueStatus = "CANCELED"
+ // IssueOpen is the issue status for OPEN.
+ IssueOpen IssueStatus = "OPEN"
+ // IssueDone is the issue status for DONE.
+ IssueDone IssueStatus = "DONE"
+ // IssueCanceled is the issue status for CANCELED.
+ IssueCanceled IssueStatus = "CANCELED"
)
-func (e IssueStatus) String() string {
- switch e {
- case Issue_Open:
- return "OPEN"
- case Issue_Done:
- return "DONE"
- case Issue_Canceled:
- return "CANCELED"
- }
- return ""
-}
-
-// Issue type
+// IssueType is the type of an issue.
type IssueType string
const (
- IssueGeneral IssueType = "bb.issue.general"
- IssueDatabaseCreate IssueType = "bb.issue.database.create"
- IssueDatabaseGrant IssueType = "bb.issue.database.grant"
+ // IssueGeneral is the issue type for general issues.
+ IssueGeneral IssueType = "bb.issue.general"
+ // IssueDatabaseCreate is the issue type for creating databases.
+ IssueDatabaseCreate IssueType = "bb.issue.database.create"
+ // IssueDatabaseGrant is the issue type for granting databases.
+ IssueDatabaseGrant IssueType = "bb.issue.database.grant"
+ // IssueDatabaseSchemaUpdate is the issue type for updating database schemas.
IssueDatabaseSchemaUpdate IssueType = "bb.issue.database.schema.update"
- IssueDataSourceRequest IssueType = "bb.issue.data-source.request"
+ // IssueDataSourceRequest is the issue type for requesting database sources.
+ IssueDataSourceRequest IssueType = "bb.issue.data-source.request"
)
-func (e IssueType) String() string {
- switch e {
- case IssueGeneral:
- return "bb.issue.general"
- case IssueDatabaseCreate:
- return "bb.issue.database.create"
- case IssueDatabaseGrant:
- return "bb.issue.database.grant"
- case IssueDatabaseSchemaUpdate:
- return "bb.issue.database.schema.update"
- case IssueDataSourceRequest:
- return "bb.issue.data-source.request"
- }
- return "bb.unknown"
-}
-
+// IssueFieldID is the field ID for an issue.
// It has to be string type because the id for stage field contain multiple parts.
type IssueFieldID string
const (
- IssueFieldName IssueFieldID = "1"
- IssueFieldStatus IssueFieldID = "2"
- IssueFieldAssignee IssueFieldID = "3"
- IssueFieldDescription IssueFieldID = "4"
- IssueFieldProject IssueFieldID = "5"
+ // IssueFieldName is the field ID for name.
+ IssueFieldName IssueFieldID = "1"
+ // IssueFieldStatus is the field ID for status.
+ IssueFieldStatus IssueFieldID = "2"
+ // IssueFieldAssignee is the field ID for assignee.
+ IssueFieldAssignee IssueFieldID = "3"
+ // IssueFieldDescription is the field ID for description.
+ IssueFieldDescription IssueFieldID = "4"
+ // IssueFieldProject is the field ID for project.
+ IssueFieldProject IssueFieldID = "5"
+ // IssueFieldSubscriberList is the field ID for subscriber list.
IssueFieldSubscriberList IssueFieldID = "6"
- IssueFieldSql IssueFieldID = "7"
- IssueFieldRollbackSql IssueFieldID = "8"
+ // IssueFieldSQL is the field ID for SQL.
+ IssueFieldSQL IssueFieldID = "7"
+ // IssueFieldRollbackSQL is the field ID for rollback SQL.
+ IssueFieldRollbackSQL IssueFieldID = "8"
)
+// Issue is the API message for an issue.
type Issue struct {
ID int `jsonapi:"primary,issue"`
@@ -95,6 +84,7 @@ type Issue struct {
Payload string `jsonapi:"attr,payload"`
}
+// IssueCreate is the API message for creating an issue.
type IssueCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -106,15 +96,16 @@ type IssueCreate struct {
Pipeline PipelineCreate `jsonapi:"attr,pipeline"`
// Domain specific fields
- Name string `jsonapi:"attr,name"`
- Type IssueType `jsonapi:"attr,type"`
- Description string `jsonapi:"attr,description"`
- AssigneeID int `jsonapi:"attr,assigneeId"`
- SubscriberIDList []int `jsonapi:"attr,subscriberIdList"`
- RollbackIssueID *int `jsonapi:"attr,rollbackIssueId"`
- Payload string `jsonapi:"attr,payload"`
+ Name string `jsonapi:"attr,name"`
+ Type IssueType `jsonapi:"attr,type"`
+ Description string `jsonapi:"attr,description"`
+ AssigneeID int `jsonapi:"attr,assigneeId"`
+ SubscriberIDList []int `jsonapi:"attr,subscriberIdList"`
+ RollbackIssueID *int `jsonapi:"attr,rollbackIssueId"`
+ Payload string `jsonapi:"attr,payload"`
}
+// IssueFind is the API message for finding issues.
type IssueFind struct {
ID *int
@@ -130,14 +121,7 @@ type IssueFind struct {
Limit *int
}
-func (find *IssueFind) String() string {
- str, err := json.Marshal(*find)
- if err != nil {
- return err.Error()
- }
- return string(str)
-}
-
+// IssuePatch is the API message for patching an issue.
type IssuePatch struct {
ID int `jsonapi:"primary,issuePatch"`
@@ -154,6 +138,7 @@ type IssuePatch struct {
Payload *string `jsonapi:"attr,payload"`
}
+// IssueStatusPatch is the API message for patching status of an issue.
type IssueStatusPatch struct {
ID int `jsonapi:"primary,issueStatusPatch"`
@@ -166,6 +151,7 @@ type IssueStatusPatch struct {
Comment string `jsonapi:"attr,comment"`
}
+// IssueService is the services for issues.
type IssueService interface {
CreateIssue(ctx context.Context, create *IssueCreate) (*Issue, error)
FindIssueList(ctx context.Context, find *IssueFind) ([]*Issue, error)
diff --git a/api/issue_subscriber.go b/api/issue_subscriber.go
index d3108d41e9..19601affa5 100644
--- a/api/issue_subscriber.go
+++ b/api/issue_subscriber.go
@@ -2,6 +2,7 @@ package api
import "context"
+// IssueSubscriber is the API message for an issue subscriber.
type IssueSubscriber struct {
// Domain specific fields
IssueID int `jsonapi:"attr,issueId"`
@@ -9,24 +10,28 @@ type IssueSubscriber struct {
Subscriber *Principal `jsonapi:"attr,subscriber"`
}
+// IssueSubscriberCreate is the API message for creating an issue subscriber.
type IssueSubscriberCreate struct {
// Domain specific fields
IssueID int
SubscriberID int `jsonapi:"attr,subscriberId"`
}
+// IssueSubscriberFind is the API message for finding issue subscribers.
type IssueSubscriberFind struct {
// Domain specific fields
IssueID *int
SubscriberID *int
}
+// IssueSubscriberDelete is the API message for deleting an issue subscriber.
type IssueSubscriberDelete struct {
// Domain specific fields
IssueID int
SubscriberID int
}
+// IssueSubscriberService is the service for issue subscribers.
type IssueSubscriberService interface {
CreateIssueSubscriber(ctx context.Context, create *IssueSubscriberCreate) (*IssueSubscriber, error)
FindIssueSubscriberList(ctx context.Context, find *IssueSubscriberFind) ([]*IssueSubscriber, error)
diff --git a/api/member.go b/api/member.go
index d6c0fed3fc..2d69d8be7d 100644
--- a/api/member.go
+++ b/api/member.go
@@ -5,31 +5,27 @@ import (
"encoding/json"
)
+// MemberStatus is the status of an member.
type MemberStatus string
const (
+ // Unknown is the member status for UNKNOWN.
Unknown MemberStatus = "UNKNOWN"
+ // Invited is the member status for INVITED.
Invited MemberStatus = "INVITED"
- Active MemberStatus = "ACTIVE"
+ // Active is the member status for ACTIVE.
+ Active MemberStatus = "ACTIVE"
)
-func (e MemberStatus) String() string {
- switch e {
- case Unknown:
- return "UNKNOWN"
- case Invited:
- return "INVITED"
- case Active:
- return "ACTIVE"
- }
- return ""
-}
-
+// Role is the type of a role.
type Role string
const (
- Owner Role = "OWNER"
- DBA Role = "DBA"
+ // Owner is the OWNER role.
+ Owner Role = "OWNER"
+ // DBA is the DBA role.
+ DBA Role = "DBA"
+ // Developer is the DEVELOPER role.
Developer Role = "DEVELOPER"
)
@@ -45,6 +41,7 @@ func (e Role) String() string {
return ""
}
+// Member is the API message for a member.
type Member struct {
ID int `jsonapi:"primary,member"`
@@ -64,6 +61,7 @@ type Member struct {
Principal *Principal `jsonapi:"attr,principal"`
}
+// MemberCreate is the API message for creating a member.
type MemberCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -75,6 +73,7 @@ type MemberCreate struct {
PrincipalID int `jsonapi:"attr,principalId"`
}
+// MemberFind is the API message for finding members.
type MemberFind struct {
ID *int
@@ -91,6 +90,7 @@ func (find *MemberFind) String() string {
return string(str)
}
+// MemberPatch is the API message for patching a member.
type MemberPatch struct {
ID int
@@ -103,6 +103,7 @@ type MemberPatch struct {
Role *string `jsonapi:"attr,role"`
}
+// MemberService is the service for members.
type MemberService interface {
CreateMember(ctx context.Context, create *MemberCreate) (*Member, error)
FindMemberList(ctx context.Context, find *MemberFind) ([]*Member, error)
diff --git a/api/pipeline.go b/api/pipeline.go
index a4f9947833..d1367b1cd8 100644
--- a/api/pipeline.go
+++ b/api/pipeline.go
@@ -5,29 +5,34 @@ import (
"encoding/json"
)
-const ONBOARDING_PIPELINE_ID = 101
+// OnboardingPipelineID is the ID for onboarding pipelines.
+const OnboardingPipelineID = 101
-// Pipeline status
+// PipelineStatus is the status for pipelines.
type PipelineStatus string
const (
- Pipeline_Open PipelineStatus = "OPEN"
- Pipeline_Done PipelineStatus = "DONE"
- Pipeline_Canceled PipelineStatus = "CANCELED"
+ // PipelineOpen is the pipeline status for OPEN.
+ PipelineOpen PipelineStatus = "OPEN"
+ // PipelineDone is the pipeline status for DONE.
+ PipelineDone PipelineStatus = "DONE"
+ // PipelineCanceled is the pipeline status for CANCELED.
+ PipelineCanceled PipelineStatus = "CANCELED"
)
func (e PipelineStatus) String() string {
switch e {
- case Pipeline_Open:
+ case PipelineOpen:
return "OPEN"
- case Pipeline_Done:
+ case PipelineDone:
return "DONE"
- case Pipeline_Canceled:
+ case PipelineCanceled:
return "CANCELED"
}
return ""
}
+// Pipeline is the API message for pipelines.
type Pipeline struct {
ID int `jsonapi:"primary,pipeline"`
@@ -47,6 +52,7 @@ type Pipeline struct {
Status PipelineStatus `jsonapi:"attr,status"`
}
+// PipelineCreate is the API message for creating a pipeline.
type PipelineCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -59,6 +65,7 @@ type PipelineCreate struct {
Name string `jsonapi:"attr,name"`
}
+// PipelineFind is the API message for finding pipelines.
type PipelineFind struct {
ID *int
@@ -74,6 +81,7 @@ func (find *PipelineFind) String() string {
return string(str)
}
+// PipelinePatch is the API message for patching a pipeline.
type PipelinePatch struct {
ID int `jsonapi:"primary,pipelinePatch"`
@@ -85,6 +93,7 @@ type PipelinePatch struct {
Status *PipelineStatus `jsonapi:"attr,status"`
}
+// PipelineService is the service for pipelines.
type PipelineService interface {
CreatePipeline(ctx context.Context, create *PipelineCreate) (*Pipeline, error)
FindPipelineList(ctx context.Context, find *PipelineFind) ([]*Pipeline, error)
diff --git a/api/plan.go b/api/plan.go
index ed4a448ddf..a0cf385b6b 100644
--- a/api/plan.go
+++ b/api/plan.go
@@ -1,44 +1,54 @@
package api
+// FeatureType is the type of a feature.
type FeatureType string
const (
- FEATURE_ADMIN FeatureType = "bb.admin"
- FEATURE_DBA_WORKFLOW FeatureType = "bb.dba-workflow"
- FEATURE_DATA_SOURCE FeatureType = "bb.data-source"
+ // FeatureAdmin is the feature type for admin.
+ FeatureAdmin FeatureType = "bb.admin"
+ // FeatureDBAWorkflow is the feature type for DBA.
+ FeatureDBAWorkflow FeatureType = "bb.dba-workflow"
+ // FeatureDataSource is the feature type for data sources.
+ FeatureDataSource FeatureType = "bb.data-source"
)
func (e FeatureType) String() string {
switch e {
- case FEATURE_ADMIN:
+ case FeatureAdmin:
return "bb.admin"
- case FEATURE_DBA_WORKFLOW:
+ case FeatureDBAWorkflow:
return "bb.dba-workflow"
- case FEATURE_DATA_SOURCE:
+ case FeatureDataSource:
return "bb.data-source"
}
return ""
}
+// PlanType is the type for a plan.
type PlanType int
const (
+ // FREE is the plan type for FREE.
FREE PlanType = iota
+ // TEAM is the plan type for TEAM.
TEAM
+ // ENTERPRISE is the plan type for ENTERPRISE.
ENTERPRISE
)
-// A map from the a particular feature to the respective enablement of a particular plan
-var FEATURE_MATRIX = map[FeatureType][3]bool{
+// FeatureMatrix is a map from the a particular feature to the respective enablement of a particular plan
+var FeatureMatrix = map[FeatureType][3]bool{
"bb.admin": {false, true, true},
"bb.dba-workflow": {false, false, true},
"bb.data-source": {false, false, false},
}
+// Plan is the API message for a plan.
type Plan struct {
Type PlanType `jsonapi:"attr,type"`
}
+// PlanPatch is the API message for patching a plan.
type PlanPatch struct {
Type PlanType `jsonapi:"attr,type"`
}
diff --git a/api/policy.go b/api/policy.go
index 06b7cbb50c..4df48acd2b 100644
--- a/api/policy.go
+++ b/api/policy.go
@@ -42,6 +42,7 @@ var (
}
)
+// Policy is the API message for a policy.
type Policy struct {
ID int `jsonapi:"primary,policy"`
diff --git a/api/principal.go b/api/principal.go
index 5ea4703776..bcd7700d06 100644
--- a/api/principal.go
+++ b/api/principal.go
@@ -5,13 +5,17 @@ import (
"encoding/json"
)
-const SYSTEM_BOT_ID = 1
+// SystemBotID is the ID of the system robot.
+const SystemBotID = 1
+// PrincipalType is the type of a principal.
type PrincipalType string
const (
+ // EndUser is the principal type for END_USER.
EndUser PrincipalType = "END_USER"
- BOT PrincipalType = "BOT"
+ // BOT is the principal type for BOT.
+ BOT PrincipalType = "BOT"
)
func (e PrincipalType) String() string {
@@ -24,6 +28,7 @@ func (e PrincipalType) String() string {
return ""
}
+// Principal is the API message for principals.
type Principal struct {
ID int `jsonapi:"primary,principal"`
@@ -44,7 +49,7 @@ type Principal struct {
Role Role `jsonapi:"attr,role"`
}
-// Customize the Principal Marshal method so the returned object
+// MarshalJSON customizes the Principal Marshal method so the returned object
// can map directly to the frontend Principal object without any conversion.
func (p *Principal) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
@@ -70,6 +75,7 @@ func (p *Principal) MarshalJSON() ([]byte, error) {
})
}
+// PrincipalCreate is the API message for creating a principal.
type PrincipalCreate struct {
// Standard fields
// For signup, value is SYSTEM_BOT_ID
@@ -84,6 +90,7 @@ type PrincipalCreate struct {
PasswordHash string
}
+// PrincipalFind is the API message for finding principals.
type PrincipalFind struct {
ID *int
@@ -99,6 +106,7 @@ func (find *PrincipalFind) String() string {
return string(str)
}
+// PrincipalPatch is the API message for patching a principal.
type PrincipalPatch struct {
ID int
@@ -112,6 +120,7 @@ type PrincipalPatch struct {
PasswordHash *string
}
+// PrincipalService is the service for principals.
type PrincipalService interface {
CreatePrincipal(ctx context.Context, create *PrincipalCreate) (*Principal, error)
FindPrincipalList(ctx context.Context) ([]*Principal, error)
diff --git a/api/project.go b/api/project.go
index cf171f5246..794f099ea0 100644
--- a/api/project.go
+++ b/api/project.go
@@ -6,37 +6,44 @@ import (
"encoding/json"
)
-const DEFAULT_PROJECT_ID = 1
+// DefaultProjectID is the ID for the default project.
+const DefaultProjectID = 1
+// ProjectWorkflowType is the workflow type for projects.
type ProjectWorkflowType string
const (
- UI_WORKFLOW ProjectWorkflowType = "UI"
- VCS_WORKFLOW ProjectWorkflowType = "VCS"
+ // UIWorkflow is the UI workflow.
+ UIWorkflow ProjectWorkflowType = "UI"
+ // VCSWorkflow is the VCS workflow.
+ VCSWorkflow ProjectWorkflowType = "VCS"
)
func (e ProjectWorkflowType) String() string {
switch e {
- case UI_WORKFLOW:
+ case UIWorkflow:
return "UI"
- case VCS_WORKFLOW:
+ case VCSWorkflow:
return "VCS"
}
return ""
}
+// ProjectVisibility is the visibility of a project.
type ProjectVisibility string
const (
- PUBLIC ProjectVisibility = "PUBLIC"
- PRIVATE ProjectVisibility = "PRIVATE"
+ // Public is the project visibility for PUBLIC.
+ Public ProjectVisibility = "PUBLIC"
+ // Private is the project visibility for PRIVATE.
+ Private ProjectVisibility = "PRIVATE"
)
func (e ProjectVisibility) String() string {
switch e {
- case PUBLIC:
+ case Public:
return "PUBLIC"
- case PRIVATE:
+ case Private:
return "PRIVATE"
}
return ""
@@ -52,6 +59,7 @@ const (
TenantModeTenant ProjectTenantMode = "TENANT"
)
+// Project is the API message for a project.
type Project struct {
ID int `jsonapi:"primary,project"`
@@ -75,6 +83,7 @@ type Project struct {
TenantMode ProjectTenantMode `jsonapi:"attr,tenantMode"`
}
+// ProjectCreate is the API message for creating a project.
type ProjectCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -85,6 +94,7 @@ type ProjectCreate struct {
Key string `jsonapi:"attr,key"`
}
+// ProjectFind is the API message for finding projects.
type ProjectFind struct {
ID *int
@@ -104,6 +114,7 @@ func (find *ProjectFind) String() string {
return string(str)
}
+// ProjectPatch is the API message for patching a project.
type ProjectPatch struct {
ID int `jsonapi:"primary,projectPatch"`
@@ -119,6 +130,7 @@ type ProjectPatch struct {
TenantMode *ProjectTenantMode `jsonapi:"attr,tenantMode"`
}
+// ProjectService is the service for projects.
type ProjectService interface {
CreateProject(ctx context.Context, create *ProjectCreate) (*Project, error)
FindProjectList(ctx context.Context, find *ProjectFind) ([]*Project, error)
diff --git a/api/project_member.go b/api/project_member.go
index 127a768c34..8ee636ec55 100644
--- a/api/project_member.go
+++ b/api/project_member.go
@@ -5,10 +5,13 @@ import (
"encoding/json"
)
+// ProjectRole is the role in projects.
type ProjectRole string
const (
- ProjectOwner ProjectRole = "OWNER"
+ // ProjectOwner is the owner of a project.
+ ProjectOwner ProjectRole = "OWNER"
+ // ProjectDeveloper is the developer of a project.
ProjectDeveloper ProjectRole = "DEVELOPER"
)
@@ -22,6 +25,7 @@ func (e ProjectRole) String() string {
return ""
}
+// ProjectMember is the API message for project members.
type ProjectMember struct {
ID int `jsonapi:"primary,projectMember"`
@@ -43,6 +47,7 @@ type ProjectMember struct {
Principal *Principal `jsonapi:"attr,principal"`
}
+// ProjectMemberCreate is the API message for creating a project member.
type ProjectMemberCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -56,6 +61,7 @@ type ProjectMemberCreate struct {
PrincipalID int `jsonapi:"attr,principalId"`
}
+// ProjectMemberFind is the API message for finding project members.
type ProjectMemberFind struct {
ID *int
@@ -71,6 +77,7 @@ func (find *ProjectMemberFind) String() string {
return string(str)
}
+// ProjectMemberPatch is the API message for patching a project member.
type ProjectMemberPatch struct {
ID int
@@ -82,6 +89,7 @@ type ProjectMemberPatch struct {
Role *string `jsonapi:"attr,role"`
}
+// ProjectMemberDelete is the API message for deleting a project member.
type ProjectMemberDelete struct {
ID int
@@ -90,6 +98,7 @@ type ProjectMemberDelete struct {
DeleterID int
}
+// ProjectMemberService is the service for project members.
type ProjectMemberService interface {
CreateProjectMember(ctx context.Context, create *ProjectMemberCreate) (*ProjectMember, error)
FindProjectMemberList(ctx context.Context, find *ProjectMemberFind) ([]*ProjectMember, error)
diff --git a/api/project_webhook.go b/api/project_webhook.go
index cd48447876..c928eee479 100644
--- a/api/project_webhook.go
+++ b/api/project_webhook.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
)
+// ProjectWebhook is the API message for project webhooks.
type ProjectWebhook struct {
ID int `jsonapi:"primary,projectWebhookMember"`
@@ -27,6 +28,7 @@ type ProjectWebhook struct {
ActivityList []string `jsonapi:"attr,activityList"`
}
+// ProjectWebhookCreate is the API message for creating a project webhook.
type ProjectWebhookCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -42,6 +44,7 @@ type ProjectWebhookCreate struct {
ActivityList []string `jsonapi:"attr,activityList"`
}
+// ProjectWebhookFind is the API message for finding project webhooks.
type ProjectWebhookFind struct {
ID *int
@@ -58,6 +61,7 @@ func (find *ProjectWebhookFind) String() string {
return string(str)
}
+// ProjectWebhookPatch is the API message for patching a project webhook.
type ProjectWebhookPatch struct {
ID int
@@ -71,6 +75,7 @@ type ProjectWebhookPatch struct {
ActivityList *string `jsonapi:"attr,activityList"`
}
+// ProjectWebhookDelete is the API message for deleting a project webhook.
type ProjectWebhookDelete struct {
ID int
@@ -79,10 +84,12 @@ type ProjectWebhookDelete struct {
DeleterID int
}
+// ProjectWebhookTestResult is the test result of a project webhook.
type ProjectWebhookTestResult struct {
Error string `jsonapi:"attr,error"`
}
+// ProjectWebhookService is the service for project webhooks.
type ProjectWebhookService interface {
CreateProjectWebhook(ctx context.Context, create *ProjectWebhookCreate) (*ProjectWebhook, error)
FindProjectWebhookList(ctx context.Context, find *ProjectWebhookFind) ([]*ProjectWebhook, error)
diff --git a/api/repository.go b/api/repository.go
index 3e3de31c41..648809f617 100644
--- a/api/repository.go
+++ b/api/repository.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
)
+// Repository is the API message for a repository.
type Repository struct {
ID int `jsonapi:"primary,repository"`
@@ -44,6 +45,7 @@ type Repository struct {
RefreshToken string
}
+// RepositoryCreate is the API message for creating a repository.
type RepositoryCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -74,6 +76,7 @@ type RepositoryCreate struct {
WebhookSecretToken string
}
+// RepositoryFind is the API message for finding repositories.
type RepositoryFind struct {
ID *int
@@ -93,6 +96,7 @@ func (find *RepositoryFind) String() string {
return string(str)
}
+// RepositoryPatch is the API message for patching a repository.
type RepositoryPatch struct {
ID int `jsonapi:"primary,repositoryPatch"`
@@ -107,6 +111,7 @@ type RepositoryPatch struct {
SchemaPathTemplate *string `jsonapi:"attr,schemaPathTemplate"`
}
+// RepositoryDelete is the API message for deleting a repository.
type RepositoryDelete struct {
// Related fields
// When deleting the repository, we need to update the correponding project workflow type to "UI",
@@ -118,6 +123,7 @@ type RepositoryDelete struct {
DeleterID int
}
+// RepositoryService is the service for repositories.
type RepositoryService interface {
CreateRepository(ctx context.Context, create *RepositoryCreate) (*Repository, error)
FindRepositoryList(ctx context.Context, find *RepositoryFind) ([]*Repository, error)
diff --git a/api/setting.go b/api/setting.go
index 3193e5761d..1ce9493cb8 100644
--- a/api/setting.go
+++ b/api/setting.go
@@ -5,17 +5,21 @@ import (
"encoding/json"
)
+// SettingName is the name of a setting.
type SettingName string
const (
+ // SettingAuthSecret is the setting name for auth secret.
SettingAuthSecret SettingName = "bb.auth.secret"
- // The console URL, it supports following variables
+ // SettingConsoleURL is the setting name for console URL.
+ // The console URL supports following variables
// {{DB_NAME}}: the database name
// e.g. For a phpmyadmin instance running on http://myphpadmin.example.com:8080, the setting would be:
// http://myphpadmin.example.com:8080/index.php?route=/database/sql&db={{DB_NAME}}
SettingConsoleURL SettingName = "bb.console.url"
)
+// Setting is the API message for a setting.
type Setting struct {
ID int `jsonapi:"primary,setting"`
@@ -33,6 +37,7 @@ type Setting struct {
Description string `jsonapi:"attr,description"`
}
+// SettingCreate is the API message for creating a setting.
type SettingCreate struct {
CreatorID int
Name SettingName
@@ -40,10 +45,12 @@ type SettingCreate struct {
Description string
}
+// SettingFind is the API message for finding settings.
type SettingFind struct {
Name *SettingName
}
+// SettingPatch is the API message for patching a setting.
type SettingPatch struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -61,6 +68,7 @@ func (find *SettingFind) String() string {
return string(str)
}
+// SettingService is the service for settings.
type SettingService interface {
// Creates new setting and returns if not exist, returns the existing one otherwise.
CreateSettingIfNotExist(ctx context.Context, create *SettingCreate) (*Setting, error)
diff --git a/api/slug.go b/api/slug.go
index bffc65229b..87ae462e24 100644
--- a/api/slug.go
+++ b/api/slug.go
@@ -6,22 +6,27 @@ import (
"github.com/gosimple/slug"
)
+// IssueSlug is the slug formatter for issuees.
func IssueSlug(issue *Issue) string {
return fmt.Sprintf("%s-%d", slug.Make(issue.Name), issue.ID)
}
+// ProjectSlug is the slug formatter for projects.
func ProjectSlug(project *Project) string {
return fmt.Sprintf("%s-%d", slug.Make(project.Name), project.ID)
}
+// ProjectShortSlug is the slug short formatter for projects.
func ProjectShortSlug(project *Project) string {
return slug.Make(project.Name)
}
+// EnvSlug is the slug formatter for environments.
func EnvSlug(env *Environment) string {
return slug.Make(env.Name)
}
+// ProjectWebhookSlug is the slug formatter for project webhooks.
func ProjectWebhookSlug(projectWebhook *ProjectWebhook) string {
return fmt.Sprintf("%s-%d", slug.Make(projectWebhook.Name), projectWebhook.ID)
}
diff --git a/api/sql.go b/api/sql.go
index 06d1e62351..3391703179 100644
--- a/api/sql.go
+++ b/api/sql.go
@@ -6,6 +6,7 @@ import (
"github.com/bytebase/bytebase/plugin/db"
)
+// ConnectionInfo is the API message for connection infos.
type ConnectionInfo struct {
Engine db.Type `jsonapi:"attr,engine"`
Host string `jsonapi:"attr,host"`
@@ -16,15 +17,18 @@ type ConnectionInfo struct {
InstanceID *int `jsonapi:"attr,instanceId"`
}
-type SqlSyncSchema struct {
+// SQLSyncSchema is the API message for sync schemas.
+type SQLSyncSchema struct {
InstanceID int `jsonapi:"attr,instanceId"`
}
-type SqlResultSet struct {
+// SQLResultSet is the API message for SQL results.
+type SQLResultSet struct {
// SQL operation may fail for connection issue and there is no proper http status code for it, so we return error in the response body.
Error string `jsonapi:"attr,error"`
}
-type SqlService interface {
- Ping(ctx context.Context, config *ConnectionInfo) (*SqlResultSet, error)
+// SQLService is the service for SQL.
+type SQLService interface {
+ Ping(ctx context.Context, config *ConnectionInfo) (*SQLResultSet, error)
}
diff --git a/api/stage.go b/api/stage.go
index 89482be39e..eb634d81c1 100644
--- a/api/stage.go
+++ b/api/stage.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
)
+// Stage is the API message for a stage.
type Stage struct {
ID int `jsonapi:"primary,stage"`
@@ -27,6 +28,7 @@ type Stage struct {
Name string `jsonapi:"attr,name"`
}
+// StageCreate is the API message for creating a stage.
type StageCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -41,6 +43,7 @@ type StageCreate struct {
Name string `jsonapi:"attr,name"`
}
+// StageFind is the API message for finding stages.
type StageFind struct {
ID *int
@@ -56,6 +59,7 @@ func (find *StageFind) String() string {
return string(str)
}
+// StageService is the service for stages.
type StageService interface {
CreateStage(ctx context.Context, create *StageCreate) (*Stage, error)
FindStageList(ctx context.Context, find *StageFind) ([]*Stage, error)
diff --git a/api/table.go b/api/table.go
index 84748cea2a..e4e82e3d85 100644
--- a/api/table.go
+++ b/api/table.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
)
+// Table is the API message for a table.
type Table struct {
ID int `jsonapi:"primary,table"`
@@ -35,6 +36,7 @@ type Table struct {
IndexList []*Index `jsonapi:"attr,indexList"`
}
+// TableCreate is the API message for creating a table.
type TableCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -58,6 +60,7 @@ type TableCreate struct {
Comment string
}
+// TableFind is the API message for finding tables.
type TableFind struct {
ID *int
@@ -76,11 +79,13 @@ func (find *TableFind) String() string {
return string(str)
}
+// TableDelete is the API message for deleting a table.
type TableDelete struct {
// Related fields
DatabaseID int
}
+// TableService is the service for tables.
type TableService interface {
CreateTable(ctx context.Context, create *TableCreate) (*Table, error)
FindTableList(ctx context.Context, find *TableFind) ([]*Table, error)
diff --git a/api/table_index.go b/api/table_index.go
index 05fc412f43..e96eca2893 100644
--- a/api/table_index.go
+++ b/api/table_index.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
)
+// Index is the API message for an index.
type Index struct {
ID int `jsonapi:"primary,index"`
@@ -28,6 +29,7 @@ type Index struct {
Comment string `json:"comment"`
}
+// IndexCreate is the API message for creating an index.
type IndexCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -47,6 +49,7 @@ type IndexCreate struct {
Comment string
}
+// IndexFind is the API message for finding indices.
type IndexFind struct {
ID *int
@@ -67,6 +70,7 @@ func (find *IndexFind) String() string {
return string(str)
}
+// IndexService is the service for indices.
type IndexService interface {
CreateIndex(ctx context.Context, create *IndexCreate) (*Index, error)
FindIndexList(ctx context.Context, find *IndexFind) ([]*Index, error)
diff --git a/api/task.go b/api/task.go
index d45b68ba1d..07631f8760 100644
--- a/api/task.go
+++ b/api/task.go
@@ -9,18 +9,29 @@ import (
)
// These are special onboarding tasks for demo purpose when bootstraping the workspace.
-const ONBOARDING_TASK_ID1 = 101
-const ONBOARDING_TASK_ID2 = 102
+// OnboardingTaskID1 is the ID for onboarding task1.
+const OnboardingTaskID1 = 101
+
+// OnboardingTaskID2 is the ID for onboarding task2.
+const OnboardingTaskID2 = 102
+
+// TaskStatus is the status of a task.
type TaskStatus string
const (
- TaskPending TaskStatus = "PENDING"
+ // TaskPending is the task status for PENDING.
+ TaskPending TaskStatus = "PENDING"
+ // TaskPendingApproval is the task status for PENDING_APPROVAL.
TaskPendingApproval TaskStatus = "PENDING_APPROVAL"
- TaskRunning TaskStatus = "RUNNING"
- TaskDone TaskStatus = "DONE"
- TaskFailed TaskStatus = "FAILED"
- TaskCanceled TaskStatus = "CANCELED"
+ // TaskRunning is the task status for RUNNING.
+ TaskRunning TaskStatus = "RUNNING"
+ // TaskDone is the task status for DONE.
+ TaskDone TaskStatus = "DONE"
+ // TaskFailed is the task status for FAILED.
+ TaskFailed TaskStatus = "FAILED"
+ // TaskCanceled is the task status for CANCELED.
+ TaskCanceled TaskStatus = "CANCELED"
)
func (e TaskStatus) String() string {
@@ -45,16 +56,23 @@ func (e TaskStatus) String() string {
type TaskType string
const (
- TaskGeneral TaskType = "bb.task.general"
- TaskDatabaseCreate TaskType = "bb.task.database.create"
+ // TaskGeneral is the task type for general tasks.
+ TaskGeneral TaskType = "bb.task.general"
+ // TaskDatabaseCreate is the task type for creating databases.
+ TaskDatabaseCreate TaskType = "bb.task.database.create"
+ // TaskDatabaseSchemaUpdate is the task type for updating database schemas.
TaskDatabaseSchemaUpdate TaskType = "bb.task.database.schema.update"
- TaskDatabaseBackup TaskType = "bb.task.database.backup"
- TaskDatabaseRestore TaskType = "bb.task.database.restore"
+ // TaskDatabaseBackup is the task type for creating database backups.
+ TaskDatabaseBackup TaskType = "bb.task.database.backup"
+ // TaskDatabaseRestore is the task type for restoring databases.
+ TaskDatabaseRestore TaskType = "bb.task.database.restore"
)
// These payload types are only used when marshalling to the json format for saving into the database.
// So we annotate with json tag using camelCase naming which is consistent with normal
// json naming convention
+
+// TaskDatabaseCreatePayload is the task payload for creating databases.
type TaskDatabaseCreatePayload struct {
// The project owning the database.
ProjectID int `json:"projectId,omitempty"`
@@ -85,6 +103,7 @@ type TaskDatabaseRestorePayload struct {
BackupID int `json:"backupId,omitempty"`
}
+// Task is the API message for a task.
type Task struct {
ID int `jsonapi:"primary,task"`
@@ -115,6 +134,7 @@ type Task struct {
Payload string `jsonapi:"attr,payload"`
}
+// TaskCreate is the API message for creating a task.
type TaskCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -143,6 +163,7 @@ type TaskCreate struct {
MigrationType db.MigrationType `jsonapi:"attr,migrationType"`
}
+// TaskFind is the API message for finding tasks.
type TaskFind struct {
ID *int
@@ -162,6 +183,7 @@ func (find *TaskFind) String() string {
return string(str)
}
+// TaskPatch is the API message for patching a task.
type TaskPatch struct {
ID int
@@ -174,6 +196,7 @@ type TaskPatch struct {
Payload *string
}
+// TaskStatusPatch is the API message for patching a task status.
type TaskStatusPatch struct {
ID int
@@ -188,6 +211,7 @@ type TaskStatusPatch struct {
Result *string
}
+// TaskService is the service for tasks.
type TaskService interface {
CreateTask(ctx context.Context, create *TaskCreate) (*Task, error)
FindTaskList(ctx context.Context, find *TaskFind) ([]*Task, error)
diff --git a/api/task_check_run.go b/api/task_check_run.go
index cd883a4377..943db0ed4c 100644
--- a/api/task_check_run.go
+++ b/api/task_check_run.go
@@ -9,13 +9,19 @@ import (
"github.com/bytebase/bytebase/plugin/db"
)
+// TaskCheckRunStatus is the status of a task check run.
type TaskCheckRunStatus string
const (
- TaskCheckRunUnknown TaskCheckRunStatus = "UNKNOWN"
- TaskCheckRunRunning TaskCheckRunStatus = "RUNNING"
- TaskCheckRunDone TaskCheckRunStatus = "DONE"
- TaskCheckRunFailed TaskCheckRunStatus = "FAILED"
+ // TaskCheckRunUnknown is the task check run status for UNKNOWN.
+ TaskCheckRunUnknown TaskCheckRunStatus = "UNKNOWN"
+ // TaskCheckRunRunning is the task check run status for RUNNING.
+ TaskCheckRunRunning TaskCheckRunStatus = "RUNNING"
+ // TaskCheckRunDone is the task check run status for DONE.
+ TaskCheckRunDone TaskCheckRunStatus = "DONE"
+ // TaskCheckRunFailed is the task check run status for FAILED.
+ TaskCheckRunFailed TaskCheckRunStatus = "FAILED"
+ // TaskCheckRunCanceled is the task check run status for CANCELED.
TaskCheckRunCanceled TaskCheckRunStatus = "CANCELED"
)
@@ -33,12 +39,16 @@ func (e TaskCheckRunStatus) String() string {
return "UNKNOWN"
}
+// TaskCheckStatus is the status of a task check.
type TaskCheckStatus string
const (
+ // TaskCheckStatusSuccess is the task check status for SUCCESS.
TaskCheckStatusSuccess TaskCheckStatus = "SUCCESS"
- TaskCheckStatusWarn TaskCheckStatus = "WARN"
- TaskCheckStatusError TaskCheckStatus = "ERROR"
+ // TaskCheckStatusWarn is the task check status for WARN.
+ TaskCheckStatusWarn TaskCheckStatus = "WARN"
+ // TaskCheckStatusError is the task check status for ERROR.
+ TaskCheckStatusError TaskCheckStatus = "ERROR"
)
func (e TaskCheckStatus) String() string {
@@ -57,13 +67,19 @@ func (e TaskCheckStatus) String() string {
type TaskCheckType string
const (
- TaskCheckDatabaseStatementFakeAdvise TaskCheckType = "bb.task-check.database.statement.fake-advise"
- TaskCheckDatabaseStatementSyntax TaskCheckType = "bb.task-check.database.statement.syntax"
+ // TaskCheckDatabaseStatementFakeAdvise is the task check type for fake advise.
+ TaskCheckDatabaseStatementFakeAdvise TaskCheckType = "bb.task-check.database.statement.fake-advise"
+ // TaskCheckDatabaseStatementSyntax is the task check type for statement syntax.
+ TaskCheckDatabaseStatementSyntax TaskCheckType = "bb.task-check.database.statement.syntax"
+ // TaskCheckDatabaseStatementCompatibility is the task check type for statement compatibility.
TaskCheckDatabaseStatementCompatibility TaskCheckType = "bb.task-check.database.statement.compatibility"
- TaskCheckDatabaseConnect TaskCheckType = "bb.task-check.database.connect"
- TaskCheckInstanceMigrationSchema TaskCheckType = "bb.task-check.instance.migration-schema"
+ // TaskCheckDatabaseConnect is the task check type for database connection.
+ TaskCheckDatabaseConnect TaskCheckType = "bb.task-check.database.connect"
+ // TaskCheckInstanceMigrationSchema is the task check type for migrating schemas.
+ TaskCheckInstanceMigrationSchema TaskCheckType = "bb.task-check.instance.migration-schema"
)
+// TaskCheckDatabaseStatementAdvisePayload is the task check payload for database statement advise.
type TaskCheckDatabaseStatementAdvisePayload struct {
Statement string `json:"statement,omitempty"`
DbType db.Type `json:"dbType,omitempty"`
@@ -71,6 +87,7 @@ type TaskCheckDatabaseStatementAdvisePayload struct {
Collation string `json:"collation,omitempty"`
}
+// TaskCheckResult is the result of task checks.
type TaskCheckResult struct {
Status TaskCheckStatus `json:"status,omitempty"`
Code common.Code `json:"code,omitempty"`
@@ -78,11 +95,13 @@ type TaskCheckResult struct {
Content string `json:"content,omitempty"`
}
+// TaskCheckRunResultPayload is the result payload of a task check run.
type TaskCheckRunResultPayload struct {
Detail string `json:"detail,omitempty"`
ResultList []TaskCheckResult `json:"resultList,omitempty"`
}
+// TaskCheckRun is the API message for task check run.
type TaskCheckRun struct {
ID int `jsonapi:"primary,taskCheckRun"`
@@ -106,6 +125,7 @@ type TaskCheckRun struct {
Payload string `jsonapi:"attr,payload"`
}
+// TaskCheckRunCreate is the API message for creating a task check run.
type TaskCheckRunCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -126,6 +146,7 @@ type TaskCheckRunCreate struct {
SkipIfAlreadyTerminated bool
}
+// TaskCheckRunFind is the API message for finding task check runs.
type TaskCheckRunFind struct {
ID *int
@@ -147,6 +168,7 @@ func (find *TaskCheckRunFind) String() string {
return string(str)
}
+// TaskCheckRunStatusPatch is the API message for patching a task check run.
type TaskCheckRunStatusPatch struct {
ID *int
@@ -159,6 +181,7 @@ type TaskCheckRunStatusPatch struct {
Result string
}
+// TaskCheckRunService is the service for task check runs.
type TaskCheckRunService interface {
// For a particular task and a particular check type, we only create a new TaskCheckRun if matches all conditions below:
// 1. There is no existing RUNNING check run. If this is the case, then returns that RUNNING check run.
diff --git a/api/task_run.go b/api/task_run.go
index ff6da06c24..0e605f36c1 100644
--- a/api/task_run.go
+++ b/api/task_run.go
@@ -8,13 +8,19 @@ import (
"github.com/bytebase/bytebase/common"
)
+// TaskRunStatus is the status of a task run.
type TaskRunStatus string
const (
- TaskRunUnknown TaskRunStatus = "UNKNOWN"
- TaskRunRunning TaskRunStatus = "RUNNING"
- TaskRunDone TaskRunStatus = "DONE"
- TaskRunFailed TaskRunStatus = "FAILED"
+ // TaskRunUnknown is the task run status for UNKNOWN.
+ TaskRunUnknown TaskRunStatus = "UNKNOWN"
+ // TaskRunRunning is the task run status for RUNNING.
+ TaskRunRunning TaskRunStatus = "RUNNING"
+ // TaskRunDone is the task run status for DONE.
+ TaskRunDone TaskRunStatus = "DONE"
+ // TaskRunFailed is the task run status for FAILED.
+ TaskRunFailed TaskRunStatus = "FAILED"
+ // TaskRunCanceled is the task run status for CANCELED.
TaskRunCanceled TaskRunStatus = "CANCELED"
)
@@ -32,12 +38,14 @@ func (e TaskRunStatus) String() string {
return "UNKNOWN"
}
+// TaskRunResultPayload is the result payload for a task run.
type TaskRunResultPayload struct {
Detail string `json:"detail,omitempty"`
MigrationID int64 `json:"migrationId,omitempty"`
Version string `json:"version,omitempty"`
}
+// TaskRun is the API message for a task run.
type TaskRun struct {
ID int `jsonapi:"primary,taskRun"`
@@ -62,6 +70,7 @@ type TaskRun struct {
Payload string `jsonapi:"attr,payload"`
}
+// TaskRunCreate is the API message for creating a task run.
type TaskRunCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -76,6 +85,7 @@ type TaskRunCreate struct {
Payload string `jsonapi:"attr,payload"`
}
+// TaskRunFind is the API message for finding task runs.
type TaskRunFind struct {
ID *int
@@ -94,6 +104,7 @@ func (find *TaskRunFind) String() string {
return string(str)
}
+// TaskRunStatusPatch is the API message for patching a task run.
type TaskRunStatusPatch struct {
ID *int
@@ -111,6 +122,7 @@ type TaskRunStatusPatch struct {
Result *string
}
+// TaskRunService is the service for task runs.
type TaskRunService interface {
CreateTaskRunTx(ctx context.Context, tx *sql.Tx, create *TaskRunCreate) (*TaskRun, error)
FindTaskRunListTx(ctx context.Context, tx *sql.Tx, find *TaskRunFind) ([]*TaskRun, error)
diff --git a/api/vcs.go b/api/vcs.go
index ff053a5a34..c4661b7cb2 100644
--- a/api/vcs.go
+++ b/api/vcs.go
@@ -7,6 +7,7 @@ import (
"github.com/bytebase/bytebase/common"
)
+// VCS is the API message for VCS.
type VCS struct {
ID int `jsonapi:"primary,vcs"`
@@ -22,11 +23,12 @@ type VCS struct {
Name string `jsonapi:"attr,name"`
Type common.VCSType `jsonapi:"attr,type"`
InstanceURL string `jsonapi:"attr,instanceUrl"`
- ApiURL string `jsonapi:"attr,apiUrl"`
+ APIURL string `jsonapi:"attr,apiUrl"`
ApplicationID string `jsonapi:"attr,applicationId"`
Secret string `jsonapi:"attr,secret"`
}
+// VCSCreate is the API message for creating a VCS.
type VCSCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -36,12 +38,13 @@ type VCSCreate struct {
Name string `jsonapi:"attr,name"`
Type common.VCSType `jsonapi:"attr,type"`
InstanceURL string `jsonapi:"attr,instanceUrl"`
- // ApiURL derives from InstanceURL
- ApiURL string
+ // APIURL derives from InstanceURL
+ APIURL string
ApplicationID string `jsonapi:"attr,applicationId"`
Secret string `jsonapi:"attr,secret"`
}
+// VCSFind is the API message for finding VCSs.
type VCSFind struct {
ID *int
}
@@ -54,6 +57,7 @@ func (find *VCSFind) String() string {
return string(str)
}
+// VCSPatch is the API message for patching a VCS.
type VCSPatch struct {
ID int
@@ -67,6 +71,7 @@ type VCSPatch struct {
Secret *string `jsonapi:"attr,secret"`
}
+// VCSDelete is the API message for deleting a VCS.
type VCSDelete struct {
ID int
@@ -75,6 +80,7 @@ type VCSDelete struct {
DeleterID int
}
+// VCSService is the service for VCSs.
type VCSService interface {
CreateVCS(ctx context.Context, create *VCSCreate) (*VCS, error)
FindVCSList(ctx context.Context, find *VCSFind) ([]*VCS, error)
diff --git a/api/view.go b/api/view.go
index 4d489946df..1eed92568d 100644
--- a/api/view.go
+++ b/api/view.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
)
+// View is the API message for a view.
type View struct {
ID int `jsonapi:"primary,view"`
@@ -26,6 +27,7 @@ type View struct {
Comment string `jsonapi:"attr,comment"`
}
+// ViewCreate is the API message for creating a view.
type ViewCreate struct {
// Standard fields
// Value is assigned from the jwt subject field passed by the client.
@@ -42,6 +44,7 @@ type ViewCreate struct {
Comment string
}
+// ViewFind is the API message for finding views.
type ViewFind struct {
ID *int
@@ -60,11 +63,13 @@ func (find *ViewFind) String() string {
return string(str)
}
+// ViewDelete is the API message for deleting a view.
type ViewDelete struct {
// Related fields
DatabaseID int
}
+// ViewService is the service for views.
type ViewService interface {
CreateView(ctx context.Context, create *ViewCreate) (*View, error)
FindViewList(ctx context.Context, find *ViewFind) ([]*View, error)
diff --git a/bin/server/cmd/root.go b/bin/server/cmd/root.go
index 56d263c6c3..1be960e351 100644
--- a/bin/server/cmd/root.go
+++ b/bin/server/cmd/root.go
@@ -235,7 +235,7 @@ func initSetting(ctx context.Context, settingService api.SettingService) (*confi
result := &config{}
{
configCreate := &api.SettingCreate{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
Name: api.SettingAuthSecret,
Value: common.RandomString(SECRET_LENGTH),
Description: "Random string used to sign the JWT auth token.",
@@ -249,7 +249,7 @@ func initSetting(ctx context.Context, settingService api.SettingService) (*confi
{
configCreate := &api.SettingCreate{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
Name: api.SettingConsoleURL,
Value: "",
Description: "URL for the external console (e.g. phpMyAdmin).",
diff --git a/server/anomaly_scanner.go b/server/anomaly_scanner.go
index 1645cfc885..9813411fd7 100644
--- a/server/anomaly_scanner.go
+++ b/server/anomaly_scanner.go
@@ -164,7 +164,7 @@ func (s *AnomalyScanner) checkInstanceAnomaly(ctx context.Context, instance *api
zap.Error(err))
} else {
_, err = s.server.AnomalyService.UpsertActiveAnomaly(ctx, &api.AnomalyUpsert{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
InstanceID: instance.ID,
Type: api.AnomalyInstanceConnection,
Payload: string(payload),
@@ -202,7 +202,7 @@ func (s *AnomalyScanner) checkInstanceAnomaly(ctx context.Context, instance *api
} else {
if setup {
_, err = s.server.AnomalyService.UpsertActiveAnomaly(ctx, &api.AnomalyUpsert{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
InstanceID: instance.ID,
Type: api.AnomalyInstanceMigrationSchema,
})
@@ -245,7 +245,7 @@ func (s *AnomalyScanner) checkDatabaseAnomaly(ctx context.Context, instance *api
zap.Error(err))
} else {
_, err = s.server.AnomalyService.UpsertActiveAnomaly(ctx, &api.AnomalyUpsert{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
InstanceID: instance.ID,
DatabaseID: &database.ID,
Type: api.AnomalyDatabaseConnection,
@@ -336,7 +336,7 @@ func (s *AnomalyScanner) checkDatabaseAnomaly(ctx context.Context, instance *api
zap.Error(err))
} else {
_, err = s.server.AnomalyService.UpsertActiveAnomaly(ctx, &api.AnomalyUpsert{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
InstanceID: instance.ID,
DatabaseID: &database.ID,
Type: api.AnomalyDatabaseSchemaDrift,
@@ -423,7 +423,7 @@ func (s *AnomalyScanner) checkBackupAnomaly(ctx context.Context, instance *api.I
zap.Error(err))
} else {
_, err = s.server.AnomalyService.UpsertActiveAnomaly(ctx, &api.AnomalyUpsert{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
InstanceID: instance.ID,
DatabaseID: &database.ID,
Type: api.AnomalyDatabaseBackupPolicyViolation,
@@ -507,7 +507,7 @@ func (s *AnomalyScanner) checkBackupAnomaly(ctx context.Context, instance *api.I
zap.Error(err))
} else {
_, err = s.server.AnomalyService.UpsertActiveAnomaly(ctx, &api.AnomalyUpsert{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
InstanceID: instance.ID,
DatabaseID: &database.ID,
Type: api.AnomalyDatabaseBackupMissing,
diff --git a/server/auth.go b/server/auth.go
index 53727f05da..2434bed844 100644
--- a/server/auth.go
+++ b/server/auth.go
@@ -87,7 +87,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {
}
principalCreate := &api.PrincipalCreate{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
Type: api.EndUser,
Name: signup.Name,
Email: signup.Email,
diff --git a/server/backup_runner.go b/server/backup_runner.go
index e640ce8b41..c7471700ba 100644
--- a/server/backup_runner.go
+++ b/server/backup_runner.go
@@ -136,7 +136,7 @@ func (s *BackupRunner) scheduleBackupTask(ctx context.Context, database *api.Dat
}
backupCreate := &api.BackupCreate{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
DatabaseID: database.ID,
Name: backupName,
Status: api.BackupStatusPendingCreate,
diff --git a/server/instance.go b/server/instance.go
index 6ce43bb372..ff1aaa2dda 100644
--- a/server/instance.go
+++ b/server/instance.go
@@ -224,7 +224,7 @@ func (s *Server) registerInstanceRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch instance ID: %v", id)).SetInternal(err)
}
- resultSet := &api.SqlResultSet{}
+ resultSet := &api.SQLResultSet{}
db, err := db.Open(
ctx,
instance.Engine,
diff --git a/server/issue.go b/server/issue.go
index b188141147..5834b5c138 100644
--- a/server/issue.go
+++ b/server/issue.go
@@ -565,9 +565,9 @@ func (s *Server) CreateIssue(ctx context.Context, issueCreate *api.IssueCreate,
func (s *Server) ChangeIssueStatus(ctx context.Context, issue *api.Issue, newStatus api.IssueStatus, updaterID int, comment string) (*api.Issue, error) {
var pipelineStatus api.PipelineStatus
switch newStatus {
- case api.Issue_Open:
- pipelineStatus = api.Pipeline_Open
- case api.Issue_Done:
+ case api.IssueOpen:
+ pipelineStatus = api.PipelineOpen
+ case api.IssueDone:
// Returns error if any of the tasks is not DONE.
for _, stage := range issue.Pipeline.StageList {
for _, task := range stage.TaskList {
@@ -576,8 +576,8 @@ func (s *Server) ChangeIssueStatus(ctx context.Context, issue *api.Issue, newSta
}
}
}
- pipelineStatus = api.Pipeline_Done
- case api.Issue_Canceled:
+ pipelineStatus = api.PipelineDone
+ case api.IssueCanceled:
// If we want to cancel the issue, we find the current running tasks, mark each of them CANCELED.
// We keep PENDING and FAILED tasks as is since the issue maybe reopened later, and it's better to
// keep those tasks in the same state before the issue was canceled.
@@ -590,7 +590,7 @@ func (s *Server) ChangeIssueStatus(ctx context.Context, issue *api.Issue, newSta
}
}
}
- pipelineStatus = api.Pipeline_Canceled
+ pipelineStatus = api.PipelineCanceled
}
pipelinePatch := &api.PipelinePatch{
@@ -644,7 +644,7 @@ func (s *Server) ChangeIssueStatus(ctx context.Context, issue *api.Issue, newSta
}
func (s *Server) PostInboxIssueActivity(ctx context.Context, issue *api.Issue, activity_id int) error {
- if issue.CreatorID != api.SYSTEM_BOT_ID {
+ if issue.CreatorID != api.SystemBotID {
inboxCreate := &api.InboxCreate{
ReceiverID: issue.CreatorID,
ActivityID: activity_id,
@@ -655,7 +655,7 @@ func (s *Server) PostInboxIssueActivity(ctx context.Context, issue *api.Issue, a
}
}
- if issue.AssigneeID != api.SYSTEM_BOT_ID && issue.AssigneeID != issue.CreatorID {
+ if issue.AssigneeID != api.SystemBotID && issue.AssigneeID != issue.CreatorID {
inboxCreate := &api.InboxCreate{
ReceiverID: issue.AssigneeID,
ActivityID: activity_id,
@@ -667,7 +667,7 @@ func (s *Server) PostInboxIssueActivity(ctx context.Context, issue *api.Issue, a
}
for _, subscriberID := range issue.SubscriberIDList {
- if subscriberID != api.SYSTEM_BOT_ID && subscriberID != issue.CreatorID && subscriberID != issue.AssigneeID {
+ if subscriberID != api.SystemBotID && subscriberID != issue.CreatorID && subscriberID != issue.AssigneeID {
inboxCreate := &api.InboxCreate{
ReceiverID: subscriberID,
ActivityID: activity_id,
diff --git a/server/pipeline.go b/server/pipeline.go
index d5e92b34ec..a85d954f04 100644
--- a/server/pipeline.go
+++ b/server/pipeline.go
@@ -55,11 +55,11 @@ func (s *Server) ScheduleNextTaskIfNeeded(ctx context.Context, pipeline *api.Pip
skipIfAlreadyTerminated := true
if task.Status == api.TaskPendingApproval {
- return s.TaskCheckScheduler.ScheduleCheckIfNeeded(ctx, task, api.SYSTEM_BOT_ID, skipIfAlreadyTerminated)
+ return s.TaskCheckScheduler.ScheduleCheckIfNeeded(ctx, task, api.SystemBotID, skipIfAlreadyTerminated)
}
if task.Status == api.TaskPending {
- if _, err := s.TaskCheckScheduler.ScheduleCheckIfNeeded(ctx, task, api.SYSTEM_BOT_ID, skipIfAlreadyTerminated); err != nil {
+ if _, err := s.TaskCheckScheduler.ScheduleCheckIfNeeded(ctx, task, api.SystemBotID, skipIfAlreadyTerminated); err != nil {
return nil, err
}
updatedTask, err := s.TaskScheduler.ScheduleIfNeeded(ctx, task)
diff --git a/server/plan.go b/server/plan.go
index bf14663c66..a60e44c54f 100644
--- a/server/plan.go
+++ b/server/plan.go
@@ -40,5 +40,5 @@ func (s *Server) registerPlanRoutes(g *echo.Group) {
}
func (s *Server) feature(feature api.FeatureType) bool {
- return api.FEATURE_MATRIX[feature][s.plan]
+ return api.FeatureMatrix[feature][s.plan]
}
diff --git a/server/principal.go b/server/principal.go
index a57242b239..c1246b4ce3 100644
--- a/server/principal.go
+++ b/server/principal.go
@@ -159,7 +159,7 @@ func (s *Server) ComposePrincipalByID(ctx context.Context, id int) (*api.Princip
}
func (s *Server) ComposePrincipalRole(ctx context.Context, principal *api.Principal) error {
- if principal.ID == api.SYSTEM_BOT_ID {
+ if principal.ID == api.SystemBotID {
principal.Role = api.Owner
} else {
memberFind := &api.MemberFind{
diff --git a/server/sql.go b/server/sql.go
index 5966d0769a..f8cab720b1 100644
--- a/server/sql.go
+++ b/server/sql.go
@@ -47,7 +47,7 @@ func (s *Server) registerSqlRoutes(g *echo.Group) {
db.ConnectionContext{},
)
- resultSet := &api.SqlResultSet{}
+ resultSet := &api.SQLResultSet{}
if err != nil {
hostPort := connectionInfo.Host
if connectionInfo.Port != "" {
@@ -70,7 +70,7 @@ func (s *Server) registerSqlRoutes(g *echo.Group) {
g.POST("/sql/syncschema", func(c echo.Context) error {
ctx := context.Background()
- sync := &api.SqlSyncSchema{}
+ sync := &api.SQLSyncSchema{}
if err := jsonapi.UnmarshalPayload(c.Request().Body, sync); err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "Malformatted sql sync schema request").SetInternal(err)
}
@@ -93,8 +93,8 @@ func (s *Server) registerSqlRoutes(g *echo.Group) {
})
}
-func (s *Server) SyncEngineVersionAndSchema(ctx context.Context, instance *api.Instance) (rs *api.SqlResultSet) {
- resultSet := &api.SqlResultSet{}
+func (s *Server) SyncEngineVersionAndSchema(ctx context.Context, instance *api.Instance) (rs *api.SQLResultSet) {
+ resultSet := &api.SQLResultSet{}
err := func() error {
driver, err := GetDatabaseDriver(ctx, instance, "", s.l)
if err != nil {
@@ -112,7 +112,7 @@ func (s *Server) SyncEngineVersionAndSchema(ctx context.Context, instance *api.I
if version != instance.EngineVersion {
_, err := s.InstanceService.PatchInstance(ctx, &api.InstancePatch{
ID: instance.ID,
- UpdaterID: api.SYSTEM_BOT_ID,
+ UpdaterID: api.SystemBotID,
EngineVersion: &version,
})
if err != nil {
@@ -174,7 +174,7 @@ func (s *Server) SyncEngineVersionAndSchema(ctx context.Context, instance *api.I
var recreateTableSchema = func(database *api.Database, table db.DBTable) error {
// Table
tableCreate := &api.TableCreate{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
CreatedTs: table.CreatedTs,
UpdatedTs: table.UpdatedTs,
DatabaseID: database.ID,
@@ -205,7 +205,7 @@ func (s *Server) SyncEngineVersionAndSchema(ctx context.Context, instance *api.I
if err != nil {
if common.ErrorCode(err) == common.NotFound {
columnCreate := &api.ColumnCreate{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
DatabaseID: database.ID,
TableID: upsertedTable.ID,
Name: column.Name,
@@ -238,7 +238,7 @@ func (s *Server) SyncEngineVersionAndSchema(ctx context.Context, instance *api.I
if err != nil {
if common.ErrorCode(err) == common.NotFound {
indexCreate := &api.IndexCreate{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
DatabaseID: database.ID,
TableID: upsertedTable.ID,
Name: index.Name,
@@ -263,7 +263,7 @@ func (s *Server) SyncEngineVersionAndSchema(ctx context.Context, instance *api.I
var recreateViewSchema = func(database *api.Database, view db.DBView) error {
// View
viewCreate := &api.ViewCreate{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
CreatedTs: view.CreatedTs,
UpdatedTs: view.UpdatedTs,
DatabaseID: database.ID,
@@ -289,7 +289,7 @@ func (s *Server) SyncEngineVersionAndSchema(ctx context.Context, instance *api.I
// Upsert user found in the instance
for _, user := range userList {
userUpsert := &api.InstanceUserUpsert{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
InstanceID: instance.ID,
Name: user.Name,
Grant: user.Grant,
@@ -354,7 +354,7 @@ func (s *Server) SyncEngineVersionAndSchema(ctx context.Context, instance *api.I
ts := time.Now().Unix()
databasePatch := &api.DatabasePatch{
ID: matchedDb.ID,
- UpdaterID: api.SYSTEM_BOT_ID,
+ UpdaterID: api.SystemBotID,
SyncStatus: &syncStatus,
LastSuccessfulSyncTs: &ts,
}
@@ -398,8 +398,8 @@ func (s *Server) SyncEngineVersionAndSchema(ctx context.Context, instance *api.I
} else {
// Case 2, only appear in the synced db schema
databaseCreate := &api.DatabaseCreate{
- CreatorID: api.SYSTEM_BOT_ID,
- ProjectID: api.DEFAULT_PROJECT_ID,
+ CreatorID: api.SystemBotID,
+ ProjectID: api.DefaultProjectID,
InstanceID: instance.ID,
EnvironmentID: instance.EnvironmentID,
Name: schema.Name,
@@ -444,7 +444,7 @@ func (s *Server) SyncEngineVersionAndSchema(ctx context.Context, instance *api.I
ts := time.Now().Unix()
databasePatch := &api.DatabasePatch{
ID: db.ID,
- UpdaterID: api.SYSTEM_BOT_ID,
+ UpdaterID: api.SystemBotID,
SyncStatus: &syncStatus,
LastSuccessfulSyncTs: &ts,
}
diff --git a/server/task.go b/server/task.go
index c20fcbf9de..05ead124f5 100644
--- a/server/task.go
+++ b/server/task.go
@@ -99,7 +99,7 @@ func (s *Server) registerTaskRoutes(g *echo.Group) {
return echo.NewHTTPError(http.StatusInternalServerError, fmt.Errorf("failed to marshal statement advise payload: %v, err: %w", task.Name, err))
}
_, err = s.TaskCheckRunService.CreateTaskCheckRunIfNeeded(ctx, &api.TaskCheckRunCreate{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
TaskID: task.ID,
Type: api.TaskCheckDatabaseStatementSyntax,
Payload: string(payload),
@@ -115,7 +115,7 @@ func (s *Server) registerTaskRoutes(g *echo.Group) {
}
_, err = s.TaskCheckRunService.CreateTaskCheckRunIfNeeded(ctx, &api.TaskCheckRunCreate{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
TaskID: task.ID,
Type: api.TaskCheckDatabaseStatementCompatibility,
Payload: string(payload),
@@ -411,7 +411,7 @@ func (s *Server) ChangeTaskStatusWithPatch(ctx context.Context, task *api.Task,
// Schedule the task if it's being just approved
if task.Status == api.TaskPendingApproval && updatedTask.Status == api.TaskPending {
skipIfAlreadyTerminated := false
- if _, err := s.TaskCheckScheduler.ScheduleCheckIfNeeded(ctx, updatedTask, api.SYSTEM_BOT_ID, skipIfAlreadyTerminated); err != nil {
+ if _, err := s.TaskCheckScheduler.ScheduleCheckIfNeeded(ctx, updatedTask, api.SystemBotID, skipIfAlreadyTerminated); err != nil {
return nil, fmt.Errorf("failed to schedule task check \"%v\" after approval", updatedTask.Name)
}
@@ -475,7 +475,7 @@ func (s *Server) ChangeTaskStatusWithPatch(ctx context.Context, task *api.Task,
// If this is the last task in the pipeline and just completed, and the assignee is system bot:
// Case 1: If the task is associated with an issue, then we mark the issue (including the pipeline) as DONE.
// Case 2: If the task is NOT associated with an issue, then we mark the pipeline as DONE.
- if updatedTask.Status == "DONE" && (issue == nil || issue.AssigneeID == api.SYSTEM_BOT_ID) {
+ if updatedTask.Status == "DONE" && (issue == nil || issue.AssigneeID == api.SystemBotID) {
pipeline, err := s.ComposePipelineByID(ctx, updatedTask.PipelineID)
if err != nil {
return nil, fmt.Errorf("failed to fetch pipeline/issue as DONE after completing task %v", updatedTask.Name)
@@ -483,7 +483,7 @@ func (s *Server) ChangeTaskStatusWithPatch(ctx context.Context, task *api.Task,
lastStage := pipeline.StageList[len(pipeline.StageList)-1]
if lastStage.TaskList[len(lastStage.TaskList)-1].ID == updatedTask.ID {
if issue == nil {
- status := api.Pipeline_Done
+ status := api.PipelineDone
pipelinePatch := &api.PipelinePatch{
ID: pipeline.ID,
UpdaterID: taskStatusPatch.UpdaterID,
@@ -494,7 +494,7 @@ func (s *Server) ChangeTaskStatusWithPatch(ctx context.Context, task *api.Task,
}
} else {
issue.Pipeline = pipeline
- _, err := s.ChangeIssueStatus(ctx, issue, api.Issue_Done, taskStatusPatch.UpdaterID, "")
+ _, err := s.ChangeIssueStatus(ctx, issue, api.IssueDone, taskStatusPatch.UpdaterID, "")
if err != nil {
return nil, fmt.Errorf("failed to mark issue %v as DONE after completing task %v: %w", issue.Name, updatedTask.Name, err)
}
diff --git a/server/task_check_scheduler.go b/server/task_check_scheduler.go
index 990cf150f2..b0a7b4f04d 100644
--- a/server/task_check_scheduler.go
+++ b/server/task_check_scheduler.go
@@ -105,7 +105,7 @@ func (s *TaskCheckScheduler) Run() error {
taskCheckRunStatusPatch := &api.TaskCheckRunStatusPatch{
ID: &taskCheckRun.ID,
- UpdaterID: api.SYSTEM_BOT_ID,
+ UpdaterID: api.SystemBotID,
Status: api.TaskCheckRunDone,
Code: common.Ok,
Result: string(bytes),
@@ -141,7 +141,7 @@ func (s *TaskCheckScheduler) Run() error {
taskCheckRunStatusPatch := &api.TaskCheckRunStatusPatch{
ID: &taskCheckRun.ID,
- UpdaterID: api.SYSTEM_BOT_ID,
+ UpdaterID: api.SystemBotID,
Status: api.TaskCheckRunFailed,
Code: common.ErrorCode(err),
Result: string(bytes),
diff --git a/server/task_executor_database_backup.go b/server/task_executor_database_backup.go
index 8be3b4a73f..5bdc2bb30e 100644
--- a/server/task_executor_database_backup.go
+++ b/server/task_executor_database_backup.go
@@ -68,7 +68,7 @@ func (exec *DatabaseBackupTaskExecutor) RunOnce(ctx context.Context, server *Ser
if _, err = server.BackupService.PatchBackup(ctx, &api.BackupPatch{
ID: backup.ID,
Status: newBackupStatus,
- UpdaterID: api.SYSTEM_BOT_ID,
+ UpdaterID: api.SystemBotID,
Comment: comment,
}); err != nil {
return true, nil, fmt.Errorf("failed to patch backup: %w", err)
diff --git a/server/task_executor_database_restore.go b/server/task_executor_database_restore.go
index 0e6a019493..23fd4aa215 100644
--- a/server/task_executor_database_restore.go
+++ b/server/task_executor_database_restore.go
@@ -101,7 +101,7 @@ func (exec *DatabaseRestoreTaskExecutor) RunOnce(ctx context.Context, server *Se
// inconsistent data. We choose to do Patch afterwards since this one is unlikely to fail.
databasePatch := &api.DatabasePatch{
ID: targetDatabase.ID,
- UpdaterID: api.SYSTEM_BOT_ID,
+ UpdaterID: api.SystemBotID,
SourceBackupID: &backup.ID,
}
if _, err = server.DatabaseService.PatchDatabase(ctx, databasePatch); err != nil {
diff --git a/server/task_scheduler.go b/server/task_scheduler.go
index 350271365d..ae3d9ab6d4 100644
--- a/server/task_scheduler.go
+++ b/server/task_scheduler.go
@@ -52,7 +52,7 @@ func (s *TaskScheduler) Run() error {
ctx := context.Background()
// Inspect all open pipelines and schedule the next PENDING task if applicable
- pipelineStatus := api.Pipeline_Open
+ pipelineStatus := api.PipelineOpen
pipelineFind := &api.PipelineFind{
Status: &pipelineStatus,
}
@@ -62,7 +62,7 @@ func (s *TaskScheduler) Run() error {
return
}
for _, pipeline := range pipelineList {
- if pipeline.ID == api.ONBOARDING_PIPELINE_ID {
+ if pipeline.ID == api.OnboardingPipelineID {
continue
}
if err := s.server.ComposePipelineRelationship(ctx, pipeline); err != nil {
@@ -94,7 +94,7 @@ func (s *TaskScheduler) Run() error {
}
for _, task := range taskList {
- if task.ID == api.ONBOARDING_TASK_ID1 || task.ID == api.ONBOARDING_TASK_ID2 {
+ if task.ID == api.OnboardingTaskID1 || task.ID == api.OnboardingTaskID2 {
continue
}
@@ -149,7 +149,7 @@ func (s *TaskScheduler) Run() error {
result := string(bytes)
taskStatusPatch := &api.TaskStatusPatch{
ID: task.ID,
- UpdaterID: api.SYSTEM_BOT_ID,
+ UpdaterID: api.SystemBotID,
Status: api.TaskDone,
Code: &code,
Result: &result,
@@ -184,7 +184,7 @@ func (s *TaskScheduler) Run() error {
result := string(bytes)
taskStatusPatch := &api.TaskStatusPatch{
ID: task.ID,
- UpdaterID: api.SYSTEM_BOT_ID,
+ UpdaterID: api.SystemBotID,
Status: api.TaskFailed,
Code: &code,
Result: &result,
@@ -273,7 +273,7 @@ func (s *TaskScheduler) ScheduleIfNeeded(ctx context.Context, task *api.Task) (*
}
}
}
- updatedTask, err := s.server.ChangeTaskStatus(ctx, task, api.TaskRunning, api.SYSTEM_BOT_ID)
+ updatedTask, err := s.server.ChangeTaskStatus(ctx, task, api.TaskRunning, api.SystemBotID)
if err != nil {
return nil, err
}
diff --git a/server/vcs.go b/server/vcs.go
index 89629f0e4c..094e62be29 100644
--- a/server/vcs.go
+++ b/server/vcs.go
@@ -25,7 +25,7 @@ func (s *Server) registerVCSRoutes(g *echo.Group) {
}
// Trim ending "/"
vcsCreate.InstanceURL = strings.TrimRight(vcsCreate.InstanceURL, "/")
- vcsCreate.ApiURL = fmt.Sprintf("%s/%s", vcsCreate.InstanceURL, gitlab.ApiPath)
+ vcsCreate.APIURL = fmt.Sprintf("%s/%s", vcsCreate.InstanceURL, gitlab.ApiPath)
vcs, err := s.VCSService.CreateVCS(ctx, vcsCreate)
if err != nil {
diff --git a/server/webhook.go b/server/webhook.go
index 44f269c17f..34d5334af2 100644
--- a/server/webhook.go
+++ b/server/webhook.go
@@ -134,7 +134,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
}
activityCreate := &api.ActivityCreate{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
ContainerID: repository.ProjectID,
Type: api.ActivityProjectRepositoryPush,
Level: api.ActivityWarn,
@@ -289,10 +289,10 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
Name: commit.Title,
Type: api.IssueDatabaseSchemaUpdate,
Description: commit.Message,
- AssigneeID: api.SYSTEM_BOT_ID,
+ AssigneeID: api.SystemBotID,
}
- issue, err := s.CreateIssue(ctx, issueCreate, api.SYSTEM_BOT_ID)
+ issue, err := s.CreateIssue(ctx, issueCreate, api.SystemBotID)
if err != nil {
s.l.Warn("Failed to create update schema task for added repository file", zap.Error(err),
zap.String("file", added))
@@ -313,7 +313,7 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
}
activityCreate := &api.ActivityCreate{
- CreatorID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
ContainerID: repository.ProjectID,
Type: api.ActivityProjectRepositoryPush,
Level: api.ActivityInfo,
diff --git a/store/database.go b/store/database.go
index e5e940dcdf..eb6b152899 100644
--- a/store/database.go
+++ b/store/database.go
@@ -71,7 +71,7 @@ func (s *DatabaseService) CreateDatabaseTx(ctx context.Context, tx *sql.Tx, crea
// Enable automatic backup setting based on backup plan policy.
if backupPlanPolicy.Schedule != api.BackupPlanPolicyScheduleUnset {
backupSettingUpsert := &api.BackupSettingUpsert{
- UpdaterID: api.SYSTEM_BOT_ID,
+ UpdaterID: api.SystemBotID,
DatabaseID: database.ID,
Enabled: true,
Hour: rand.Intn(24),
diff --git a/store/instance.go b/store/instance.go
index 13e41c1058..24881cf904 100644
--- a/store/instance.go
+++ b/store/instance.go
@@ -46,7 +46,7 @@ func (s *InstanceService) CreateInstance(ctx context.Context, create *api.Instan
// Create * database
databaseCreate := &api.DatabaseCreate{
CreatorID: create.CreatorID,
- ProjectID: api.DEFAULT_PROJECT_ID,
+ ProjectID: api.DefaultProjectID,
InstanceID: instance.ID,
EnvironmentID: instance.EnvironmentID,
Name: api.AllDatabaseName,
diff --git a/store/policy.go b/store/policy.go
index e801348703..4ec15d7af0 100644
--- a/store/policy.go
+++ b/store/policy.go
@@ -49,8 +49,8 @@ func (s *PolicyService) FindPolicy(ctx context.Context, find *api.PolicyFind) (*
return nil, err
} else if len(list) == 0 {
ret = &api.Policy{
- CreatorID: api.SYSTEM_BOT_ID,
- UpdaterID: api.SYSTEM_BOT_ID,
+ CreatorID: api.SystemBotID,
+ UpdaterID: api.SystemBotID,
EnvironmentID: *find.EnvironmentID,
Type: *find.Type,
}
diff --git a/store/repository.go b/store/repository.go
index f154ed1fca..5d8fd93275 100644
--- a/store/repository.go
+++ b/store/repository.go
@@ -129,7 +129,7 @@ func (s *RepositoryService) DeleteRepository(ctx context.Context, delete *api.Re
// createRepository creates a new repository.
func (s *RepositoryService) createRepository(ctx context.Context, tx *Tx, create *api.RepositoryCreate) (*api.Repository, error) {
// Updates the project workflow_type to "VCS"
- workflowType := api.VCS_WORKFLOW
+ workflowType := api.VCSWorkflow
projectPatch := api.ProjectPatch{
ID: create.ProjectID,
UpdaterID: create.CreatorID,
@@ -383,7 +383,7 @@ func patchRepository(ctx context.Context, tx *Tx, patch *api.RepositoryPatch) (*
// deleteRepository permanently deletes a repository by ID.
func (s *RepositoryService) deleteRepository(ctx context.Context, tx *Tx, delete *api.RepositoryDelete) error {
// Updates the project workflow_type to "UI"
- workflowType := api.UI_WORKFLOW
+ workflowType := api.UIWorkflow
projectPatch := api.ProjectPatch{
ID: delete.ProjectID,
UpdaterID: delete.DeleterID,
diff --git a/store/vcs.go b/store/vcs.go
index eab7eb6f69..3b8c0dce3a 100644
--- a/store/vcs.go
+++ b/store/vcs.go
@@ -146,7 +146,7 @@ func createVCS(ctx context.Context, tx *Tx, create *api.VCSCreate) (*api.VCS, er
create.Name,
create.Type,
create.InstanceURL,
- create.ApiURL,
+ create.APIURL,
create.ApplicationID,
create.Secret,
)
@@ -167,7 +167,7 @@ func createVCS(ctx context.Context, tx *Tx, create *api.VCSCreate) (*api.VCS, er
&vcs.Name,
&vcs.Type,
&vcs.InstanceURL,
- &vcs.ApiURL,
+ &vcs.APIURL,
&vcs.ApplicationID,
&vcs.Secret,
); err != nil {
@@ -219,7 +219,7 @@ func findVCSList(ctx context.Context, tx *Tx, find *api.VCSFind) (_ []*api.VCS,
&vcs.Name,
&vcs.Type,
&vcs.InstanceURL,
- &vcs.ApiURL,
+ &vcs.APIURL,
&vcs.ApplicationID,
&vcs.Secret,
); err != nil {
@@ -275,7 +275,7 @@ func patchVCS(ctx context.Context, tx *Tx, patch *api.VCSPatch) (*api.VCS, error
&vcs.Name,
&vcs.Type,
&vcs.InstanceURL,
- &vcs.ApiURL,
+ &vcs.APIURL,
&vcs.ApplicationID,
&vcs.Secret,
); err != nil {