Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Configure pre-commit and fix some lint errors (#62)
satorude5a7a1603f8
diff --git a/.golangci.yaml b/.golangci.yamlnew file mode 100644index 0000000000..4c44c5fae9--- /dev/null+++ b/.golangci.yaml@@ -0,0 +1,3 @@+linters:+ disable:+ - errcheckdiff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlnew file mode 100644index 0000000000..ad6ba0f24c--- /dev/null+++ b/.pre-commit-config.yaml@@ -0,0 +1,11 @@+repos:+- repo: https://github.com/pre-commit/pre-commit-hooks+ rev: v2.3.0+ hooks:+ - id: check-yaml+ - id: end-of-file-fixer+ - id: trailing-whitespace+- repo: https://github.com/golangci/golangci-lint+ rev: v1.33.0+ hooks:+ - id: golangci-lintdiff --git a/README.md b/README.mdindex 4f645c4e39..72ab520215 100644--- a/README.md+++ b/README.md@@ -112,21 +112,25 @@ working on the code:### Steps-1. Install [Air](https://github.com/cosmtrek/air#installation)+1. Install [Air](https://github.com/cosmtrek/air#installation)-1. Pull source+1. Pull source```bashgit clone https://github.com/bytebase/bytebase```-1. Start backend using air (with live reload)+1. Set up pre-commit hooks+ - Install [pre-commit](https://pre-commit.com/index.html#install)+ - Run `pre-commit install` inside the `bytebase` directory++1. Start backend using air (with live reload)```bashair -c scripts/.air.toml```-1. Start frontend (with live reload)+1. Start frontend (with live reload)```bashcd frontend && yarn && yarn devdiff --git a/plugin/db/snowflake/snowflake.go b/plugin/db/snowflake/snowflake.goindex 92d55396d6..21db748fad 100644--- a/plugin/db/snowflake/snowflake.go+++ b/plugin/db/snowflake/snowflake.go@@ -185,7 +185,7 @@ func (driver *Driver) syncTableSchema(ctx context.Context, database string) ([]dSELECTTABLE_SCHEMA,TABLE_NAME,- IFNULL(COLUMN_NAME, ''),+ IFNULL(COLUMN_NAME, ''),ORDINAL_POSITION,COLUMN_DEFAULT,IS_NULLABLE,@@ -234,7 +234,7 @@ func (driver *Driver) syncTableSchema(ctx context.Context, database string) ([]dquery = fmt.Sprintf(`SELECT- TABLE_SCHEMA,+ TABLE_SCHEMA,TABLE_NAME,DATE_PART(EPOCH_SECOND, CREATED),DATE_PART(EPOCH_SECOND, LAST_ALTERED),@@ -277,7 +277,7 @@ func (driver *Driver) syncTableSchema(ctx context.Context, database string) ([]dquery = fmt.Sprintf(`SELECT- TABLE_SCHEMA,+ TABLE_SCHEMA,TABLE_NAME,DATE_PART(EPOCH_SECOND, CREATED),DATE_PART(EPOCH_SECOND, LAST_ALTERED),@@ -380,7 +380,7 @@ func getDatabasesTxn(ctx context.Context, tx *sql.Tx) ([]string, error) {}query := `- SELECT+ SELECTDATABASE_NAMEFROM SNOWFLAKE.INFORMATION_SCHEMA.DATABASES`rows, err := tx.QueryContext(ctx, query)@@ -513,7 +513,7 @@ func (driver *Driver) NeedsSetupMigration(ctx context.Context) (bool, error) {}const query = `- SELECT+ SELECT1FROM BYTEBASE.INFORMATION_SCHEMA.TABLESWHERE TABLE_SCHEMA='PUBLIC' AND TABLE_NAME = 'MIGRATION_HISTORY'@@ -653,7 +653,6 @@ const ("--\n" +"-- Snowflake database structure for %s\n" +"--\n"- useDatabaseFmt = "use %s;")func (driver *Driver) Dump(ctx context.Context, database string, out io.Writer, schemaOnly bool) error {@@ -681,13 +680,11 @@ func dumpTxn(ctx context.Context, txn *sql.Tx, database string, out io.Writer, sif database != "" {dumpableDbNames = []string{database}} else {- dbNames, err := getDatabasesTxn(ctx, txn)+ var err error+ dumpableDbNames, err = getDatabasesTxn(ctx, txn)if err != nil {return fmt.Errorf("failed to get databases: %s", err)}- for _, dbName := range dbNames {- dumpableDbNames = append(dumpableDbNames, dbName)- }}// Use ACCOUNTADMIN role to dump database;diff --git a/server/principal.go b/server/principal.goindex a94dc2ade9..a57242b239 100644--- a/server/principal.go+++ b/server/principal.go@@ -151,7 +151,9 @@ func (s *Server) ComposePrincipalByID(ctx context.Context, id int) (*api.Principreturn nil, err}- s.ComposePrincipalRole(ctx, principal)+ if err = s.ComposePrincipalRole(ctx, principal); err != nil {+ return nil, err+ }return principal, nil}