From e0a78dd34b2ccb2c2881ab9aaefa9aa785642316 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Tue, 10 Sep 2024 16:53:02 +0900 Subject: [PATCH 001/305] fix: bump edge-runtime to 1.58.3 (#2668) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index f81e21a40..93331225a 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.83.2" studioImage = "supabase/studio:20240729-ce42139" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.58.2" + edgeRuntimeImage = "supabase/edge-runtime:v1.58.3" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.158.1" From 24ea3cb3ff261c22515197259c4aa3e31e0b30a8 Mon Sep 17 00:00:00 2001 From: Tim Kral <152592907+tim-dianahr@users.noreply.github.com> Date: Wed, 11 Sep 2024 03:45:18 -0700 Subject: [PATCH 002/305] feat: allow Cognito configuration from env var (#2660) Allow Cognito configuration from Env --- pkg/config/config.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/config/config.go b/pkg/config/config.go index 3d3be2f27..4340b48f8 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -1072,10 +1072,17 @@ func (c *tpaCognito) validate() error { if c.UserPoolID == "" { return errors.New("Invalid config: auth.third_party.cognito is enabled but without a user_pool_id.") } + var err error + if c.UserPoolID, err = maybeLoadEnv(c.UserPoolID); err != nil { + return err + } if c.UserPoolRegion == "" { return errors.New("Invalid config: auth.third_party.cognito is enabled but without a user_pool_region.") } + if c.UserPoolRegion, err = maybeLoadEnv(c.UserPoolRegion); err != nil { + return err + } return nil } From b409d6a602ff046f76d6da08c752ccdcaf48f260 Mon Sep 17 00:00:00 2001 From: arvalaan <9444629+arvalaan@users.noreply.github.com> Date: Wed, 11 Sep 2024 13:08:22 +0200 Subject: [PATCH 003/305] fix: Health Check issue on Podman/Windows (#2656) * Fixed Health Check issue on Podman/Windows This solves the issue where the `supabase start` command exits with an error because the health check isnt performed properly. * chore: reformat code * Update start.go --------- Co-authored-by: Han Qiao --- internal/start/start.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/start/start.go b/internal/start/start.go index d1a9612a9..4b967e6ca 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -944,7 +944,7 @@ EOF "PG_META_DB_PASSWORD=" + dbConfig.Password, }, Healthcheck: &container.HealthConfig{ - Test: []string{"CMD", "node", `--eval='fetch("http://127.0.0.1:8080/health").then((r) => {if (r.status !== 200) throw new Error(r.status)})'`}, + Test: []string{"CMD-SHELL", `node --eval="fetch('http://127.0.0.1:8080/health').then((r) => {if (!r.ok) throw new Error(r.status)})"`}, Interval: 10 * time.Second, Timeout: 2 * time.Second, Retries: 3, @@ -990,7 +990,7 @@ EOF "HOSTNAME=0.0.0.0", }, Healthcheck: &container.HealthConfig{ - Test: []string{"CMD", "node", `--eval='fetch("http://127.0.0.1:3000/api/profile", (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})'`}, + Test: []string{"CMD-SHELL", `node --eval="fetch('http://127.0.0.1:3000/api/profile').then((r) => {if (!r.ok) throw new Error(r.status)})"`}, Interval: 10 * time.Second, Timeout: 2 * time.Second, Retries: 3, From 787bc92704fea4efb2c244216532da6e28753d97 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Wed, 11 Sep 2024 14:01:33 +0200 Subject: [PATCH 004/305] feat: add db lint fail-on flag (#2664) --- cmd/db.go | 8 ++++- docs/supabase/db/lint.md | 8 +++++ internal/db/lint/lint.go | 30 +++++++++++++---- internal/db/lint/lint_test.go | 62 +++++++++++++++++++++++++++++++++-- 4 files changed, 98 insertions(+), 10 deletions(-) diff --git a/cmd/db.go b/cmd/db.go index e2b109a21..30935d284 100644 --- a/cmd/db.go +++ b/cmd/db.go @@ -196,11 +196,16 @@ var ( Value: lint.AllowedLevels[0], } + lintFailOn = utils.EnumFlag{ + Allowed: append([]string{"none"}, lint.AllowedLevels...), + Value: "none", + } + dbLintCmd = &cobra.Command{ Use: "lint", Short: "Checks local database for typing error", RunE: func(cmd *cobra.Command, args []string) error { - return lint.Run(cmd.Context(), schema, level.Value, flags.DbConfig, afero.NewOsFs()) + return lint.Run(cmd.Context(), schema, level.Value, lintFailOn.Value, flags.DbConfig, afero.NewOsFs()) }, } @@ -310,6 +315,7 @@ func init() { dbLintCmd.MarkFlagsMutuallyExclusive("db-url", "linked", "local") lintFlags.StringSliceVarP(&schema, "schema", "s", []string{}, "Comma separated list of schema to include.") lintFlags.Var(&level, "level", "Error level to emit.") + lintFlags.Var(&lintFailOn, "fail-on", "Error level to exit with non-zero status.") dbCmd.AddCommand(dbLintCmd) // Build start command dbCmd.AddCommand(dbStartCmd) diff --git a/docs/supabase/db/lint.md b/docs/supabase/db/lint.md index 33415dc21..3718d2d31 100644 --- a/docs/supabase/db/lint.md +++ b/docs/supabase/db/lint.md @@ -7,3 +7,11 @@ Requires the local development stack to be running when linting against the loca Runs `plpgsql_check` extension in the local Postgres container to check for errors in all schemas. The default lint level is `warning` and can be raised to error via the `--level` flag. To lint against specific schemas only, pass in the `--schema` flag. + +The `--fail-on` flag can be used to control when the command should exit with a non-zero status code. The possible values are: + +- `none` (default): Always exit with a zero status code, regardless of lint results. +- `warning`: Exit with a non-zero status code if any warnings or errors are found. +- `error`: Exit with a non-zero status code only if errors are found. + +This flag is particularly useful in CI/CD pipelines where you want to fail the build based on certain lint conditions. \ No newline at end of file diff --git a/internal/db/lint/lint.go b/internal/db/lint/lint.go index dc3026006..5701d89be 100644 --- a/internal/db/lint/lint.go +++ b/internal/db/lint/lint.go @@ -39,7 +39,7 @@ func toEnum(level string) LintLevel { return -1 } -func Run(ctx context.Context, schema []string, level string, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { +func Run(ctx context.Context, schema []string, level string, failOn string, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { // Sanity checks. conn, err := utils.ConnectByConfig(ctx, config, options...) if err != nil { @@ -55,7 +55,26 @@ func Run(ctx context.Context, schema []string, level string, config pgconn.Confi fmt.Fprintln(os.Stderr, "\nNo schema errors found") return nil } - return printResultJSON(result, toEnum(level), os.Stdout) + + // Apply filtering based on the minimum level + minLevel := toEnum(level) + filtered := filterResult(result, minLevel) + err = printResultJSON(filtered, os.Stdout) + if err != nil { + return err + } + // Check for fail-on condition + failOnLevel := toEnum(failOn) + if failOnLevel != -1 { + for _, r := range filtered { + for _, issue := range r.Issues { + if toEnum(issue.Level) >= failOnLevel { + return fmt.Errorf("fail-on is set to %s, non-zero exit", AllowedLevels[failOnLevel]) + } + } + } + } + return nil } func filterResult(result []Result, minLevel LintLevel) (filtered []Result) { @@ -73,15 +92,14 @@ func filterResult(result []Result, minLevel LintLevel) (filtered []Result) { return filtered } -func printResultJSON(result []Result, minLevel LintLevel, stdout io.Writer) error { - filtered := filterResult(result, minLevel) - if len(filtered) == 0 { +func printResultJSON(result []Result, stdout io.Writer) error { + if len(result) == 0 { return nil } // Pretty print output enc := json.NewEncoder(stdout) enc.SetIndent("", " ") - if err := enc.Encode(filtered); err != nil { + if err := enc.Encode(result); err != nil { return errors.Errorf("failed to print result json: %w", err) } return nil diff --git a/internal/db/lint/lint_test.go b/internal/db/lint/lint_test.go index 40ce05033..8d7abef8f 100644 --- a/internal/db/lint/lint_test.go +++ b/internal/db/lint/lint_test.go @@ -65,7 +65,7 @@ func TestLintCommand(t *testing.T) { Reply("SELECT 1", []interface{}{"f1", string(data)}). Query("rollback").Reply("ROLLBACK") // Run test - err = Run(context.Background(), []string{"public"}, "warning", dbConfig, fsys, conn.Intercept) + err = Run(context.Background(), []string{"public"}, "warning", "none", dbConfig, fsys, conn.Intercept) // Check error assert.NoError(t, err) assert.Empty(t, apitest.ListUnmatchedRequests()) @@ -221,7 +221,8 @@ func TestPrintResult(t *testing.T) { t.Run("filters warning level", func(t *testing.T) { // Run test var out bytes.Buffer - assert.NoError(t, printResultJSON(result, toEnum("warning"), &out)) + filtered := filterResult(result, toEnum("warning")) + assert.NoError(t, printResultJSON(filtered, &out)) // Validate output var actual []Result assert.NoError(t, json.Unmarshal(out.Bytes(), &actual)) @@ -231,7 +232,8 @@ func TestPrintResult(t *testing.T) { t.Run("filters error level", func(t *testing.T) { // Run test var out bytes.Buffer - assert.NoError(t, printResultJSON(result, toEnum("error"), &out)) + filtered := filterResult(result, toEnum("error")) + assert.NoError(t, printResultJSON(filtered, &out)) // Validate output var actual []Result assert.NoError(t, json.Unmarshal(out.Bytes(), &actual)) @@ -240,4 +242,58 @@ func TestPrintResult(t *testing.T) { Issues: []Issue{result[0].Issues[1]}, }}, actual) }) + + t.Run("exits with non-zero status on warning", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewMemMapFs() + // Setup mock postgres + conn := pgtest.NewConn() + defer conn.Close(t) + conn.Query("begin").Reply("BEGIN"). + Query(ENABLE_PGSQL_CHECK). + Reply("CREATE EXTENSION"). + Query(checkSchemaScript, "public"). + Reply("SELECT 1", []interface{}{"f1", `{"function":"22751","issues":[{"level":"warning","message":"test warning"}]}`}). + Query("rollback").Reply("ROLLBACK") + // Run test + err := Run(context.Background(), []string{"public"}, "warning", "warning", dbConfig, fsys, conn.Intercept) + // Check error + assert.ErrorContains(t, err, "fail-on is set to warning, non-zero exit") + }) + + t.Run("exits with non-zero status on error", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewMemMapFs() + // Setup mock postgres + conn := pgtest.NewConn() + defer conn.Close(t) + conn.Query("begin").Reply("BEGIN"). + Query(ENABLE_PGSQL_CHECK). + Reply("CREATE EXTENSION"). + Query(checkSchemaScript, "public"). + Reply("SELECT 1", []interface{}{"f1", `{"function":"22751","issues":[{"level":"error","message":"test error"}]}`}). + Query("rollback").Reply("ROLLBACK") + // Run test + err := Run(context.Background(), []string{"public"}, "warning", "error", dbConfig, fsys, conn.Intercept) + // Check error + assert.ErrorContains(t, err, "fail-on is set to error, non-zero exit") + }) + + t.Run("does not exit with non-zero status when fail-on is none", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewMemMapFs() + // Setup mock postgres + conn := pgtest.NewConn() + defer conn.Close(t) + conn.Query("begin").Reply("BEGIN"). + Query(ENABLE_PGSQL_CHECK). + Reply("CREATE EXTENSION"). + Query(checkSchemaScript, "public"). + Reply("SELECT 1", []interface{}{"f1", `{"function":"22751","issues":[{"level":"error","message":"test error"}]}`}). + Query("rollback").Reply("ROLLBACK") + // Run test + err := Run(context.Background(), []string{"public"}, "warning", "none", dbConfig, fsys, conn.Intercept) + // Check error + assert.NoError(t, err) + }) } From 90220bbdbc57e12a27a0bbe051f8f84cde5e64c9 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Wed, 11 Sep 2024 13:38:44 +0800 Subject: [PATCH 005/305] feat: support delete all credentials from keyring --- go.mod | 2 +- internal/utils/credentials/keyring_darwin.go | 34 +++++++++++++++++++ internal/utils/credentials/keyring_linux.go | 33 ++++++++++++++++++ internal/utils/credentials/keyring_test.go | 28 +++++++++++++++ internal/utils/credentials/keyring_windows.go | 25 ++++++++++++++ internal/utils/credentials/store.go | 5 +++ 6 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 internal/utils/credentials/keyring_darwin.go create mode 100644 internal/utils/credentials/keyring_linux.go create mode 100644 internal/utils/credentials/keyring_test.go create mode 100644 internal/utils/credentials/keyring_windows.go diff --git a/go.mod b/go.mod index fe4ede743..09427deeb 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/charmbracelet/glamour v0.7.0 github.com/charmbracelet/lipgloss v0.12.1 github.com/containers/common v0.59.2 + github.com/danieljoos/wincred v1.2.1 github.com/deepmap/oapi-codegen/v2 v2.2.0 github.com/docker/cli v26.1.5+incompatible github.com/docker/docker v26.1.5+incompatible @@ -114,7 +115,6 @@ require ( github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/cyphar/filepath-securejoin v0.2.5 // indirect github.com/daixiang0/gci v0.13.4 // indirect - github.com/danieljoos/wincred v1.2.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/denis-tingaikin/go-header v0.5.0 // indirect github.com/distribution/reference v0.6.0 // indirect diff --git a/internal/utils/credentials/keyring_darwin.go b/internal/utils/credentials/keyring_darwin.go new file mode 100644 index 000000000..cca5d72fa --- /dev/null +++ b/internal/utils/credentials/keyring_darwin.go @@ -0,0 +1,34 @@ +//go:build darwin + +package credentials + +import ( + "os/exec" + + "github.com/go-errors/errors" +) + +const execPathKeychain = "/usr/bin/security" + +func deleteAll(service string) error { + if len(service) == 0 { + return errors.New("missing service name") + } + // Delete each secret in a while loop until there is no more left + for { + if err := exec.Command( + execPathKeychain, + "delete-generic-password", + "-s", service, + ).Run(); err == nil { + continue + } else if errors.Is(err, exec.ErrNotFound) { + return errors.New(ErrNotSupported) + } else if exitError, ok := err.(*exec.ExitError); ok && exitError.ExitCode() == 44 { + // Exit 44 means no item exists for this service name + return nil + } else { + return errors.Errorf("failed to delete all credentials: %w", err) + } + } +} diff --git a/internal/utils/credentials/keyring_linux.go b/internal/utils/credentials/keyring_linux.go new file mode 100644 index 000000000..08095cfb7 --- /dev/null +++ b/internal/utils/credentials/keyring_linux.go @@ -0,0 +1,33 @@ +//go:build linux + +package credentials + +import ( + "github.com/go-errors/errors" + ss "github.com/zalando/go-keyring/secret_service" +) + +func deleteAll(service string) error { + svc, err := ss.NewSecretService() + if err != nil { + return errors.Errorf("failed to create secret service: %w", err) + } + + collection := svc.GetLoginCollection() + if err := svc.Unlock(collection.Path()); err != nil { + return errors.Errorf("failed to unlock collection: %w", err) + } + + search := map[string]string{"service": service} + results, err := svc.SearchItems(collection, search) + if err != nil { + return errors.Errorf("failed to search items: %w", err) + } + + for _, item := range results { + if err := svc.Delete(item); err != nil { + return errors.Errorf("failed to delete all credentials: %w", err) + } + } + return nil +} diff --git a/internal/utils/credentials/keyring_test.go b/internal/utils/credentials/keyring_test.go new file mode 100644 index 000000000..0569276aa --- /dev/null +++ b/internal/utils/credentials/keyring_test.go @@ -0,0 +1,28 @@ +package credentials + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/zalando/go-keyring" +) + +func TestDeleteAll(t *testing.T) { + service := "test-cli" + // Nothing to delete + err := deleteAll(service) + assert.NoError(t, err) + // Setup 2 items + err = keyring.Set(service, "key1", "value") + assert.NoError(t, err) + err = keyring.Set(service, "key2", "value") + assert.NoError(t, err) + // Delete all items + err = deleteAll(service) + assert.NoError(t, err) + // Check items are gone + _, err = keyring.Get(service, "key1") + assert.ErrorIs(t, err, keyring.ErrNotFound) + _, err = keyring.Get(service, "key2") + assert.ErrorIs(t, err, keyring.ErrNotFound) +} diff --git a/internal/utils/credentials/keyring_windows.go b/internal/utils/credentials/keyring_windows.go new file mode 100644 index 000000000..0366a686d --- /dev/null +++ b/internal/utils/credentials/keyring_windows.go @@ -0,0 +1,25 @@ +//go:build windows + +package credentials + +import ( + "github.com/danieljoos/wincred" + "github.com/go-errors/errors" +) + +func deleteAll(service string) error { + if err := assertKeyringSupported(); err != nil { + return err + } + creds, err := wincred.FilteredList(service + ":") + if err != nil { + return errors.Errorf("failed to list credentials: %w", err) + } + for _, c := range creds { + gc := wincred.GenericCredential{Credential: *c} + if err := gc.Delete(); err != nil { + return errors.Errorf("failed to delete all credentials: %w", err) + } + } + return nil +} diff --git a/internal/utils/credentials/store.go b/internal/utils/credentials/store.go index 32a2abd24..ac7f01866 100644 --- a/internal/utils/credentials/store.go +++ b/internal/utils/credentials/store.go @@ -53,6 +53,11 @@ func Delete(project string) error { return nil } +// Deletes all stored credentials for the namespace +func DeleteAll() error { + return deleteAll(namespace) +} + func assertKeyringSupported() error { // Suggested check: https://github.com/microsoft/WSL/issues/423 if f, err := os.ReadFile("/proc/sys/kernel/osrelease"); err == nil { From 6003aae1c7d336ef264017d928d9db62884b8aa1 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Wed, 11 Sep 2024 15:03:50 +0800 Subject: [PATCH 006/305] chore: add linux tests dependency --- .github/workflows/ci.yml | 2 ++ test/login_test.go | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b107b1cf4..0f4078158 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,8 @@ jobs: go-version-file: go.mod cache: true + # Required by: internal/utils/credentials/keyring_test.go + - uses: t1m0thyj/unlock-keyring@v1 - run: | go run gotest.tools/gotestsum -- ./... -race -v -count=1 \ -coverpkg ./cmd/...,./internal/... -coverprofile=coverage.out diff --git a/test/login_test.go b/test/login_test.go index 81f9cb895..2f1e018fb 100644 --- a/test/login_test.go +++ b/test/login_test.go @@ -5,7 +5,6 @@ import ( "context" "net/http" "os" - "path/filepath" "sync" "testing" @@ -57,13 +56,13 @@ func (suite *LoginTestSuite) TestLink() { require.NoError(suite.T(), login.RunE(login, []string{})) // check token is saved - home, err := os.UserHomeDir() - require.NoError(suite.T(), err) - _, err = os.Stat(filepath.Join(home, ".supabase/access-token")) - require.NoError(suite.T(), err) - token, err := os.ReadFile(filepath.Join(home, ".supabase/access-token")) - require.NoError(suite.T(), err) - require.Equal(suite.T(), key, string(token)) + // home, err := os.UserHomeDir() + // require.NoError(suite.T(), err) + // _, err = os.Stat(filepath.Join(home, ".supabase/access-token")) + // require.NoError(suite.T(), err) + // token, err := os.ReadFile(filepath.Join(home, ".supabase/access-token")) + // require.NoError(suite.T(), err) + // require.Equal(suite.T(), key, string(token)) } // hooks From e60bc21e7f7a55d24885a4f9d8611b464c0f4c78 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Wed, 11 Sep 2024 16:49:04 +0200 Subject: [PATCH 007/305] feat: db reset skip seed flag (#2665) * wip * feat: db reset --skip-seed flag Add a flag option to the command Closes #2534 * chore: apply suggestions from code review Co-authored-by: Han Qiao * feat: add db.seed enabled config params * chore: remove unused type * Update db.go * Apply suggestions from code review --------- Co-authored-by: Han Qiao --- cmd/db.go | 6 ++++++ internal/db/reset/reset_test.go | 27 ++++++++++++++++++++++++++ internal/migration/apply/apply.go | 3 +++ internal/migration/apply/apply_test.go | 24 +++++++++++++++++++++++ pkg/config/config.go | 8 ++++++++ 5 files changed, 68 insertions(+) diff --git a/cmd/db.go b/cmd/db.go index 30935d284..2ddb4072f 100644 --- a/cmd/db.go +++ b/cmd/db.go @@ -183,10 +183,15 @@ var ( }, } + noSeed bool + dbResetCmd = &cobra.Command{ Use: "reset", Short: "Resets the local database to current migrations", RunE: func(cmd *cobra.Command, args []string) error { + if noSeed { + utils.Config.Db.Seed.Enabled = false + } return reset.Run(cmd.Context(), migrationVersion, flags.DbConfig, afero.NewOsFs()) }, } @@ -304,6 +309,7 @@ func init() { resetFlags.String("db-url", "", "Resets the database specified by the connection string (must be percent-encoded).") resetFlags.Bool("linked", false, "Resets the linked project with local migrations.") resetFlags.Bool("local", true, "Resets the local database with local migrations.") + resetFlags.BoolVar(&noSeed, "no-seed", false, "Skip running the seed script after reset.") dbResetCmd.MarkFlagsMutuallyExclusive("db-url", "linked", "local") resetFlags.StringVar(&migrationVersion, "version", "", "Reset up to the specified version.") dbCmd.AddCommand(dbResetCmd) diff --git a/internal/db/reset/reset_test.go b/internal/db/reset/reset_test.go index 38fef4b96..03da968c5 100644 --- a/internal/db/reset/reset_test.go +++ b/internal/db/reset/reset_test.go @@ -357,6 +357,33 @@ func TestResetRemote(t *testing.T) { assert.NoError(t, err) }) + t.Run("resets remote database with seed config disabled", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewMemMapFs() + path := filepath.Join(utils.MigrationsDir, "0_schema.sql") + require.NoError(t, afero.WriteFile(fsys, path, nil, 0644)) + seedPath := filepath.Join(utils.SeedDataPath) + // Will raise an error when seeding + require.NoError(t, afero.WriteFile(fsys, seedPath, []byte("INSERT INTO test_table;"), 0644)) + // Setup mock postgres + conn := pgtest.NewConn() + defer conn.Close(t) + conn.Query(migration.ListSchemas, escapedSchemas). + Reply("SELECT 1", []interface{}{"private"}). + Query("DROP SCHEMA IF EXISTS private CASCADE"). + Reply("DROP SCHEMA"). + Query(migration.DropObjects). + Reply("INSERT 0") + helper.MockMigrationHistory(conn). + Query(migration.INSERT_MIGRATION_VERSION, "0", "schema", nil). + Reply("INSERT 0 1") + utils.Config.Db.Seed.Enabled = false + // Run test + err := resetRemote(context.Background(), "", dbConfig, fsys, conn.Intercept) + // No error should be raised since we're skipping the seed + assert.NoError(t, err) + }) + t.Run("throws error on connect failure", func(t *testing.T) { // Setup in-memory fs fsys := afero.NewMemMapFs() diff --git a/internal/migration/apply/apply.go b/internal/migration/apply/apply.go index c9df3cacd..44195297f 100644 --- a/internal/migration/apply/apply.go +++ b/internal/migration/apply/apply.go @@ -20,6 +20,9 @@ func MigrateAndSeed(ctx context.Context, version string, conn *pgx.Conn, fsys af if err := migration.ApplyMigrations(ctx, migrations, conn, afero.NewIOFS(fsys)); err != nil { return err } + if !utils.Config.Db.Seed.Enabled { + return nil + } return SeedDatabase(ctx, conn, fsys) } diff --git a/internal/migration/apply/apply_test.go b/internal/migration/apply/apply_test.go index 7150f6263..b8c041749 100644 --- a/internal/migration/apply/apply_test.go +++ b/internal/migration/apply/apply_test.go @@ -38,6 +38,30 @@ func TestMigrateDatabase(t *testing.T) { assert.NoError(t, err) }) + t.Run("skip seeding when seed config is disabled", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewMemMapFs() + path := filepath.Join(utils.MigrationsDir, "0_test.sql") + sql := "create schema public" + require.NoError(t, afero.WriteFile(fsys, path, []byte(sql), 0644)) + seedPath := filepath.Join(utils.SeedDataPath) + // This will raise an error when seeding + require.NoError(t, afero.WriteFile(fsys, seedPath, []byte("INSERT INTO test_table;"), 0644)) + // Setup mock postgres + conn := pgtest.NewConn() + defer conn.Close(t) + helper.MockMigrationHistory(conn). + Query(sql). + Reply("CREATE SCHEMA"). + Query(migration.INSERT_MIGRATION_VERSION, "0", "test", []string{sql}). + Reply("INSERT 0 1") + utils.Config.Db.Seed.Enabled = false + // Run test + err := MigrateAndSeed(context.Background(), "", conn.MockClient(t), fsys) + // No error should be returned since seeding is skipped + assert.NoError(t, err) + }) + t.Run("ignores empty local directory", func(t *testing.T) { assert.NoError(t, MigrateAndSeed(context.Background(), "", nil, afero.NewMemMapFs())) }) diff --git a/pkg/config/config.go b/pkg/config/config.go index 4340b48f8..a116b3ad7 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -160,6 +160,11 @@ type ( Password string `toml:"-"` RootKey string `toml:"-" mapstructure:"root_key"` Pooler pooler `toml:"pooler"` + Seed seed `toml:"seed"` + } + + seed struct { + Enabled bool `toml:"enabled"` } pooler struct { @@ -457,6 +462,9 @@ func NewConfig(editors ...ConfigEditor) config { EncryptionKey: "12345678901234567890123456789032", SecretKeyBase: "EAx3IQ/wRG1v47ZD4NE4/9RzBI8Jmil3x0yhcW4V2NHBP6c2iPIzwjofi2Ep4HIG", }, + Seed: seed{ + Enabled: true, + }, }, Realtime: realtime{ Image: realtimeImage, From 3599b8e599d69a9f9e949def104da5c8d6094d88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 11 Sep 2024 23:58:28 +0800 Subject: [PATCH 008/305] chore(deps): bump github.com/docker/cli from 26.1.5+incompatible to 27.2.1+incompatible (#2667) * chore(deps): bump github.com/docker/cli Bumps [github.com/docker/cli](https://github.com/docker/cli) from 26.1.5+incompatible to 27.2.1+incompatible. - [Commits](https://github.com/docker/cli/compare/v26.1.5...v27.2.1) --- updated-dependencies: - dependency-name: github.com/docker/cli dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * chore: update docker library version --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Qiao Han --- go.mod | 4 ++-- go.sum | 8 ++++---- internal/db/branch/create/create.go | 6 +++--- internal/db/branch/delete/delete.go | 6 +++--- internal/start/start_test.go | 5 +++-- internal/stop/stop_test.go | 10 ++++++---- internal/testing/apitest/docker.go | 9 +++++---- internal/utils/docker.go | 16 ++++++---------- internal/utils/docker_test.go | 5 +++-- test/branch_test.go | 6 +++--- 10 files changed, 38 insertions(+), 37 deletions(-) diff --git a/go.mod b/go.mod index 09427deeb..20656c2f5 100644 --- a/go.mod +++ b/go.mod @@ -14,8 +14,8 @@ require ( github.com/containers/common v0.59.2 github.com/danieljoos/wincred v1.2.1 github.com/deepmap/oapi-codegen/v2 v2.2.0 - github.com/docker/cli v26.1.5+incompatible - github.com/docker/docker v26.1.5+incompatible + github.com/docker/cli v27.2.1+incompatible + github.com/docker/docker v27.2.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 github.com/getsentry/sentry-go v0.28.1 diff --git a/go.sum b/go.sum index 9dcf2a2a7..9b4c057b8 100644 --- a/go.sum +++ b/go.sum @@ -234,13 +234,13 @@ github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk= github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE= -github.com/docker/cli v26.1.5+incompatible h1:NxXGSdz2N+Ibdaw330TDO3d/6/f7MvHuiMbuFaIQDTk= -github.com/docker/cli v26.1.5+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v27.2.1+incompatible h1:U5BPtiD0viUzjGAjV1p0MGB8eVA3L3cbIrnyWmSJI70= +github.com/docker/cli v27.2.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v26.1.5+incompatible h1:NEAxTwEjxV6VbBMBoGG3zPqbiJosIApZjxlbrG9q3/g= -github.com/docker/docker v26.1.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.2.1+incompatible h1:fQdiLfW7VLscyoeYEBz7/J8soYFDZV1u6VW6gJEjNMI= +github.com/docker/docker v27.2.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.1 h1:j/eKUktUltBtMzKqmfLB0PAgqYyMHOp5vfsD1807oKo= github.com/docker/docker-credential-helpers v0.8.1/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0= diff --git a/internal/db/branch/create/create.go b/internal/db/branch/create/create.go index 98996e8c9..085e10f9d 100644 --- a/internal/db/branch/create/create.go +++ b/internal/db/branch/create/create.go @@ -9,7 +9,7 @@ import ( "os" "path/filepath" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/pkg/stdcopy" "github.com/go-errors/errors" "github.com/spf13/afero" @@ -70,7 +70,7 @@ func assertNewBranchIsValid(branchPath string, fsys afero.Fs) error { } func createBranch(ctx context.Context, branch string) error { - exec, err := utils.Docker.ContainerExecCreate(ctx, utils.DbId, types.ExecConfig{ + exec, err := utils.Docker.ContainerExecCreate(ctx, utils.DbId, container.ExecOptions{ Cmd: []string{"/bin/bash", "-c", cloneScript}, Env: []string{"DB_NAME=" + branch}, AttachStderr: true, @@ -80,7 +80,7 @@ func createBranch(ctx context.Context, branch string) error { return err } // Read exec output - resp, err := utils.Docker.ContainerExecAttach(ctx, exec.ID, types.ExecStartCheck{}) + resp, err := utils.Docker.ContainerExecAttach(ctx, exec.ID, container.ExecStartOptions{}) if err != nil { return err } diff --git a/internal/db/branch/delete/delete.go b/internal/db/branch/delete/delete.go index a3bfde6f9..f59f5e51c 100644 --- a/internal/db/branch/delete/delete.go +++ b/internal/db/branch/delete/delete.go @@ -7,7 +7,7 @@ import ( "io" "path/filepath" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/pkg/stdcopy" "github.com/go-errors/errors" "github.com/spf13/afero" @@ -58,7 +58,7 @@ func deleteBranchDir(branch string, fsys afero.Fs) error { } func deleteBranchPG(ctx context.Context, branch string) error { - exec, err := utils.Docker.ContainerExecCreate(ctx, utils.DbId, types.ExecConfig{ + exec, err := utils.Docker.ContainerExecCreate(ctx, utils.DbId, container.ExecOptions{ Cmd: []string{"dropdb", "--username", "postgres", "--host", "127.0.0.1", branch}, AttachStderr: true, AttachStdout: true, @@ -67,7 +67,7 @@ func deleteBranchPG(ctx context.Context, branch string) error { return err } // Read exec output - resp, err := utils.Docker.ContainerExecAttach(ctx, exec.ID, types.ExecStartCheck{}) + resp, err := utils.Docker.ContainerExecAttach(ctx, exec.ID, container.ExecStartOptions{}) if err != nil { return err } diff --git a/internal/start/start_test.go b/internal/start/start_test.go index 645a1cd70..654831ccb 100644 --- a/internal/start/start_test.go +++ b/internal/start/start_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/volume" "github.com/h2non/gock" "github.com/jackc/pgconn" @@ -85,7 +86,7 @@ func TestDatabaseStart(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Post("/v" + utils.Docker.ClientVersion() + "/networks/create"). Reply(http.StatusCreated). - JSON(types.NetworkCreateResponse{}) + JSON(network.CreateResponse{}) // Caches all dependencies imageUrl := utils.GetRegistryImageUrl(utils.Config.Db.Image) gock.New(utils.Docker.DaemonHost()). @@ -201,7 +202,7 @@ func TestDatabaseStart(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Post("/v" + utils.Docker.ClientVersion() + "/networks/create"). Reply(http.StatusCreated). - JSON(types.NetworkCreateResponse{}) + JSON(network.CreateResponse{}) // Caches all dependencies imageUrl := utils.GetRegistryImageUrl(utils.Config.Db.Image) gock.New(utils.Docker.DaemonHost()). diff --git a/internal/stop/stop_test.go b/internal/stop/stop_test.go index dbb8b9030..419df28bc 100644 --- a/internal/stop/stop_test.go +++ b/internal/stop/stop_test.go @@ -9,6 +9,8 @@ import ( "testing" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/volume" "github.com/h2non/gock" "github.com/spf13/afero" @@ -33,11 +35,11 @@ func TestStopCommand(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Post("/v" + utils.Docker.ClientVersion() + "/containers/prune"). Reply(http.StatusOK). - JSON(types.ContainersPruneReport{}) + JSON(container.PruneReport{}) gock.New(utils.Docker.DaemonHost()). Post("/v" + utils.Docker.ClientVersion() + "/networks/prune"). Reply(http.StatusOK). - JSON(types.NetworksPruneReport{}) + JSON(network.PruneReport{}) gock.New(utils.Docker.DaemonHost()). Get("/v" + utils.Docker.ClientVersion() + "/volumes"). Reply(http.StatusOK). @@ -94,11 +96,11 @@ func TestStopServices(t *testing.T) { gock.New(utils.Docker.DaemonHost()). Post("/v" + utils.Docker.ClientVersion() + "/containers/prune"). Reply(http.StatusOK). - JSON(types.ContainersPruneReport{}) + JSON(container.PruneReport{}) gock.New(utils.Docker.DaemonHost()). Post("/v" + utils.Docker.ClientVersion() + "/networks/prune"). Reply(http.StatusOK). - JSON(types.NetworksPruneReport{}) + JSON(network.PruneReport{}) // Run test err := stop(context.Background(), true, io.Discard) // Check error diff --git a/internal/testing/apitest/docker.go b/internal/testing/apitest/docker.go index 37f5549ee..21a4d7dd2 100644 --- a/internal/testing/apitest/docker.go +++ b/internal/testing/apitest/docker.go @@ -8,6 +8,7 @@ import ( "github.com/docker/docker/api" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/volume" "github.com/docker/docker/client" "github.com/docker/docker/pkg/stdcopy" @@ -38,7 +39,7 @@ func MockDockerStart(docker *client.Client, image, containerID string) { gock.New(docker.DaemonHost()). Post("/v" + docker.ClientVersion() + "/networks/create"). Reply(http.StatusCreated). - JSON(types.NetworkCreateResponse{}) + JSON(network.CreateResponse{}) gock.New(docker.DaemonHost()). Post("/v" + docker.ClientVersion() + "/volumes/create"). Persist(). @@ -62,15 +63,15 @@ func MockDockerStop(docker *client.Client) { gock.New(docker.DaemonHost()). Post("/v" + docker.ClientVersion() + "/containers/prune"). Reply(http.StatusOK). - JSON(types.ContainersPruneReport{}) + JSON(container.PruneReport{}) gock.New(docker.DaemonHost()). Post("/v" + docker.ClientVersion() + "/volumes/prune"). Reply(http.StatusOK). - JSON(types.VolumesPruneReport{}) + JSON(volume.PruneReport{}) gock.New(docker.DaemonHost()). Post("/v" + docker.ClientVersion() + "/networks/prune"). Reply(http.StatusOK). - JSON(types.NetworksPruneReport{}) + JSON(network.PruneReport{}) } // Ref: internal/utils/docker.go::DockerRunOnce diff --git a/internal/utils/docker.go b/internal/utils/docker.go index 8a44c75d3..678d93e98 100644 --- a/internal/utils/docker.go +++ b/internal/utils/docker.go @@ -20,7 +20,6 @@ import ( dockerConfig "github.com/docker/cli/cli/config" dockerFlags "github.com/docker/cli/cli/flags" "github.com/docker/cli/cli/streams" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/image" @@ -65,10 +64,7 @@ func DockerNetworkCreateIfNotExists(ctx context.Context, mode container.NetworkM if !isUserDefined(mode) { return nil } - _, err := Docker.NetworkCreate(ctx, mode.NetworkName(), types.NetworkCreate{ - CheckDuplicate: true, - Labels: labels, - }) + _, err := Docker.NetworkCreate(ctx, mode.NetworkName(), network.CreateOptions{Labels: labels}) // if error is network already exists, no need to propagate to user if errdefs.IsConflict(err) || errors.Is(err, podman.ErrNetworkExists) { return nil @@ -410,19 +406,19 @@ func DockerStreamLogsOnce(ctx context.Context, containerId string, stdout, stder } // Exec a command once inside a container, returning stdout and throwing error on non-zero exit code. -func DockerExecOnce(ctx context.Context, container string, env []string, cmd []string) (string, error) { +func DockerExecOnce(ctx context.Context, containerId string, env []string, cmd []string) (string, error) { stderr := io.Discard if viper.GetBool("DEBUG") { stderr = os.Stderr } var out bytes.Buffer - err := DockerExecOnceWithStream(ctx, container, "", env, cmd, &out, stderr) + err := DockerExecOnceWithStream(ctx, containerId, "", env, cmd, &out, stderr) return out.String(), err } -func DockerExecOnceWithStream(ctx context.Context, container, workdir string, env, cmd []string, stdout, stderr io.Writer) error { +func DockerExecOnceWithStream(ctx context.Context, containerId, workdir string, env, cmd []string, stdout, stderr io.Writer) error { // Reset shadow database - exec, err := Docker.ContainerExecCreate(ctx, container, types.ExecConfig{ + exec, err := Docker.ContainerExecCreate(ctx, containerId, container.ExecOptions{ Env: env, Cmd: cmd, WorkingDir: workdir, @@ -433,7 +429,7 @@ func DockerExecOnceWithStream(ctx context.Context, container, workdir string, en return errors.Errorf("failed to exec docker create: %w", err) } // Read exec output - resp, err := Docker.ContainerExecAttach(ctx, exec.ID, types.ExecStartCheck{}) + resp, err := Docker.ContainerExecAttach(ctx, exec.ID, container.ExecStartOptions{}) if err != nil { return errors.Errorf("failed to exec docker attach: %w", err) } diff --git a/internal/utils/docker_test.go b/internal/utils/docker_test.go index a3f92bd01..6a0cdf034 100644 --- a/internal/utils/docker_test.go +++ b/internal/utils/docker_test.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" + "github.com/docker/docker/api/types/network" "github.com/docker/docker/pkg/jsonmessage" "github.com/docker/docker/pkg/stdcopy" "github.com/h2non/gock" @@ -133,7 +134,7 @@ func TestRunOnce(t *testing.T) { gock.New(Docker.DaemonHost()). Post("/v" + Docker.ClientVersion() + "/networks/create"). Reply(http.StatusCreated). - JSON(types.NetworkCreateResponse{}) + JSON(network.CreateResponse{}) gock.New(Docker.DaemonHost()). Post("/v" + Docker.ClientVersion() + "/containers/create"). Reply(http.StatusServiceUnavailable) @@ -155,7 +156,7 @@ func TestRunOnce(t *testing.T) { gock.New(Docker.DaemonHost()). Post("/v" + Docker.ClientVersion() + "/networks/create"). Reply(http.StatusCreated). - JSON(types.NetworkCreateResponse{}) + JSON(network.CreateResponse{}) gock.New(Docker.DaemonHost()). Post("/v" + Docker.ClientVersion() + "/containers/create"). Reply(http.StatusOK). diff --git a/test/branch_test.go b/test/branch_test.go index a3d869024..07d3608d2 100644 --- a/test/branch_test.go +++ b/test/branch_test.go @@ -5,7 +5,7 @@ import ( "encoding/json" "os" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/stretchr/testify/require" ) @@ -31,8 +31,8 @@ func (suite *DBTestSuite) TestBranchCreate() { // check commands in exec calls require.Equal(suite.T(), 2, len(suite.bodies)) - var execBody types.ExecConfig + var execBody container.ExecOptions require.NoError(suite.T(), json.Unmarshal([]byte(suite.bodies[0]), &execBody)) - var startBody types.ExecStartCheck + var startBody container.ExecStartOptions require.NoError(suite.T(), json.Unmarshal([]byte(suite.bodies[1]), &startBody)) } From 0453ebde3196e94181040e3931461bcda1dc1759 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:46:18 +0800 Subject: [PATCH 009/305] chore(deps): bump golang.org/x/oauth2 from 0.21.0 to 0.23.0 (#2675) Bumps [golang.org/x/oauth2](https://github.com/golang/oauth2) from 0.21.0 to 0.23.0. - [Commits](https://github.com/golang/oauth2/compare/v0.21.0...v0.23.0) --- updated-dependencies: - dependency-name: golang.org/x/oauth2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 20656c2f5..3afaae639 100644 --- a/go.mod +++ b/go.mod @@ -51,7 +51,7 @@ require ( github.com/zalando/go-keyring v0.2.5 go.opentelemetry.io/otel v1.28.0 golang.org/x/mod v0.20.0 - golang.org/x/oauth2 v0.21.0 + golang.org/x/oauth2 v0.23.0 golang.org/x/term v0.22.0 google.golang.org/grpc v1.65.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 9b4c057b8..526882ddf 100644 --- a/go.sum +++ b/go.sum @@ -1203,8 +1203,8 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= -golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= From 07d3af29cb5b8b803712a2d2490f8b41ee42efa3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:48:19 +0800 Subject: [PATCH 010/305] chore(deps): bump golang.org/x/term from 0.22.0 to 0.24.0 (#2676) Bumps [golang.org/x/term](https://github.com/golang/term) from 0.22.0 to 0.24.0. - [Commits](https://github.com/golang/term/compare/v0.22.0...v0.24.0) --- updated-dependencies: - dependency-name: golang.org/x/term dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 3afaae639..7c40a01dd 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( go.opentelemetry.io/otel v1.28.0 golang.org/x/mod v0.20.0 golang.org/x/oauth2 v0.23.0 - golang.org/x/term v0.22.0 + golang.org/x/term v0.24.0 google.golang.org/grpc v1.65.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.12.0 @@ -337,7 +337,7 @@ require ( golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect golang.org/x/net v0.26.0 // indirect golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect + golang.org/x/sys v0.25.0 // indirect golang.org/x/text v0.16.0 // indirect golang.org/x/tools v0.22.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect diff --git a/go.sum b/go.sum index 526882ddf..24cc549d9 100644 --- a/go.sum +++ b/go.sum @@ -1291,8 +1291,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= -golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1307,8 +1307,8 @@ golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= +golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From cae1ba1c143ee02f7a5911da7085ab2c61ec222b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:57:31 +0800 Subject: [PATCH 011/305] chore(deps): bump github.com/containers/common from 0.59.2 to 0.60.2 (#2624) Bumps [github.com/containers/common](https://github.com/containers/common) from 0.59.2 to 0.60.2. - [Release notes](https://github.com/containers/common/releases) - [Commits](https://github.com/containers/common/compare/v0.59.2...v0.60.2) --- updated-dependencies: - dependency-name: github.com/containers/common dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 22 +++++++++++----------- go.sum | 56 ++++++++++++++++++++++++++++---------------------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/go.mod b/go.mod index 7c40a01dd..9ba9b1c33 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/charmbracelet/bubbletea v0.25.0 github.com/charmbracelet/glamour v0.7.0 github.com/charmbracelet/lipgloss v0.12.1 - github.com/containers/common v0.59.2 + github.com/containers/common v0.60.2 github.com/danieljoos/wincred v1.2.1 github.com/deepmap/oapi-codegen/v2 v2.2.0 github.com/docker/cli v27.2.1+incompatible @@ -111,9 +111,9 @@ require ( github.com/cloudwego/iasm v0.2.0 // indirect github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect github.com/containerd/log v0.1.0 // indirect - github.com/containers/storage v1.54.0 // indirect + github.com/containers/storage v1.55.0 // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect - github.com/cyphar/filepath-securejoin v0.2.5 // indirect + github.com/cyphar/filepath-securejoin v0.3.1 // indirect github.com/daixiang0/gci v0.13.4 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/denis-tingaikin/go-header v0.5.0 // indirect @@ -121,7 +121,7 @@ require ( github.com/dlclark/regexp2 v1.4.0 // indirect github.com/dnephin/pflag v1.0.7 // indirect github.com/docker/distribution v2.8.3+incompatible // indirect - github.com/docker/docker-credential-helpers v0.8.1 // indirect + github.com/docker/docker-credential-helpers v0.8.2 // indirect github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect github.com/docker/go-metrics v0.0.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect @@ -225,7 +225,7 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-localereader v0.0.1 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mgechev/revive v1.3.7 // indirect github.com/microcosm-cc/bluemonday v1.0.25 // indirect @@ -332,14 +332,14 @@ require ( go.uber.org/multierr v1.9.0 // indirect go.uber.org/zap v1.24.0 // indirect golang.org/x/arch v0.8.0 // indirect - golang.org/x/crypto v0.24.0 // indirect - golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect + golang.org/x/crypto v0.26.0 // indirect + golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect - golang.org/x/net v0.26.0 // indirect - golang.org/x/sync v0.7.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.25.0 // indirect - golang.org/x/text v0.16.0 // indirect - golang.org/x/tools v0.22.0 // indirect + golang.org/x/text v0.17.0 // indirect + golang.org/x/tools v0.24.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect google.golang.org/protobuf v1.34.2 // indirect diff --git a/go.sum b/go.sum index 24cc549d9..98f9a1b3f 100644 --- a/go.sum +++ b/go.sum @@ -200,10 +200,10 @@ github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2 github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= -github.com/containers/common v0.59.2 h1:FcURZzlMYMVZXqjMEop6C0A3yWilrfmWUPUw09APHvI= -github.com/containers/common v0.59.2/go.mod h1:/PHpbapKSHQU29Jmjn3Ld3jekoHvX0zx7qQxxyPqSTM= -github.com/containers/storage v1.54.0 h1:xwYAlf6n9OnIlURQLLg3FYHbO74fQ/2W2N6EtQEUM4I= -github.com/containers/storage v1.54.0/go.mod h1:PlMOoinRrBSnhYODLxt4EXl0nmJt+X0kjG0Xdt9fMTw= +github.com/containers/common v0.60.2 h1:utcwp2YkO8c0mNlwRxsxfOiqfj157FRrBjxgjR6f+7o= +github.com/containers/common v0.60.2/go.mod h1:I0upBi1qJX3QmzGbUOBN1LVP6RvkKhd3qQpZbQT+Q54= +github.com/containers/storage v1.55.0 h1:wTWZ3YpcQf1F+dSP4KxG9iqDfpQY1otaUXjPpffuhgg= +github.com/containers/storage v1.55.0/go.mod h1:28cB81IDk+y7ok60Of6u52RbCeBRucbFOeLunhER1RQ= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -213,8 +213,8 @@ github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/curioswitch/go-reassign v0.2.0 h1:G9UZyOcpk/d7Gd6mqYgd8XYWFMw/znxwGDUstnC9DIo= github.com/curioswitch/go-reassign v0.2.0/go.mod h1:x6OpXuWvgfQaMGks2BZybTngWjT84hqJfKoO8Tt/Roc= -github.com/cyphar/filepath-securejoin v0.2.5 h1:6iR5tXJ/e6tJZzzdMc1km3Sa7RRIVBKAK32O2s7AYfo= -github.com/cyphar/filepath-securejoin v0.2.5/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= +github.com/cyphar/filepath-securejoin v0.3.1 h1:1V7cHiaW+C+39wEfpH6XlLBQo3j/PciWFrgfCLS8XrE= +github.com/cyphar/filepath-securejoin v0.3.1/go.mod h1:F7i41x/9cBF7lzCrVsYs9fuzwRZm4NQsGTBdpp6mETc= github.com/daixiang0/gci v0.13.4 h1:61UGkmpoAcxHM2hhNkZEf5SzwQtWJXTSws7jaPyqwlw= github.com/daixiang0/gci v0.13.4/go.mod h1:12etP2OniiIdP4q+kjUGrC/rUagga7ODbqsom5Eo5Yk= github.com/danieljoos/wincred v1.2.1 h1:dl9cBrupW8+r5250DYkYxocLeZ1Y4vB1kxgtjxw8GQs= @@ -241,8 +241,8 @@ github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBi github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v27.2.1+incompatible h1:fQdiLfW7VLscyoeYEBz7/J8soYFDZV1u6VW6gJEjNMI= github.com/docker/docker v27.2.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/docker-credential-helpers v0.8.1 h1:j/eKUktUltBtMzKqmfLB0PAgqYyMHOp5vfsD1807oKo= -github.com/docker/docker-credential-helpers v0.8.1/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= +github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo= +github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c/go.mod h1:CADgU4DSXK5QUlFslkQu2yW2TKzFZcXq/leZfM0UH5Q= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= @@ -468,8 +468,8 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6 h1:k7nVchz72niMH6YLQNvHSdIE7iqsQxK1P41mySCvssg= -github.com/google/pprof v0.0.0-20240424215950-a892ee059fd6/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= +github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k= +github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= @@ -697,8 +697,8 @@ github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2J github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.6.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -763,12 +763,12 @@ github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU= github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= -github.com/onsi/ginkgo/v2 v2.18.0 h1:W9Y7IWXxPUpAit9ieMOLI7PJZGaW22DTKgiVAuhDTLc= -github.com/onsi/ginkgo/v2 v2.18.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To= +github.com/onsi/ginkgo/v2 v2.20.0 h1:PE84V2mHqoT1sglvHc8ZdQtPcwmvvt29WLEEO3xmdZw= +github.com/onsi/ginkgo/v2 v2.20.0/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= -github.com/onsi/gomega v1.33.1 h1:dsYjIxxSR755MDmKVsaFQTE22ChNBcuuTWgkUDSubOk= -github.com/onsi/gomega v1.33.1/go.mod h1:U4R44UsT+9eLIaYRB2a5qajjtQYn0hauxvRm16AVYg0= +github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= +github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= @@ -1096,8 +1096,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI= -golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1108,8 +1108,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM= -golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f h1:phY1HzDcf18Aq9A8KkmRtY9WvOFIxN8wgfvy6Zm1DV8= @@ -1195,8 +1195,8 @@ golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ= -golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1220,8 +1220,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1325,8 +1325,8 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1403,8 +1403,8 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= -golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= -golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= +golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= +golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 8093b105f190c0bfc2fffa6deb5ad25b2ff39a6e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 05:02:05 +0000 Subject: [PATCH 012/305] chore(deps): bump go.opentelemetry.io/otel from 1.28.0 to 1.30.0 (#2678) Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.28.0 to 1.30.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.28.0...v1.30.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/otel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 9ba9b1c33..f14d05da1 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( github.com/stripe/pg-schema-diff v0.7.0 github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 github.com/zalando/go-keyring v0.2.5 - go.opentelemetry.io/otel v1.28.0 + go.opentelemetry.io/otel v1.30.0 golang.org/x/mod v0.20.0 golang.org/x/oauth2 v0.23.0 golang.org/x/term v0.24.0 @@ -322,10 +322,10 @@ require ( go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect - go.opentelemetry.io/otel/metric v1.28.0 // indirect + go.opentelemetry.io/otel/metric v1.30.0 // indirect go.opentelemetry.io/otel/sdk v1.28.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect - go.opentelemetry.io/otel/trace v1.28.0 // indirect + go.opentelemetry.io/otel/trace v1.30.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/automaxprocs v1.5.3 // indirect diff --git a/go.sum b/go.sum index 98f9a1b3f..67018d330 100644 --- a/go.sum +++ b/go.sum @@ -1028,8 +1028,8 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= -go.opentelemetry.io/otel v1.28.0 h1:/SqNcYk+idO0CxKEUOtKQClMK/MimZihKYMruSMViUo= -go.opentelemetry.io/otel v1.28.0/go.mod h1:q68ijF8Fc8CnMHKyzqL6akLO46ePnjkgfIMIjUIX9z4= +go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= +go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 h1:U2guen0GhqH8o/G2un8f/aG/y++OuW6MyCo6hT9prXk= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0/go.mod h1:yeGZANgEcpdx/WK0IvvRFC+2oLiMS2u4L/0Rj2M2Qr0= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY= @@ -1038,14 +1038,14 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 h1:R3X6Z go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0/go.mod h1:QWFXnDavXWwMx2EEcZsf3yxgEKAqsxQ+Syjp+seyInw= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 h1:j9+03ymgYhPKmeXGk5Zu+cIZOlVzd9Zv7QIiyItjFBU= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0/go.mod h1:Y5+XiUG4Emn1hTfciPzGPJaSI+RpDts6BnCIir0SLqk= -go.opentelemetry.io/otel/metric v1.28.0 h1:f0HGvSl1KRAU1DLgLGFjrwVyismPlnuU6JD6bOeuA5Q= -go.opentelemetry.io/otel/metric v1.28.0/go.mod h1:Fb1eVBFZmLVTMb6PPohq3TO9IIhUisDsbJoL/+uQW4s= +go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= +go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= -go.opentelemetry.io/otel/trace v1.28.0 h1:GhQ9cUuQGmNDd5BTCP2dAvv75RdMxEfTmYejp+lkx9g= -go.opentelemetry.io/otel/trace v1.28.0/go.mod h1:jPyXzNPg6da9+38HEwElrQiHlVMTnVfM3/yv2OlIHaI= +go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= +go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= From d5482e0240d2cada58a969ba0fefd493b743edef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 05:06:38 +0000 Subject: [PATCH 013/305] chore(deps): bump google.golang.org/grpc from 1.65.0 to 1.66.2 (#2680) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.65.0 to 1.66.2. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.65.0...v1.66.2) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f14d05da1..92fa58da1 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,7 @@ require ( golang.org/x/mod v0.20.0 golang.org/x/oauth2 v0.23.0 golang.org/x/term v0.24.0 - google.golang.org/grpc v1.65.0 + google.golang.org/grpc v1.66.2 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.12.0 ) diff --git a/go.sum b/go.sum index 67018d330..c68d19b6f 100644 --- a/go.sum +++ b/go.sum @@ -1479,8 +1479,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= -google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= +google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= +google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From e55fef95db26bfa87faece6c8752dda7486222f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:18:51 +0800 Subject: [PATCH 014/305] chore(deps): bump github.com/slack-go/slack from 0.13.1 to 0.14.0 (#2679) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 92fa58da1..2b03c580c 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 github.com/muesli/reflow v0.3.0 github.com/oapi-codegen/runtime v1.1.1 - github.com/slack-go/slack v0.13.1 + github.com/slack-go/slack v0.14.0 github.com/spf13/afero v1.11.0 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index c68d19b6f..b7b4497ee 100644 --- a/go.sum +++ b/go.sum @@ -900,8 +900,8 @@ github.com/sivchari/tenv v1.7.1 h1:PSpuD4bu6fSmtWMxSGWcvqUUgIn7k3yOJhOIzVWn8Ak= github.com/sivchari/tenv v1.7.1/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg= github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= -github.com/slack-go/slack v0.13.1 h1:6UkM3U1OnbhPsYeb1IMkQ6HSNOSikWluwOncJt4Tz/o= -github.com/slack-go/slack v0.13.1/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= +github.com/slack-go/slack v0.14.0 h1:6c0UTfbRnvRssZUsZ2qe0Iu07VAMPjRqOa6oX8ewF4k= +github.com/slack-go/slack v0.14.0/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= github.com/sonatard/noctx v0.0.2 h1:L7Dz4De2zDQhW8S0t+KUjY0MAQJd6SgVwhzNIc4ok00= github.com/sonatard/noctx v0.0.2/go.mod h1:kzFz+CzWSjQ2OzIm46uJZoXuBpa2+0y3T36U18dWqIo= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= From 54fa89850b9be9a25a38889460b5948294ade13d Mon Sep 17 00:00:00 2001 From: Gildas Garcia <1122076+djhi@users.noreply.github.com> Date: Fri, 13 Sep 2024 07:19:06 +0200 Subject: [PATCH 015/305] feat: add support for multiple output formats (#2674) --- cmd/root.go | 1 + cmd/sso.go | 17 +++---- cmd/status.go | 1 + internal/projects/apiKeys/api_keys.go | 13 +++-- internal/projects/create/create.go | 8 ++- internal/projects/list/list.go | 70 ++++++++++++++++++--------- internal/utils/output.go | 5 ++ 7 files changed, 76 insertions(+), 39 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index de3b9375d..f7caa54fd 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -243,6 +243,7 @@ func init() { flags.String("workdir", "", "path to a Supabase project directory") flags.Bool("experimental", false, "enable experimental features") flags.String("network-id", "", "use the specified docker network instead of a generated one") + flags.Var(&utils.OutputFormat, "output", "output format of status variables") flags.Var(&utils.DNSResolver, "dns-resolver", "lookup domain names using the specified resolver") flags.BoolVar(&createTicket, "create-ticket", false, "create a support ticket for any CLI error") cobra.CheckErr(viper.BindPFlags(flags)) diff --git a/cmd/sso.go b/cmd/sso.go index 766c749fe..a9b4db7d3 100644 --- a/cmd/sso.go +++ b/cmd/sso.go @@ -33,10 +33,6 @@ var ( ssoDomains []string ssoAddDomains []string ssoRemoveDomains []string - ssoOutput = utils.EnumFlag{ - Allowed: utils.OutputDefaultAllowed, - Value: utils.OutputPretty, - } ssoAddCmd = &cobra.Command{ Use: "add", @@ -47,7 +43,7 @@ var ( return create.Run(cmd.Context(), create.RunParams{ ProjectRef: flags.ProjectRef, Type: ssoProviderType.String(), - Format: ssoOutput.Value, + Format: utils.OutputFormat.Value, MetadataFile: ssoMetadataFile, MetadataURL: ssoMetadataURL, SkipURLValidation: ssoSkipURLValidation, @@ -68,7 +64,7 @@ var ( return errors.Errorf("identity provider ID %q is not a UUID", args[0]) } - return remove.Run(cmd.Context(), flags.ProjectRef, args[0], ssoOutput.Value) + return remove.Run(cmd.Context(), flags.ProjectRef, args[0], utils.OutputFormat.Value) }, } @@ -86,7 +82,7 @@ var ( return update.Run(cmd.Context(), update.RunParams{ ProjectRef: flags.ProjectRef, ProviderID: args[0], - Format: ssoOutput.Value, + Format: utils.OutputFormat.Value, MetadataFile: ssoMetadataFile, MetadataURL: ssoMetadataURL, @@ -110,7 +106,7 @@ var ( return errors.Errorf("identity provider ID %q is not a UUID", args[0]) } - format := ssoOutput.Value + format := utils.OutputFormat.Value if ssoMetadata { format = utils.OutputMetadata } @@ -125,7 +121,7 @@ var ( Long: "List all connections to a SSO identity provider to your Supabase project.", Example: ` supabase sso list --project-ref mwjylndxudmiehsxhmmz`, RunE: func(cmd *cobra.Command, args []string) error { - return list.Run(cmd.Context(), flags.ProjectRef, ssoOutput.Value) + return list.Run(cmd.Context(), flags.ProjectRef, utils.OutputFormat.Value) }, } @@ -135,7 +131,7 @@ var ( Long: "Returns all of the important SSO information necessary for your project to be registered with a SAML 2.0 compatible identity provider.", Example: ` supabase sso info --project-ref mwjylndxudmiehsxhmmz`, RunE: func(cmd *cobra.Command, args []string) error { - return info.Run(cmd.Context(), flags.ProjectRef, ssoOutput.Value) + return info.Run(cmd.Context(), flags.ProjectRef, utils.OutputFormat.Value) }, } ) @@ -143,7 +139,6 @@ var ( func init() { persistentFlags := ssoCmd.PersistentFlags() persistentFlags.StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.") - persistentFlags.VarP(&ssoOutput, "output", "o", "Output format") ssoAddFlags := ssoAddCmd.Flags() ssoAddFlags.VarP(&ssoProviderType, "type", "t", "Type of identity provider (according to supported protocol).") ssoAddFlags.StringSliceVar(&ssoDomains, "domains", nil, "Comma separated list of email domains to associate with the added identity provider.") diff --git a/cmd/status.go b/cmd/status.go index 5f131c90d..13540bfb1 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -18,6 +18,7 @@ var ( Allowed: append([]string{utils.OutputEnv}, utils.OutputDefaultAllowed...), Value: utils.OutputPretty, } + statusCmd = &cobra.Command{ GroupID: groupLocalDev, Use: "status", diff --git a/internal/projects/apiKeys/api_keys.go b/internal/projects/apiKeys/api_keys.go index 2561e1d67..4fcbfe06a 100644 --- a/internal/projects/apiKeys/api_keys.go +++ b/internal/projects/apiKeys/api_keys.go @@ -3,6 +3,7 @@ package apiKeys import ( "context" "fmt" + "os" "strings" "github.com/go-errors/errors" @@ -18,14 +19,18 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { return err } - table := `|NAME|KEY VALUE| + if utils.OutputFormat.Value == utils.OutputPretty { + table := `|NAME|KEY VALUE| |-|-| ` - for _, entry := range keys { - table += fmt.Sprintf("|`%s`|`%s`|\n", strings.ReplaceAll(entry.Name, "|", "\\|"), entry.ApiKey) + for _, entry := range keys { + table += fmt.Sprintf("|`%s`|`%s`|\n", strings.ReplaceAll(entry.Name, "|", "\\|"), entry.ApiKey) + } + + return list.RenderTable(table) } - return list.RenderTable(table) + return utils.EncodeOutput(utils.OutputFormat.Value, os.Stdout, keys) } func RunGetApiKeys(ctx context.Context, projectRef string) ([]api.ApiKeyResponse, error) { diff --git a/internal/projects/create/create.go b/internal/projects/create/create.go index 1df4b3878..e8541c3e5 100644 --- a/internal/projects/create/create.go +++ b/internal/projects/create/create.go @@ -35,8 +35,12 @@ func Run(ctx context.Context, params api.V1CreateProjectBody, fsys afero.Fs) err } projectUrl := fmt.Sprintf("%s/project/%s", utils.GetSupabaseDashboardURL(), resp.JSON201.Id) - fmt.Printf("Created a new project %s at %s\n", utils.Aqua(resp.JSON201.Name), utils.Bold(projectUrl)) - return nil + fmt.Fprintf(os.Stderr, "Created a new project %s at %s\n", utils.Aqua(resp.JSON201.Name), utils.Bold(projectUrl)) + if utils.OutputFormat.Value == utils.OutputPretty { + return nil + } + + return utils.EncodeOutput(utils.OutputFormat.Value, os.Stdout, resp.JSON201) } func printKeyValue(key, value string) string { diff --git a/internal/projects/list/list.go b/internal/projects/list/list.go index 18798ec00..b16b6d4fc 100644 --- a/internal/projects/list/list.go +++ b/internal/projects/list/list.go @@ -5,15 +5,20 @@ import ( "fmt" "os" "strings" - "time" "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/supabase/cli/internal/migration/list" "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/api" ) +type linkedProject struct { + api.V1ProjectResponse `yaml:",inline"` + Linked bool `json:"linked"` +} + func Run(ctx context.Context, fsys afero.Fs) error { resp, err := utils.GetSupabase().V1ListAllProjectsWithResponse(ctx) if err != nil { @@ -29,30 +34,51 @@ func Run(ctx context.Context, fsys afero.Fs) error { fmt.Fprintln(os.Stderr, err) } - table := `LINKED|ORG ID|REFERENCE ID|NAME|REGION|CREATED AT (UTC) + var projects []linkedProject + for _, project := range *resp.JSON200 { + projects = append(projects, linkedProject{ + V1ProjectResponse: project, + Linked: project.Id == projectRef, + }) + } + + if utils.OutputFormat.Value == utils.OutputPretty { + table := `LINKED|ORG ID|REFERENCE ID|NAME|REGION|CREATED AT (UTC) |-|-|-|-|-|-| ` - for _, project := range *resp.JSON200 { - if t, err := time.Parse(time.RFC3339, project.CreatedAt); err == nil { - project.CreatedAt = t.UTC().Format("2006-01-02 15:04:05") - } - if region, ok := utils.RegionMap[project.Region]; ok { - project.Region = region + for _, project := range projects { + table += fmt.Sprintf( + "|`%s`|`%s`|`%s`|`%s`|`%s`|`%s`|\n", + formatBullet(project.Linked), + project.OrganizationId, + project.Id, + strings.ReplaceAll(project.Name, "|", "\\|"), + formatRegion(project.Region), + utils.FormatTimestamp(project.CreatedAt), + ) } - linked := " " - if project.Id == projectRef { - linked = " ●" - } - table += fmt.Sprintf( - "|`%s`|`%s`|`%s`|`%s`|`%s`|`%s`|\n", - linked, - project.OrganizationId, - project.Id, - strings.ReplaceAll(project.Name, "|", "\\|"), - project.Region, - utils.FormatTimestamp(project.CreatedAt), - ) + return list.RenderTable(table) + } else if utils.OutputFormat.Value == utils.OutputToml { + return utils.EncodeOutput(utils.OutputFormat.Value, os.Stdout, struct { + Projects []linkedProject `toml:"projects"` + }{ + Projects: projects, + }) } - return list.RenderTable(table) + return utils.EncodeOutput(utils.OutputFormat.Value, os.Stdout, projects) +} + +func formatBullet(value bool) string { + if value { + return " ●" + } + return " " +} + +func formatRegion(region string) string { + if readable, ok := utils.RegionMap[region]; ok { + return readable + } + return region } diff --git a/internal/utils/output.go b/internal/utils/output.go index 4b916c373..6d1a72aa4 100644 --- a/internal/utils/output.go +++ b/internal/utils/output.go @@ -29,6 +29,11 @@ var ( OutputToml, OutputYaml, } + + OutputFormat = EnumFlag{ + Allowed: OutputDefaultAllowed, + Value: OutputPretty, + } ) func EncodeOutput(format string, w io.Writer, value any) error { From 92669a875ac49ecab8c9f6186b528f13335c22d6 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Fri, 13 Sep 2024 13:28:39 +0200 Subject: [PATCH 016/305] feat: add --all flag to stop command (#2672) * feat: add --all flag to stop command Add a --all flag to stop command to stop all services/volumes of all projects on the machine * chore: add docs for --all stop flag * chore: rename functions * chore: mark project-id and all flags mutually exclusive * chore: fix lint * chore: refactor use utils.DockerRemoveAll * chore: use projectId instead of config in ProjectFilter * Update internal/stop/stop.go --------- Co-authored-by: Han Qiao --- cmd/stop.go | 5 +- docs/supabase/stop.md | 2 + internal/db/start/start.go | 2 +- internal/start/start.go | 2 +- internal/status/status.go | 2 +- internal/stop/stop.go | 33 +++++++++----- internal/stop/stop_test.go | 93 +++++++++++++++++++++++++++++++++++--- internal/utils/docker.go | 13 ++++-- 8 files changed, 126 insertions(+), 26 deletions(-) diff --git a/cmd/stop.go b/cmd/stop.go index 19401326f..6a6f4aa55 100644 --- a/cmd/stop.go +++ b/cmd/stop.go @@ -12,6 +12,7 @@ import ( var ( noBackup bool projectId string + all bool stopCmd = &cobra.Command{ GroupID: groupLocalDev, @@ -19,7 +20,7 @@ var ( Short: "Stop all local Supabase containers", RunE: func(cmd *cobra.Command, args []string) error { ctx, _ := signal.NotifyContext(cmd.Context(), os.Interrupt) - return stop.Run(ctx, !noBackup, projectId, afero.NewOsFs()) + return stop.Run(ctx, !noBackup, projectId, all, afero.NewOsFs()) }, } ) @@ -30,5 +31,7 @@ func init() { flags.StringVar(&projectId, "project-id", "", "Local project ID to stop.") cobra.CheckErr(flags.MarkHidden("backup")) flags.BoolVar(&noBackup, "no-backup", false, "Deletes all data volumes after stopping.") + flags.BoolVar(&all, "all", false, "Stop all local Supabase instances from all projects across the machine.") + stopCmd.MarkFlagsMutuallyExclusive("project-id", "all") rootCmd.AddCommand(stopCmd) } diff --git a/docs/supabase/stop.md b/docs/supabase/stop.md index e18261ab3..870fa8603 100644 --- a/docs/supabase/stop.md +++ b/docs/supabase/stop.md @@ -5,3 +5,5 @@ Stops the Supabase local development stack. Requires `supabase/config.toml` to be created in your current working directory by running `supabase init`. All Docker resources are maintained across restarts. Use `--no-backup` flag to reset your local development data between restarts. + +Use the `--all` flag to stop all local Supabase projects instances on the machine. Use with caution with `--no-backup` as it will delete all supabase local projects data. \ No newline at end of file diff --git a/internal/db/start/start.go b/internal/db/start/start.go index 14c2e9a12..e7f03fd61 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -45,7 +45,7 @@ func Run(ctx context.Context, fsys afero.Fs) error { utils.Config.Analytics.Enabled = false err := StartDatabase(ctx, fsys, os.Stderr) if err != nil { - if err := utils.DockerRemoveAll(context.Background(), os.Stderr); err != nil { + if err := utils.DockerRemoveAll(context.Background(), os.Stderr, utils.Config.ProjectId); err != nil { fmt.Fprintln(os.Stderr, err) } } diff --git a/internal/start/start.go b/internal/start/start.go index 4b967e6ca..1a2226832 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -86,7 +86,7 @@ func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string, ignore if ignoreHealthCheck && start.IsUnhealthyError(err) { fmt.Fprintln(os.Stderr, err) } else { - if err := utils.DockerRemoveAll(context.Background(), os.Stderr); err != nil { + if err := utils.DockerRemoveAll(context.Background(), os.Stderr, utils.Config.ProjectId); err != nil { fmt.Fprintln(os.Stderr, err) } return err diff --git a/internal/status/status.go b/internal/status/status.go index 0963be09c..e78af5cd2 100644 --- a/internal/status/status.go +++ b/internal/status/status.go @@ -89,7 +89,7 @@ func Run(ctx context.Context, names CustomName, format string, fsys afero.Fs) er func checkServiceHealth(ctx context.Context) ([]string, error) { resp, err := utils.Docker.ContainerList(ctx, container.ListOptions{ - Filters: utils.CliProjectFilter(), + Filters: utils.CliProjectFilter(utils.Config.ProjectId), }) if err != nil { return nil, errors.Errorf("failed to list running containers: %w", err) diff --git a/internal/stop/stop.go b/internal/stop/stop.go index b4bd94c23..39c5e00e5 100644 --- a/internal/stop/stop.go +++ b/internal/stop/stop.go @@ -11,33 +11,42 @@ import ( "github.com/supabase/cli/internal/utils" ) -func Run(ctx context.Context, backup bool, projectId string, fsys afero.Fs) error { - // Sanity checks. - if len(projectId) > 0 { - utils.Config.ProjectId = projectId - } else if err := utils.LoadConfigFS(fsys); err != nil { - return err +func Run(ctx context.Context, backup bool, projectId string, all bool, fsys afero.Fs) error { + var searchProjectIdFilter string + if !all { + // Sanity checks. + if len(projectId) > 0 { + utils.Config.ProjectId = projectId + } else if err := utils.LoadConfigFS(fsys); err != nil { + return err + } + searchProjectIdFilter = utils.Config.ProjectId } // Stop all services if err := utils.RunProgram(ctx, func(p utils.Program, ctx context.Context) error { w := utils.StatusWriter{Program: p} - return stop(ctx, backup, w) + return stop(ctx, backup, w, searchProjectIdFilter) }); err != nil { return err } fmt.Println("Stopped " + utils.Aqua("supabase") + " local development setup.") if resp, err := utils.Docker.VolumeList(ctx, volume.ListOptions{ - Filters: utils.CliProjectFilter(), + Filters: utils.CliProjectFilter(searchProjectIdFilter), }); err == nil && len(resp.Volumes) > 0 { - listVolume := fmt.Sprintf("docker volume ls --filter label=%s=%s", utils.CliProjectLabel, utils.Config.ProjectId) - utils.CmdSuggestion = "Local data are backed up to docker volume. Use docker to show them: " + utils.Aqua(listVolume) + if len(searchProjectIdFilter) > 0 { + listVolume := fmt.Sprintf("docker volume ls --filter label=%s=%s", utils.CliProjectLabel, searchProjectIdFilter) + utils.CmdSuggestion = "Local data are backed up to docker volume. Use docker to show them: " + utils.Aqua(listVolume) + } else { + listVolume := fmt.Sprintf("docker volume ls --filter label=%s", utils.CliProjectLabel) + utils.CmdSuggestion = "Local data are backed up to docker volume. Use docker to show them: " + utils.Aqua(listVolume) + } } return nil } -func stop(ctx context.Context, backup bool, w io.Writer) error { +func stop(ctx context.Context, backup bool, w io.Writer, projectId string) error { utils.NoBackupVolume = !backup - return utils.DockerRemoveAll(ctx, w) + return utils.DockerRemoveAll(ctx, w, projectId) } diff --git a/internal/stop/stop_test.go b/internal/stop/stop_test.go index 419df28bc..da571330b 100644 --- a/internal/stop/stop_test.go +++ b/internal/stop/stop_test.go @@ -3,6 +3,7 @@ package stop import ( "context" "errors" + "fmt" "io" "net/http" "os" @@ -47,7 +48,87 @@ func TestStopCommand(t *testing.T) { Name: utils.DbId, }}}) // Run test - err := Run(context.Background(), true, "", fsys) + err := Run(context.Background(), true, "", false, fsys) + // Check error + assert.NoError(t, err) + assert.Empty(t, apitest.ListUnmatchedRequests()) + }) + + t.Run("stops all instances when --all flag is used", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewMemMapFs() + require.NoError(t, utils.WriteConfig(fsys, false)) + // Setup mock docker + require.NoError(t, apitest.MockDocker(utils.Docker)) + defer gock.OffAll() + + projects := []string{"project1", "project2"} + + // Mock initial ContainerList for all containers + gock.New(utils.Docker.DaemonHost()). + Get("/v"+utils.Docker.ClientVersion()+"/containers/json"). + MatchParam("all", "true"). + Reply(http.StatusOK). + JSON([]types.Container{ + {ID: "container1", Labels: map[string]string{utils.CliProjectLabel: "project1"}}, + {ID: "container2", Labels: map[string]string{utils.CliProjectLabel: "project2"}}, + }) + + // Mock initial VolumeList + gock.New(utils.Docker.DaemonHost()). + Get("/v" + utils.Docker.ClientVersion() + "/volumes"). + Reply(http.StatusOK). + JSON(volume.ListResponse{ + Volumes: []*volume.Volume{ + {Name: "volume1", Labels: map[string]string{utils.CliProjectLabel: "project1"}}, + {Name: "volume2", Labels: map[string]string{utils.CliProjectLabel: "project2"}}, + }, + }) + + // Mock stopOneProject for each project + for _, projectId := range projects { + // Mock ContainerList for each project + gock.New(utils.Docker.DaemonHost()). + Get("/v"+utils.Docker.ClientVersion()+"/containers/json"). + MatchParam("all", "1"). + MatchParam("filters", fmt.Sprintf(`{"label":{"com.supabase.cli.project=%s":true}}`, projectId)). + Reply(http.StatusOK). + JSON([]types.Container{{ID: "container-" + projectId, State: "running"}}) + + // Mock container stop + gock.New(utils.Docker.DaemonHost()). + Post("/v" + utils.Docker.ClientVersion() + "/containers/container-" + projectId + "/stop"). + Reply(http.StatusOK) + + gock.New(utils.Docker.DaemonHost()). + Post("/v" + utils.Docker.ClientVersion() + "/containers/prune"). + Reply(http.StatusOK). + JSON(container.PruneReport{}) + gock.New(utils.Docker.DaemonHost()). + Post("/v" + utils.Docker.ClientVersion() + "/networks/prune"). + Reply(http.StatusOK). + JSON(network.PruneReport{}) + gock.New(utils.Docker.DaemonHost()). + Get("/v"+utils.Docker.ClientVersion()+"/volumes"). + MatchParam("filters", fmt.Sprintf(`{"label":{"com.supabase.cli.project=%s":true}}`, projectId)). + Reply(http.StatusOK). + JSON(volume.ListResponse{Volumes: []*volume.Volume{{Name: "volume-" + projectId}}}) + } + + // Mock final ContainerList to verify all containers are stopped + gock.New(utils.Docker.DaemonHost()). + Get("/v"+utils.Docker.ClientVersion()+"/containers/json"). + MatchParam("all", "true"). + Reply(http.StatusOK). + JSON([]types.Container{}) + gock.New(utils.Docker.DaemonHost()). + Get("/v" + utils.Docker.ClientVersion() + "/containers/json"). + Reply(http.StatusOK). + JSON([]types.Container{}) + + // Run test + err := Run(context.Background(), true, "", true, fsys) + // Check error assert.NoError(t, err) assert.Empty(t, apitest.ListUnmatchedRequests()) @@ -57,7 +138,7 @@ func TestStopCommand(t *testing.T) { // Setup in-memory fs fsys := afero.NewMemMapFs() // Run test - err := Run(context.Background(), false, "", fsys) + err := Run(context.Background(), false, "", false, fsys) // Check error assert.ErrorIs(t, err, os.ErrNotExist) }) @@ -73,7 +154,7 @@ func TestStopCommand(t *testing.T) { Get("/v" + utils.Docker.ClientVersion() + "/containers/json"). Reply(http.StatusServiceUnavailable) // Run test - err := Run(context.Background(), false, "test", afero.NewReadOnlyFs(fsys)) + err := Run(context.Background(), false, "test", false, afero.NewReadOnlyFs(fsys)) // Check error assert.ErrorContains(t, err, "request returned Service Unavailable for API route and version") assert.Empty(t, apitest.ListUnmatchedRequests()) @@ -102,7 +183,7 @@ func TestStopServices(t *testing.T) { Reply(http.StatusOK). JSON(network.PruneReport{}) // Run test - err := stop(context.Background(), true, io.Discard) + err := stop(context.Background(), true, io.Discard, utils.Config.ProjectId) // Check error assert.NoError(t, err) assert.Empty(t, apitest.ListUnmatchedRequests()) @@ -119,7 +200,7 @@ func TestStopServices(t *testing.T) { defer gock.OffAll() apitest.MockDockerStop(utils.Docker) // Run test - err := stop(context.Background(), false, io.Discard) + err := stop(context.Background(), false, io.Discard, utils.Config.ProjectId) // Check error assert.NoError(t, err) assert.Empty(t, apitest.ListUnmatchedRequests()) @@ -137,7 +218,7 @@ func TestStopServices(t *testing.T) { Post("/v" + utils.Docker.ClientVersion() + "/containers/prune"). ReplyError(errors.New("network error")) // Run test - err := stop(context.Background(), true, io.Discard) + err := stop(context.Background(), true, io.Discard, utils.Config.ProjectId) // Check error assert.ErrorContains(t, err, "network error") assert.Empty(t, apitest.ListUnmatchedRequests()) diff --git a/internal/utils/docker.go b/internal/utils/docker.go index 678d93e98..80106583b 100644 --- a/internal/utils/docker.go +++ b/internal/utils/docker.go @@ -92,9 +92,9 @@ func WaitAll[T any](containers []T, exec func(container T) error) []error { // NoBackupVolume TODO: encapsulate this state in a class var NoBackupVolume = false -func DockerRemoveAll(ctx context.Context, w io.Writer) error { +func DockerRemoveAll(ctx context.Context, w io.Writer, projectId string) error { fmt.Fprintln(w, "Stopping containers...") - args := CliProjectFilter() + args := CliProjectFilter(projectId) containers, err := Docker.ContainerList(ctx, container.ListOptions{ All: true, Filters: args, @@ -144,9 +144,14 @@ func DockerRemoveAll(ctx context.Context, w io.Writer) error { return nil } -func CliProjectFilter() filters.Args { +func CliProjectFilter(projectId string) filters.Args { + if len(projectId) == 0 { + return filters.NewArgs( + filters.Arg("label", CliProjectLabel), + ) + } return filters.NewArgs( - filters.Arg("label", CliProjectLabel+"="+Config.ProjectId), + filters.Arg("label", CliProjectLabel+"="+projectId), ) } From 230be7f40f251774b94a5ecc5b8025c4da22e58e Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Fri, 13 Sep 2024 14:29:28 +0200 Subject: [PATCH 017/305] fix: logout credentials cleanup (#2670) --- internal/link/link.go | 2 +- internal/login/login_test.go | 4 +- internal/logout/logout.go | 6 +++ internal/logout/logout_test.go | 25 ++++++++- internal/projects/create/create.go | 2 +- internal/projects/delete/delete.go | 2 +- internal/unlink/unlink.go | 2 +- internal/unlink/unlink_test.go | 4 +- internal/utils/access_token.go | 8 +-- internal/utils/access_token_test.go | 4 +- internal/utils/credentials/store.go | 38 ++++++++----- internal/utils/credentials/store_mock.go | 68 ++++++++++++++++++++++++ internal/utils/flags/db_url.go | 2 +- 13 files changed, 136 insertions(+), 31 deletions(-) create mode 100644 internal/utils/credentials/store_mock.go diff --git a/internal/link/link.go b/internal/link/link.go index 9113f5434..3a2831070 100644 --- a/internal/link/link.go +++ b/internal/link/link.go @@ -43,7 +43,7 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func( return err } // Save database password - if err := credentials.Set(projectRef, config.Password); err != nil { + if err := credentials.StoreProvider.Set(projectRef, config.Password); err != nil { fmt.Fprintln(os.Stderr, "Failed to save database password:", err) } } diff --git a/internal/login/login_test.go b/internal/login/login_test.go index faf351e99..758fbc5c4 100644 --- a/internal/login/login_test.go +++ b/internal/login/login_test.go @@ -40,7 +40,7 @@ func TestLoginCommand(t *testing.T) { Token: token, Fsys: afero.NewMemMapFs(), })) - saved, err := credentials.Get(utils.AccessTokenKey) + saved, err := credentials.StoreProvider.Get(utils.AccessTokenKey) assert.NoError(t, err) assert.Equal(t, token, saved) }) @@ -83,7 +83,7 @@ func TestLoginCommand(t *testing.T) { expectedBrowserUrl := fmt.Sprintf("%s/cli/login?session_id=%s&token_name=%s&public_key=%s", utils.GetSupabaseDashboardURL(), sessionId, tokenName, publicKey) assert.Contains(t, out.String(), expectedBrowserUrl) - saved, err := credentials.Get(utils.AccessTokenKey) + saved, err := credentials.StoreProvider.Get(utils.AccessTokenKey) assert.NoError(t, err) assert.Equal(t, token, saved) assert.Empty(t, apitest.ListUnmatchedRequests()) diff --git a/internal/logout/logout.go b/internal/logout/logout.go index c117abd94..abbd191b8 100644 --- a/internal/logout/logout.go +++ b/internal/logout/logout.go @@ -8,6 +8,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/credentials" ) func Run(ctx context.Context, stdout *os.File, fsys afero.Fs) error { @@ -24,6 +25,11 @@ func Run(ctx context.Context, stdout *os.File, fsys afero.Fs) error { return err } + // Delete all possible stored project credentials + if err := credentials.StoreProvider.DeleteAll(); err != nil { + fmt.Fprintln(utils.GetDebugLogger(), err) + } + fmt.Fprintln(stdout, "Access token deleted successfully. You are now logged out.") return nil } diff --git a/internal/logout/logout_test.go b/internal/logout/logout_test.go index 0bb39be5c..42f9f8ead 100644 --- a/internal/logout/logout_test.go +++ b/internal/logout/logout_test.go @@ -33,16 +33,37 @@ func TestLogoutCommand(t *testing.T) { assert.Empty(t, saved) }) + t.Run("removes all Supabase CLI credentials", func(t *testing.T) { + t.Cleanup(credentials.MockInit()) + require.NoError(t, credentials.StoreProvider.Set(utils.AccessTokenKey, token)) + require.NoError(t, credentials.StoreProvider.Set("project1", "password1")) + require.NoError(t, credentials.StoreProvider.Set("project2", "password2")) + t.Cleanup(fstest.MockStdin(t, "y")) + // Run test + err := Run(context.Background(), os.Stdout, afero.NewMemMapFs()) + // Check error + assert.NoError(t, err) + // Check that access token has been removed + saved, _ := credentials.StoreProvider.Get(utils.AccessTokenKey) + assert.Empty(t, saved) + // check that project 1 has been removed + saved, _ = credentials.StoreProvider.Get("project1") + assert.Empty(t, saved) + // check that project 2 has been removed + saved, _ = credentials.StoreProvider.Get("project2") + assert.Empty(t, saved) + }) + t.Run("skips logout by default", func(t *testing.T) { keyring.MockInit() - require.NoError(t, credentials.Set(utils.AccessTokenKey, token)) + require.NoError(t, credentials.StoreProvider.Set(utils.AccessTokenKey, token)) // Setup in-memory fs fsys := afero.NewMemMapFs() // Run test err := Run(context.Background(), os.Stdout, fsys) // Check error assert.ErrorIs(t, err, context.Canceled) - saved, err := credentials.Get(utils.AccessTokenKey) + saved, err := credentials.StoreProvider.Get(utils.AccessTokenKey) assert.NoError(t, err) assert.Equal(t, token, saved) }) diff --git a/internal/projects/create/create.go b/internal/projects/create/create.go index e8541c3e5..01ebf6308 100644 --- a/internal/projects/create/create.go +++ b/internal/projects/create/create.go @@ -30,7 +30,7 @@ func Run(ctx context.Context, params api.V1CreateProjectBody, fsys afero.Fs) err flags.ProjectRef = resp.JSON201.Id viper.Set("DB_PASSWORD", params.DbPass) - if err := credentials.Set(flags.ProjectRef, params.DbPass); err != nil { + if err := credentials.StoreProvider.Set(flags.ProjectRef, params.DbPass); err != nil { fmt.Fprintln(os.Stderr, "Failed to save database password:", err) } diff --git a/internal/projects/delete/delete.go b/internal/projects/delete/delete.go index c8ce9d535..f042f62e1 100644 --- a/internal/projects/delete/delete.go +++ b/internal/projects/delete/delete.go @@ -43,7 +43,7 @@ func Run(ctx context.Context, ref string, fsys afero.Fs) error { } // Unlink project - if err := credentials.Delete(ref); err != nil && !errors.Is(err, keyring.ErrNotFound) { + if err := credentials.StoreProvider.Delete(ref); err != nil && !errors.Is(err, keyring.ErrNotFound) { fmt.Fprintln(os.Stderr, err) } if match, err := afero.FileContainsBytes(fsys, utils.ProjectRefPath, []byte(ref)); match { diff --git a/internal/unlink/unlink.go b/internal/unlink/unlink.go index aa0f76871..c6297581e 100644 --- a/internal/unlink/unlink.go +++ b/internal/unlink/unlink.go @@ -34,7 +34,7 @@ func Unlink(projectRef string, fsys afero.Fs) error { allErrors = append(allErrors, wrapped) } // Remove linked credentials - if err := credentials.Delete(projectRef); err != nil && + if err := credentials.StoreProvider.Delete(projectRef); err != nil && !errors.Is(err, credentials.ErrNotSupported) && !errors.Is(err, keyring.ErrNotFound) { allErrors = append(allErrors, err) diff --git a/internal/unlink/unlink_test.go b/internal/unlink/unlink_test.go index e8bd284b6..9b526e109 100644 --- a/internal/unlink/unlink_test.go +++ b/internal/unlink/unlink_test.go @@ -23,7 +23,7 @@ func TestUnlinkCommand(t *testing.T) { fsys := afero.NewMemMapFs() require.NoError(t, afero.WriteFile(fsys, utils.ProjectRefPath, []byte(project), 0644)) // Save database password - require.NoError(t, credentials.Set(project, "test")) + require.NoError(t, credentials.StoreProvider.Set(project, "test")) // Run test err := Run(context.Background(), fsys) // Check error @@ -33,7 +33,7 @@ func TestUnlinkCommand(t *testing.T) { assert.NoError(t, err) assert.False(t, exists) // Check credentials does not exist - _, err = credentials.Get(project) + _, err = credentials.StoreProvider.Get(project) assert.ErrorIs(t, err, keyring.ErrNotFound) }) diff --git a/internal/utils/access_token.go b/internal/utils/access_token.go index c94b9de83..f7ef90a01 100644 --- a/internal/utils/access_token.go +++ b/internal/utils/access_token.go @@ -41,7 +41,7 @@ func loadAccessToken(fsys afero.Fs) (string, error) { return accessToken, nil } // Load from native credentials store - if accessToken, err := credentials.Get(AccessTokenKey); err == nil { + if accessToken, err := credentials.StoreProvider.Get(AccessTokenKey); err == nil { return accessToken, nil } // Fallback to token file @@ -68,7 +68,7 @@ func SaveAccessToken(accessToken string, fsys afero.Fs) error { return errors.New(ErrInvalidToken) } // Save to native credentials store - if err := credentials.Set(AccessTokenKey, accessToken); err == nil { + if err := credentials.StoreProvider.Set(AccessTokenKey, accessToken); err == nil { return nil } // Fallback to token file @@ -94,13 +94,13 @@ func DeleteAccessToken(fsys afero.Fs) error { if err := fallbackDeleteToken(fsys); err == nil { // Typically user system should only have either token file or keyring. // But we delete from both just in case. - _ = credentials.Delete(AccessTokenKey) + _ = credentials.StoreProvider.Delete(AccessTokenKey) return nil } else if !errors.Is(err, os.ErrNotExist) { return err } // Fallback not found, delete from native credentials store - err := credentials.Delete(AccessTokenKey) + err := credentials.StoreProvider.Delete(AccessTokenKey) if errors.Is(err, credentials.ErrNotSupported) || errors.Is(err, keyring.ErrNotFound) { return errors.New(ErrNotLoggedIn) } else if err != nil { diff --git a/internal/utils/access_token_test.go b/internal/utils/access_token_test.go index 846158487..f31988876 100644 --- a/internal/utils/access_token_test.go +++ b/internal/utils/access_token_test.go @@ -165,7 +165,7 @@ func TestSaveTokenFallback(t *testing.T) { func TestDeleteToken(t *testing.T) { t.Run("deletes both keyring and fallback", func(t *testing.T) { token := string(apitest.RandomAccessToken(t)) - require.NoError(t, credentials.Set(AccessTokenKey, token)) + require.NoError(t, credentials.StoreProvider.Set(AccessTokenKey, token)) // Setup in-memory fs fsys := afero.NewMemMapFs() require.NoError(t, fallbackSaveToken(token, fsys)) @@ -173,7 +173,7 @@ func TestDeleteToken(t *testing.T) { err := DeleteAccessToken(fsys) // Check error assert.NoError(t, err) - _, err = credentials.Get(AccessTokenKey) + _, err = credentials.StoreProvider.Get(AccessTokenKey) assert.ErrorIs(t, err, keyring.ErrNotFound) path, err := getAccessTokenPath() assert.NoError(t, err) diff --git a/internal/utils/credentials/store.go b/internal/utils/credentials/store.go index ac7f01866..02f97e200 100644 --- a/internal/utils/credentials/store.go +++ b/internal/utils/credentials/store.go @@ -13,8 +13,19 @@ const namespace = "Supabase CLI" var ErrNotSupported = errors.New("Keyring is not supported on WSL") -// Retrieves the stored password of a project and username -func Get(project string) (string, error) { +type Store interface { + Get(key string) (string, error) + Set(key, value string) error + Delete(project string) error + DeleteAll() error +} + +type KeyringStore struct{} + +var StoreProvider Store = &KeyringStore{} + +// Get retrieves the password for a project from the keyring. +func (ks *KeyringStore) Get(project string) (string, error) { if err := assertKeyringSupported(); err != nil { return "", err } @@ -27,34 +38,33 @@ func Get(project string) (string, error) { return val, nil } -// Stores the password of a project and username -func Set(project, password string) error { +func (ks *KeyringStore) Set(project, password string) error { if err := assertKeyringSupported(); err != nil { return err } - if err := keyring.Set(namespace, project, password); errors.Is(err, exec.ErrNotFound) { - return errors.New(ErrNotSupported) - } else if err != nil { + if err := keyring.Set(namespace, project, password); err != nil { + if errors.Is(err, exec.ErrNotFound) { + return ErrNotSupported + } return errors.Errorf("failed to set credentials: %w", err) } return nil } -// Erases the stored password of a project and username -func Delete(project string) error { +func (ks *KeyringStore) Delete(project string) error { if err := assertKeyringSupported(); err != nil { return err } - if err := keyring.Delete(namespace, project); errors.Is(err, exec.ErrNotFound) { - return errors.New(ErrNotSupported) - } else if err != nil { + if err := keyring.Delete(namespace, project); err != nil { + if errors.Is(err, exec.ErrNotFound) { + return ErrNotSupported + } return errors.Errorf("failed to delete credentials: %w", err) } return nil } -// Deletes all stored credentials for the namespace -func DeleteAll() error { +func (ks *KeyringStore) DeleteAll() error { return deleteAll(namespace) } diff --git a/internal/utils/credentials/store_mock.go b/internal/utils/credentials/store_mock.go new file mode 100644 index 000000000..32715fc37 --- /dev/null +++ b/internal/utils/credentials/store_mock.go @@ -0,0 +1,68 @@ +package credentials + +import ( + "github.com/zalando/go-keyring" +) + +type mockProvider struct { + mockStore map[string]map[string]string + mockError error +} + +// Get retrieves the password for a project from the mock store. +func (m *mockProvider) Get(project string) (string, error) { + if m.mockError != nil { + return "", m.mockError + } + if pass, ok := m.mockStore[namespace][project]; ok { + return pass, nil + } + return "", keyring.ErrNotFound +} + +// Set stores the password for a project in the mock store. +func (m *mockProvider) Set(project, password string) error { + if m.mockError != nil { + return m.mockError + } + if m.mockStore == nil { + m.mockStore = make(map[string]map[string]string) + } + if m.mockStore[namespace] == nil { + m.mockStore[namespace] = make(map[string]string) + } + m.mockStore[namespace][project] = password + return nil +} + +// Delete removes the password for a project from the mock store. +func (m *mockProvider) Delete(project string) error { + if m.mockError != nil { + return m.mockError + } + if _, ok := m.mockStore[namespace][project]; ok { + delete(m.mockStore[namespace], project) + return nil + } + return keyring.ErrNotFound +} + +// DeleteAll removes all passwords from the mock store. +func (m *mockProvider) DeleteAll() error { + if m.mockError != nil { + return m.mockError + } + delete(m.mockStore, namespace) + return nil +} + +func MockInit() func() { + oldStore := StoreProvider + teardown := func() { + StoreProvider = oldStore + } + StoreProvider = &mockProvider{ + mockStore: map[string]map[string]string{}, + } + return teardown +} diff --git a/internal/utils/flags/db_url.go b/internal/utils/flags/db_url.go index c183aa1ad..6fc912179 100644 --- a/internal/utils/flags/db_url.go +++ b/internal/utils/flags/db_url.go @@ -104,7 +104,7 @@ func getPassword(projectRef string) string { if password := viper.GetString("DB_PASSWORD"); len(password) > 0 { return password } - if password, err := credentials.Get(projectRef); err == nil { + if password, err := credentials.StoreProvider.Get(projectRef); err == nil { return password } resetUrl := fmt.Sprintf("%s/project/%s/settings/database", utils.GetSupabaseDashboardURL(), projectRef) From 5c0d71b1eb083e0785a3249fa14b3a824d5214e2 Mon Sep 17 00:00:00 2001 From: avallete Date: Mon, 16 Sep 2024 17:55:19 +0200 Subject: [PATCH 018/305] feat: add no-deploy flag for functions under config.toml --- internal/functions/deploy/deploy.go | 12 ++++++ internal/functions/deploy/deploy_test.go | 49 ++++++++++++++++++++++++ internal/functions/serve/serve.go | 1 + pkg/config/config.go | 1 + 4 files changed, 63 insertions(+) diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index 8cbfbd0e7..51e640003 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -35,6 +35,7 @@ func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bo if err != nil { return err } + functionConfig = FilterFunctionsToDeploy(functionConfig) api := function.NewEdgeRuntimeAPI(projectRef, *utils.GetSupabase(), NewDockerBundler(fsys)) if err := api.UpsertFunctions(ctx, functionConfig); err != nil { return err @@ -93,3 +94,14 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, } return functionConfig, nil } + +func FilterFunctionsToDeploy(functionsConfig config.FunctionConfig) config.FunctionConfig { + // Filter out all functions with NoDeploy set to true + filteredFunctions := make(config.FunctionConfig) + for slug, fc := range functionsConfig { + if !fc.NoDeploy { + filteredFunctions[slug] = fc + } + } + return filteredFunctions +} diff --git a/internal/functions/deploy/deploy_test.go b/internal/functions/deploy/deploy_test.go index faea4a710..ca5731323 100644 --- a/internal/functions/deploy/deploy_test.go +++ b/internal/functions/deploy/deploy_test.go @@ -121,6 +121,55 @@ import_map = "./import_map.json" assert.Empty(t, apitest.ListUnmatchedRequests()) }) + t.Run("skip deploy functions from config", func(t *testing.T) { + t.Cleanup(func() { clear(utils.Config.Functions) }) + // Setup in-memory fs + fsys := afero.NewMemMapFs() + require.NoError(t, utils.WriteConfig(fsys, false)) + f, err := fsys.OpenFile(utils.ConfigPath, os.O_APPEND|os.O_WRONLY, 0600) + require.NoError(t, err) + _, err = f.WriteString(` +[functions.` + slug + `] +import_map = "./import_map.json" +no_deploy = true +`) + require.NoError(t, err) + require.NoError(t, f.Close()) + importMapPath, err := filepath.Abs(filepath.Join(utils.SupabaseDirPath, "import_map.json")) + require.NoError(t, err) + require.NoError(t, afero.WriteFile(fsys, importMapPath, []byte("{}"), 0644)) + // Setup function entrypoint + entrypointPath := filepath.Join(utils.FunctionsDir, slug, "index.ts") + require.NoError(t, afero.WriteFile(fsys, entrypointPath, []byte{}, 0644)) + ignorePath := filepath.Join(utils.FunctionsDir, "_ignore", "index.ts") + require.NoError(t, afero.WriteFile(fsys, ignorePath, []byte{}, 0644)) + // Setup valid project ref + project := apitest.RandomProjectRef() + // Setup valid access token + token := apitest.RandomAccessToken(t) + t.Setenv("SUPABASE_ACCESS_TOKEN", string(token)) + // Setup valid deno path + _, err = fsys.Create(utils.DenoPathOverride) + require.NoError(t, err) + // Setup mock api + defer gock.OffAll() + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project + "/functions"). + Reply(http.StatusOK). + JSON([]api.FunctionResponse{}) + require.NoError(t, apitest.MockDocker(utils.Docker)) + apitest.MockDockerStart(utils.Docker, imageUrl, containerId) + require.NoError(t, apitest.MockDockerLogs(utils.Docker, containerId, "bundled")) + // Setup output file + outputDir := filepath.Join(utils.TempDir, fmt.Sprintf(".output_%s", slug)) + require.NoError(t, afero.WriteFile(fsys, filepath.Join(outputDir, "output.eszip"), []byte(""), 0644)) + // Run test + err = Run(context.Background(), nil, project, nil, "", fsys) + // Check error + assert.NoError(t, err) + assert.Empty(t, apitest.ListUnmatchedRequests()) + }) + t.Run("throws error on malformed slug", func(t *testing.T) { // Setup in-memory fs fsys := afero.NewMemMapFs() diff --git a/internal/functions/serve/serve.go b/internal/functions/serve/serve.go index 3b6f85119..625e9cea6 100644 --- a/internal/functions/serve/serve.go +++ b/internal/functions/serve/serve.go @@ -217,6 +217,7 @@ func populatePerFunctionConfigs(cwd, importMapPath string, noVerifyJWT *bool, fs if err != nil { return nil, "", err } + functionsConfig = deploy.FilterFunctionsToDeploy(functionsConfig) binds := []string{} for slug, fc := range functionsConfig { modules, err := deploy.GetBindMounts(cwd, utils.FunctionsDir, "", fc.Entrypoint, fc.ImportMap, fsys) diff --git a/pkg/config/config.go b/pkg/config/config.go index a116b3ad7..e1fb5eb9f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -412,6 +412,7 @@ type ( VerifyJWT *bool `toml:"verify_jwt" json:"verifyJWT"` ImportMap string `toml:"import_map" json:"importMapPath,omitempty"` Entrypoint string `json:"-"` + NoDeploy bool `toml:"no_deploy"` } analytics struct { From 2440bbdd6cd87df7b25e8ab3c683c58863eb6d3d Mon Sep 17 00:00:00 2001 From: avallete Date: Mon, 16 Sep 2024 21:24:31 +0200 Subject: [PATCH 019/305] chore: add debug logs --- internal/functions/deploy/deploy.go | 16 +++++++++++----- internal/functions/serve/serve.go | 5 ++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index 51e640003..e183832ef 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -35,7 +35,10 @@ func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bo if err != nil { return err } - functionConfig = FilterFunctionsToDeploy(functionConfig) + functionConfig, skippedFunctions := FilterFunctionsToDeploy(functionConfig) + if len(skippedFunctions) > 0 { + fmt.Fprintf(utils.GetDebugLogger(), "Skipped deploying the following functions: %s\n", strings.Join(skippedFunctions, ", ")) + } api := function.NewEdgeRuntimeAPI(projectRef, *utils.GetSupabase(), NewDockerBundler(fsys)) if err := api.UpsertFunctions(ctx, functionConfig); err != nil { return err @@ -95,13 +98,16 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, return functionConfig, nil } -func FilterFunctionsToDeploy(functionsConfig config.FunctionConfig) config.FunctionConfig { +func FilterFunctionsToDeploy(functionsConfig config.FunctionConfig) (functionsToDeploy config.FunctionConfig, skippedFunctions []string) { // Filter out all functions with NoDeploy set to true - filteredFunctions := make(config.FunctionConfig) + functionsToDeploy = make(config.FunctionConfig) + skippedFunctions = []string{} for slug, fc := range functionsConfig { if !fc.NoDeploy { - filteredFunctions[slug] = fc + functionsToDeploy[slug] = fc + } else { + skippedFunctions = append(skippedFunctions, slug) } } - return filteredFunctions + return functionsToDeploy, skippedFunctions } diff --git a/internal/functions/serve/serve.go b/internal/functions/serve/serve.go index 625e9cea6..58bcef6ac 100644 --- a/internal/functions/serve/serve.go +++ b/internal/functions/serve/serve.go @@ -217,7 +217,10 @@ func populatePerFunctionConfigs(cwd, importMapPath string, noVerifyJWT *bool, fs if err != nil { return nil, "", err } - functionsConfig = deploy.FilterFunctionsToDeploy(functionsConfig) + functionsConfig, skippedFunctions := deploy.FilterFunctionsToDeploy(functionsConfig) + if len(skippedFunctions) > 0 { + fmt.Fprintf(utils.GetDebugLogger(), "Skipped serve the following functions: %s\n", strings.Join(skippedFunctions, ", ")) + } binds := []string{} for slug, fc := range functionsConfig { modules, err := deploy.GetBindMounts(cwd, utils.FunctionsDir, "", fc.Entrypoint, fc.ImportMap, fsys) From 9b9bb4a8190a5c0727399ffa40a945dcc61073cf Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:12:30 +0800 Subject: [PATCH 020/305] chore(deps): bump golang.org/x/mod from 0.20.0 to 0.21.0 (#2686) Bumps [golang.org/x/mod](https://github.com/golang/mod) from 0.20.0 to 0.21.0. - [Commits](https://github.com/golang/mod/compare/v0.20.0...v0.21.0) --- updated-dependencies: - dependency-name: golang.org/x/mod dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2b03c580c..1d790e827 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 github.com/zalando/go-keyring v0.2.5 go.opentelemetry.io/otel v1.30.0 - golang.org/x/mod v0.20.0 + golang.org/x/mod v0.21.0 golang.org/x/oauth2 v0.23.0 golang.org/x/term v0.24.0 google.golang.org/grpc v1.66.2 diff --git a/go.sum b/go.sum index b7b4497ee..4fdaab3fb 100644 --- a/go.sum +++ b/go.sum @@ -1146,8 +1146,8 @@ golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= -golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= +golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= From b0a0488208dd52357454a3f3d51f598827921fe1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar=20Carrasco?= Date: Tue, 17 Sep 2024 07:13:31 +0100 Subject: [PATCH 021/305] fix: update deno.unstable settings in VS Code settings.json template (#2684) Update the "deno.unstable" settings in .vscode/settings.json to replace the deprecated boolean flag option. Refactor the settings to include the following flags: - bare-node-builtins - byonm - sloppy-imports - unsafe-proto - webgpu - broadcast-channel - worker-options - cron - kv - ffi - fs - http - net --- internal/init/templates/.vscode/settings.json | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/internal/init/templates/.vscode/settings.json b/internal/init/templates/.vscode/settings.json index 5d0c9ed1c..af62c23f8 100644 --- a/internal/init/templates/.vscode/settings.json +++ b/internal/init/templates/.vscode/settings.json @@ -3,7 +3,21 @@ "supabase/functions" ], "deno.lint": true, - "deno.unstable": true, + "deno.unstable": [ + "bare-node-builtins", + "byonm", + "sloppy-imports", + "unsafe-proto", + "webgpu", + "broadcast-channel", + "worker-options", + "cron", + "kv", + "ffi", + "fs", + "http", + "net" + ], "[typescript]": { "editor.defaultFormatter": "denoland.vscode-deno" } From a537dc0ef7dfd43ec1695f757c7caf2de70aa4d3 Mon Sep 17 00:00:00 2001 From: avallete Date: Tue, 17 Sep 2024 10:55:30 +0200 Subject: [PATCH 022/305] chore: apply PR comments Change NoDeploy to Enabled Include the filtering logic into GetFunctionsSlugs --- internal/functions/deploy/deploy.go | 39 +++++++++--------------- internal/functions/deploy/deploy_test.go | 21 +++++++------ internal/functions/serve/serve.go | 9 +++--- pkg/config/config.go | 2 +- 4 files changed, 32 insertions(+), 39 deletions(-) diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index e183832ef..62b1b8fc6 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -16,6 +16,7 @@ import ( func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bool, importMapPath string, fsys afero.Fs) error { // Load function config and project id + var skippedFunctions []string if err := utils.LoadConfigFS(fsys); err != nil { return err } else if len(slugs) > 0 { @@ -24,9 +25,12 @@ func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bo return err } } - } else if slugs, err = GetFunctionSlugs(fsys); err != nil { + } else if slugs, skippedFunctions, err = GetFunctionSlugs(fsys); err != nil { return err } + if len(skippedFunctions) > 0 { + fmt.Fprintf(utils.GetDebugLogger(), "Skipped deploying the following functions: %s\n", strings.Join(skippedFunctions, ", ")) + } // TODO: require all functions to be deployed from config for v2 if len(slugs) == 0 { return errors.Errorf("No Functions specified or found in %s", utils.Bold(utils.FunctionsDir)) @@ -35,10 +39,6 @@ func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bo if err != nil { return err } - functionConfig, skippedFunctions := FilterFunctionsToDeploy(functionConfig) - if len(skippedFunctions) > 0 { - fmt.Fprintf(utils.GetDebugLogger(), "Skipped deploying the following functions: %s\n", strings.Join(skippedFunctions, ", ")) - } api := function.NewEdgeRuntimeAPI(projectRef, *utils.GetSupabase(), NewDockerBundler(fsys)) if err := api.UpsertFunctions(ctx, functionConfig); err != nil { return err @@ -49,20 +49,25 @@ func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bo return nil } -func GetFunctionSlugs(fsys afero.Fs) ([]string, error) { +func GetFunctionSlugs(fsys afero.Fs) (slugs []string, disabledSlugs []string, err error) { pattern := filepath.Join(utils.FunctionsDir, "*", "index.ts") paths, err := afero.Glob(fsys, pattern) if err != nil { - return nil, errors.Errorf("failed to glob function slugs: %w", err) + return nil, nil, errors.Errorf("failed to glob function slugs: %w", err) } - var slugs []string for _, path := range paths { slug := filepath.Base(filepath.Dir(path)) if utils.FuncSlugPattern.MatchString(slug) { - slugs = append(slugs, slug) + functionConfig := utils.Config.Functions[slug] + // If the function config Enabled is not defined, or defined and set to true + if functionConfig.Enabled == nil || (functionConfig.Enabled != nil && *functionConfig.Enabled) { + slugs = append(slugs, slug) + } else { + disabledSlugs = append(disabledSlugs, slug) + } } } - return slugs, nil + return slugs, disabledSlugs, nil } func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, fsys afero.Fs) (config.FunctionConfig, error) { @@ -97,17 +102,3 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, } return functionConfig, nil } - -func FilterFunctionsToDeploy(functionsConfig config.FunctionConfig) (functionsToDeploy config.FunctionConfig, skippedFunctions []string) { - // Filter out all functions with NoDeploy set to true - functionsToDeploy = make(config.FunctionConfig) - skippedFunctions = []string{} - for slug, fc := range functionsConfig { - if !fc.NoDeploy { - functionsToDeploy[slug] = fc - } else { - skippedFunctions = append(skippedFunctions, slug) - } - } - return functionsToDeploy, skippedFunctions -} diff --git a/internal/functions/deploy/deploy_test.go b/internal/functions/deploy/deploy_test.go index ca5731323..adf49e63f 100644 --- a/internal/functions/deploy/deploy_test.go +++ b/internal/functions/deploy/deploy_test.go @@ -121,7 +121,7 @@ import_map = "./import_map.json" assert.Empty(t, apitest.ListUnmatchedRequests()) }) - t.Run("skip deploy functions from config", func(t *testing.T) { + t.Run("skip disabled functions from config", func(t *testing.T) { t.Cleanup(func() { clear(utils.Config.Functions) }) // Setup in-memory fs fsys := afero.NewMemMapFs() @@ -129,20 +129,18 @@ import_map = "./import_map.json" f, err := fsys.OpenFile(utils.ConfigPath, os.O_APPEND|os.O_WRONLY, 0600) require.NoError(t, err) _, err = f.WriteString(` -[functions.` + slug + `] +[functions.disabled-func] +enabled = false import_map = "./import_map.json" -no_deploy = true `) require.NoError(t, err) require.NoError(t, f.Close()) importMapPath, err := filepath.Abs(filepath.Join(utils.SupabaseDirPath, "import_map.json")) require.NoError(t, err) require.NoError(t, afero.WriteFile(fsys, importMapPath, []byte("{}"), 0644)) - // Setup function entrypoint - entrypointPath := filepath.Join(utils.FunctionsDir, slug, "index.ts") - require.NoError(t, afero.WriteFile(fsys, entrypointPath, []byte{}, 0644)) - ignorePath := filepath.Join(utils.FunctionsDir, "_ignore", "index.ts") - require.NoError(t, afero.WriteFile(fsys, ignorePath, []byte{}, 0644)) + // Setup function entrypoints + require.NoError(t, afero.WriteFile(fsys, filepath.Join(utils.FunctionsDir, "enabled-func", "index.ts"), []byte{}, 0644)) + require.NoError(t, afero.WriteFile(fsys, filepath.Join(utils.FunctionsDir, "disabled-func", "index.ts"), []byte{}, 0644)) // Setup valid project ref project := apitest.RandomProjectRef() // Setup valid access token @@ -157,11 +155,16 @@ no_deploy = true Get("/v1/projects/" + project + "/functions"). Reply(http.StatusOK). JSON([]api.FunctionResponse{}) + gock.New(utils.DefaultApiHost). + Post("/v1/projects/"+project+"/functions"). + MatchParam("slug", "enabled-func"). + Reply(http.StatusCreated). + JSON(api.FunctionResponse{Id: "1"}) require.NoError(t, apitest.MockDocker(utils.Docker)) apitest.MockDockerStart(utils.Docker, imageUrl, containerId) require.NoError(t, apitest.MockDockerLogs(utils.Docker, containerId, "bundled")) // Setup output file - outputDir := filepath.Join(utils.TempDir, fmt.Sprintf(".output_%s", slug)) + outputDir := filepath.Join(utils.TempDir, ".output_enabled-func") require.NoError(t, afero.WriteFile(fsys, filepath.Join(outputDir, "output.eszip"), []byte(""), 0644)) // Run test err = Run(context.Background(), nil, project, nil, "", fsys) diff --git a/internal/functions/serve/serve.go b/internal/functions/serve/serve.go index 58bcef6ac..e2b0c91ae 100644 --- a/internal/functions/serve/serve.go +++ b/internal/functions/serve/serve.go @@ -209,18 +209,17 @@ func parseEnvFile(envFilePath string, fsys afero.Fs) ([]string, error) { } func populatePerFunctionConfigs(cwd, importMapPath string, noVerifyJWT *bool, fsys afero.Fs) ([]string, string, error) { - slugs, err := deploy.GetFunctionSlugs(fsys) + slugs, skippedFunctions, err := deploy.GetFunctionSlugs(fsys) if err != nil { return nil, "", err } + if len(skippedFunctions) > 0 { + fmt.Fprintf(utils.GetDebugLogger(), "Skipped serve the following functions: %s\n", strings.Join(skippedFunctions, ", ")) + } functionsConfig, err := deploy.GetFunctionConfig(slugs, importMapPath, noVerifyJWT, fsys) if err != nil { return nil, "", err } - functionsConfig, skippedFunctions := deploy.FilterFunctionsToDeploy(functionsConfig) - if len(skippedFunctions) > 0 { - fmt.Fprintf(utils.GetDebugLogger(), "Skipped serve the following functions: %s\n", strings.Join(skippedFunctions, ", ")) - } binds := []string{} for slug, fc := range functionsConfig { modules, err := deploy.GetBindMounts(cwd, utils.FunctionsDir, "", fc.Entrypoint, fc.ImportMap, fsys) diff --git a/pkg/config/config.go b/pkg/config/config.go index e1fb5eb9f..db441e9bc 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -409,10 +409,10 @@ type ( FunctionConfig map[string]function function struct { + Enabled *bool `toml:"enabled"` VerifyJWT *bool `toml:"verify_jwt" json:"verifyJWT"` ImportMap string `toml:"import_map" json:"importMapPath,omitempty"` Entrypoint string `json:"-"` - NoDeploy bool `toml:"no_deploy"` } analytics struct { From 4afe868c91271d639dde9279453a56fd7fbe9516 Mon Sep 17 00:00:00 2001 From: avallete Date: Tue, 17 Sep 2024 11:02:25 +0200 Subject: [PATCH 023/305] chore: extract enabled check into function --- internal/functions/deploy/deploy.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index 62b1b8fc6..bbdbaa965 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -58,9 +58,8 @@ func GetFunctionSlugs(fsys afero.Fs) (slugs []string, disabledSlugs []string, er for _, path := range paths { slug := filepath.Base(filepath.Dir(path)) if utils.FuncSlugPattern.MatchString(slug) { - functionConfig := utils.Config.Functions[slug] // If the function config Enabled is not defined, or defined and set to true - if functionConfig.Enabled == nil || (functionConfig.Enabled != nil && *functionConfig.Enabled) { + if isFunctionEnabled(slug) { slugs = append(slugs, slug) } else { disabledSlugs = append(disabledSlugs, slug) @@ -102,3 +101,12 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, } return functionConfig, nil } + +func isFunctionEnabled(slug string) bool { + functionConfig := utils.Config.Functions[slug] + // If the function config Enabled is not defined, or defined and set to true + if functionConfig.Enabled == nil || (functionConfig.Enabled != nil && *functionConfig.Enabled) { + return true + } + return false +} From 6184f7a940f63268bda6ba6adcf99caab62beb4b Mon Sep 17 00:00:00 2001 From: avallete Date: Tue, 17 Sep 2024 11:03:18 +0200 Subject: [PATCH 024/305] chore: remove redundant comment --- internal/functions/deploy/deploy.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index bbdbaa965..74f4a3e79 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -58,7 +58,6 @@ func GetFunctionSlugs(fsys afero.Fs) (slugs []string, disabledSlugs []string, er for _, path := range paths { slug := filepath.Base(filepath.Dir(path)) if utils.FuncSlugPattern.MatchString(slug) { - // If the function config Enabled is not defined, or defined and set to true if isFunctionEnabled(slug) { slugs = append(slugs, slug) } else { From 9c1b27a4ccc133270288f7dd19d33828e5e796e7 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Tue, 17 Sep 2024 17:38:18 +0200 Subject: [PATCH 025/305] fix: db test on SELinux enabled systems (#2683) --- internal/db/test/test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/db/test/test.go b/internal/db/test/test.go index 03aa3a548..263305736 100644 --- a/internal/db/test/test.go +++ b/internal/db/test/test.go @@ -67,7 +67,8 @@ func Run(ctx context.Context, testFiles []string, config pgconn.Config, fsys afe }() } // Use custom network when connecting to local database - hostConfig := container.HostConfig{Binds: binds} + // disable selinux via security-opt to allow pg-tap to work properly + hostConfig := container.HostConfig{Binds: binds, SecurityOpt: []string{"label:disable"}} if utils.IsLocalDatabase(config) { config.Host = utils.DbAliases[0] config.Port = 5432 From 3419c0dd9a3001c3925e564b6f7315338bc24c8a Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Wed, 18 Sep 2024 10:49:00 +0200 Subject: [PATCH 026/305] chore: Apply suggestions from code review Co-authored-by: Han Qiao --- internal/functions/deploy/deploy.go | 5 +---- internal/functions/serve/serve.go | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index 74f4a3e79..3abe74f49 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -104,8 +104,5 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, func isFunctionEnabled(slug string) bool { functionConfig := utils.Config.Functions[slug] // If the function config Enabled is not defined, or defined and set to true - if functionConfig.Enabled == nil || (functionConfig.Enabled != nil && *functionConfig.Enabled) { - return true - } - return false + return functionConfig.Enabled == nil || functionConfig.Enabled } diff --git a/internal/functions/serve/serve.go b/internal/functions/serve/serve.go index e2b0c91ae..316f7c4a6 100644 --- a/internal/functions/serve/serve.go +++ b/internal/functions/serve/serve.go @@ -214,7 +214,7 @@ func populatePerFunctionConfigs(cwd, importMapPath string, noVerifyJWT *bool, fs return nil, "", err } if len(skippedFunctions) > 0 { - fmt.Fprintf(utils.GetDebugLogger(), "Skipped serve the following functions: %s\n", strings.Join(skippedFunctions, ", ")) + fmt.Fprintf(utils.GetDebugLogger(), "Skipped serving the following functions: %s\n", strings.Join(skippedFunctions, ", ")) } functionsConfig, err := deploy.GetFunctionConfig(slugs, importMapPath, noVerifyJWT, fsys) if err != nil { From 963a71e313fe746e4e8011b336d315657605df16 Mon Sep 17 00:00:00 2001 From: avallete Date: Wed, 18 Sep 2024 11:46:15 +0200 Subject: [PATCH 027/305] chore: fix dereference --- internal/functions/deploy/deploy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index 3abe74f49..fbed1313c 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -104,5 +104,5 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, func isFunctionEnabled(slug string) bool { functionConfig := utils.Config.Functions[slug] // If the function config Enabled is not defined, or defined and set to true - return functionConfig.Enabled == nil || functionConfig.Enabled + return functionConfig.Enabled == nil || *functionConfig.Enabled } From 044ba619c3f846426e294125421df8653f9b8e39 Mon Sep 17 00:00:00 2001 From: avallete Date: Thu, 19 Sep 2024 15:32:24 +0200 Subject: [PATCH 028/305] chore: start command validate exclude arguments When providing --exclude flags, check the arguments match actuals images names show a warning otherwise. Also fix a bug where stack couldnt start if storage was enabled in config but excluded in the arguments Related: https://www.notion.so/supabase/exclude-doesnt-seem-to-work-f38b8444b62f4308aef657a52d51692b --- internal/start/start.go | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/internal/start/start.go b/internal/start/start.go index 1a2226832..b6eeb654c 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -10,6 +10,7 @@ import ( "os" "path" "path/filepath" + "sort" "strconv" "strings" "text/template" @@ -43,9 +44,39 @@ func suggestUpdateCmd(serviceImages map[string]string) string { return cmd } +func validateExcludedContainers(excludedContainers []string) { + // Validate excluded containers + validContainers := ExcludableContainers() + var invalidContainers []string + + for _, e := range excludedContainers { + found := false + for _, v := range validContainers { + if strings.EqualFold(e, v) { + found = true + break + } + } + if !found { + invalidContainers = append(invalidContainers, e) + } + } + + if len(invalidContainers) > 0 { + // Sort the names list so it's easier to visually spot the one you looking for + sort.Strings(validContainers) + warning := fmt.Sprintf("%s The following container names are not valid to exclude: %s\nValid containers to exclude are: %s\n", + utils.Yellow("Warning:"), + utils.Aqua(strings.Join(invalidContainers, ", ")), + utils.Aqua(strings.Join(validContainers, ", "))) + fmt.Fprint(os.Stderr, warning) + } +} + func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string, ignoreHealthCheck bool) error { // Sanity checks. { + validateExcludedContainers(excludedContainers) if err := utils.LoadConfigFS(fsys); err != nil { return err } @@ -189,6 +220,7 @@ func run(p utils.Program, ctx context.Context, fsys afero.Fs, excludedContainers } var started []string + var isStorageEnabled = utils.Config.Storage.Enabled && !isContainerExcluded(utils.Config.Storage.Image, excluded) p.Send(utils.StatusMsg("Starting containers...")) // Start Logflare @@ -827,7 +859,7 @@ EOF } // Start Storage. - if utils.Config.Storage.Enabled && !isContainerExcluded(utils.Config.Storage.Image, excluded) { + if isStorageEnabled && !isContainerExcluded(utils.Config.Storage.Image, excluded) { dockerStoragePath := "/mnt" if _, err := utils.DockerStart( ctx, @@ -885,7 +917,7 @@ EOF } // Start Storage ImgProxy. - if utils.Config.Storage.Enabled && utils.Config.Storage.ImageTransformation.Enabled && !isContainerExcluded(utils.Config.Storage.ImageTransformation.Image, excluded) { + if isStorageEnabled && utils.Config.Storage.ImageTransformation.Enabled && !isContainerExcluded(utils.Config.Storage.ImageTransformation.Image, excluded) { if _, err := utils.DockerStart( ctx, container.Config{ From d660a36491712ee96a4abbb11351aa9fb2762f24 Mon Sep 17 00:00:00 2001 From: avallete Date: Fri, 20 Sep 2024 09:19:49 +0200 Subject: [PATCH 029/305] chore: apply PR comments --- cmd/start.go | 34 ++++++++++++++++++++++++++++++++++ internal/start/start.go | 33 +-------------------------------- 2 files changed, 35 insertions(+), 32 deletions(-) diff --git a/cmd/start.go b/cmd/start.go index b3cba1a4c..3d51298dc 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -1,13 +1,46 @@ package cmd import ( + "fmt" + "os" + "sort" "strings" "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/supabase/cli/internal/start" + "github.com/supabase/cli/internal/utils" ) +func validateExcludedContainers(excludedContainers []string) { + // Validate excluded containers + validContainers := start.ExcludableContainers() + var invalidContainers []string + + for _, e := range excludedContainers { + found := false + for _, v := range validContainers { + if strings.EqualFold(e, v) { + found = true + break + } + } + if !found { + invalidContainers = append(invalidContainers, e) + } + } + + if len(invalidContainers) > 0 { + // Sort the names list so it's easier to visually spot the one you looking for + sort.Strings(validContainers) + warning := fmt.Sprintf("%s The following container names are not valid to exclude: %s\nValid containers to exclude are: %s\n", + utils.Yellow("Warning:"), + utils.Aqua(strings.Join(invalidContainers, ", ")), + utils.Aqua(strings.Join(validContainers, ", "))) + fmt.Fprint(os.Stderr, warning) + } +} + var ( allowedContainers = start.ExcludableContainers() excludedContainers []string @@ -19,6 +52,7 @@ var ( Use: "start", Short: "Start containers for Supabase local development", RunE: func(cmd *cobra.Command, args []string) error { + validateExcludedContainers(excludedContainers) return start.Run(cmd.Context(), afero.NewOsFs(), excludedContainers, ignoreHealthCheck) }, } diff --git a/internal/start/start.go b/internal/start/start.go index b6eeb654c..09dd294b7 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -10,7 +10,6 @@ import ( "os" "path" "path/filepath" - "sort" "strconv" "strings" "text/template" @@ -44,39 +43,9 @@ func suggestUpdateCmd(serviceImages map[string]string) string { return cmd } -func validateExcludedContainers(excludedContainers []string) { - // Validate excluded containers - validContainers := ExcludableContainers() - var invalidContainers []string - - for _, e := range excludedContainers { - found := false - for _, v := range validContainers { - if strings.EqualFold(e, v) { - found = true - break - } - } - if !found { - invalidContainers = append(invalidContainers, e) - } - } - - if len(invalidContainers) > 0 { - // Sort the names list so it's easier to visually spot the one you looking for - sort.Strings(validContainers) - warning := fmt.Sprintf("%s The following container names are not valid to exclude: %s\nValid containers to exclude are: %s\n", - utils.Yellow("Warning:"), - utils.Aqua(strings.Join(invalidContainers, ", ")), - utils.Aqua(strings.Join(validContainers, ", "))) - fmt.Fprint(os.Stderr, warning) - } -} - func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string, ignoreHealthCheck bool) error { // Sanity checks. { - validateExcludedContainers(excludedContainers) if err := utils.LoadConfigFS(fsys); err != nil { return err } @@ -859,7 +828,7 @@ EOF } // Start Storage. - if isStorageEnabled && !isContainerExcluded(utils.Config.Storage.Image, excluded) { + if isStorageEnabled { dockerStoragePath := "/mnt" if _, err := utils.DockerStart( ctx, From cf504abf6ac82c45f1681eadc8c25e60cfe28d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Caba=C3=A7o?= Date: Fri, 20 Sep 2024 14:10:53 +0100 Subject: [PATCH 030/305] feat(realtime): add longpoll route to kong (#2506) realtime: Add longpoll route --- internal/start/templates/kong.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/start/templates/kong.yml b/internal/start/templates/kong.yml index 3865eba1c..8f1d28fd8 100644 --- a/internal/start/templates/kong.yml +++ b/internal/start/templates/kong.yml @@ -76,7 +76,7 @@ services: headers: - "Content-Profile: graphql_public" - name: realtime-v1-ws - _comment: "Realtime: /realtime/v1/* -> ws://realtime:4000/socket/*" + _comment: "Realtime: /realtime/v1/* -> ws://realtime:4000/socket/websocket" url: http://{{ .RealtimeId }}:4000/socket protocol: ws routes: @@ -86,6 +86,17 @@ services: - /realtime/v1/ plugins: - name: cors + - name: realtime-v1-longpoll + _comment: "Realtime: /realtime/v1/* -> ws://realtime:4000/socket/longpoll" + url: http://{{ .RealtimeId }}:4000/socket + protocol: http + routes: + - name: realtime-v1-longpoll + strip_path: true + paths: + - /realtime/v1/ + plugins: + - name: cors - name: realtime-v1-rest _comment: "Realtime: /realtime/v1/* -> http://realtime:4000/api/*" url: http://{{ .RealtimeId }}:4000/api From a66a39086b1a1820dc90d1ffa6f2a4302eefb00b Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Fri, 20 Sep 2024 15:17:44 +0200 Subject: [PATCH 031/305] chore: apply comment update cmd/start.go Co-authored-by: Han Qiao --- cmd/start.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cmd/start.go b/cmd/start.go index 3d51298dc..ae3faf01e 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -18,14 +18,7 @@ func validateExcludedContainers(excludedContainers []string) { var invalidContainers []string for _, e := range excludedContainers { - found := false - for _, v := range validContainers { - if strings.EqualFold(e, v) { - found = true - break - } - } - if !found { + if !utils.SliceContains(validContainers, e) { invalidContainers = append(invalidContainers, e) } } From a0a5d5f136d2caabc0af639b5957e689dfe46c21 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Fri, 20 Sep 2024 16:24:58 +0200 Subject: [PATCH 032/305] fix: the container ulimits for reatime (#2694) * fix: set the container Ressource Ulimits according to env variables * chore: refactor extract logic in it's own function * chore: fix invalid condition * fix: remove RLIMIT for dev container * fix: use undefined RLIMIT_NOFILE --- internal/db/start/start.go | 2 +- internal/start/start.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/db/start/start.go b/internal/db/start/start.go index e7f03fd61..3039b04d9 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -237,7 +237,7 @@ func initRealtimeJob(host string) utils.DockerJob { "SECRET_KEY_BASE=" + utils.Config.Realtime.SecretKeyBase, "ERL_AFLAGS=" + utils.ToRealtimeEnv(utils.Config.Realtime.IpVersion), "DNS_NODES=''", - "RLIMIT_NOFILE=10000", + "RLIMIT_NOFILE=", "SEED_SELF_HOST=true", fmt.Sprintf("MAX_HEADER_LENGTH=%d", utils.Config.Realtime.MaxHeaderLength), }, diff --git a/internal/start/start.go b/internal/start/start.go index 09dd294b7..2c3017ce5 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -760,7 +760,7 @@ EOF "SECRET_KEY_BASE=" + utils.Config.Realtime.SecretKeyBase, "ERL_AFLAGS=" + utils.ToRealtimeEnv(utils.Config.Realtime.IpVersion), "DNS_NODES=''", - "RLIMIT_NOFILE=10000", + "RLIMIT_NOFILE=", "SEED_SELF_HOST=true", fmt.Sprintf("MAX_HEADER_LENGTH=%d", utils.Config.Realtime.MaxHeaderLength), }, From cd94f35483131d541920cbe581280e223684f3c2 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Sat, 21 Sep 2024 17:19:06 +0800 Subject: [PATCH 033/305] fix: handle version prefix in globals (#2701) --- pkg/migration/seed.go | 8 ++++++-- pkg/migration/seed_test.go | 4 ++-- pkg/migration/testdata/{globals.sql => 1_globals.sql} | 0 3 files changed, 8 insertions(+), 4 deletions(-) rename pkg/migration/testdata/{globals.sql => 1_globals.sql} (100%) diff --git a/pkg/migration/seed.go b/pkg/migration/seed.go index 79b2dbc22..f299e9f05 100644 --- a/pkg/migration/seed.go +++ b/pkg/migration/seed.go @@ -28,9 +28,13 @@ func SeedGlobals(ctx context.Context, pending []string, conn *pgx.Conn, fsys fs. for _, path := range pending { filename := filepath.Base(path) fmt.Fprintf(os.Stderr, "Seeding globals from %s...\n", filename) - if globals, err := NewMigrationFromFile(path, fsys); err != nil { + globals, err := NewMigrationFromFile(path, fsys) + if err != nil { return err - } else if err := globals.ExecBatch(ctx, conn); err != nil { + } + // Skip inserting to migration history + globals.Version = "" + if err := globals.ExecBatch(ctx, conn); err != nil { return err } } diff --git a/pkg/migration/seed_test.go b/pkg/migration/seed_test.go index cf88a818f..e81d814a9 100644 --- a/pkg/migration/seed_test.go +++ b/pkg/migration/seed_test.go @@ -52,11 +52,11 @@ func TestSeedData(t *testing.T) { }) } -//go:embed testdata/globals.sql +//go:embed testdata/1_globals.sql var testGlobals string func TestSeedGlobals(t *testing.T) { - pending := []string{"testdata/globals.sql"} + pending := []string{"testdata/1_globals.sql"} t.Run("seeds from file", func(t *testing.T) { // Setup mock postgres diff --git a/pkg/migration/testdata/globals.sql b/pkg/migration/testdata/1_globals.sql similarity index 100% rename from pkg/migration/testdata/globals.sql rename to pkg/migration/testdata/1_globals.sql From d4b920a16b1a5496dc864ae5f48f235184fdc9aa Mon Sep 17 00:00:00 2001 From: Crispy1975 <12525875+Crispy1975@users.noreply.github.com> Date: Tue, 17 Sep 2024 14:46:35 +0100 Subject: [PATCH 034/305] chore: remove cname swap message as it is no longer a requirement --- internal/hostnames/common.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/hostnames/common.go b/internal/hostnames/common.go index 4ec371da7..0105c95d1 100644 --- a/internal/hostnames/common.go +++ b/internal/hostnames/common.go @@ -128,7 +128,7 @@ Please ensure that your custom domain is set up as a CNAME record to your Supaba records = fmt.Sprintf("\n\t%s TXT -> %s", owner.Name, owner.Value) } if ssl[0].TxtName != "" { - records = fmt.Sprintf("%s\n\t%s TXT -> %s (replace any existing CNAME records)", records, ssl[0].TxtName, ssl[0].TxtValue) + records = fmt.Sprintf("%s\n\t%s TXT -> %s", records, ssl[0].TxtName, ssl[0].TxtValue) } status := fmt.Sprintf("Custom hostname verification in-progress; please configure the appropriate DNS entries and request re-verification.\n"+ "Required outstanding validation records: %s\n", From 570158335c9dfdcaef5f455f5dc428ccd8fc779f Mon Sep 17 00:00:00 2001 From: Crispy1975 <12525875+Crispy1975@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:42:45 +0100 Subject: [PATCH 035/305] fix: ensure the cli and ui flow for custom domains match --- internal/hostnames/common.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/internal/hostnames/common.go b/internal/hostnames/common.go index 0105c95d1..c01e6a0da 100644 --- a/internal/hostnames/common.go +++ b/internal/hostnames/common.go @@ -104,7 +104,6 @@ Please ensure that your custom domain is set up as a CNAME record to your Supaba if err != nil { return "", errors.Errorf("failed to deserialize body: %w", err) } - owner := res.Result.OwnershipVerification ssl := res.Result.Ssl.ValidationRecords if res.Result.Ssl.Status == "initializing" { return appendRawOutputIfNeeded("Custom hostname setup is being initialized; please request re-verification in a few seconds.\n", response, includeRawOutput), nil @@ -124,9 +123,6 @@ Please ensure that your custom domain is set up as a CNAME record to your Supaba return "", errors.Errorf("expected a single SSL verification record, received: %+v", ssl) } records := "" - if owner.Name != "" { - records = fmt.Sprintf("\n\t%s TXT -> %s", owner.Name, owner.Value) - } if ssl[0].TxtName != "" { records = fmt.Sprintf("%s\n\t%s TXT -> %s", records, ssl[0].TxtName, ssl[0].TxtValue) } From 01256a1721f04e3bd8e032340a530870c7d67539 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Tue, 24 Sep 2024 17:19:42 +0800 Subject: [PATCH 036/305] feat: support remote config overrides (#2704) * feat: setup basics for branch config override * fix: use pointers for falsy values to determine emptyness * chore: refactor turn Auth.EnableSignup into pointer * wip: attemps non pointer approach * fix: use direct toml parsing to distinguish undefined values * chore: restore gomod * chore: refactor to a single function leverage mergo * chore: fix lint * fix: add branch override logic to LoadConfigFs * fix: inverted logic * chore: add env branch override test * chore: add test for slices merging * chore: remote config overrides * chore: validate project id * Apply suggestions from code review Co-authored-by: Andrew Valleteau --------- Co-authored-by: avallete Co-authored-by: Andrew Valleteau --- pkg/config/config.go | 57 +++++++++++++++++++++++++++++---- pkg/config/config_test.go | 35 ++++++++++++++++++++ pkg/config/testdata/config.toml | 14 ++++++++ 3 files changed, 99 insertions(+), 7 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index db441e9bc..18414546a 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -9,6 +9,7 @@ import ( "fmt" "io" "io/fs" + "maps" "net" "net/http" "net/url" @@ -119,7 +120,8 @@ func (c CustomClaims) NewToken() *jwt.Token { // // Default values for internal configs should be added to `var Config` initializer. type ( - config struct { + // Common config fields between our "base" config and any "remote" branch specific + baseConfig struct { ProjectId string `toml:"project_id"` Hostname string `toml:"-"` Api api `toml:"api"` @@ -135,6 +137,12 @@ type ( Experimental experimental `toml:"experimental" mapstructure:"-"` } + config struct { + baseConfig + Overrides map[string]interface{} `toml:"remotes"` + Remotes map[string]baseConfig `toml:"-"` + } + api struct { Enabled bool `toml:"enabled"` Image string `toml:"-"` @@ -438,6 +446,16 @@ type ( } ) +func (c *baseConfig) Clone() baseConfig { + copy := *c + copy.Storage.Buckets = maps.Clone(c.Storage.Buckets) + copy.Functions = maps.Clone(c.Functions) + copy.Auth.External = maps.Clone(c.Auth.External) + copy.Auth.Email.Template = maps.Clone(c.Auth.Email.Template) + copy.Auth.Sms.TestOTP = maps.Clone(c.Auth.Sms.TestOTP) + return copy +} + type ConfigEditor func(*config) func WithHostname(hostname string) ConfigEditor { @@ -447,7 +465,7 @@ func WithHostname(hostname string) ConfigEditor { } func NewConfig(editors ...ConfigEditor) config { - initial := config{ + initial := config{baseConfig: baseConfig{ Hostname: "127.0.0.1", Api: api{ Image: postgrestImage, @@ -543,7 +561,7 @@ func NewConfig(editors ...ConfigEditor) config { EdgeRuntime: edgeRuntime{ Image: edgeRuntimeImage, }, - } + }} for _, apply := range editors { apply(&initial) } @@ -587,7 +605,6 @@ func (c *config) Load(path string, fsys fs.FS) error { if _, err := dec.Decode(c); err != nil { return errors.Errorf("failed to decode config template: %w", err) } - // Load user defined config if metadata, err := toml.DecodeFS(fsys, builder.ConfigPath, c); err != nil { cwd, osErr := os.Getwd() if osErr != nil { @@ -595,7 +612,11 @@ func (c *config) Load(path string, fsys fs.FS) error { } return errors.Errorf("cannot read config in %s: %w", cwd, err) } else if undecoded := metadata.Undecoded(); len(undecoded) > 0 { - fmt.Fprintf(os.Stderr, "Unknown config fields: %+v\n", undecoded) + for _, key := range undecoded { + if key[0] != "remotes" { + fmt.Fprintf(os.Stderr, "Unknown config field: [%s]\n", key) + } + } } // Load secrets from .env file if err := loadDefaultEnv(); err != nil { @@ -685,10 +706,32 @@ func (c *config) Load(path string, fsys fs.FS) error { } c.Functions[slug] = function } - return c.Validate() + if err := c.baseConfig.Validate(); err != nil { + return err + } + c.Remotes = make(map[string]baseConfig, len(c.Overrides)) + for name, remote := range c.Overrides { + base := c.baseConfig.Clone() + // Encode a toml file with only config overrides + var buf bytes.Buffer + if err := toml.NewEncoder(&buf).Encode(remote); err != nil { + return errors.Errorf("failed to encode map to TOML: %w", err) + } + // Decode overrides using base config as defaults + if metadata, err := toml.NewDecoder(&buf).Decode(&base); err != nil { + return errors.Errorf("failed to decode remote config: %w", err) + } else if undecoded := metadata.Undecoded(); len(undecoded) > 0 { + fmt.Fprintf(os.Stderr, "Unknown config fields: %+v\n", undecoded) + } + if err := base.Validate(); err != nil { + return err + } + c.Remotes[name] = base + } + return nil } -func (c *config) Validate() error { +func (c *baseConfig) Validate() error { if c.ProjectId == "" { return errors.New("Missing required field in config: project_id") } else if sanitized := sanitizeProjectId(c.ProjectId); sanitized != c.ProjectId { diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 29a605059..733b3c7b7 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -55,6 +55,41 @@ func TestConfigParsing(t *testing.T) { // Run test assert.Error(t, config.Load("", fsys)) }) + + t.Run("config file with remotes", func(t *testing.T) { + config := NewConfig() + // Setup in-memory fs + fsys := fs.MapFS{ + "supabase/config.toml": &fs.MapFile{Data: testInitConfigEmbed}, + "supabase/templates/invite.html": &fs.MapFile{}, + } + // Run test + t.Setenv("TWILIO_AUTH_TOKEN", "token") + t.Setenv("AZURE_CLIENT_ID", "hello") + t.Setenv("AZURE_SECRET", "this is cool") + t.Setenv("AUTH_SEND_SMS_SECRETS", "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw==") + t.Setenv("SENDGRID_API_KEY", "sendgrid") + assert.NoError(t, config.Load("", fsys)) + // Check the default value in the config + assert.Equal(t, "http://127.0.0.1:3000", config.Auth.SiteUrl) + assert.Equal(t, true, config.Auth.EnableSignup) + assert.Equal(t, true, config.Auth.External["azure"].Enabled) + assert.Equal(t, []string{"image/png", "image/jpeg"}, config.Storage.Buckets["images"].AllowedMimeTypes) + // Check the values for remotes override + production, ok := config.Remotes["production"] + assert.True(t, ok) + staging, ok := config.Remotes["staging"] + assert.True(t, ok) + // Check the values for production override + assert.Equal(t, config.ProjectId, production.ProjectId) + assert.Equal(t, "http://feature-auth-branch.com/", production.Auth.SiteUrl) + assert.Equal(t, false, production.Auth.EnableSignup) + assert.Equal(t, false, production.Auth.External["azure"].Enabled) + assert.Equal(t, "nope", production.Auth.External["azure"].ClientId) + // Check the values for the staging override + assert.Equal(t, "staging-project", staging.ProjectId) + assert.Equal(t, []string{"image/png"}, staging.Storage.Buckets["images"].AllowedMimeTypes) + }) } func TestFileSizeLimitConfigParsing(t *testing.T) { diff --git a/pkg/config/testdata/config.toml b/pkg/config/testdata/config.toml index f7061c1e7..a7aa36544 100644 --- a/pkg/config/testdata/config.toml +++ b/pkg/config/testdata/config.toml @@ -217,3 +217,17 @@ s3_region = "ap-southeast-1" s3_access_key = "" # Configures AWS_SECRET_ACCESS_KEY for S3 bucket s3_secret_key = "" + +[remotes.production.auth] +site_url = "http://feature-auth-branch.com/" +enable_signup = false + +[remotes.production.auth.external.azure] +enabled = false +client_id = "nope" + +[remotes.staging] +project_id = "staging-project" + +[remotes.staging.storage.buckets.images] +allowed_mime_types = ["image/png"] From 11c5004fcbe963aae9e7a48e3884018d179a1a95 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Tue, 24 Sep 2024 12:05:22 +0200 Subject: [PATCH 037/305] fix: disable security opts for db test on bitbucket runner (#2705) hotfix(cli): disable security opts for db test on bitbucket runner --- internal/utils/docker.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/utils/docker.go b/internal/utils/docker.go index 80106583b..6264c4056 100644 --- a/internal/utils/docker.go +++ b/internal/utils/docker.go @@ -287,6 +287,9 @@ func DockerStart(ctx context.Context, config container.Config, hostConfig contai // Skip named volume for BitBucket pipeline if os.Getenv("BITBUCKET_CLONE_DIR") != "" { hostConfig.Binds = binds + // Bitbucket doesn't allow for --security-opt option to be set + // https://support.atlassian.com/bitbucket-cloud/docs/run-docker-commands-in-bitbucket-pipelines/#Full-list-of-restricted-commands + hostConfig.SecurityOpt = nil } else { // Create named volumes with labels for _, name := range sources { From 2ad2d330be6a0b8e74041f7bf725fdeff39a0358 Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Tue, 24 Sep 2024 14:49:29 +0200 Subject: [PATCH 038/305] fix: Bump studio to the latest image version 20240923 (#2706) Update studio version to 20240923 --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 93331225a..d75ce61bc 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -10,7 +10,7 @@ const ( inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" pgmetaImage = "supabase/postgres-meta:v0.83.2" - studioImage = "supabase/studio:20240729-ce42139" + studioImage = "supabase/studio:20240923-2e3e90c" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.58.3" vectorImage = "timberio/vector:0.28.1-alpine" From bb28463e6b75264dc97b2874a4b15d3561c23152 Mon Sep 17 00:00:00 2001 From: avallete Date: Tue, 24 Sep 2024 10:58:37 +0200 Subject: [PATCH 039/305] chore: use _supabase database for internals This is to avoid overloading our user postgres database with every new addition to _analytics or _realtime --- internal/db/dump/dump.go | 3 --- internal/db/reset/reset.go | 2 ++ internal/db/start/start.go | 2 +- internal/db/start/templates/schema.sql | 24 ++++++++++++++++-------- internal/start/start.go | 8 ++++---- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/internal/db/dump/dump.go b/internal/db/dump/dump.go index a52b1dc41..e75cbb8b9 100644 --- a/internal/db/dump/dump.go +++ b/internal/db/dump/dump.go @@ -100,9 +100,6 @@ func dumpData(ctx context.Context, config pgconn.Config, schema, excludeTable [] // "storage", // "supabase_functions", "supabase_migrations", - "_analytics", - "_realtime", - "_supavisor", } var env []string if len(schema) > 0 { diff --git a/internal/db/reset/reset.go b/internal/db/reset/reset.go index 62c3d3350..89a33fda5 100644 --- a/internal/db/reset/reset.go +++ b/internal/db/reset/reset.go @@ -170,7 +170,9 @@ func recreateDatabase(ctx context.Context, options ...func(*pgx.ConnConfig)) err sql := migration.MigrationFile{ Statements: []string{ "DROP DATABASE IF EXISTS postgres WITH (FORCE)", + "DROP DATABASE IF EXISTS _supabase WITH (FORCE)", "CREATE DATABASE postgres WITH OWNER postgres", + "CREATE DATABASE _supabase WITH OWNER postgres", }, } return sql.ExecBatch(ctx, conn) diff --git a/internal/db/start/start.go b/internal/db/start/start.go index 3039b04d9..c25aa24e1 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -228,7 +228,7 @@ func initRealtimeJob(host string) utils.DockerJob { "DB_PORT=5432", "DB_USER=supabase_admin", "DB_PASSWORD=" + utils.Config.Db.Password, - "DB_NAME=postgres", + "DB_NAME=_supabase", "DB_AFTER_CONNECT_QUERY=SET search_path TO _realtime", "DB_ENC_KEY=" + utils.Config.Realtime.EncryptionKey, "API_JWT_SECRET=" + utils.Config.Auth.JwtSecret, diff --git a/internal/db/start/templates/schema.sql b/internal/db/start/templates/schema.sql index 0d0010231..418f0ee05 100644 --- a/internal/db/start/templates/schema.sql +++ b/internal/db/start/templates/schema.sql @@ -12,14 +12,22 @@ ALTER USER supabase_storage_admin WITH PASSWORD :'pgpass'; ALTER USER supabase_replication_admin WITH PASSWORD :'pgpass'; ALTER USER supabase_read_only_user WITH PASSWORD :'pgpass'; -create schema if not exists _realtime; -alter schema _realtime owner to postgres; - -create schema if not exists _analytics; -alter schema _analytics owner to postgres; - -create schema if not exists _supavisor; -alter schema _supavisor owner to postgres; +CREATE DATABASE _supabase WITH OWNER postgres; +-- Connect to the _supabase database +\c _supabase +-- Create schemas in _supabase database for +-- internals tools and reports to not overload user database +-- with non-user activity +CREATE SCHEMA IF NOT EXISTS _realtime; +ALTER SCHEMA _realtime OWNER TO postgres; + +CREATE SCHEMA IF NOT EXISTS _analytics; +ALTER SCHEMA _analytics OWNER TO postgres; + +CREATE SCHEMA IF NOT EXISTS _supavisor; +ALTER SCHEMA _supavisor OWNER TO postgres; +-- Switch back to the main database +\c postgres BEGIN; diff --git a/internal/start/start.go b/internal/start/start.go index 2c3017ce5..413b8e2ed 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -195,7 +195,7 @@ func run(p utils.Program, ctx context.Context, fsys afero.Fs, excludedContainers // Start Logflare if utils.Config.Analytics.Enabled && !isContainerExcluded(utils.Config.Analytics.Image, excluded) { env := []string{ - "DB_DATABASE=" + dbConfig.Database, + "DB_DATABASE=_supabase", "DB_HOSTNAME=" + dbConfig.Host, fmt.Sprintf("DB_PORT=%d", dbConfig.Port), "DB_SCHEMA=_analytics", @@ -228,7 +228,7 @@ func run(p utils.Program, ctx context.Context, fsys afero.Fs, excludedContainers ) case config.LogflarePostgres: env = append(env, - fmt.Sprintf("POSTGRES_BACKEND_URL=postgresql://%s:%s@%s:%d/%s", dbConfig.User, dbConfig.Password, dbConfig.Host, dbConfig.Port, dbConfig.Database), + fmt.Sprintf("POSTGRES_BACKEND_URL=postgresql://%s:%s@%s:%d/%s", dbConfig.User, dbConfig.Password, dbConfig.Host, dbConfig.Port, "_supabase"), "POSTGRES_BACKEND_SCHEMA=_analytics", ) } @@ -750,7 +750,7 @@ EOF fmt.Sprintf("DB_PORT=%d", dbConfig.Port), "DB_USER=supabase_admin", "DB_PASSWORD=" + dbConfig.Password, - "DB_NAME=" + dbConfig.Database, + "DB_NAME=_supabase", "DB_AFTER_CONNECT_QUERY=SET search_path TO _realtime", "DB_ENC_KEY=" + utils.Config.Realtime.EncryptionKey, "API_JWT_SECRET=" + utils.Config.Auth.JwtSecret, @@ -1045,7 +1045,7 @@ EOF "PORT=4000", fmt.Sprintf("PROXY_PORT_SESSION=%d", portSession), fmt.Sprintf("PROXY_PORT_TRANSACTION=%d", portTransaction), - fmt.Sprintf("DATABASE_URL=ecto://%s:%s@%s:%d/%s", dbConfig.User, dbConfig.Password, dbConfig.Host, dbConfig.Port, dbConfig.Database), + fmt.Sprintf("DATABASE_URL=ecto://%s:%s@%s:%d/%s", dbConfig.User, dbConfig.Password, dbConfig.Host, dbConfig.Port, "_supabase"), "CLUSTER_POSTGRES=true", "SECRET_KEY_BASE=" + utils.Config.Db.Pooler.SecretKeyBase, "VAULT_ENC_KEY=" + utils.Config.Db.Pooler.EncryptionKey, From 5e946870f2127d6e4bbf55edc0b4252f08f12148 Mon Sep 17 00:00:00 2001 From: avallete Date: Tue, 24 Sep 2024 15:15:26 +0200 Subject: [PATCH 040/305] chore: fix tests mocks --- internal/db/reset/reset.go | 2 +- internal/db/reset/reset_test.go | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/db/reset/reset.go b/internal/db/reset/reset.go index 89a33fda5..d53392ae9 100644 --- a/internal/db/reset/reset.go +++ b/internal/db/reset/reset.go @@ -170,8 +170,8 @@ func recreateDatabase(ctx context.Context, options ...func(*pgx.ConnConfig)) err sql := migration.MigrationFile{ Statements: []string{ "DROP DATABASE IF EXISTS postgres WITH (FORCE)", - "DROP DATABASE IF EXISTS _supabase WITH (FORCE)", "CREATE DATABASE postgres WITH OWNER postgres", + "DROP DATABASE IF EXISTS _supabase WITH (FORCE)", "CREATE DATABASE _supabase WITH OWNER postgres", }, } diff --git a/internal/db/reset/reset_test.go b/internal/db/reset/reset_test.go index 03da968c5..ffb9898cf 100644 --- a/internal/db/reset/reset_test.go +++ b/internal/db/reset/reset_test.go @@ -145,6 +145,10 @@ func TestRecreateDatabase(t *testing.T) { Query("DROP DATABASE IF EXISTS postgres WITH (FORCE)"). Reply("DROP DATABASE"). Query("CREATE DATABASE postgres WITH OWNER postgres"). + Reply("CREATE DATABASE"). + Query("DROP DATABASE IF EXISTS _supabase WITH (FORCE)"). + Reply("DROP DATABASE"). + Query("CREATE DATABASE _supabase WITH OWNER postgres"). Reply("CREATE DATABASE") // Run test assert.NoError(t, recreateDatabase(context.Background(), conn.Intercept)) @@ -194,8 +198,11 @@ func TestRecreateDatabase(t *testing.T) { Reply("DO"). Query("DROP DATABASE IF EXISTS postgres WITH (FORCE)"). ReplyError(pgerrcode.ObjectInUse, `database "postgres" is used by an active logical replication slot`). - Query("CREATE DATABASE postgres WITH OWNER postgres") - // Run test + Query("CREATE DATABASE postgres WITH OWNER postgres"). + Query("DROP DATABASE IF EXISTS _supabase WITH (FORCE)"). + Reply("DROP DATABASE"). + Query("CREATE DATABASE _supabase WITH OWNER postgres"). + Reply("CREATE DATABASE") err := recreateDatabase(context.Background(), conn.Intercept) // Check error assert.ErrorContains(t, err, `ERROR: database "postgres" is used by an active logical replication slot (SQLSTATE 55006)`) From e6788f3bc03e91af979c000435cf6ba4610c3dcf Mon Sep 17 00:00:00 2001 From: avallete Date: Tue, 24 Sep 2024 18:03:41 +0200 Subject: [PATCH 041/305] chore: add realtime schema as well --- internal/db/start/templates/schema.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/db/start/templates/schema.sql b/internal/db/start/templates/schema.sql index 418f0ee05..45a936a2e 100644 --- a/internal/db/start/templates/schema.sql +++ b/internal/db/start/templates/schema.sql @@ -20,6 +20,8 @@ CREATE DATABASE _supabase WITH OWNER postgres; -- with non-user activity CREATE SCHEMA IF NOT EXISTS _realtime; ALTER SCHEMA _realtime OWNER TO postgres; +CREATE SCHEMA IF NOT EXISTS realtime; +ALTER SCHEMA realtime OWNER TO postgres; CREATE SCHEMA IF NOT EXISTS _analytics; ALTER SCHEMA _analytics OWNER TO postgres; From 76ef3d2d3ed394302a05bb67194aa30a0136ce87 Mon Sep 17 00:00:00 2001 From: avallete Date: Tue, 24 Sep 2024 19:25:36 +0200 Subject: [PATCH 042/305] fix: make the start work for postgres 14 and 13 --- internal/db/dump/dump.go | 4 ++++ internal/db/start/start.go | 11 +++++++++-- internal/db/start/templates/_supabase.sql | 18 ++++++++++++++++++ internal/db/start/templates/schema.sql | 19 ------------------- 4 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 internal/db/start/templates/_supabase.sql diff --git a/internal/db/dump/dump.go b/internal/db/dump/dump.go index e75cbb8b9..94e2ba7af 100644 --- a/internal/db/dump/dump.go +++ b/internal/db/dump/dump.go @@ -100,6 +100,10 @@ func dumpData(ctx context.Context, config pgconn.Config, schema, excludeTable [] // "storage", // "supabase_functions", "supabase_migrations", + // TODO: Remove in a few version in favor of _supabase internal db + "_analytics", + "_realtime", + "_supavisor", } var env []string if len(schema) > 0 { diff --git a/internal/db/start/start.go b/internal/db/start/start.go index c25aa24e1..8ed608ad7 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -29,6 +29,8 @@ var ( HealthTimeout = 120 * time.Second //go:embed templates/schema.sql initialSchema string + //go:embed templates/_supabase.sql + _supabaseSchema string ) func Run(ctx context.Context, fsys afero.Fs) error { @@ -82,7 +84,7 @@ func NewContainerConfig() container.Config { Retries: 3, }, Entrypoint: []string{"sh", "-c", `cat <<'EOF' > /etc/postgresql.schema.sql && cat <<'EOF' > /etc/postgresql-custom/pgsodium_root.key && docker-entrypoint.sh postgres -D /etc/postgresql -` + initialSchema + ` +` + initialSchema + "\n" + _supabaseSchema + "\n" + ` EOF ` + utils.Config.Db.RootKey + ` EOF @@ -122,7 +124,12 @@ func StartDatabase(ctx context.Context, fsys afero.Fs, w io.Writer, options ...f }, } if utils.Config.Db.MajorVersion <= 14 { - config.Entrypoint = nil + config.Entrypoint = []string{"sh", "-c", ` + cat <<'EOF' > /docker-entrypoint-initdb.d/supabase_schema.sql +` + _supabaseSchema + ` +EOF + docker-entrypoint.sh postgres -D /etc/postgresql + `} hostConfig.Tmpfs = map[string]string{"/docker-entrypoint-initdb.d": ""} } // Creating volume will not override existing volume, so we must inspect explicitly diff --git a/internal/db/start/templates/_supabase.sql b/internal/db/start/templates/_supabase.sql new file mode 100644 index 000000000..d391166a2 --- /dev/null +++ b/internal/db/start/templates/_supabase.sql @@ -0,0 +1,18 @@ +CREATE DATABASE _supabase WITH OWNER postgres; + +-- Switch to the newly created _supabase database +\c _supabase +-- Create schemas in _supabase database for +-- internals tools and reports to not overload user database +-- with non-user activity +CREATE SCHEMA IF NOT EXISTS _realtime; +ALTER SCHEMA _realtime OWNER TO postgres; +CREATE SCHEMA IF NOT EXISTS realtime; +ALTER SCHEMA realtime OWNER TO postgres; + +CREATE SCHEMA IF NOT EXISTS _analytics; +ALTER SCHEMA _analytics OWNER TO postgres; + +CREATE SCHEMA IF NOT EXISTS _supavisor; +ALTER SCHEMA _supavisor OWNER TO postgres; +\c postgres \ No newline at end of file diff --git a/internal/db/start/templates/schema.sql b/internal/db/start/templates/schema.sql index 45a936a2e..2ff6cf48f 100644 --- a/internal/db/start/templates/schema.sql +++ b/internal/db/start/templates/schema.sql @@ -12,25 +12,6 @@ ALTER USER supabase_storage_admin WITH PASSWORD :'pgpass'; ALTER USER supabase_replication_admin WITH PASSWORD :'pgpass'; ALTER USER supabase_read_only_user WITH PASSWORD :'pgpass'; -CREATE DATABASE _supabase WITH OWNER postgres; --- Connect to the _supabase database -\c _supabase --- Create schemas in _supabase database for --- internals tools and reports to not overload user database --- with non-user activity -CREATE SCHEMA IF NOT EXISTS _realtime; -ALTER SCHEMA _realtime OWNER TO postgres; -CREATE SCHEMA IF NOT EXISTS realtime; -ALTER SCHEMA realtime OWNER TO postgres; - -CREATE SCHEMA IF NOT EXISTS _analytics; -ALTER SCHEMA _analytics OWNER TO postgres; - -CREATE SCHEMA IF NOT EXISTS _supavisor; -ALTER SCHEMA _supavisor OWNER TO postgres; --- Switch back to the main database -\c postgres - BEGIN; -- Create pg_net extension From fd04d07c60c8634326975b27b962bd729eaff182 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Wed, 25 Sep 2024 08:28:05 +0200 Subject: [PATCH 043/305] feat: add custom seed path to config (#2702) * chore: replace SeedDataPath by DefaultSeedDataPath * wip: add path seed matching logic * chore: add test for utils.GetSeedFiles * chore: wip tests mock * chore: fix lint * chore: show seed path * chore: change comment * chore: apply pr suggestions * chore: fix lint * chore: keep default value assignation * chore: remove DefaultSeedPath * chore: keep consistent WARNING message * chore: inline get seed file path * chore: address review comments --------- Co-authored-by: Qiao Han --- cmd/db.go | 2 +- cmd/start.go | 2 +- internal/db/push/push.go | 6 ++- internal/db/push/push_test.go | 4 +- internal/db/reset/reset_test.go | 2 +- internal/db/start/start_test.go | 3 +- internal/init/init.go | 18 +------ internal/init/init_test.go | 13 ----- internal/migration/apply/apply.go | 8 +-- internal/migration/apply/apply_test.go | 10 ++-- internal/utils/misc.go | 22 +++++++- internal/utils/misc_test.go | 73 ++++++++++++++++++++++++++ pkg/config/config.go | 6 ++- pkg/config/templates/config.toml | 8 +++ pkg/config/testdata/config.toml | 8 +++ pkg/config/utils.go | 2 - pkg/migration/seed.go | 3 +- 17 files changed, 140 insertions(+), 50 deletions(-) diff --git a/cmd/db.go b/cmd/db.go index 2ddb4072f..2d64edd74 100644 --- a/cmd/db.go +++ b/cmd/db.go @@ -276,7 +276,7 @@ func init() { pushFlags := dbPushCmd.Flags() pushFlags.BoolVar(&includeAll, "include-all", false, "Include all migrations not found on remote history table.") pushFlags.BoolVar(&includeRoles, "include-roles", false, "Include custom roles from "+utils.CustomRolesPath+".") - pushFlags.BoolVar(&includeSeed, "include-seed", false, "Include seed data from "+utils.SeedDataPath+".") + pushFlags.BoolVar(&includeSeed, "include-seed", false, "Include seed data from your config.") pushFlags.BoolVar(&dryRun, "dry-run", false, "Print the migrations that would be applied, but don't actually apply them.") pushFlags.String("db-url", "", "Pushes to the database specified by the connection string (must be percent-encoded).") pushFlags.Bool("linked", true, "Pushes to the linked project.") diff --git a/cmd/start.go b/cmd/start.go index ae3faf01e..a7af80e0c 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -27,7 +27,7 @@ func validateExcludedContainers(excludedContainers []string) { // Sort the names list so it's easier to visually spot the one you looking for sort.Strings(validContainers) warning := fmt.Sprintf("%s The following container names are not valid to exclude: %s\nValid containers to exclude are: %s\n", - utils.Yellow("Warning:"), + utils.Yellow("WARNING:"), utils.Aqua(strings.Join(invalidContainers, ", ")), utils.Aqua(strings.Join(validContainers, ", "))) fmt.Fprint(os.Stderr, warning) diff --git a/internal/db/push/push.go b/internal/db/push/push.go index 68e3be9ac..0bff15163 100644 --- a/internal/db/push/push.go +++ b/internal/db/push/push.go @@ -41,7 +41,11 @@ func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, fmt.Fprintln(os.Stderr, "Would push these migrations:") fmt.Fprint(os.Stderr, utils.Bold(confirmPushAll(pending))) if includeSeed { - fmt.Fprintln(os.Stderr, "Would seed data "+utils.Bold(utils.SeedDataPath)+"...") + seedPaths, err := utils.GetSeedFiles(fsys) + if err != nil { + return err + } + fmt.Fprintf(os.Stderr, "Would seed data %v...\n", seedPaths) } } else { msg := fmt.Sprintf("Do you want to push these migrations to the remote database?\n%s\n", confirmPushAll(pending)) diff --git a/internal/db/push/push_test.go b/internal/db/push/push_test.go index e4f6353ec..72df15ef9 100644 --- a/internal/db/push/push_test.go +++ b/internal/db/push/push_test.go @@ -162,7 +162,9 @@ func TestPushAll(t *testing.T) { t.Run("throws error on seed failure", func(t *testing.T) { // Setup in-memory fs - fsys := &fstest.OpenErrorFs{DenyPath: utils.SeedDataPath} + seedPath := filepath.Join(utils.SupabaseDirPath, "seed.sql") + fsys := &fstest.OpenErrorFs{DenyPath: seedPath} + _, _ = fsys.Create(seedPath) path := filepath.Join(utils.MigrationsDir, "0_test.sql") require.NoError(t, afero.WriteFile(fsys, path, []byte{}, 0644)) // Setup mock postgres diff --git a/internal/db/reset/reset_test.go b/internal/db/reset/reset_test.go index 03da968c5..0be21f3b2 100644 --- a/internal/db/reset/reset_test.go +++ b/internal/db/reset/reset_test.go @@ -362,7 +362,7 @@ func TestResetRemote(t *testing.T) { fsys := afero.NewMemMapFs() path := filepath.Join(utils.MigrationsDir, "0_schema.sql") require.NoError(t, afero.WriteFile(fsys, path, nil, 0644)) - seedPath := filepath.Join(utils.SeedDataPath) + seedPath := filepath.Join(utils.SupabaseDirPath, "seed.sql") // Will raise an error when seeding require.NoError(t, afero.WriteFile(fsys, seedPath, []byte("INSERT INTO test_table;"), 0644)) // Setup mock postgres diff --git a/internal/db/start/start_test.go b/internal/db/start/start_test.go index dcc93b4c8..e4072df98 100644 --- a/internal/db/start/start_test.go +++ b/internal/db/start/start_test.go @@ -6,6 +6,7 @@ import ( "io" "net/http" "os" + "path/filepath" "testing" "github.com/docker/docker/api/types" @@ -60,7 +61,7 @@ func TestStartDatabase(t *testing.T) { roles := "create role test" require.NoError(t, afero.WriteFile(fsys, utils.CustomRolesPath, []byte(roles), 0644)) seed := "INSERT INTO employees(name) VALUES ('Alice')" - require.NoError(t, afero.WriteFile(fsys, utils.SeedDataPath, []byte(seed), 0644)) + require.NoError(t, afero.WriteFile(fsys, filepath.Join(utils.SupabaseDirPath, "seed.sql"), []byte(seed), 0644)) // Setup mock docker require.NoError(t, apitest.MockDocker(utils.Docker)) defer gock.OffAll() diff --git a/internal/init/init.go b/internal/init/init.go index 033638dd9..f4e470b02 100644 --- a/internal/init/init.go +++ b/internal/init/init.go @@ -40,19 +40,14 @@ func Run(ctx context.Context, fsys afero.Fs, createVscodeSettings, createIntelli return err } - // 2. Create `seed.sql`. - if err := initSeed(fsys); err != nil { - return err - } - - // 3. Append to `.gitignore`. + // 2. Append to `.gitignore`. if utils.IsGitRepo() { if err := updateGitIgnore(utils.GitIgnorePath, fsys); err != nil { return err } } - // 4. Generate VS Code settings. + // 3. Generate VS Code settings. if createVscodeSettings != nil { if *createVscodeSettings { return writeVscodeConfig(fsys) @@ -77,15 +72,6 @@ func Run(ctx context.Context, fsys afero.Fs, createVscodeSettings, createIntelli return nil } -func initSeed(fsys afero.Fs) error { - f, err := fsys.OpenFile(utils.SeedDataPath, os.O_WRONLY|os.O_CREATE, 0644) - if err != nil { - return errors.Errorf("failed to create seed file: %w", err) - } - defer f.Close() - return nil -} - func updateGitIgnore(ignorePath string, fsys afero.Fs) error { var contents []byte diff --git a/internal/init/init_test.go b/internal/init/init_test.go index 09bf6ab0f..47e35b89e 100644 --- a/internal/init/init_test.go +++ b/internal/init/init_test.go @@ -28,10 +28,6 @@ func TestInitCommand(t *testing.T) { exists, err = afero.Exists(fsys, utils.GitIgnorePath) assert.NoError(t, err) assert.True(t, exists) - // Validate generated seed.sql - exists, err = afero.Exists(fsys, utils.SeedDataPath) - assert.NoError(t, err) - assert.True(t, exists) // Validate vscode settings file isn't generated exists, err = afero.Exists(fsys, settingsPath) assert.NoError(t, err) @@ -70,15 +66,6 @@ func TestInitCommand(t *testing.T) { assert.Error(t, Run(context.Background(), fsys, nil, nil, utils.InitParams{})) }) - t.Run("throws error on seed failure", func(t *testing.T) { - // Setup in-memory fs - fsys := &fstest.OpenErrorFs{DenyPath: utils.SeedDataPath} - // Run test - err := Run(context.Background(), fsys, nil, nil, utils.InitParams{}) - // Check error - assert.ErrorIs(t, err, os.ErrPermission) - }) - t.Run("creates vscode settings file", func(t *testing.T) { // Setup in-memory fs fsys := &afero.MemMapFs{} diff --git a/internal/migration/apply/apply.go b/internal/migration/apply/apply.go index 44195297f..6796930d2 100644 --- a/internal/migration/apply/apply.go +++ b/internal/migration/apply/apply.go @@ -27,11 +27,11 @@ func MigrateAndSeed(ctx context.Context, version string, conn *pgx.Conn, fsys af } func SeedDatabase(ctx context.Context, conn *pgx.Conn, fsys afero.Fs) error { - err := migration.SeedData(ctx, []string{utils.SeedDataPath}, conn, afero.NewIOFS(fsys)) - if errors.Is(err, os.ErrNotExist) { - return nil + seedPaths, err := utils.GetSeedFiles(fsys) + if err != nil { + return err } - return err + return migration.SeedData(ctx, seedPaths, conn, afero.NewIOFS(fsys)) } func CreateCustomRoles(ctx context.Context, conn *pgx.Conn, fsys afero.Fs) error { diff --git a/internal/migration/apply/apply_test.go b/internal/migration/apply/apply_test.go index b8c041749..6c5b915fd 100644 --- a/internal/migration/apply/apply_test.go +++ b/internal/migration/apply/apply_test.go @@ -44,7 +44,7 @@ func TestMigrateDatabase(t *testing.T) { path := filepath.Join(utils.MigrationsDir, "0_test.sql") sql := "create schema public" require.NoError(t, afero.WriteFile(fsys, path, []byte(sql), 0644)) - seedPath := filepath.Join(utils.SeedDataPath) + seedPath := filepath.Join(utils.SupabaseDirPath, "seed.sql") // This will raise an error when seeding require.NoError(t, afero.WriteFile(fsys, seedPath, []byte("INSERT INTO test_table;"), 0644)) // Setup mock postgres @@ -82,7 +82,7 @@ func TestSeedDatabase(t *testing.T) { fsys := afero.NewMemMapFs() // Setup seed file sql := "INSERT INTO employees(name) VALUES ('Alice')" - require.NoError(t, afero.WriteFile(fsys, utils.SeedDataPath, []byte(sql), 0644)) + require.NoError(t, afero.WriteFile(fsys, filepath.Join(utils.SupabaseDirPath, "seed.sql"), []byte(sql), 0644)) // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) @@ -100,7 +100,9 @@ func TestSeedDatabase(t *testing.T) { t.Run("throws error on read failure", func(t *testing.T) { // Setup in-memory fs - fsys := &fstest.OpenErrorFs{DenyPath: utils.SeedDataPath} + seedPath := filepath.Join(utils.SupabaseDirPath, "seed.sql") + fsys := &fstest.OpenErrorFs{DenyPath: seedPath} + _, _ = fsys.Create(seedPath) // Run test err := SeedDatabase(context.Background(), nil, fsys) // Check error @@ -112,7 +114,7 @@ func TestSeedDatabase(t *testing.T) { fsys := afero.NewMemMapFs() // Setup seed file sql := "INSERT INTO employees(name) VALUES ('Alice')" - require.NoError(t, afero.WriteFile(fsys, utils.SeedDataPath, []byte(sql), 0644)) + require.NoError(t, afero.WriteFile(fsys, filepath.Join(utils.SupabaseDirPath, "seed.sql"), []byte(sql), 0644)) // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) diff --git a/internal/utils/misc.go b/internal/utils/misc.go index 8118b8213..d4e49f046 100644 --- a/internal/utils/misc.go +++ b/internal/utils/misc.go @@ -8,6 +8,7 @@ import ( "os" "path/filepath" "regexp" + "sort" "time" "github.com/docker/docker/client" @@ -148,7 +149,6 @@ var ( FallbackImportMapPath = filepath.Join(FunctionsDir, "import_map.json") FallbackEnvFilePath = filepath.Join(FunctionsDir, ".env") DbTestsDir = filepath.Join(SupabaseDirPath, "tests") - SeedDataPath = filepath.Join(SupabaseDirPath, "seed.sql") CustomRolesPath = filepath.Join(SupabaseDirPath, "roles.sql") ErrNotLinked = errors.Errorf("Cannot find project ref. Have you run %s?", Aqua("supabase link")) @@ -157,6 +157,26 @@ var ( ErrNotRunning = errors.Errorf("%s is not running.", Aqua("supabase start")) ) +// Match the glob patterns from the config to get a deduplicated +// array of all migrations files to apply in the declared order. +func GetSeedFiles(fsys afero.Fs) ([]string, error) { + seedPaths := Config.Db.Seed.SqlPaths + var files []string + for _, pattern := range seedPaths { + fullPattern := filepath.Join(SupabaseDirPath, pattern) + matches, err := afero.Glob(fsys, fullPattern) + if err != nil { + return nil, errors.Errorf("failed to apply glob pattern for %w", err) + } + if len(matches) == 0 { + fmt.Fprintf(os.Stderr, "%s Your pattern %s matched 0 seed files.\n", Yellow("WARNING:"), pattern) + } + sort.Strings(matches) + files = append(files, matches...) + } + return RemoveDuplicates(files), nil +} + func GetCurrentTimestamp() string { // Magic number: https://stackoverflow.com/q/45160822. return time.Now().UTC().Format("20060102150405") diff --git a/internal/utils/misc_test.go b/internal/utils/misc_test.go index 6472c2145..c16abdf00 100644 --- a/internal/utils/misc_test.go +++ b/internal/utils/misc_test.go @@ -75,3 +75,76 @@ func TestProjectRoot(t *testing.T) { assert.Equal(t, cwd, path) }) } + +func TestGetSeedFiles(t *testing.T) { + t.Run("returns seed files matching patterns", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewMemMapFs() + // Create seed files + require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/seed1.sql", []byte("INSERT INTO table1 VALUES (1);"), 0644)) + require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/seed2.sql", []byte("INSERT INTO table2 VALUES (2);"), 0644)) + require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/seed3.sql", []byte("INSERT INTO table2 VALUES (2);"), 0644)) + require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/another.sql", []byte("INSERT INTO table2 VALUES (2);"), 0644)) + require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/ignore.sql", []byte("INSERT INTO table3 VALUES (3);"), 0644)) + // Mock config patterns + Config.Db.Seed.SqlPaths = []string{"seeds/seed[12].sql", "seeds/ano*.sql"} + + // Run test + files, err := GetSeedFiles(fsys) + + // Check error + assert.NoError(t, err) + // Validate files + assert.ElementsMatch(t, []string{"supabase/seeds/seed1.sql", "supabase/seeds/seed2.sql", "supabase/seeds/another.sql"}, files) + }) + t.Run("returns seed files matching patterns skip duplicates", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewMemMapFs() + // Create seed files + require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/seed1.sql", []byte("INSERT INTO table1 VALUES (1);"), 0644)) + require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/seed2.sql", []byte("INSERT INTO table2 VALUES (2);"), 0644)) + require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/seed3.sql", []byte("INSERT INTO table2 VALUES (2);"), 0644)) + require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/another.sql", []byte("INSERT INTO table2 VALUES (2);"), 0644)) + require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/ignore.sql", []byte("INSERT INTO table3 VALUES (3);"), 0644)) + // Mock config patterns + Config.Db.Seed.SqlPaths = []string{"seeds/seed[12].sql", "seeds/ano*.sql", "seeds/seed*.sql"} + + // Run test + files, err := GetSeedFiles(fsys) + + // Check error + assert.NoError(t, err) + // Validate files + assert.ElementsMatch(t, []string{"supabase/seeds/seed1.sql", "supabase/seeds/seed2.sql", "supabase/seeds/another.sql", "supabase/seeds/seed3.sql"}, files) + }) + + t.Run("returns error on invalid pattern", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewMemMapFs() + // Mock config patterns + Config.Db.Seed.SqlPaths = []string{"[*!#@D#"} + + // Run test + files, err := GetSeedFiles(fsys) + + // Check error + assert.Nil(t, err) + // The resuling seed list should be empty + assert.ElementsMatch(t, []string{}, files) + }) + + t.Run("returns empty list if no files match", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewMemMapFs() + // Mock config patterns + Config.Db.Seed.SqlPaths = []string{"seeds/*.sql"} + + // Run test + files, err := GetSeedFiles(fsys) + + // Check error + assert.NoError(t, err) + // Validate files + assert.Empty(t, files) + }) +} diff --git a/pkg/config/config.go b/pkg/config/config.go index 18414546a..3636e7e9c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -172,7 +172,8 @@ type ( } seed struct { - Enabled bool `toml:"enabled"` + Enabled bool `toml:"enabled"` + SqlPaths []string `toml:"sql_paths"` } pooler struct { @@ -482,7 +483,8 @@ func NewConfig(editors ...ConfigEditor) config { SecretKeyBase: "EAx3IQ/wRG1v47ZD4NE4/9RzBI8Jmil3x0yhcW4V2NHBP6c2iPIzwjofi2Ep4HIG", }, Seed: seed{ - Enabled: true, + Enabled: true, + SqlPaths: []string{"./seed.sql"}, }, }, Realtime: realtime{ diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index 37646aa63..112237748 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -39,6 +39,14 @@ default_pool_size = 20 # Maximum number of client connections allowed. max_client_conn = 100 +[db.seed] +# If enabled, seeds the database after migrations during a db reset. +enabled = true +# Specifies an ordered list of seed files to load during db reset. +# Supports glob patterns relative to supabase directory. For example: +# sql_paths = ['./seeds/*.sql', '../project-src/seeds/*-load-testing.sql'] +sql_paths = ['./seed.sql'] + [realtime] enabled = true # Bind realtime via either IPv4 or IPv6. (default: IPv4) diff --git a/pkg/config/testdata/config.toml b/pkg/config/testdata/config.toml index a7aa36544..76e070c60 100644 --- a/pkg/config/testdata/config.toml +++ b/pkg/config/testdata/config.toml @@ -39,6 +39,14 @@ default_pool_size = 20 # Maximum number of client connections allowed. max_client_conn = 100 +[db.seed] +# If enabled, seeds the database after migrations during a db reset. +enabled = true +# Specifies an ordered list of seed files to load during db reset. +# Supports glob patterns relative to supabase directory. For example: +# sql_paths = ['./seeds/*.sql', '../project-src/seeds/*-load-testing.sql'] +sql_paths = ['./seed.sql'] + [realtime] enabled = true # Bind realtime via either IPv4 or IPv6. (default: IPv6) diff --git a/pkg/config/utils.go b/pkg/config/utils.go index b2318b5a9..ac26a38d2 100644 --- a/pkg/config/utils.go +++ b/pkg/config/utils.go @@ -29,7 +29,6 @@ type pathBuilder struct { FallbackImportMapPath string FallbackEnvFilePath string DbTestsDir string - SeedDataPath string CustomRolesPath string } @@ -63,7 +62,6 @@ func NewPathBuilder(configPath string) pathBuilder { FallbackImportMapPath: filepath.Join(base, "functions", "import_map.json"), FallbackEnvFilePath: filepath.Join(base, "functions", ".env"), DbTestsDir: filepath.Join(base, "tests"), - SeedDataPath: filepath.Join(base, "seed.sql"), CustomRolesPath: filepath.Join(base, "roles.sql"), } } diff --git a/pkg/migration/seed.go b/pkg/migration/seed.go index f299e9f05..62a2c875b 100644 --- a/pkg/migration/seed.go +++ b/pkg/migration/seed.go @@ -12,8 +12,7 @@ import ( func SeedData(ctx context.Context, pending []string, conn *pgx.Conn, fsys fs.FS) error { for _, path := range pending { - filename := filepath.Base(path) - fmt.Fprintf(os.Stderr, "Seeding data from %s...\n", filename) + fmt.Fprintf(os.Stderr, "Seeding data from %s...\n", path) // Batch seed commands, safe to use statement cache if seed, err := NewMigrationFromFile(path, fsys); err != nil { return err From 371a163cc6bafc72fa5a3eca3718a6c3a1d063a8 Mon Sep 17 00:00:00 2001 From: avallete Date: Wed, 25 Sep 2024 09:57:59 +0200 Subject: [PATCH 044/305] chore: add bitbucket build canary badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 63ca688be..3229bc369 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Supabase CLI (v1) -[![Coverage Status](https://coveralls.io/repos/github/supabase/cli/badge.svg?branch=main)](https://coveralls.io/github/supabase/cli?branch=main) +[![Coverage Status](https://coveralls.io/repos/github/supabase/cli/badge.svg?branch=main)](https://coveralls.io/github/supabase/cli?branch=main) [![Bitbucket Pipelines](https://img.shields.io/bitbucket/pipelines/supabase-cli/setup-cli/master?style=flat-square&label=Bitbucket%20Canary)](https://bitbucket.org/supabase-cli/setup-cli/pipelines) [Supabase](https://supabase.io) is an open source Firebase alternative. We're building the features of Firebase using enterprise-grade open source tools. From d5a34fc78536fa0d1cb8f21f2d35476440dfd6d3 Mon Sep 17 00:00:00 2001 From: avallete Date: Wed, 25 Sep 2024 10:12:45 +0200 Subject: [PATCH 045/305] chore: add gitlab canary badge --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3229bc369..750bd8895 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Supabase CLI (v1) -[![Coverage Status](https://coveralls.io/repos/github/supabase/cli/badge.svg?branch=main)](https://coveralls.io/github/supabase/cli?branch=main) [![Bitbucket Pipelines](https://img.shields.io/bitbucket/pipelines/supabase-cli/setup-cli/master?style=flat-square&label=Bitbucket%20Canary)](https://bitbucket.org/supabase-cli/setup-cli/pipelines) +[![Coverage Status](https://coveralls.io/repos/github/supabase/cli/badge.svg?branch=main)](https://coveralls.io/github/supabase/cli?branch=main) [![Bitbucket Pipelines](https://img.shields.io/bitbucket/pipelines/supabase-cli/setup-cli/master?style=flat-square&label=Bitbucket%20Canary)](https://bitbucket.org/supabase-cli/setup-cli/pipelines) [![Gitlab Pipeline Status](https://img.shields.io/gitlab/pipeline-status/sweatybridge%2Fsetup-cli?label=Gitlab%20Canary) +](https://gitlab.com/sweatybridge/setup-cli/-/pipelines) [Supabase](https://supabase.io) is an open source Firebase alternative. We're building the features of Firebase using enterprise-grade open source tools. From 1623aa9b95ec90e21c5bae5a0d50dcf272abe92f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Caba=C3=A7o?= Date: Thu, 26 Sep 2024 02:02:07 +0100 Subject: [PATCH 046/305] fix: Bump up studio image (#2711) From ccf214d252a76ea87e5b3d72ed61c66c59ef7a48 Mon Sep 17 00:00:00 2001 From: avallete Date: Fri, 27 Sep 2024 13:53:47 +0200 Subject: [PATCH 047/305] chore: restore realtime to postgres database --- internal/db/start/templates/_supabase.sql | 5 ----- internal/db/start/templates/schema.sql | 3 +++ internal/start/start.go | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/db/start/templates/_supabase.sql b/internal/db/start/templates/_supabase.sql index d391166a2..c339d2b61 100644 --- a/internal/db/start/templates/_supabase.sql +++ b/internal/db/start/templates/_supabase.sql @@ -5,11 +5,6 @@ CREATE DATABASE _supabase WITH OWNER postgres; -- Create schemas in _supabase database for -- internals tools and reports to not overload user database -- with non-user activity -CREATE SCHEMA IF NOT EXISTS _realtime; -ALTER SCHEMA _realtime OWNER TO postgres; -CREATE SCHEMA IF NOT EXISTS realtime; -ALTER SCHEMA realtime OWNER TO postgres; - CREATE SCHEMA IF NOT EXISTS _analytics; ALTER SCHEMA _analytics OWNER TO postgres; diff --git a/internal/db/start/templates/schema.sql b/internal/db/start/templates/schema.sql index 2ff6cf48f..534dd1207 100644 --- a/internal/db/start/templates/schema.sql +++ b/internal/db/start/templates/schema.sql @@ -12,6 +12,9 @@ ALTER USER supabase_storage_admin WITH PASSWORD :'pgpass'; ALTER USER supabase_replication_admin WITH PASSWORD :'pgpass'; ALTER USER supabase_read_only_user WITH PASSWORD :'pgpass'; +create schema if not exists _realtime; +alter schema _realtime owner to postgres; + BEGIN; -- Create pg_net extension diff --git a/internal/start/start.go b/internal/start/start.go index 413b8e2ed..72f34b8e7 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -750,7 +750,7 @@ EOF fmt.Sprintf("DB_PORT=%d", dbConfig.Port), "DB_USER=supabase_admin", "DB_PASSWORD=" + dbConfig.Password, - "DB_NAME=_supabase", + "DB_NAME=" + dbConfig.Database, "DB_AFTER_CONNECT_QUERY=SET search_path TO _realtime", "DB_ENC_KEY=" + utils.Config.Realtime.EncryptionKey, "API_JWT_SECRET=" + utils.Config.Auth.JwtSecret, From e911718c22eecae9b039119c289b766de58fe8fa Mon Sep 17 00:00:00 2001 From: avallete Date: Fri, 27 Sep 2024 16:06:33 +0200 Subject: [PATCH 048/305] chore: remove relatime migration --- internal/db/start/start.go | 2 +- internal/db/start/templates/_supabase.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/db/start/start.go b/internal/db/start/start.go index 8ed608ad7..9614528f5 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -235,7 +235,7 @@ func initRealtimeJob(host string) utils.DockerJob { "DB_PORT=5432", "DB_USER=supabase_admin", "DB_PASSWORD=" + utils.Config.Db.Password, - "DB_NAME=_supabase", + "DB_NAME=postgres", "DB_AFTER_CONNECT_QUERY=SET search_path TO _realtime", "DB_ENC_KEY=" + utils.Config.Realtime.EncryptionKey, "API_JWT_SECRET=" + utils.Config.Auth.JwtSecret, diff --git a/internal/db/start/templates/_supabase.sql b/internal/db/start/templates/_supabase.sql index c339d2b61..6e5d8487b 100644 --- a/internal/db/start/templates/_supabase.sql +++ b/internal/db/start/templates/_supabase.sql @@ -10,4 +10,4 @@ ALTER SCHEMA _analytics OWNER TO postgres; CREATE SCHEMA IF NOT EXISTS _supavisor; ALTER SCHEMA _supavisor OWNER TO postgres; -\c postgres \ No newline at end of file +\c postgres From 3115143937d6ed665bc547e66def7f96032b8c81 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Fri, 27 Sep 2024 18:10:42 +0200 Subject: [PATCH 049/305] Update internal/db/start/start.go Co-authored-by: Han Qiao --- internal/db/start/start.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/db/start/start.go b/internal/db/start/start.go index 9614528f5..74e40554a 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -84,7 +84,8 @@ func NewContainerConfig() container.Config { Retries: 3, }, Entrypoint: []string{"sh", "-c", `cat <<'EOF' > /etc/postgresql.schema.sql && cat <<'EOF' > /etc/postgresql-custom/pgsodium_root.key && docker-entrypoint.sh postgres -D /etc/postgresql -` + initialSchema + "\n" + _supabaseSchema + "\n" + ` +` + initialSchema + ` +` + _supabaseSchema + ` EOF ` + utils.Config.Db.RootKey + ` EOF From c8e553faacdfc90d4d6f04a4c05890d60a1dab21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Tue, 1 Oct 2024 13:22:30 +0900 Subject: [PATCH 050/305] fix: bump edge-runtime to 1.58.11 (#2718) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index d75ce61bc..9d91a8489 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.83.2" studioImage = "supabase/studio:20240923-2e3e90c" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.58.3" + edgeRuntimeImage = "supabase/edge-runtime:v1.58.11" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.158.1" From 4ee741f5216b99a69461fb5185f1b248cff06cb3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 22:35:49 +0000 Subject: [PATCH 051/305] chore(deps): bump github.com/containers/common from 0.60.2 to 0.60.4 (#2722) Bumps [github.com/containers/common](https://github.com/containers/common) from 0.60.2 to 0.60.4. - [Release notes](https://github.com/containers/common/releases) - [Commits](https://github.com/containers/common/compare/v0.60.2...v0.60.4) --- updated-dependencies: - dependency-name: github.com/containers/common dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 1d790e827..aff55f8eb 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/charmbracelet/bubbletea v0.25.0 github.com/charmbracelet/glamour v0.7.0 github.com/charmbracelet/lipgloss v0.12.1 - github.com/containers/common v0.60.2 + github.com/containers/common v0.60.4 github.com/danieljoos/wincred v1.2.1 github.com/deepmap/oapi-codegen/v2 v2.2.0 github.com/docker/cli v27.2.1+incompatible diff --git a/go.sum b/go.sum index 4fdaab3fb..43131167a 100644 --- a/go.sum +++ b/go.sum @@ -200,8 +200,8 @@ github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2 github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= -github.com/containers/common v0.60.2 h1:utcwp2YkO8c0mNlwRxsxfOiqfj157FRrBjxgjR6f+7o= -github.com/containers/common v0.60.2/go.mod h1:I0upBi1qJX3QmzGbUOBN1LVP6RvkKhd3qQpZbQT+Q54= +github.com/containers/common v0.60.4 h1:H5+LAMHPZEqX6vVNOQ+IguVsaFl8kbO/SZ/VPXjxhy0= +github.com/containers/common v0.60.4/go.mod h1:I0upBi1qJX3QmzGbUOBN1LVP6RvkKhd3qQpZbQT+Q54= github.com/containers/storage v1.55.0 h1:wTWZ3YpcQf1F+dSP4KxG9iqDfpQY1otaUXjPpffuhgg= github.com/containers/storage v1.55.0/go.mod h1:28cB81IDk+y7ok60Of6u52RbCeBRucbFOeLunhER1RQ= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= From 3bb06fb7d4f3ca94c6f00f967e2d4082698b6ca5 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Fri, 4 Oct 2024 16:47:08 +0800 Subject: [PATCH 052/305] chore: glob seed paths when loading config (#2726) --- internal/db/push/push.go | 6 +- internal/db/push/push_test.go | 3 +- internal/db/start/start_test.go | 4 +- internal/migration/apply/apply.go | 6 +- internal/migration/apply/apply_test.go | 18 ++++-- internal/utils/misc.go | 21 ------ internal/utils/misc_test.go | 73 --------------------- pkg/config/config.go | 47 ++++++++++++-- pkg/config/config_test.go | 88 ++++++++++++++++++++++++++ 9 files changed, 152 insertions(+), 114 deletions(-) diff --git a/internal/db/push/push.go b/internal/db/push/push.go index 0bff15163..5439f16cc 100644 --- a/internal/db/push/push.go +++ b/internal/db/push/push.go @@ -41,11 +41,7 @@ func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, fmt.Fprintln(os.Stderr, "Would push these migrations:") fmt.Fprint(os.Stderr, utils.Bold(confirmPushAll(pending))) if includeSeed { - seedPaths, err := utils.GetSeedFiles(fsys) - if err != nil { - return err - } - fmt.Fprintf(os.Stderr, "Would seed data %v...\n", seedPaths) + fmt.Fprintf(os.Stderr, "Would seed data %v...\n", utils.Config.Db.Seed.SqlPaths) } } else { msg := fmt.Sprintf("Do you want to push these migrations to the remote database?\n%s\n", confirmPushAll(pending)) diff --git a/internal/db/push/push_test.go b/internal/db/push/push_test.go index 72df15ef9..1616216d9 100644 --- a/internal/db/push/push_test.go +++ b/internal/db/push/push_test.go @@ -161,8 +161,9 @@ func TestPushAll(t *testing.T) { }) t.Run("throws error on seed failure", func(t *testing.T) { - // Setup in-memory fs seedPath := filepath.Join(utils.SupabaseDirPath, "seed.sql") + utils.Config.Db.Seed.SqlPaths = []string{seedPath} + // Setup in-memory fs fsys := &fstest.OpenErrorFs{DenyPath: seedPath} _, _ = fsys.Create(seedPath) path := filepath.Join(utils.MigrationsDir, "0_test.sql") diff --git a/internal/db/start/start_test.go b/internal/db/start/start_test.go index e4072df98..555141192 100644 --- a/internal/db/start/start_test.go +++ b/internal/db/start/start_test.go @@ -52,6 +52,8 @@ func TestInitBranch(t *testing.T) { func TestStartDatabase(t *testing.T) { t.Run("initialize main branch", func(t *testing.T) { + seedPath := filepath.Join(utils.SupabaseDirPath, "seed.sql") + utils.Config.Db.Seed.SqlPaths = []string{seedPath} utils.Config.Db.MajorVersion = 15 utils.DbId = "supabase_db_test" utils.ConfigId = "supabase_config_test" @@ -61,7 +63,7 @@ func TestStartDatabase(t *testing.T) { roles := "create role test" require.NoError(t, afero.WriteFile(fsys, utils.CustomRolesPath, []byte(roles), 0644)) seed := "INSERT INTO employees(name) VALUES ('Alice')" - require.NoError(t, afero.WriteFile(fsys, filepath.Join(utils.SupabaseDirPath, "seed.sql"), []byte(seed), 0644)) + require.NoError(t, afero.WriteFile(fsys, seedPath, []byte(seed), 0644)) // Setup mock docker require.NoError(t, apitest.MockDocker(utils.Docker)) defer gock.OffAll() diff --git a/internal/migration/apply/apply.go b/internal/migration/apply/apply.go index 6796930d2..9ead81dd5 100644 --- a/internal/migration/apply/apply.go +++ b/internal/migration/apply/apply.go @@ -27,11 +27,7 @@ func MigrateAndSeed(ctx context.Context, version string, conn *pgx.Conn, fsys af } func SeedDatabase(ctx context.Context, conn *pgx.Conn, fsys afero.Fs) error { - seedPaths, err := utils.GetSeedFiles(fsys) - if err != nil { - return err - } - return migration.SeedData(ctx, seedPaths, conn, afero.NewIOFS(fsys)) + return migration.SeedData(ctx, utils.Config.Db.Seed.SqlPaths, conn, afero.NewIOFS(fsys)) } func CreateCustomRoles(ctx context.Context, conn *pgx.Conn, fsys afero.Fs) error { diff --git a/internal/migration/apply/apply_test.go b/internal/migration/apply/apply_test.go index 6c5b915fd..25362c5fe 100644 --- a/internal/migration/apply/apply_test.go +++ b/internal/migration/apply/apply_test.go @@ -77,12 +77,15 @@ func TestMigrateDatabase(t *testing.T) { } func TestSeedDatabase(t *testing.T) { + seedPath := filepath.Join(utils.SupabaseDirPath, "seed.sql") + utils.Config.Db.Seed.SqlPaths = []string{seedPath} + t.Run("seeds from file", func(t *testing.T) { // Setup in-memory fs fsys := afero.NewMemMapFs() // Setup seed file sql := "INSERT INTO employees(name) VALUES ('Alice')" - require.NoError(t, afero.WriteFile(fsys, filepath.Join(utils.SupabaseDirPath, "seed.sql"), []byte(sql), 0644)) + require.NoError(t, afero.WriteFile(fsys, seedPath, []byte(sql), 0644)) // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) @@ -95,12 +98,19 @@ func TestSeedDatabase(t *testing.T) { }) t.Run("ignores missing seed", func(t *testing.T) { - assert.NoError(t, SeedDatabase(context.Background(), nil, afero.NewMemMapFs())) + sqlPaths := utils.Config.Db.Seed.SqlPaths + utils.Config.Db.Seed.SqlPaths = []string{} + t.Cleanup(func() { utils.Config.Db.Seed.SqlPaths = sqlPaths }) + // Setup in-memory fs + fsys := afero.NewMemMapFs() + // Run test + err := SeedDatabase(context.Background(), nil, fsys) + // Check error + assert.NoError(t, err) }) t.Run("throws error on read failure", func(t *testing.T) { // Setup in-memory fs - seedPath := filepath.Join(utils.SupabaseDirPath, "seed.sql") fsys := &fstest.OpenErrorFs{DenyPath: seedPath} _, _ = fsys.Create(seedPath) // Run test @@ -114,7 +124,7 @@ func TestSeedDatabase(t *testing.T) { fsys := afero.NewMemMapFs() // Setup seed file sql := "INSERT INTO employees(name) VALUES ('Alice')" - require.NoError(t, afero.WriteFile(fsys, filepath.Join(utils.SupabaseDirPath, "seed.sql"), []byte(sql), 0644)) + require.NoError(t, afero.WriteFile(fsys, seedPath, []byte(sql), 0644)) // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) diff --git a/internal/utils/misc.go b/internal/utils/misc.go index d4e49f046..adb0efa9c 100644 --- a/internal/utils/misc.go +++ b/internal/utils/misc.go @@ -8,7 +8,6 @@ import ( "os" "path/filepath" "regexp" - "sort" "time" "github.com/docker/docker/client" @@ -157,26 +156,6 @@ var ( ErrNotRunning = errors.Errorf("%s is not running.", Aqua("supabase start")) ) -// Match the glob patterns from the config to get a deduplicated -// array of all migrations files to apply in the declared order. -func GetSeedFiles(fsys afero.Fs) ([]string, error) { - seedPaths := Config.Db.Seed.SqlPaths - var files []string - for _, pattern := range seedPaths { - fullPattern := filepath.Join(SupabaseDirPath, pattern) - matches, err := afero.Glob(fsys, fullPattern) - if err != nil { - return nil, errors.Errorf("failed to apply glob pattern for %w", err) - } - if len(matches) == 0 { - fmt.Fprintf(os.Stderr, "%s Your pattern %s matched 0 seed files.\n", Yellow("WARNING:"), pattern) - } - sort.Strings(matches) - files = append(files, matches...) - } - return RemoveDuplicates(files), nil -} - func GetCurrentTimestamp() string { // Magic number: https://stackoverflow.com/q/45160822. return time.Now().UTC().Format("20060102150405") diff --git a/internal/utils/misc_test.go b/internal/utils/misc_test.go index c16abdf00..6472c2145 100644 --- a/internal/utils/misc_test.go +++ b/internal/utils/misc_test.go @@ -75,76 +75,3 @@ func TestProjectRoot(t *testing.T) { assert.Equal(t, cwd, path) }) } - -func TestGetSeedFiles(t *testing.T) { - t.Run("returns seed files matching patterns", func(t *testing.T) { - // Setup in-memory fs - fsys := afero.NewMemMapFs() - // Create seed files - require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/seed1.sql", []byte("INSERT INTO table1 VALUES (1);"), 0644)) - require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/seed2.sql", []byte("INSERT INTO table2 VALUES (2);"), 0644)) - require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/seed3.sql", []byte("INSERT INTO table2 VALUES (2);"), 0644)) - require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/another.sql", []byte("INSERT INTO table2 VALUES (2);"), 0644)) - require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/ignore.sql", []byte("INSERT INTO table3 VALUES (3);"), 0644)) - // Mock config patterns - Config.Db.Seed.SqlPaths = []string{"seeds/seed[12].sql", "seeds/ano*.sql"} - - // Run test - files, err := GetSeedFiles(fsys) - - // Check error - assert.NoError(t, err) - // Validate files - assert.ElementsMatch(t, []string{"supabase/seeds/seed1.sql", "supabase/seeds/seed2.sql", "supabase/seeds/another.sql"}, files) - }) - t.Run("returns seed files matching patterns skip duplicates", func(t *testing.T) { - // Setup in-memory fs - fsys := afero.NewMemMapFs() - // Create seed files - require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/seed1.sql", []byte("INSERT INTO table1 VALUES (1);"), 0644)) - require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/seed2.sql", []byte("INSERT INTO table2 VALUES (2);"), 0644)) - require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/seed3.sql", []byte("INSERT INTO table2 VALUES (2);"), 0644)) - require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/another.sql", []byte("INSERT INTO table2 VALUES (2);"), 0644)) - require.NoError(t, afero.WriteFile(fsys, "supabase/seeds/ignore.sql", []byte("INSERT INTO table3 VALUES (3);"), 0644)) - // Mock config patterns - Config.Db.Seed.SqlPaths = []string{"seeds/seed[12].sql", "seeds/ano*.sql", "seeds/seed*.sql"} - - // Run test - files, err := GetSeedFiles(fsys) - - // Check error - assert.NoError(t, err) - // Validate files - assert.ElementsMatch(t, []string{"supabase/seeds/seed1.sql", "supabase/seeds/seed2.sql", "supabase/seeds/another.sql", "supabase/seeds/seed3.sql"}, files) - }) - - t.Run("returns error on invalid pattern", func(t *testing.T) { - // Setup in-memory fs - fsys := afero.NewMemMapFs() - // Mock config patterns - Config.Db.Seed.SqlPaths = []string{"[*!#@D#"} - - // Run test - files, err := GetSeedFiles(fsys) - - // Check error - assert.Nil(t, err) - // The resuling seed list should be empty - assert.ElementsMatch(t, []string{}, files) - }) - - t.Run("returns empty list if no files match", func(t *testing.T) { - // Setup in-memory fs - fsys := afero.NewMemMapFs() - // Mock config patterns - Config.Db.Seed.SqlPaths = []string{"seeds/*.sql"} - - // Run test - files, err := GetSeedFiles(fsys) - - // Check error - assert.NoError(t, err) - // Validate files - assert.Empty(t, files) - }) -} diff --git a/pkg/config/config.go b/pkg/config/config.go index 3636e7e9c..06c3baec3 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -16,6 +16,7 @@ import ( "os" "path/filepath" "regexp" + "sort" "strconv" "strings" "text/template" @@ -172,8 +173,9 @@ type ( } seed struct { - Enabled bool `toml:"enabled"` - SqlPaths []string `toml:"sql_paths"` + Enabled bool `toml:"enabled"` + GlobPatterns []string `toml:"sql_paths"` + SqlPaths []string `toml:"-"` } pooler struct { @@ -483,8 +485,8 @@ func NewConfig(editors ...ConfigEditor) config { SecretKeyBase: "EAx3IQ/wRG1v47ZD4NE4/9RzBI8Jmil3x0yhcW4V2NHBP6c2iPIzwjofi2Ep4HIG", }, Seed: seed{ - Enabled: true, - SqlPaths: []string{"./seed.sql"}, + Enabled: true, + GlobPatterns: []string{"./seed.sql"}, }, }, Realtime: realtime{ @@ -708,6 +710,9 @@ func (c *config) Load(path string, fsys fs.FS) error { } c.Functions[slug] = function } + if err := c.Db.Seed.loadSeedPaths(builder.SupabaseDirPath, fsys); err != nil { + return err + } if err := c.baseConfig.Validate(); err != nil { return err } @@ -1041,6 +1046,40 @@ func loadEnvIfExists(path string) error { return nil } +// Match the glob patterns from the config to get a deduplicated +// array of all migrations files to apply in the declared order. +func (c *seed) loadSeedPaths(basePath string, fsys fs.FS) error { + if !c.Enabled { + return nil + } + if c.SqlPaths != nil { + // Reuse already allocated array + c.SqlPaths = c.SqlPaths[:0] + } + set := make(map[string]struct{}) + for _, pattern := range c.GlobPatterns { + if !filepath.IsAbs(pattern) { + pattern = filepath.Join(basePath, pattern) + } + matches, err := fs.Glob(fsys, pattern) + if err != nil { + return errors.Errorf("failed to apply glob pattern: %w", err) + } + if len(matches) == 0 { + fmt.Fprintln(os.Stderr, "No seed files matched pattern:", pattern) + } + sort.Strings(matches) + // Remove duplicates + for _, item := range matches { + if _, exists := set[item]; !exists { + set[item] = struct{}{} + c.SqlPaths = append(c.SqlPaths, item) + } + } + } + return nil +} + func (h *hookConfig) HandleHook(hookType string) error { // If not enabled do nothing if !h.Enabled { diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 733b3c7b7..7d31d77ae 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -3,6 +3,7 @@ package config import ( "bytes" _ "embed" + "path" "strings" "testing" fs "testing/fstest" @@ -247,3 +248,90 @@ func TestValidateHookURI(t *testing.T) { }) } } + +func TestLoadSeedPaths(t *testing.T) { + t.Run("returns seed files matching patterns", func(t *testing.T) { + // Setup in-memory fs + fsys := fs.MapFS{ + "supabase/seeds/seed1.sql": &fs.MapFile{Data: []byte("INSERT INTO table1 VALUES (1);")}, + "supabase/seeds/seed2.sql": &fs.MapFile{Data: []byte("INSERT INTO table2 VALUES (2);")}, + "supabase/seeds/seed3.sql": &fs.MapFile{Data: []byte("INSERT INTO table2 VALUES (2);")}, + "supabase/seeds/another.sql": &fs.MapFile{Data: []byte("INSERT INTO table2 VALUES (2);")}, + "supabase/seeds/ignore.sql": &fs.MapFile{Data: []byte("INSERT INTO table3 VALUES (3);")}, + } + // Mock config patterns + config := seed{ + Enabled: true, + GlobPatterns: []string{ + "seeds/seed[12].sql", + "seeds/ano*.sql", + }, + } + // Run test + err := config.loadSeedPaths("supabase", fsys) + // Check error + assert.NoError(t, err) + // Validate files + assert.ElementsMatch(t, []string{ + "supabase/seeds/seed1.sql", + "supabase/seeds/seed2.sql", + "supabase/seeds/another.sql", + }, config.SqlPaths) + }) + t.Run("returns seed files matching patterns skip duplicates", func(t *testing.T) { + // Setup in-memory fs + fsys := fs.MapFS{ + "supabase/seeds/seed1.sql": &fs.MapFile{Data: []byte("INSERT INTO table1 VALUES (1);")}, + "supabase/seeds/seed2.sql": &fs.MapFile{Data: []byte("INSERT INTO table2 VALUES (2);")}, + "supabase/seeds/seed3.sql": &fs.MapFile{Data: []byte("INSERT INTO table2 VALUES (2);")}, + "supabase/seeds/another.sql": &fs.MapFile{Data: []byte("INSERT INTO table2 VALUES (2);")}, + "supabase/seeds/ignore.sql": &fs.MapFile{Data: []byte("INSERT INTO table3 VALUES (3);")}, + } + // Mock config patterns + config := seed{ + Enabled: true, + GlobPatterns: []string{ + "seeds/seed[12].sql", + "seeds/ano*.sql", + "seeds/seed*.sql", + }, + } + // Run test + err := config.loadSeedPaths("supabase", fsys) + // Check error + assert.NoError(t, err) + // Validate files + assert.ElementsMatch(t, []string{ + "supabase/seeds/seed1.sql", + "supabase/seeds/seed2.sql", + "supabase/seeds/another.sql", + "supabase/seeds/seed3.sql", + }, config.SqlPaths) + }) + + t.Run("returns error on invalid pattern", func(t *testing.T) { + // Setup in-memory fs + fsys := fs.MapFS{} + // Mock config patterns + config := seed{Enabled: true, GlobPatterns: []string{"[*!#@D#"}} + // Run test + err := config.loadSeedPaths("", fsys) + // Check error + assert.ErrorIs(t, err, path.ErrBadPattern) + // The resuling seed list should be empty + assert.Empty(t, config.SqlPaths) + }) + + t.Run("returns empty list if no files match", func(t *testing.T) { + // Setup in-memory fs + fsys := fs.MapFS{} + // Mock config patterns + config := seed{Enabled: true, GlobPatterns: []string{"seeds/*.sql"}} + // Run test + err := config.loadSeedPaths("", fsys) + // Check error + assert.NoError(t, err) + // Validate files + assert.Empty(t, config.SqlPaths) + }) +} From 0efc21dcb23a5935d7d96a5f01643058b931ccb0 Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Fri, 4 Oct 2024 15:21:35 +0200 Subject: [PATCH 053/305] chore: Bump studio to the latest image version 20240930 (#2720) Update studio version to 20240930 --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 9d91a8489..c51e19fbd 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -10,7 +10,7 @@ const ( inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" pgmetaImage = "supabase/postgres-meta:v0.83.2" - studioImage = "supabase/studio:20240923-2e3e90c" + studioImage = "supabase/studio:20240930-16f2b8e" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.58.11" vectorImage = "timberio/vector:0.28.1-alpine" From 333a2ca5522e493cd35a853f258e9fd9b5098558 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Fri, 4 Oct 2024 18:14:57 +0200 Subject: [PATCH 054/305] fix: email templates for monorepos (#2723) * fix: email templates for monorepos Fixes: https://github.com/supabase/cli/issues/2721 * Update pkg/config/config.go * Revert "Update pkg/config/config.go" This reverts commit 2dbc9f0e1dd5ee1b3f14f9cc17e01c5ec0fe984e. --------- Co-authored-by: Han Qiao Co-authored-by: Qiao Han --- pkg/config/config.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 06c3baec3..0b2468224 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -710,10 +710,11 @@ func (c *config) Load(path string, fsys fs.FS) error { } c.Functions[slug] = function } + if err := c.Db.Seed.loadSeedPaths(builder.SupabaseDirPath, fsys); err != nil { return err } - if err := c.baseConfig.Validate(); err != nil { + if err := c.baseConfig.Validate(fsys); err != nil { return err } c.Remotes = make(map[string]baseConfig, len(c.Overrides)) @@ -730,7 +731,7 @@ func (c *config) Load(path string, fsys fs.FS) error { } else if undecoded := metadata.Undecoded(); len(undecoded) > 0 { fmt.Fprintf(os.Stderr, "Unknown config fields: %+v\n", undecoded) } - if err := base.Validate(); err != nil { + if err := base.Validate(fsys); err != nil { return err } c.Remotes[name] = base @@ -738,7 +739,7 @@ func (c *config) Load(path string, fsys fs.FS) error { return nil } -func (c *baseConfig) Validate() error { +func (c *baseConfig) Validate(fsys fs.FS) error { if c.ProjectId == "" { return errors.New("Missing required field in config: project_id") } else if sanitized := sanitizeProjectId(c.ProjectId); sanitized != c.ProjectId { @@ -833,8 +834,10 @@ func (c *baseConfig) Validate() error { } // Validate email config for name, tmpl := range c.Auth.Email.Template { - if len(tmpl.ContentPath) > 0 && !fs.ValidPath(filepath.Clean(tmpl.ContentPath)) { - return errors.Errorf("Invalid config for auth.email.%s.content_path: %s", name, tmpl.ContentPath) + if len(tmpl.ContentPath) > 0 { + if _, err = fs.Stat(fsys, filepath.Clean(tmpl.ContentPath)); err != nil { + return errors.Errorf("Invalid config for auth.email.%s.content_path: %s", name, tmpl.ContentPath) + } } } if c.Auth.Email.Smtp.Pass, err = maybeLoadEnv(c.Auth.Email.Smtp.Pass); err != nil { From 9365527e770dcf21d88d6f2a37c5dd69038f1d68 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sun, 6 Oct 2024 16:08:00 +0800 Subject: [PATCH 055/305] fix: inspect storage container before seeding buckets --- internal/db/reset/reset.go | 11 +++-- internal/db/reset/reset_test.go | 74 ++++++++++++++++++++++++++++++--- 2 files changed, 76 insertions(+), 9 deletions(-) diff --git a/internal/db/reset/reset.go b/internal/db/reset/reset.go index d53392ae9..2622e77ff 100644 --- a/internal/db/reset/reset.go +++ b/internal/db/reset/reset.go @@ -10,6 +10,7 @@ import ( "strings" "time" + "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" "github.com/docker/docker/errdefs" @@ -54,9 +55,11 @@ func Run(ctx context.Context, version string, config pgconn.Config, fsys afero.F return err } // Seed objects from supabase/buckets directory - if utils.Config.Storage.Enabled { - if err := start.WaitForHealthyService(ctx, 30*time.Second, utils.StorageId); err != nil { - return err + if resp, err := utils.Docker.ContainerInspect(ctx, utils.StorageId); err == nil { + if resp.State.Health == nil || resp.State.Health.Status != types.Healthy { + if err := start.WaitForHealthyService(ctx, 30*time.Second, utils.StorageId); err != nil { + return err + } } if err := buckets.Run(ctx, "", false, fsys); err != nil { return err @@ -212,7 +215,7 @@ func restartServices(ctx context.Context) error { services := listServicesToRestart() result := utils.WaitAll(services, func(id string) error { if err := utils.Docker.ContainerRestart(ctx, id, container.StopOptions{}); err != nil && !errdefs.IsNotFound(err) { - return errors.Errorf("Failed to restart %s: %w", id, err) + return errors.Errorf("failed to restart %s: %w", id, err) } return nil }) diff --git a/internal/db/reset/reset_test.go b/internal/db/reset/reset_test.go index ace03c9b4..c65aa0ef9 100644 --- a/internal/db/reset/reset_test.go +++ b/internal/db/reset/reset_test.go @@ -24,6 +24,7 @@ import ( "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/pkg/migration" "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/pkg/storage" ) func TestResetCommand(t *testing.T) { @@ -38,6 +39,69 @@ func TestResetCommand(t *testing.T) { Database: "postgres", } + t.Run("seeds storage after reset", func(t *testing.T) { + utils.DbId = "test-reset" + utils.ConfigId = "test-config" + utils.Config.Db.MajorVersion = 15 + // Setup in-memory fs + fsys := afero.NewMemMapFs() + // Setup mock docker + require.NoError(t, apitest.MockDocker(utils.Docker)) + defer gock.OffAll() + gock.New(utils.Docker.DaemonHost()). + Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId). + Reply(http.StatusOK). + JSON(types.ContainerJSON{}) + gock.New(utils.Docker.DaemonHost()). + Delete("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId). + Reply(http.StatusOK) + gock.New(utils.Docker.DaemonHost()). + Delete("/v" + utils.Docker.ClientVersion() + "/volumes/" + utils.DbId). + Reply(http.StatusOK) + apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Db.Image), utils.DbId) + gock.New(utils.Docker.DaemonHost()). + Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json"). + Reply(http.StatusOK). + JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ + State: &types.ContainerState{ + Running: true, + Health: &types.Health{Status: types.Healthy}, + }, + }}) + // Setup mock postgres + conn := pgtest.NewConn() + defer conn.Close(t) + // Restarts services + utils.StorageId = "test-storage" + utils.GotrueId = "test-auth" + utils.RealtimeId = "test-realtime" + utils.PoolerId = "test-pooler" + for _, container := range listServicesToRestart() { + gock.New(utils.Docker.DaemonHost()). + Post("/v" + utils.Docker.ClientVersion() + "/containers/" + container + "/restart"). + Reply(http.StatusOK) + } + // Seeds storage + gock.New(utils.Docker.DaemonHost()). + Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.StorageId + "/json"). + Reply(http.StatusOK). + JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ + State: &types.ContainerState{ + Running: true, + Health: &types.Health{Status: types.Healthy}, + }, + }}) + gock.New(utils.Config.Api.ExternalUrl). + Get("/storage/v1/bucket"). + Reply(http.StatusOK). + JSON([]storage.BucketResponse{}) + // Run test + err := Run(context.Background(), "", dbConfig, fsys, conn.Intercept) + // Check error + assert.NoError(t, err) + assert.Empty(t, apitest.ListUnmatchedRequests()) + }) + t.Run("throws error on context canceled", func(t *testing.T) { // Setup in-memory fs fsys := afero.NewMemMapFs() @@ -225,7 +289,7 @@ func TestRestartDatabase(t *testing.T) { JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ State: &types.ContainerState{ Running: true, - Health: &types.Health{Status: "healthy"}, + Health: &types.Health{Status: types.Healthy}, }, }}) // Restarts services @@ -260,7 +324,7 @@ func TestRestartDatabase(t *testing.T) { JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ State: &types.ContainerState{ Running: true, - Health: &types.Health{Status: "healthy"}, + Health: &types.Health{Status: types.Healthy}, }, }}) // Restarts services @@ -279,9 +343,9 @@ func TestRestartDatabase(t *testing.T) { // Run test err := RestartDatabase(context.Background(), io.Discard) // Check error - assert.ErrorContains(t, err, "Failed to restart "+utils.StorageId) - assert.ErrorContains(t, err, "Failed to restart "+utils.GotrueId) - assert.ErrorContains(t, err, "Failed to restart "+utils.RealtimeId) + assert.ErrorContains(t, err, "failed to restart "+utils.StorageId) + assert.ErrorContains(t, err, "failed to restart "+utils.GotrueId) + assert.ErrorContains(t, err, "failed to restart "+utils.RealtimeId) assert.Empty(t, apitest.ListUnmatchedRequests()) }) From 73b591c6ecd428301735e089d3aa7af71bc7ce5f Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sun, 6 Oct 2024 16:08:41 +0800 Subject: [PATCH 056/305] chore: use healthy enum from docker api --- internal/db/diff/diff_test.go | 6 +++--- internal/db/start/start_test.go | 4 ++-- internal/migration/squash/squash_test.go | 6 +++--- internal/start/start_test.go | 6 +++--- internal/status/status.go | 3 ++- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/internal/db/diff/diff_test.go b/internal/db/diff/diff_test.go index d5e8c6a46..6ada103c7 100644 --- a/internal/db/diff/diff_test.go +++ b/internal/db/diff/diff_test.go @@ -55,7 +55,7 @@ func TestRun(t *testing.T) { JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ State: &types.ContainerState{ Running: true, - Health: &types.Health{Status: "healthy"}, + Health: &types.Health{Status: types.Healthy}, }, }}) apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Realtime.Image), "test-shadow-realtime") @@ -267,7 +267,7 @@ func TestDiffDatabase(t *testing.T) { JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ State: &types.ContainerState{ Running: true, - Health: &types.Health{Status: "healthy"}, + Health: &types.Health{Status: types.Healthy}, }, }}) gock.New(utils.Docker.DaemonHost()). @@ -303,7 +303,7 @@ At statement 0: create schema public`) JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ State: &types.ContainerState{ Running: true, - Health: &types.Health{Status: "healthy"}, + Health: &types.Health{Status: types.Healthy}, }, }}) gock.New(utils.Docker.DaemonHost()). diff --git a/internal/db/start/start_test.go b/internal/db/start/start_test.go index 555141192..8d1816b0b 100644 --- a/internal/db/start/start_test.go +++ b/internal/db/start/start_test.go @@ -78,7 +78,7 @@ func TestStartDatabase(t *testing.T) { JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ State: &types.ContainerState{ Running: true, - Health: &types.Health{Status: "healthy"}, + Health: &types.Health{Status: types.Healthy}, }, }}) apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Realtime.Image), "test-realtime") @@ -126,7 +126,7 @@ func TestStartDatabase(t *testing.T) { JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ State: &types.ContainerState{ Running: true, - Health: &types.Health{Status: "healthy"}, + Health: &types.Health{Status: types.Healthy}, }, }}) // Run test diff --git a/internal/migration/squash/squash_test.go b/internal/migration/squash/squash_test.go index c85f014c0..cc0461f3b 100644 --- a/internal/migration/squash/squash_test.go +++ b/internal/migration/squash/squash_test.go @@ -61,7 +61,7 @@ func TestSquashCommand(t *testing.T) { JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ State: &types.ContainerState{ Running: true, - Health: &types.Health{Status: "healthy"}, + Health: &types.Health{Status: types.Healthy}, }, }}) gock.New(utils.Docker.DaemonHost()). @@ -251,7 +251,7 @@ func TestSquashMigrations(t *testing.T) { JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ State: &types.ContainerState{ Running: true, - Health: &types.Health{Status: "healthy"}, + Health: &types.Health{Status: types.Healthy}, }, }}) gock.New(utils.Docker.DaemonHost()). @@ -286,7 +286,7 @@ func TestSquashMigrations(t *testing.T) { JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ State: &types.ContainerState{ Running: true, - Health: &types.Health{Status: "healthy"}, + Health: &types.Health{Status: types.Healthy}, }, }}) gock.New(utils.Docker.DaemonHost()). diff --git a/internal/start/start_test.go b/internal/start/start_test.go index 654831ccb..079eb3c79 100644 --- a/internal/start/start_test.go +++ b/internal/start/start_test.go @@ -160,7 +160,7 @@ func TestDatabaseStart(t *testing.T) { JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ State: &types.ContainerState{ Running: true, - Health: &types.Health{Status: "healthy"}, + Health: &types.Health{Status: types.Healthy}, }, }}) } @@ -177,7 +177,7 @@ func TestDatabaseStart(t *testing.T) { JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ State: &types.ContainerState{ Running: true, - Health: &types.Health{Status: "healthy"}, + Health: &types.Health{Status: types.Healthy}, }, }}) gock.New(utils.Config.Api.ExternalUrl). @@ -225,7 +225,7 @@ func TestDatabaseStart(t *testing.T) { JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ State: &types.ContainerState{ Running: true, - Health: &types.Health{Status: "healthy"}, + Health: &types.Health{Status: types.Healthy}, }, }}) // Run test diff --git a/internal/status/status.go b/internal/status/status.go index e78af5cd2..1b9d02f90 100644 --- a/internal/status/status.go +++ b/internal/status/status.go @@ -14,6 +14,7 @@ import ( "sync" "time" + "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/go-errors/errors" "github.com/spf13/afero" @@ -114,7 +115,7 @@ func assertContainerHealthy(ctx context.Context, container string) error { return errors.Errorf("failed to inspect container health: %w", err) } else if !resp.State.Running { return errors.Errorf("%s container is not running: %s", container, resp.State.Status) - } else if resp.State.Health != nil && resp.State.Health.Status != "healthy" { + } else if resp.State.Health != nil && resp.State.Health.Status != types.Healthy { return errors.Errorf("%s container is not ready: %s", container, resp.State.Health.Status) } return nil From b04503926c2dbe2815d2b25b0d800aa1a775c547 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sun, 6 Oct 2024 16:08:58 +0800 Subject: [PATCH 057/305] chore: remove syslog config --- internal/db/reset/reset.go | 4 ---- internal/db/start/start.go | 2 -- 2 files changed, 6 deletions(-) diff --git a/internal/db/reset/reset.go b/internal/db/reset/reset.go index 2622e77ff..88e595047 100644 --- a/internal/db/reset/reset.go +++ b/internal/db/reset/reset.go @@ -115,10 +115,6 @@ func resetDatabase15(ctx context.Context, version string, fsys afero.Fs, options if err := utils.Docker.VolumeRemove(ctx, utils.DbId, true); err != nil { return errors.Errorf("failed to remove volume: %w", err) } - // Skip syslog if vector container is not started - if _, err := utils.Docker.ContainerInspect(ctx, utils.VectorId); err != nil { - utils.Config.Analytics.Enabled = false - } config := start.NewContainerConfig() hostConfig := start.NewHostConfig() networkingConfig := network.NetworkingConfig{ diff --git a/internal/db/start/start.go b/internal/db/start/start.go index 74e40554a..912f845df 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -43,8 +43,6 @@ func Run(ctx context.Context, fsys afero.Fs) error { } else if !errors.Is(err, utils.ErrNotRunning) { return err } - // Skip logflare container in db start - utils.Config.Analytics.Enabled = false err := StartDatabase(ctx, fsys, os.Stderr) if err != nil { if err := utils.DockerRemoveAll(context.Background(), os.Stderr, utils.Config.ProjectId); err != nil { From 887b5bb921ee4df787ac4c6045d00360112b3470 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Fri, 4 Oct 2024 23:14:51 +0800 Subject: [PATCH 058/305] feat: track seeded files in migration table --- internal/db/push/push.go | 33 +++++++-- internal/migration/apply/apply.go | 6 +- internal/migration/apply/apply_test.go | 62 ----------------- pkg/migration/file.go | 64 +++++++++++++---- pkg/migration/history.go | 12 ++++ pkg/migration/seed.go | 58 ++++++++++++++-- pkg/migration/seed_test.go | 95 +++++++++++++++++++++++--- pkg/pgtest/mock.go | 8 ++- pkg/pgxv5/rows.go | 22 +++--- 9 files changed, 252 insertions(+), 108 deletions(-) diff --git a/internal/db/push/push.go b/internal/db/push/push.go index 5439f16cc..226a76751 100644 --- a/internal/db/push/push.go +++ b/internal/db/push/push.go @@ -29,7 +29,14 @@ func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, if err != nil { return err } - if len(pending) == 0 { + var seeds []migration.SeedFile + if includeSeed { + seeds, err = migration.GetPendingSeeds(ctx, utils.Config.Db.Seed.SqlPaths, conn, afero.NewIOFS(fsys)) + if err != nil { + return err + } + } + if len(pending) == 0 && len(seeds) == 0 { fmt.Println("Remote database is up to date.") return nil } @@ -38,10 +45,13 @@ func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, if includeRoles { fmt.Fprintln(os.Stderr, "Would create custom roles "+utils.Bold(utils.CustomRolesPath)+"...") } - fmt.Fprintln(os.Stderr, "Would push these migrations:") - fmt.Fprint(os.Stderr, utils.Bold(confirmPushAll(pending))) - if includeSeed { - fmt.Fprintf(os.Stderr, "Would seed data %v...\n", utils.Config.Db.Seed.SqlPaths) + if len(pending) > 0 { + fmt.Fprintln(os.Stderr, "Would push these migrations:") + fmt.Fprint(os.Stderr, utils.Bold(confirmPushAll(pending))) + } + if includeSeed && len(seeds) > 0 { + fmt.Fprintln(os.Stderr, "Would seed these files:") + fmt.Fprint(os.Stderr, utils.Bold(confirmSeedAll(seeds))) } } else { msg := fmt.Sprintf("Do you want to push these migrations to the remote database?\n%s\n", confirmPushAll(pending)) @@ -59,7 +69,7 @@ func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, return err } if includeSeed { - if err := apply.SeedDatabase(ctx, conn, fsys); err != nil { + if err := migration.SeedData(ctx, seeds, conn, afero.NewIOFS(fsys)); err != nil { return err } } @@ -75,3 +85,14 @@ func confirmPushAll(pending []string) (msg string) { } return msg } + +func confirmSeedAll(pending []migration.SeedFile) (msg string) { + for _, seed := range pending { + notice := seed.Path + if seed.Dirty { + notice += " (hash update)" + } + msg += fmt.Sprintf(" • %s\n", notice) + } + return msg +} diff --git a/internal/migration/apply/apply.go b/internal/migration/apply/apply.go index 9ead81dd5..f8c466259 100644 --- a/internal/migration/apply/apply.go +++ b/internal/migration/apply/apply.go @@ -27,7 +27,11 @@ func MigrateAndSeed(ctx context.Context, version string, conn *pgx.Conn, fsys af } func SeedDatabase(ctx context.Context, conn *pgx.Conn, fsys afero.Fs) error { - return migration.SeedData(ctx, utils.Config.Db.Seed.SqlPaths, conn, afero.NewIOFS(fsys)) + seeds, err := migration.GetPendingSeeds(ctx, utils.Config.Db.Seed.SqlPaths, conn, afero.NewIOFS(fsys)) + if err != nil { + return err + } + return migration.SeedData(ctx, seeds, conn, afero.NewIOFS(fsys)) } func CreateCustomRoles(ctx context.Context, conn *pgx.Conn, fsys afero.Fs) error { diff --git a/internal/migration/apply/apply_test.go b/internal/migration/apply/apply_test.go index 25362c5fe..286093743 100644 --- a/internal/migration/apply/apply_test.go +++ b/internal/migration/apply/apply_test.go @@ -6,7 +6,6 @@ import ( "path/filepath" "testing" - "github.com/jackc/pgerrcode" "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -75,64 +74,3 @@ func TestMigrateDatabase(t *testing.T) { assert.ErrorIs(t, err, os.ErrPermission) }) } - -func TestSeedDatabase(t *testing.T) { - seedPath := filepath.Join(utils.SupabaseDirPath, "seed.sql") - utils.Config.Db.Seed.SqlPaths = []string{seedPath} - - t.Run("seeds from file", func(t *testing.T) { - // Setup in-memory fs - fsys := afero.NewMemMapFs() - // Setup seed file - sql := "INSERT INTO employees(name) VALUES ('Alice')" - require.NoError(t, afero.WriteFile(fsys, seedPath, []byte(sql), 0644)) - // Setup mock postgres - conn := pgtest.NewConn() - defer conn.Close(t) - conn.Query(sql). - Reply("INSERT 0 1") - // Run test - err := SeedDatabase(context.Background(), conn.MockClient(t), fsys) - // Check error - assert.NoError(t, err) - }) - - t.Run("ignores missing seed", func(t *testing.T) { - sqlPaths := utils.Config.Db.Seed.SqlPaths - utils.Config.Db.Seed.SqlPaths = []string{} - t.Cleanup(func() { utils.Config.Db.Seed.SqlPaths = sqlPaths }) - // Setup in-memory fs - fsys := afero.NewMemMapFs() - // Run test - err := SeedDatabase(context.Background(), nil, fsys) - // Check error - assert.NoError(t, err) - }) - - t.Run("throws error on read failure", func(t *testing.T) { - // Setup in-memory fs - fsys := &fstest.OpenErrorFs{DenyPath: seedPath} - _, _ = fsys.Create(seedPath) - // Run test - err := SeedDatabase(context.Background(), nil, fsys) - // Check error - assert.ErrorIs(t, err, os.ErrPermission) - }) - - t.Run("throws error on insert failure", func(t *testing.T) { - // Setup in-memory fs - fsys := afero.NewMemMapFs() - // Setup seed file - sql := "INSERT INTO employees(name) VALUES ('Alice')" - require.NoError(t, afero.WriteFile(fsys, seedPath, []byte(sql), 0644)) - // Setup mock postgres - conn := pgtest.NewConn() - defer conn.Close(t) - conn.Query(sql). - ReplyError(pgerrcode.NotNullViolation, `null value in column "age" of relation "employees"`) - // Run test - err := SeedDatabase(context.Background(), conn.MockClient(t), fsys) - // Check error - assert.ErrorContains(t, err, `ERROR: null value in column "age" of relation "employees" (SQLSTATE 23502)`) - }) -} diff --git a/pkg/migration/file.go b/pkg/migration/file.go index 04a945565..79da1c86a 100644 --- a/pkg/migration/file.go +++ b/pkg/migration/file.go @@ -2,6 +2,8 @@ package migration import ( "context" + "crypto/sha256" + "encoding/hex" "io" "io/fs" "path/filepath" @@ -24,6 +26,22 @@ type MigrationFile struct { var migrateFilePattern = regexp.MustCompile(`^([0-9]+)_(.*)\.sql$`) func NewMigrationFromFile(path string, fsys fs.FS) (*MigrationFile, error) { + lines, err := parseFile(path, fsys) + if err != nil { + return nil, err + } + file := MigrationFile{Statements: lines} + // Parse version from file name + filename := filepath.Base(path) + matches := migrateFilePattern.FindStringSubmatch(filename) + if len(matches) > 2 { + file.Version = matches[1] + file.Name = matches[2] + } + return &file, nil +} + +func parseFile(path string, fsys fs.FS) ([]string, error) { sql, err := fsys.Open(path) if err != nil { return nil, errors.Errorf("failed to open migration file: %w", err) @@ -37,17 +55,7 @@ func NewMigrationFromFile(path string, fsys fs.FS) (*MigrationFile, error) { } } } - file, err := NewMigrationFromReader(sql) - if err == nil { - // Parse version from file name - filename := filepath.Base(path) - matches := migrateFilePattern.FindStringSubmatch(filename) - if len(matches) > 2 { - file.Version = matches[1] - file.Name = matches[2] - } - } - return file, err + return parser.SplitAndTrim(sql) } func NewMigrationFromReader(sql io.Reader) (*MigrationFile, error) { @@ -112,12 +120,40 @@ func (m *MigrationFile) insertVersionSQL(conn *pgx.Conn, batch *pgconn.Batch) er return nil } -func (m *MigrationFile) ExecBatchWithCache(ctx context.Context, conn *pgx.Conn) error { +type SeedFile struct { + Path string + Hash string + Dirty bool `db:"-"` +} + +func NewSeedFile(path string, fsys fs.FS) (*SeedFile, error) { + sql, err := fsys.Open(path) + if err != nil { + return nil, errors.Errorf("failed to open seed file: %w", err) + } + defer sql.Close() + hash := sha256.New() + if _, err := io.Copy(hash, sql); err != nil { + return nil, errors.Errorf("failed to hash file: %w", err) + } + digest := hex.EncodeToString(hash.Sum(nil)) + return &SeedFile{Path: path, Hash: digest}, nil +} + +func (m *SeedFile) ExecBatchWithCache(ctx context.Context, conn *pgx.Conn, fsys fs.FS) error { + // Parse each file individually to reduce memory usage + lines, err := parseFile(m.Path, fsys) + if err != nil { + return err + } // Data statements don't mutate schemas, safe to use statement cache batch := pgx.Batch{} - for _, line := range m.Statements { - batch.Queue(line) + if !m.Dirty { + for _, line := range lines { + batch.Queue(line) + } } + batch.Queue(UPSERT_SEED_FILE, m.Path, m.Hash) // No need to track version here because there are no schema changes if err := conn.SendBatch(ctx, &batch).Close(); err != nil { return errors.Errorf("failed to send batch: %w", err) diff --git a/pkg/migration/history.go b/pkg/migration/history.go index 6dc8b5fc8..832651874 100644 --- a/pkg/migration/history.go +++ b/pkg/migration/history.go @@ -21,6 +21,9 @@ const ( TRUNCATE_VERSION_TABLE = "TRUNCATE supabase_migrations.schema_migrations" SELECT_VERSION_TABLE = "SELECT * FROM supabase_migrations.schema_migrations" LIST_MIGRATION_VERSION = "SELECT version FROM supabase_migrations.schema_migrations ORDER BY version" + CREATE_SEED_TABLE = "CREATE TABLE IF NOT EXISTS supabase_migrations.seed_files (path text NOT NULL PRIMARY KEY, hash text NOT NULL)" + UPSERT_SEED_FILE = "INSERT INTO supabase_migrations.seed_files(path, hash) VALUES($1, $2) ON CONFLICT (path) DO UPDATE SET hash = EXCLUDED.hash" + SELECT_SEED_TABLE = "SELECT path, hash FROM supabase_migrations.seed_files" ) // TODO: support overriding `supabase_migrations.schema_migrations` with user defined . @@ -33,6 +36,7 @@ func CreateMigrationTable(ctx context.Context, conn *pgx.Conn) error { batch.ExecParams(CREATE_VERSION_TABLE, nil, nil, nil, nil) batch.ExecParams(ADD_STATEMENTS_COLUMN, nil, nil, nil, nil) batch.ExecParams(ADD_NAME_COLUMN, nil, nil, nil, nil) + batch.ExecParams(CREATE_SEED_TABLE, nil, nil, nil, nil) if _, err := conn.PgConn().ExecBatch(ctx, &batch).ReadAll(); err != nil { return errors.Errorf("failed to create migration table: %w", err) } @@ -46,3 +50,11 @@ func ReadMigrationTable(ctx context.Context, conn *pgx.Conn) ([]MigrationFile, e } return pgxv5.CollectRows[MigrationFile](rows) } + +func ReadSeedTable(ctx context.Context, conn *pgx.Conn) ([]SeedFile, error) { + rows, err := conn.Query(ctx, SELECT_SEED_TABLE) + if err != nil { + return nil, errors.Errorf("failed to read seed table: %w", err) + } + return pgxv5.CollectRows[SeedFile](rows) +} diff --git a/pkg/migration/seed.go b/pkg/migration/seed.go index 62a2c875b..6fd5aa43c 100644 --- a/pkg/migration/seed.go +++ b/pkg/migration/seed.go @@ -7,16 +7,62 @@ import ( "os" "path/filepath" + "github.com/go-errors/errors" + "github.com/jackc/pgconn" + "github.com/jackc/pgerrcode" "github.com/jackc/pgx/v4" ) -func SeedData(ctx context.Context, pending []string, conn *pgx.Conn, fsys fs.FS) error { - for _, path := range pending { - fmt.Fprintf(os.Stderr, "Seeding data from %s...\n", path) +func getRemoteSeeds(ctx context.Context, conn *pgx.Conn) (map[string]string, error) { + remotes, err := ReadSeedTable(ctx, conn) + if err != nil { + var pgErr *pgconn.PgError + if errors.As(err, &pgErr) && pgErr.Code == pgerrcode.UndefinedTable { + // If seed table is undefined, the remote project has no migrations + return map[string]string{}, nil + } + return map[string]string{}, err + } + applied := make(map[string]string, len(remotes)) + for _, seed := range remotes { + applied[seed.Path] = seed.Hash + } + return applied, nil +} + +func GetPendingSeeds(ctx context.Context, locals []string, conn *pgx.Conn, fsys fs.FS) ([]SeedFile, error) { + applied, err := getRemoteSeeds(ctx, conn) + if err != nil { + return nil, err + } + var pending []SeedFile + for _, path := range locals { + seed, err := NewSeedFile(path, fsys) + if err != nil { + return nil, err + } + if hash, exists := applied[seed.Path]; exists { + // Skip seed files that already exist + if hash == seed.Hash { + continue + } + // Mark seed file as dirty + seed.Dirty = true + } + pending = append(pending, *seed) + } + return pending, nil +} + +func SeedData(ctx context.Context, pending []SeedFile, conn *pgx.Conn, fsys fs.FS) error { + for _, seed := range pending { + if seed.Dirty { + fmt.Fprintf(os.Stderr, "Updating seed file hash %s...\n", seed.Path) + } else { + fmt.Fprintf(os.Stderr, "Seeding data from %s...\n", seed.Path) + } // Batch seed commands, safe to use statement cache - if seed, err := NewMigrationFromFile(path, fsys); err != nil { - return err - } else if err := seed.ExecBatchWithCache(ctx, conn); err != nil { + if err := seed.ExecBatchWithCache(ctx, conn, fsys); err != nil { return err } } diff --git a/pkg/migration/seed_test.go b/pkg/migration/seed_test.go index e81d814a9..db1865ace 100644 --- a/pkg/migration/seed_test.go +++ b/pkg/migration/seed_test.go @@ -8,45 +8,122 @@ import ( fs "testing/fstest" "github.com/jackc/pgerrcode" + "github.com/jackc/pgx/v4" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/supabase/cli/pkg/pgtest" ) //go:embed testdata/seed.sql var testSeed string -func TestSeedData(t *testing.T) { +func TestPendingSeeds(t *testing.T) { pending := []string{"testdata/seed.sql"} - t.Run("seeds from file", func(t *testing.T) { + t.Run("finds new seeds", func(t *testing.T) { // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) - conn.Query(testSeed). - Reply("INSERT 0 1") + conn.Query(SELECT_SEED_TABLE). + Reply("SELECT 0") + // Run test + seeds, err := GetPendingSeeds(context.Background(), pending, conn.MockClient(t), testMigrations) + // Check error + assert.NoError(t, err) + require.Len(t, seeds, 1) + assert.Equal(t, seeds[0].Path, pending[0]) + assert.Equal(t, seeds[0].Hash, "61868484fc0ddca2a2022217629a9fd9a4cf1ca479432046290797d6d40ffcc3") + assert.False(t, seeds[0].Dirty) + }) + + t.Run("finds dirty seeds", func(t *testing.T) { + // Setup mock postgres + conn := pgtest.NewConn() + defer conn.Close(t) + conn.Query(SELECT_SEED_TABLE). + Reply("SELECT 1", SeedFile{Path: pending[0], Hash: "outdated"}) // Run test - err := SeedData(context.Background(), pending, conn.MockClient(t), testMigrations) + seeds, err := GetPendingSeeds(context.Background(), pending, conn.MockClient(t), testMigrations) // Check error assert.NoError(t, err) + require.Len(t, seeds, 1) + assert.Equal(t, seeds[0].Path, pending[0]) + assert.Equal(t, seeds[0].Hash, "61868484fc0ddca2a2022217629a9fd9a4cf1ca479432046290797d6d40ffcc3") + assert.True(t, seeds[0].Dirty) + }) + + t.Run("skips applied seed", func(t *testing.T) { + // Setup mock postgres + conn := pgtest.NewConn() + defer conn.Close(t) + conn.Query(SELECT_SEED_TABLE). + Reply("SELECT 1", SeedFile{Path: pending[0], Hash: "61868484fc0ddca2a2022217629a9fd9a4cf1ca479432046290797d6d40ffcc3"}) + // Run test + seeds, err := GetPendingSeeds(context.Background(), pending, conn.MockClient(t), testMigrations) + // Check error + assert.NoError(t, err) + require.Empty(t, seeds) + }) + + t.Run("throws error on missing seed table", func(t *testing.T) { + // Setup mock postgres + conn := pgtest.NewConn() + defer conn.Close(t) + conn.Query(SELECT_SEED_TABLE). + ReplyError(pgerrcode.UndefinedTable, `relation "seed_files" does not exist`) + // Run test + _, err := GetPendingSeeds(context.Background(), pending, conn.MockClient(t), testMigrations) + // Check error + assert.ErrorContains(t, err, `ERROR: relation "seed_files" does not exist (SQLSTATE 42P01)`) }) t.Run("throws error on missing file", func(t *testing.T) { + // Setup mock postgres + conn := pgtest.NewConn() + defer conn.Close(t) + conn.Query(SELECT_SEED_TABLE). + Reply("SELECT 0") // Setup in-memory fs fsys := fs.MapFS{} // Run test - err := SeedData(context.Background(), pending, nil, fsys) + _, err := GetPendingSeeds(context.Background(), pending, conn.MockClient(t), fsys) // Check error assert.ErrorIs(t, err, os.ErrNotExist) }) +} + +func TestSeedData(t *testing.T) { + t.Run("seeds from file", func(t *testing.T) { + seed := SeedFile{ + Path: "testdata/seed.sql", + Hash: "61868484fc0ddca2a2022217629a9fd9a4cf1ca479432046290797d6d40ffcc3", + Dirty: true, + } + // Setup mock postgres + conn := pgtest.NewConn() + defer conn.Close(t) + conn.Query(UPSERT_SEED_FILE, seed.Path, seed.Hash). + Reply("INSERT 0 1") + // Run test + err := SeedData(context.Background(), []SeedFile{seed}, conn.MockClient(t), testMigrations) + // Check error + assert.NoError(t, err) + }) - t.Run("throws error on insert failure", func(t *testing.T) { + t.Run("throws error on upsert failure", func(t *testing.T) { + seed := SeedFile{ + Path: "testdata/seed.sql", + Hash: "61868484fc0ddca2a2022217629a9fd9a4cf1ca479432046290797d6d40ffcc3", + } // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) - conn.Query(testSeed). + conn.Query(testSeed+`;INSERT INTO supabase_migrations.seed_files(path, hash) VALUES( 'testdata/seed.sql' , '61868484fc0ddca2a2022217629a9fd9a4cf1ca479432046290797d6d40ffcc3' ) ON CONFLICT (path) DO UPDATE SET hash = EXCLUDED.hash`). ReplyError(pgerrcode.NotNullViolation, `null value in column "age" of relation "employees"`) // Run test - err := SeedData(context.Background(), pending, conn.MockClient(t), testMigrations) + err := SeedData(context.Background(), []SeedFile{seed}, conn.MockClient(t, func(cc *pgx.ConnConfig) { + cc.PreferSimpleProtocol = true + }), testMigrations) // Check error assert.ErrorContains(t, err, `ERROR: null value in column "age" of relation "employees" (SQLSTATE 23502)`) }) diff --git a/pkg/pgtest/mock.go b/pkg/pgtest/mock.go index b73ad255a..0f5e9bb84 100644 --- a/pkg/pgtest/mock.go +++ b/pkg/pgtest/mock.go @@ -153,7 +153,10 @@ func (r *MockConn) Reply(tag string, rows ...interface{}) *MockConn { } else if t := reflect.TypeOf(rows[0]); t.Kind() == reflect.Struct { s := reflect.ValueOf(rows[0]) for i := 0; i < s.NumField(); i++ { - name := t.Field(i).Name + name := pgxv5.GetColumnName(t.Field(i)) + if len(name) == 0 { + continue + } v := s.Field(i).Interface() if fd := toFieldDescription(v); fd != nil { fd.Name = []byte(name) @@ -182,6 +185,9 @@ func (r *MockConn) Reply(tag string, rows ...interface{}) *MockConn { } else if t := reflect.TypeOf(data); t.Kind() == reflect.Struct { s := reflect.ValueOf(rows[0]) for i := 0; i < s.NumField(); i++ { + if name := pgxv5.GetColumnName(t.Field(i)); len(name) == 0 { + continue + } v := s.Field(i).Interface() if value, oid := r.encodeValueArg(v); oid > 0 { dr.Values = append(dr.Values, value) diff --git a/pkg/pgxv5/rows.go b/pkg/pgxv5/rows.go index 299ce868c..96aa16f5a 100644 --- a/pkg/pgxv5/rows.go +++ b/pkg/pgxv5/rows.go @@ -104,18 +104,11 @@ func appendScanTargets(dstElemValue reflect.Value, scanTargets []any, fldDescs [ return nil, err } } else { - dbTag, dbTagPresent := sf.Tag.Lookup(structTagKey) - if dbTagPresent { - dbTag = strings.Split(dbTag, ",")[0] - } - if dbTag == "-" { + colName := GetColumnName(sf) + if len(colName) == 0 { // Field is ignored, skip it. continue } - colName := dbTag - if !dbTagPresent { - colName = sf.Name - } fpos := fieldPosByName(fldDescs, colName) if fpos == -1 || fpos >= len(scanTargets) { return nil, errors.Errorf("cannot find field %s in returned row", colName) @@ -126,3 +119,14 @@ func appendScanTargets(dstElemValue reflect.Value, scanTargets []any, fldDescs [ return scanTargets, err } + +func GetColumnName(sf reflect.StructField) string { + dbTag, dbTagPresent := sf.Tag.Lookup(structTagKey) + if !dbTagPresent { + return sf.Name + } + if dbTag = strings.Split(dbTag, ",")[0]; dbTag != "-" { + return dbTag + } + return "" +} From b906fc56014db30b71a817bc3fb58c448d8c1e34 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Fri, 4 Oct 2024 23:33:33 +0800 Subject: [PATCH 059/305] chore: reduce code duplication --- internal/db/reset/reset.go | 15 +-------------- internal/db/start/start.go | 6 +++--- internal/db/start/start_test.go | 8 ++++---- internal/migration/apply/apply.go | 6 +++--- 4 files changed, 11 insertions(+), 24 deletions(-) diff --git a/internal/db/reset/reset.go b/internal/db/reset/reset.go index 88e595047..a9d2f4f4f 100644 --- a/internal/db/reset/reset.go +++ b/internal/db/reset/reset.go @@ -100,11 +100,6 @@ func resetDatabase14(ctx context.Context, version string, fsys afero.Fs, options return err } defer conn.Close(context.Background()) - if utils.Config.Db.MajorVersion > 14 { - if err := start.SetupDatabase(ctx, conn, utils.DbId, os.Stderr, fsys); err != nil { - return err - } - } return apply.MigrateAndSeed(ctx, version, conn, fsys) } @@ -131,15 +126,7 @@ func resetDatabase15(ctx context.Context, version string, fsys afero.Fs, options if err := start.WaitForHealthyService(ctx, start.HealthTimeout, utils.DbId); err != nil { return err } - conn, err := utils.ConnectLocalPostgres(ctx, pgconn.Config{}, options...) - if err != nil { - return err - } - defer conn.Close(context.Background()) - if err := start.SetupDatabase(ctx, conn, utils.DbId, os.Stderr, fsys); err != nil { - return err - } - if err := apply.MigrateAndSeed(ctx, version, conn, fsys); err != nil { + if err := start.SetupLocalDatabase(ctx, version, fsys, os.Stderr, options...); err != nil { return err } fmt.Fprintln(os.Stderr, "Restarting containers...") diff --git a/internal/db/start/start.go b/internal/db/start/start.go index 912f845df..5f2364e5d 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -147,7 +147,7 @@ EOF } // Initialize if we are on PG14 and there's no existing db volume if utils.NoBackupVolume { - if err := setupDatabase(ctx, fsys, w, options...); err != nil { + if err := SetupLocalDatabase(ctx, "", fsys, w, options...); err != nil { return err } } @@ -308,7 +308,7 @@ func initSchema15(ctx context.Context, host string) error { return nil } -func setupDatabase(ctx context.Context, fsys afero.Fs, w io.Writer, options ...func(*pgx.ConnConfig)) error { +func SetupLocalDatabase(ctx context.Context, version string, fsys afero.Fs, w io.Writer, options ...func(*pgx.ConnConfig)) error { conn, err := utils.ConnectLocalPostgres(ctx, pgconn.Config{}, options...) if err != nil { return err @@ -317,7 +317,7 @@ func setupDatabase(ctx context.Context, fsys afero.Fs, w io.Writer, options ...f if err := SetupDatabase(ctx, conn, utils.DbId, w, fsys); err != nil { return err } - return apply.MigrateAndSeed(ctx, "", conn, fsys) + return apply.MigrateAndSeed(ctx, version, conn, fsys) } func SetupDatabase(ctx context.Context, conn *pgx.Conn, host string, w io.Writer, fsys afero.Fs) error { diff --git a/internal/db/start/start_test.go b/internal/db/start/start_test.go index 8d1816b0b..24ba7f0ee 100644 --- a/internal/db/start/start_test.go +++ b/internal/db/start/start_test.go @@ -259,7 +259,7 @@ func TestSetupDatabase(t *testing.T) { Query(roles). Reply("CREATE ROLE") // Run test - err := setupDatabase(context.Background(), fsys, io.Discard, conn.Intercept) + err := SetupLocalDatabase(context.Background(), "", fsys, io.Discard, conn.Intercept) // Check error assert.NoError(t, err) assert.Empty(t, apitest.ListUnmatchedRequests()) @@ -268,7 +268,7 @@ func TestSetupDatabase(t *testing.T) { t.Run("throws error on connect failure", func(t *testing.T) { utils.Config.Db.Port = 0 // Run test - err := setupDatabase(context.Background(), nil, io.Discard) + err := SetupLocalDatabase(context.Background(), "", nil, io.Discard) // Check error assert.ErrorContains(t, err, "invalid port (outside range)") }) @@ -285,7 +285,7 @@ func TestSetupDatabase(t *testing.T) { conn := pgtest.NewConn() defer conn.Close(t) // Run test - err := setupDatabase(context.Background(), nil, io.Discard, conn.Intercept) + err := SetupLocalDatabase(context.Background(), "", nil, io.Discard, conn.Intercept) // Check error assert.ErrorContains(t, err, "network error") assert.Empty(t, apitest.ListUnmatchedRequests()) @@ -308,7 +308,7 @@ func TestSetupDatabase(t *testing.T) { conn := pgtest.NewConn() defer conn.Close(t) // Run test - err := setupDatabase(context.Background(), fsys, io.Discard, conn.Intercept) + err := SetupLocalDatabase(context.Background(), "", fsys, io.Discard, conn.Intercept) // Check error assert.ErrorIs(t, err, os.ErrPermission) assert.Empty(t, apitest.ListUnmatchedRequests()) diff --git a/internal/migration/apply/apply.go b/internal/migration/apply/apply.go index f8c466259..50d65d356 100644 --- a/internal/migration/apply/apply.go +++ b/internal/migration/apply/apply.go @@ -20,13 +20,13 @@ func MigrateAndSeed(ctx context.Context, version string, conn *pgx.Conn, fsys af if err := migration.ApplyMigrations(ctx, migrations, conn, afero.NewIOFS(fsys)); err != nil { return err } - if !utils.Config.Db.Seed.Enabled { - return nil - } return SeedDatabase(ctx, conn, fsys) } func SeedDatabase(ctx context.Context, conn *pgx.Conn, fsys afero.Fs) error { + if !utils.Config.Db.Seed.Enabled { + return nil + } seeds, err := migration.GetPendingSeeds(ctx, utils.Config.Db.Seed.SqlPaths, conn, afero.NewIOFS(fsys)) if err != nil { return err From dffb8d6ec6cf129c5c261e05d1ccbbdc751e90ec Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sat, 5 Oct 2024 00:19:10 +0800 Subject: [PATCH 060/305] chore: fix unit tests --- internal/db/push/push_test.go | 15 +++++++++++---- internal/db/start/start_test.go | 10 ++-------- internal/link/link_test.go | 3 ++- internal/migration/apply/apply.go | 4 ++-- internal/testing/helper/history.go | 4 +++- pkg/migration/apply_test.go | 7 +++++-- pkg/migration/seed.go | 7 +++++-- pkg/migration/seed_test.go | 4 ++-- 8 files changed, 32 insertions(+), 22 deletions(-) diff --git a/internal/db/push/push_test.go b/internal/db/push/push_test.go index 1616216d9..d7de969af 100644 --- a/internal/db/push/push_test.go +++ b/internal/db/push/push_test.go @@ -2,6 +2,8 @@ package push import ( "context" + "crypto/sha256" + "encoding/hex" "os" "path/filepath" "testing" @@ -161,24 +163,29 @@ func TestPushAll(t *testing.T) { }) t.Run("throws error on seed failure", func(t *testing.T) { + digest := hex.EncodeToString(sha256.New().Sum(nil)) seedPath := filepath.Join(utils.SupabaseDirPath, "seed.sql") utils.Config.Db.Seed.SqlPaths = []string{seedPath} // Setup in-memory fs - fsys := &fstest.OpenErrorFs{DenyPath: seedPath} - _, _ = fsys.Create(seedPath) + fsys := afero.NewMemMapFs() + require.NoError(t, afero.WriteFile(fsys, seedPath, []byte{}, 0644)) path := filepath.Join(utils.MigrationsDir, "0_test.sql") require.NoError(t, afero.WriteFile(fsys, path, []byte{}, 0644)) // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) conn.Query(migration.LIST_MIGRATION_VERSION). + Reply("SELECT 0"). + Query(migration.SELECT_SEED_TABLE). Reply("SELECT 0") helper.MockMigrationHistory(conn). Query(migration.INSERT_MIGRATION_VERSION, "0", "test", nil). - Reply("INSERT 0 1") + Reply("INSERT 0 1"). + Query(migration.UPSERT_SEED_FILE, seedPath, digest). + ReplyError(pgerrcode.NotNullViolation, `null value in column "hash" of relation "seed_files"`) // Run test err := Run(context.Background(), false, false, false, true, dbConfig, fsys, conn.Intercept) // Check error - assert.ErrorIs(t, err, os.ErrPermission) + assert.ErrorContains(t, err, `ERROR: null value in column "hash" of relation "seed_files" (SQLSTATE 23502)`) }) } diff --git a/internal/db/start/start_test.go b/internal/db/start/start_test.go index 24ba7f0ee..96d97da8c 100644 --- a/internal/db/start/start_test.go +++ b/internal/db/start/start_test.go @@ -6,7 +6,6 @@ import ( "io" "net/http" "os" - "path/filepath" "testing" "github.com/docker/docker/api/types" @@ -52,8 +51,6 @@ func TestInitBranch(t *testing.T) { func TestStartDatabase(t *testing.T) { t.Run("initialize main branch", func(t *testing.T) { - seedPath := filepath.Join(utils.SupabaseDirPath, "seed.sql") - utils.Config.Db.Seed.SqlPaths = []string{seedPath} utils.Config.Db.MajorVersion = 15 utils.DbId = "supabase_db_test" utils.ConfigId = "supabase_config_test" @@ -62,8 +59,6 @@ func TestStartDatabase(t *testing.T) { fsys := afero.NewMemMapFs() roles := "create role test" require.NoError(t, afero.WriteFile(fsys, utils.CustomRolesPath, []byte(roles), 0644)) - seed := "INSERT INTO employees(name) VALUES ('Alice')" - require.NoError(t, afero.WriteFile(fsys, seedPath, []byte(seed), 0644)) // Setup mock docker require.NoError(t, apitest.MockDocker(utils.Docker)) defer gock.OffAll() @@ -91,9 +86,7 @@ func TestStartDatabase(t *testing.T) { conn := pgtest.NewConn() defer conn.Close(t) conn.Query(roles). - Reply("CREATE ROLE"). - Query(seed). - Reply("INSERT 0 1") + Reply("CREATE ROLE") // Run test err := StartDatabase(context.Background(), fsys, io.Discard, conn.Intercept) // Check error @@ -274,6 +267,7 @@ func TestSetupDatabase(t *testing.T) { }) t.Run("throws error on init failure", func(t *testing.T) { + utils.Config.Realtime.Enabled = true utils.Config.Db.Port = 5432 // Setup mock docker require.NoError(t, apitest.MockDocker(utils.Docker)) diff --git a/internal/link/link_test.go b/internal/link/link_test.go index f33961293..af17eb9f5 100644 --- a/internal/link/link_test.go +++ b/internal/link/link_test.go @@ -313,7 +313,8 @@ func TestLinkDatabase(t *testing.T) { Query(migration.CREATE_VERSION_TABLE). ReplyError(pgerrcode.InsufficientPrivilege, "permission denied for relation supabase_migrations"). Query(migration.ADD_STATEMENTS_COLUMN). - Query(migration.ADD_NAME_COLUMN) + Query(migration.ADD_NAME_COLUMN). + Query(migration.CREATE_SEED_TABLE) // Run test err := linkDatabase(context.Background(), dbConfig, conn.Intercept) // Check error diff --git a/internal/migration/apply/apply.go b/internal/migration/apply/apply.go index 50d65d356..698a3ae53 100644 --- a/internal/migration/apply/apply.go +++ b/internal/migration/apply/apply.go @@ -20,10 +20,10 @@ func MigrateAndSeed(ctx context.Context, version string, conn *pgx.Conn, fsys af if err := migration.ApplyMigrations(ctx, migrations, conn, afero.NewIOFS(fsys)); err != nil { return err } - return SeedDatabase(ctx, conn, fsys) + return applySeedFiles(ctx, conn, fsys) } -func SeedDatabase(ctx context.Context, conn *pgx.Conn, fsys afero.Fs) error { +func applySeedFiles(ctx context.Context, conn *pgx.Conn, fsys afero.Fs) error { if !utils.Config.Db.Seed.Enabled { return nil } diff --git a/internal/testing/helper/history.go b/internal/testing/helper/history.go index b73d267e8..30f4a0ca2 100644 --- a/internal/testing/helper/history.go +++ b/internal/testing/helper/history.go @@ -14,6 +14,8 @@ func MockMigrationHistory(conn *pgtest.MockConn) *pgtest.MockConn { Query(migration.ADD_STATEMENTS_COLUMN). Reply("ALTER TABLE"). Query(migration.ADD_NAME_COLUMN). - Reply("ALTER TABLE") + Reply("ALTER TABLE"). + Query(migration.CREATE_SEED_TABLE). + Reply("CREATE TABLE") return conn } diff --git a/pkg/migration/apply_test.go b/pkg/migration/apply_test.go index 65a75028a..7415dfce2 100644 --- a/pkg/migration/apply_test.go +++ b/pkg/migration/apply_test.go @@ -130,7 +130,8 @@ func TestApplyMigrations(t *testing.T) { Query(CREATE_VERSION_TABLE). ReplyError(pgerrcode.InsufficientPrivilege, "permission denied for relation supabase_migrations"). Query(ADD_STATEMENTS_COLUMN). - Query(ADD_NAME_COLUMN) + Query(ADD_NAME_COLUMN). + Query(CREATE_SEED_TABLE) // Run test err := ApplyMigrations(context.Background(), pending, conn.MockClient(t), fsys) // Check error @@ -175,6 +176,8 @@ func mockMigrationHistory(conn *pgtest.MockConn) *pgtest.MockConn { Query(ADD_STATEMENTS_COLUMN). Reply("ALTER TABLE"). Query(ADD_NAME_COLUMN). - Reply("ALTER TABLE") + Reply("ALTER TABLE"). + Query(CREATE_SEED_TABLE). + Reply("CREATE TABLE") return conn } diff --git a/pkg/migration/seed.go b/pkg/migration/seed.go index 6fd5aa43c..66dd876f6 100644 --- a/pkg/migration/seed.go +++ b/pkg/migration/seed.go @@ -19,9 +19,9 @@ func getRemoteSeeds(ctx context.Context, conn *pgx.Conn) (map[string]string, err var pgErr *pgconn.PgError if errors.As(err, &pgErr) && pgErr.Code == pgerrcode.UndefinedTable { // If seed table is undefined, the remote project has no migrations - return map[string]string{}, nil + return nil, nil } - return map[string]string{}, err + return nil, err } applied := make(map[string]string, len(remotes)) for _, seed := range remotes { @@ -31,6 +31,9 @@ func getRemoteSeeds(ctx context.Context, conn *pgx.Conn) (map[string]string, err } func GetPendingSeeds(ctx context.Context, locals []string, conn *pgx.Conn, fsys fs.FS) ([]SeedFile, error) { + if len(locals) == 0 { + return nil, nil + } applied, err := getRemoteSeeds(ctx, conn) if err != nil { return nil, err diff --git a/pkg/migration/seed_test.go b/pkg/migration/seed_test.go index db1865ace..f3ba81650 100644 --- a/pkg/migration/seed_test.go +++ b/pkg/migration/seed_test.go @@ -65,7 +65,7 @@ func TestPendingSeeds(t *testing.T) { require.Empty(t, seeds) }) - t.Run("throws error on missing seed table", func(t *testing.T) { + t.Run("ignores missing seed table", func(t *testing.T) { // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) @@ -74,7 +74,7 @@ func TestPendingSeeds(t *testing.T) { // Run test _, err := GetPendingSeeds(context.Background(), pending, conn.MockClient(t), testMigrations) // Check error - assert.ErrorContains(t, err, `ERROR: relation "seed_files" does not exist (SQLSTATE 42P01)`) + assert.NoError(t, err) }) t.Run("throws error on missing file", func(t *testing.T) { From b3efd4872ff98d677ed084f85d8d815ef376cb97 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sun, 6 Oct 2024 14:03:39 +0800 Subject: [PATCH 061/305] chore: prompt before pushing seed files --- internal/db/push/push.go | 65 +++++++++++++++++++++---------- internal/db/push/push_test.go | 2 +- internal/db/start/start.go | 6 ++- internal/migration/apply/apply.go | 10 ----- internal/utils/flags/db_url.go | 5 +++ pkg/migration/seed.go | 2 +- 6 files changed, 57 insertions(+), 33 deletions(-) diff --git a/internal/db/push/push.go b/internal/db/push/push.go index 226a76751..f52d78974 100644 --- a/internal/db/push/push.go +++ b/internal/db/push/push.go @@ -10,7 +10,6 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/apply" "github.com/supabase/cli/internal/migration/up" "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/pkg/migration" @@ -36,42 +35,68 @@ func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, return err } } - if len(pending) == 0 && len(seeds) == 0 { + var globals []string + if includeRoles { + if exists, err := afero.Exists(fsys, utils.CustomRolesPath); err != nil { + return errors.Errorf("failed to find custom roles: %w", err) + } else if exists { + globals = append(globals, utils.CustomRolesPath) + } + } + if len(pending) == 0 && len(seeds) == 0 && len(globals) == 0 { fmt.Println("Remote database is up to date.") return nil } // Push pending migrations if dryRun { - if includeRoles { - fmt.Fprintln(os.Stderr, "Would create custom roles "+utils.Bold(utils.CustomRolesPath)+"...") + if len(globals) > 0 { + fmt.Fprintln(os.Stderr, "Would create custom roles "+utils.Bold(globals[0])+"...") } if len(pending) > 0 { fmt.Fprintln(os.Stderr, "Would push these migrations:") - fmt.Fprint(os.Stderr, utils.Bold(confirmPushAll(pending))) + fmt.Fprint(os.Stderr, confirmPushAll(pending)) } - if includeSeed && len(seeds) > 0 { + if len(seeds) > 0 { fmt.Fprintln(os.Stderr, "Would seed these files:") - fmt.Fprint(os.Stderr, utils.Bold(confirmSeedAll(seeds))) + fmt.Fprint(os.Stderr, confirmSeedAll(seeds)) } } else { - msg := fmt.Sprintf("Do you want to push these migrations to the remote database?\n%s\n", confirmPushAll(pending)) - if shouldPush, err := utils.NewConsole().PromptYesNo(ctx, msg, true); err != nil { - return err - } else if !shouldPush { - return errors.New(context.Canceled) - } - if includeRoles { - if err := apply.CreateCustomRoles(ctx, conn, fsys); err != nil { + if len(globals) > 0 { + msg := "Do you want to create custom roles in the database cluster?" + if shouldPush, err := utils.NewConsole().PromptYesNo(ctx, msg, true); err != nil { + return err + } else if !shouldPush { + return errors.New(context.Canceled) + } + if err := migration.SeedGlobals(ctx, globals, conn, afero.NewIOFS(fsys)); err != nil { return err } } - if err := migration.ApplyMigrations(ctx, pending, conn, afero.NewIOFS(fsys)); err != nil { - return err + if len(pending) > 0 { + msg := fmt.Sprintf("Do you want to push these migrations to the remote database?\n%s\n", confirmPushAll(pending)) + if shouldPush, err := utils.NewConsole().PromptYesNo(ctx, msg, true); err != nil { + return err + } else if !shouldPush { + return errors.New(context.Canceled) + } + if err := migration.ApplyMigrations(ctx, pending, conn, afero.NewIOFS(fsys)); err != nil { + return err + } + } else { + fmt.Fprintln(os.Stderr, "Schema migrations are up to date.") } - if includeSeed { + if len(seeds) > 0 { + msg := fmt.Sprintf("Do you want to seed the remote database with these files?\n%s\n", confirmSeedAll(seeds)) + if shouldPush, err := utils.NewConsole().PromptYesNo(ctx, msg, true); err != nil { + return err + } else if !shouldPush { + return errors.New(context.Canceled) + } if err := migration.SeedData(ctx, seeds, conn, afero.NewIOFS(fsys)); err != nil { return err } + } else if includeSeed { + fmt.Fprintln(os.Stderr, "Seed files are up to date.") } } fmt.Println("Finished " + utils.Aqua("supabase db push") + ".") @@ -81,7 +106,7 @@ func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, func confirmPushAll(pending []string) (msg string) { for _, path := range pending { filename := filepath.Base(path) - msg += fmt.Sprintf(" • %s\n", filename) + msg += fmt.Sprintf(" • %s\n", utils.Bold(filename)) } return msg } @@ -92,7 +117,7 @@ func confirmSeedAll(pending []migration.SeedFile) (msg string) { if seed.Dirty { notice += " (hash update)" } - msg += fmt.Sprintf(" • %s\n", notice) + msg += fmt.Sprintf(" • %s\n", utils.Bold(notice)) } return msg } diff --git a/internal/db/push/push_test.go b/internal/db/push/push_test.go index d7de969af..631c2cc7e 100644 --- a/internal/db/push/push_test.go +++ b/internal/db/push/push_test.go @@ -148,7 +148,7 @@ func TestPushAll(t *testing.T) { t.Run("throws error on roles failure", func(t *testing.T) { // Setup in-memory fs - fsys := &fstest.OpenErrorFs{DenyPath: utils.CustomRolesPath} + fsys := &fstest.StatErrorFs{DenyPath: utils.CustomRolesPath} path := filepath.Join(utils.MigrationsDir, "0_test.sql") require.NoError(t, afero.WriteFile(fsys, path, []byte{}, 0644)) // Setup mock postgres diff --git a/internal/db/start/start.go b/internal/db/start/start.go index 5f2364e5d..822e9aff6 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -324,5 +324,9 @@ func SetupDatabase(ctx context.Context, conn *pgx.Conn, host string, w io.Writer if err := initSchema(ctx, conn, host, w); err != nil { return err } - return apply.CreateCustomRoles(ctx, conn, fsys) + err := migration.SeedGlobals(ctx, []string{utils.CustomRolesPath}, conn, afero.NewIOFS(fsys)) + if errors.Is(err, os.ErrNotExist) { + return nil + } + return err } diff --git a/internal/migration/apply/apply.go b/internal/migration/apply/apply.go index 698a3ae53..224b342f7 100644 --- a/internal/migration/apply/apply.go +++ b/internal/migration/apply/apply.go @@ -2,9 +2,7 @@ package apply import ( "context" - "os" - "github.com/go-errors/errors" "github.com/jackc/pgx/v4" "github.com/spf13/afero" "github.com/supabase/cli/internal/migration/list" @@ -33,11 +31,3 @@ func applySeedFiles(ctx context.Context, conn *pgx.Conn, fsys afero.Fs) error { } return migration.SeedData(ctx, seeds, conn, afero.NewIOFS(fsys)) } - -func CreateCustomRoles(ctx context.Context, conn *pgx.Conn, fsys afero.Fs) error { - err := migration.SeedGlobals(ctx, []string{utils.CustomRolesPath}, conn, afero.NewIOFS(fsys)) - if errors.Is(err, os.ErrNotExist) { - return nil - } - return err -} diff --git a/internal/utils/flags/db_url.go b/internal/utils/flags/db_url.go index 6fc912179..d089f2d13 100644 --- a/internal/utils/flags/db_url.go +++ b/internal/utils/flags/db_url.go @@ -50,6 +50,11 @@ func ParseDatabaseConfig(flagSet *pflag.FlagSet, fsys afero.Fs) error { // Update connection config switch connType { case direct: + if err := utils.Config.Load("", utils.NewRootFS(fsys)); err != nil { + if !errors.Is(err, os.ErrNotExist) { + return err + } + } if flag := flagSet.Lookup("db-url"); flag != nil { config, err := pgconn.ParseConfig(flag.Value.String()) if err != nil { diff --git a/pkg/migration/seed.go b/pkg/migration/seed.go index 66dd876f6..44ac67ae0 100644 --- a/pkg/migration/seed.go +++ b/pkg/migration/seed.go @@ -60,7 +60,7 @@ func GetPendingSeeds(ctx context.Context, locals []string, conn *pgx.Conn, fsys func SeedData(ctx context.Context, pending []SeedFile, conn *pgx.Conn, fsys fs.FS) error { for _, seed := range pending { if seed.Dirty { - fmt.Fprintf(os.Stderr, "Updating seed file hash %s...\n", seed.Path) + fmt.Fprintf(os.Stderr, "Updating seed hash to %s...\n", seed.Path) } else { fmt.Fprintf(os.Stderr, "Seeding data from %s...\n", seed.Path) } From c805fc64e1ebc88d375541c224400cebc5d60619 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Mon, 7 Oct 2024 13:08:25 +0800 Subject: [PATCH 062/305] chore: create seed table separately --- internal/db/push/push_test.go | 3 ++- internal/link/link.go | 5 ++++- internal/link/link_test.go | 6 ++++-- internal/testing/helper/history.go | 9 ++++++++- pkg/migration/apply_test.go | 7 ++----- pkg/migration/history.go | 14 +++++++++++++- pkg/migration/seed.go | 5 +++++ pkg/migration/seed_test.go | 15 +++++++++++++-- 8 files changed, 51 insertions(+), 13 deletions(-) diff --git a/internal/db/push/push_test.go b/internal/db/push/push_test.go index 631c2cc7e..3a3ff3cda 100644 --- a/internal/db/push/push_test.go +++ b/internal/db/push/push_test.go @@ -180,7 +180,8 @@ func TestPushAll(t *testing.T) { Reply("SELECT 0") helper.MockMigrationHistory(conn). Query(migration.INSERT_MIGRATION_VERSION, "0", "test", nil). - Reply("INSERT 0 1"). + Reply("INSERT 0 1") + helper.MockSeedHistory(conn). Query(migration.UPSERT_SEED_FILE, seedPath, digest). ReplyError(pgerrcode.NotNullViolation, `null value in column "hash" of relation "seed_files"`) // Run test diff --git a/internal/link/link.go b/internal/link/link.go index 3a2831070..1d3824b84 100644 --- a/internal/link/link.go +++ b/internal/link/link.go @@ -183,7 +183,10 @@ func linkDatabase(ctx context.Context, config pgconn.Config, options ...func(*pg defer conn.Close(context.Background()) updatePostgresConfig(conn) // If `schema_migrations` doesn't exist on the remote database, create it. - return migration.CreateMigrationTable(ctx, conn) + if err := migration.CreateMigrationTable(ctx, conn); err != nil { + return err + } + return migration.CreateSeedTable(ctx, conn) } func linkDatabaseVersion(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/link/link_test.go b/internal/link/link_test.go index af17eb9f5..edc95d8fa 100644 --- a/internal/link/link_test.go +++ b/internal/link/link_test.go @@ -46,6 +46,7 @@ func TestLinkCommand(t *testing.T) { conn := pgtest.NewConn() defer conn.Close(t) helper.MockMigrationHistory(conn) + helper.MockSeedHistory(conn) // Flush pending mocks after test execution defer gock.OffAll() gock.New(utils.DefaultApiHost). @@ -279,6 +280,7 @@ func TestLinkDatabase(t *testing.T) { }) defer conn.Close(t) helper.MockMigrationHistory(conn) + helper.MockSeedHistory(conn) // Run test err := linkDatabase(context.Background(), dbConfig, conn.Intercept) // Check error @@ -294,6 +296,7 @@ func TestLinkDatabase(t *testing.T) { }) defer conn.Close(t) helper.MockMigrationHistory(conn) + helper.MockSeedHistory(conn) // Run test err := linkDatabase(context.Background(), dbConfig, conn.Intercept) // Check error @@ -313,8 +316,7 @@ func TestLinkDatabase(t *testing.T) { Query(migration.CREATE_VERSION_TABLE). ReplyError(pgerrcode.InsufficientPrivilege, "permission denied for relation supabase_migrations"). Query(migration.ADD_STATEMENTS_COLUMN). - Query(migration.ADD_NAME_COLUMN). - Query(migration.CREATE_SEED_TABLE) + Query(migration.ADD_NAME_COLUMN) // Run test err := linkDatabase(context.Background(), dbConfig, conn.Intercept) // Check error diff --git a/internal/testing/helper/history.go b/internal/testing/helper/history.go index 30f4a0ca2..95c846b7a 100644 --- a/internal/testing/helper/history.go +++ b/internal/testing/helper/history.go @@ -14,7 +14,14 @@ func MockMigrationHistory(conn *pgtest.MockConn) *pgtest.MockConn { Query(migration.ADD_STATEMENTS_COLUMN). Reply("ALTER TABLE"). Query(migration.ADD_NAME_COLUMN). - Reply("ALTER TABLE"). + Reply("ALTER TABLE") + return conn +} + +func MockSeedHistory(conn *pgtest.MockConn) *pgtest.MockConn { + conn.Query(migration.SET_LOCK_TIMEOUT). + Query(migration.CREATE_VERSION_SCHEMA). + Reply("CREATE SCHEMA"). Query(migration.CREATE_SEED_TABLE). Reply("CREATE TABLE") return conn diff --git a/pkg/migration/apply_test.go b/pkg/migration/apply_test.go index 7415dfce2..65a75028a 100644 --- a/pkg/migration/apply_test.go +++ b/pkg/migration/apply_test.go @@ -130,8 +130,7 @@ func TestApplyMigrations(t *testing.T) { Query(CREATE_VERSION_TABLE). ReplyError(pgerrcode.InsufficientPrivilege, "permission denied for relation supabase_migrations"). Query(ADD_STATEMENTS_COLUMN). - Query(ADD_NAME_COLUMN). - Query(CREATE_SEED_TABLE) + Query(ADD_NAME_COLUMN) // Run test err := ApplyMigrations(context.Background(), pending, conn.MockClient(t), fsys) // Check error @@ -176,8 +175,6 @@ func mockMigrationHistory(conn *pgtest.MockConn) *pgtest.MockConn { Query(ADD_STATEMENTS_COLUMN). Reply("ALTER TABLE"). Query(ADD_NAME_COLUMN). - Reply("ALTER TABLE"). - Query(CREATE_SEED_TABLE). - Reply("CREATE TABLE") + Reply("ALTER TABLE") return conn } diff --git a/pkg/migration/history.go b/pkg/migration/history.go index 832651874..5ff77ae6b 100644 --- a/pkg/migration/history.go +++ b/pkg/migration/history.go @@ -36,7 +36,6 @@ func CreateMigrationTable(ctx context.Context, conn *pgx.Conn) error { batch.ExecParams(CREATE_VERSION_TABLE, nil, nil, nil, nil) batch.ExecParams(ADD_STATEMENTS_COLUMN, nil, nil, nil, nil) batch.ExecParams(ADD_NAME_COLUMN, nil, nil, nil, nil) - batch.ExecParams(CREATE_SEED_TABLE, nil, nil, nil, nil) if _, err := conn.PgConn().ExecBatch(ctx, &batch).ReadAll(); err != nil { return errors.Errorf("failed to create migration table: %w", err) } @@ -51,6 +50,19 @@ func ReadMigrationTable(ctx context.Context, conn *pgx.Conn) ([]MigrationFile, e return pgxv5.CollectRows[MigrationFile](rows) } +func CreateSeedTable(ctx context.Context, conn *pgx.Conn) error { + // This must be run without prepared statements because each statement in the batch depends on + // the previous schema change. The lock timeout will be reset when implicit transaction ends. + batch := pgconn.Batch{} + batch.ExecParams(SET_LOCK_TIMEOUT, nil, nil, nil, nil) + batch.ExecParams(CREATE_VERSION_SCHEMA, nil, nil, nil, nil) + batch.ExecParams(CREATE_SEED_TABLE, nil, nil, nil, nil) + if _, err := conn.PgConn().ExecBatch(ctx, &batch).ReadAll(); err != nil { + return errors.Errorf("failed to create migration table: %w", err) + } + return nil +} + func ReadSeedTable(ctx context.Context, conn *pgx.Conn) ([]SeedFile, error) { rows, err := conn.Query(ctx, SELECT_SEED_TABLE) if err != nil { diff --git a/pkg/migration/seed.go b/pkg/migration/seed.go index 44ac67ae0..988e8d4bc 100644 --- a/pkg/migration/seed.go +++ b/pkg/migration/seed.go @@ -58,6 +58,11 @@ func GetPendingSeeds(ctx context.Context, locals []string, conn *pgx.Conn, fsys } func SeedData(ctx context.Context, pending []SeedFile, conn *pgx.Conn, fsys fs.FS) error { + if len(pending) > 0 { + if err := CreateSeedTable(ctx, conn); err != nil { + return err + } + } for _, seed := range pending { if seed.Dirty { fmt.Fprintf(os.Stderr, "Updating seed hash to %s...\n", seed.Path) diff --git a/pkg/migration/seed_test.go b/pkg/migration/seed_test.go index f3ba81650..7e9cd4aca 100644 --- a/pkg/migration/seed_test.go +++ b/pkg/migration/seed_test.go @@ -102,7 +102,8 @@ func TestSeedData(t *testing.T) { // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) - conn.Query(UPSERT_SEED_FILE, seed.Path, seed.Hash). + mockSeedHistory(conn). + Query(UPSERT_SEED_FILE, seed.Path, seed.Hash). Reply("INSERT 0 1") // Run test err := SeedData(context.Background(), []SeedFile{seed}, conn.MockClient(t), testMigrations) @@ -118,7 +119,8 @@ func TestSeedData(t *testing.T) { // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) - conn.Query(testSeed+`;INSERT INTO supabase_migrations.seed_files(path, hash) VALUES( 'testdata/seed.sql' , '61868484fc0ddca2a2022217629a9fd9a4cf1ca479432046290797d6d40ffcc3' ) ON CONFLICT (path) DO UPDATE SET hash = EXCLUDED.hash`). + mockSeedHistory(conn). + Query(testSeed+`;INSERT INTO supabase_migrations.seed_files(path, hash) VALUES( 'testdata/seed.sql' , '61868484fc0ddca2a2022217629a9fd9a4cf1ca479432046290797d6d40ffcc3' ) ON CONFLICT (path) DO UPDATE SET hash = EXCLUDED.hash`). ReplyError(pgerrcode.NotNullViolation, `null value in column "age" of relation "employees"`) // Run test err := SeedData(context.Background(), []SeedFile{seed}, conn.MockClient(t, func(cc *pgx.ConnConfig) { @@ -129,6 +131,15 @@ func TestSeedData(t *testing.T) { }) } +func mockSeedHistory(conn *pgtest.MockConn) *pgtest.MockConn { + conn.Query(SET_LOCK_TIMEOUT). + Query(CREATE_VERSION_SCHEMA). + Reply("CREATE SCHEMA"). + Query(CREATE_SEED_TABLE). + Reply("CREATE TABLE") + return conn +} + //go:embed testdata/1_globals.sql var testGlobals string From e642265f0d1a27a776538c520cc80de91736b25d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 16:31:19 +0800 Subject: [PATCH 063/305] chore(deps): bump bin-links from 4.0.4 to 5.0.0 (#2712) Bumps [bin-links](https://github.com/npm/bin-links) from 4.0.4 to 5.0.0. - [Release notes](https://github.com/npm/bin-links/releases) - [Changelog](https://github.com/npm/bin-links/blob/main/CHANGELOG.md) - [Commits](https://github.com/npm/bin-links/compare/v4.0.4...v5.0.0) --- updated-dependencies: - dependency-name: bin-links dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 54a6ae29f..dd3014d22 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "supabase": "bin/supabase" }, "dependencies": { - "bin-links": "^4.0.3", + "bin-links": "^5.0.0", "https-proxy-agent": "^7.0.2", "node-fetch": "^3.3.2", "tar": "7.4.3" From 52dfb4dbc907cf25231be3210cd70ee0526077b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Tue, 8 Oct 2024 16:46:15 +0900 Subject: [PATCH 064/305] fix: bump edge-runtime to 1.58.12 (#2733) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index c51e19fbd..6240c5b5d 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.83.2" studioImage = "supabase/studio:20240930-16f2b8e" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.58.11" + edgeRuntimeImage = "supabase/edge-runtime:v1.58.12" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.158.1" From ce26abdb52b26a6c88cda6b47cad25801c44c421 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Tue, 8 Oct 2024 12:37:06 +0200 Subject: [PATCH 065/305] feat: check project status at link time (#2730) * feat: check project status at link time * fix: link color * fix: testing * chore: use get project endpoint * chore: apply review suggestions --- api/beta.yaml | 25 +++++++++ internal/link/link.go | 28 ++++++++++ internal/link/link_test.go | 31 +++++++++++ pkg/api/client.gen.go | 109 +++++++++++++++++++++++++++++++++++++ 4 files changed, 193 insertions(+) diff --git a/api/beta.yaml b/api/beta.yaml index 79f3dc8f0..cba870c1e 100644 --- a/api/beta.yaml +++ b/api/beta.yaml @@ -817,6 +817,31 @@ paths: security: - bearer: [] /v1/projects/{ref}: + get: + operationId: v1-get-project + summary: Gets a specific project that belongs to the authenticated user + parameters: + - name: ref + required: true + in: path + description: Project ref + schema: + minLength: 20 + maxLength: 20 + type: string + responses: + '200': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/V1ProjectResponse' + '500': + description: Failed to retrieve project + tags: + - Projects + security: + - bearer: [] delete: operationId: v1-delete-a-project summary: Deletes the given project diff --git a/internal/link/link.go b/internal/link/link.go index 1d3824b84..0c2aa1de4 100644 --- a/internal/link/link.go +++ b/internal/link/link.go @@ -29,6 +29,11 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func( "api": utils.Config.Api, "db": utils.Config.Db, }) + + if err := checkRemoteProjectStatus(ctx, projectRef); err != nil { + return err + } + // 1. Check service config keys, err := tenant.GetApiKeys(ctx, projectRef) if err != nil { @@ -236,3 +241,26 @@ func updatePoolerConfig(config api.SupavisorConfigResponse) { utils.Config.Db.Pooler.MaxClientConn = uint(*config.MaxClientConn) } } + +func checkRemoteProjectStatus(ctx context.Context, projectRef string) error { + resp, err := utils.GetSupabase().V1GetProjectWithResponse(ctx, projectRef) + if err != nil { + return errors.Errorf("failed to retrieve remote project status: %w", err) + } + if resp.JSON200 == nil { + return errors.New("Unexpected error retrieving remote project status: " + string(resp.Body)) + } + + switch resp.JSON200.Status { + case api.V1ProjectResponseStatusINACTIVE: + utils.CmdSuggestion = fmt.Sprintf("An admin must unpause it from the Supabase dashboard at %s", utils.Aqua(fmt.Sprintf("%s/project/%s", utils.GetSupabaseDashboardURL(), projectRef))) + return errors.New("project is paused") + case api.V1ProjectResponseStatusACTIVEHEALTHY: + // Project is in the desired state, do nothing + return nil + default: + fmt.Fprintf(os.Stderr, "%s: Project status is %s instead of Active Healthy. Some operations might fail.\n", utils.Yellow("Warning"), resp.JSON200.Status) + } + + return nil +} diff --git a/internal/link/link_test.go b/internal/link/link_test.go index edc95d8fa..f39388bfd 100644 --- a/internal/link/link_test.go +++ b/internal/link/link_test.go @@ -49,6 +49,11 @@ func TestLinkCommand(t *testing.T) { helper.MockSeedHistory(conn) // Flush pending mocks after test execution defer gock.OffAll() + // Mock project status + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project). + Reply(200). + JSON(api.V1ProjectResponse{Status: api.V1ProjectResponseStatusACTIVEHEALTHY}) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/api-keys"). Reply(200). @@ -120,6 +125,11 @@ func TestLinkCommand(t *testing.T) { fsys := afero.NewMemMapFs() // Flush pending mocks after test execution defer gock.OffAll() + // Mock project status + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project). + Reply(200). + JSON(api.V1ProjectResponse{Status: api.V1ProjectResponseStatusACTIVEHEALTHY}) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/api-keys"). Reply(200). @@ -160,6 +170,11 @@ func TestLinkCommand(t *testing.T) { fsys := afero.NewReadOnlyFs(afero.NewMemMapFs()) // Flush pending mocks after test execution defer gock.OffAll() + // Mock project status + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project). + Reply(200). + JSON(api.V1ProjectResponse{Status: api.V1ProjectResponseStatusACTIVEHEALTHY}) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/api-keys"). Reply(200). @@ -194,6 +209,22 @@ func TestLinkCommand(t *testing.T) { assert.NoError(t, err) assert.False(t, exists) }) + t.Run("throws error on project inactive", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewReadOnlyFs(afero.NewMemMapFs()) + // Flush pending mocks after test execution + defer gock.OffAll() + // Mock project status + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project). + Reply(200). + JSON(api.V1ProjectResponse{Status: api.V1ProjectResponseStatusINACTIVE}) + // Run test + err := Run(context.Background(), project, fsys) + // Check error + assert.ErrorContains(t, err, "project is paused") + assert.Empty(t, apitest.ListUnmatchedRequests()) + }) } func TestLinkPostgrest(t *testing.T) { diff --git a/pkg/api/client.gen.go b/pkg/api/client.gen.go index 594246049..151b764e7 100644 --- a/pkg/api/client.gen.go +++ b/pkg/api/client.gen.go @@ -136,6 +136,9 @@ type ClientInterface interface { // V1DeleteAProject request V1DeleteAProject(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1GetProject request + V1GetProject(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1GetProjectApiKeys request V1GetProjectApiKeys(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -581,6 +584,18 @@ func (c *Client) V1DeleteAProject(ctx context.Context, ref string, reqEditors .. return c.Client.Do(req) } +func (c *Client) V1GetProject(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1GetProjectRequest(c.Server, ref) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) V1GetProjectApiKeys(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewV1GetProjectApiKeysRequest(c.Server, ref) if err != nil { @@ -2211,6 +2226,40 @@ func NewV1DeleteAProjectRequest(server string, ref string) (*http.Request, error return req, nil } +// NewV1GetProjectRequest generates requests for V1GetProject +func NewV1GetProjectRequest(server string, ref string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewV1GetProjectApiKeysRequest generates requests for V1GetProjectApiKeys func NewV1GetProjectApiKeysRequest(server string, ref string) (*http.Request, error) { var err error @@ -5127,6 +5176,9 @@ type ClientWithResponsesInterface interface { // V1DeleteAProjectWithResponse request V1DeleteAProjectWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1DeleteAProjectResponse, error) + // V1GetProjectWithResponse request + V1GetProjectWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetProjectResponse, error) + // V1GetProjectApiKeysWithResponse request V1GetProjectApiKeysWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetProjectApiKeysResponse, error) @@ -5653,6 +5705,28 @@ func (r V1DeleteAProjectResponse) StatusCode() int { return 0 } +type V1GetProjectResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *V1ProjectResponse +} + +// Status returns HTTPResponse.Status +func (r V1GetProjectResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r V1GetProjectResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type V1GetProjectApiKeysResponse struct { Body []byte HTTPResponse *http.Response @@ -7198,6 +7272,15 @@ func (c *ClientWithResponses) V1DeleteAProjectWithResponse(ctx context.Context, return ParseV1DeleteAProjectResponse(rsp) } +// V1GetProjectWithResponse request returning *V1GetProjectResponse +func (c *ClientWithResponses) V1GetProjectWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetProjectResponse, error) { + rsp, err := c.V1GetProject(ctx, ref, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1GetProjectResponse(rsp) +} + // V1GetProjectApiKeysWithResponse request returning *V1GetProjectApiKeysResponse func (c *ClientWithResponses) V1GetProjectApiKeysWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetProjectApiKeysResponse, error) { rsp, err := c.V1GetProjectApiKeys(ctx, ref, reqEditors...) @@ -8294,6 +8377,32 @@ func ParseV1DeleteAProjectResponse(rsp *http.Response) (*V1DeleteAProjectRespons return response, nil } +// ParseV1GetProjectResponse parses an HTTP response from a V1GetProjectWithResponse call +func ParseV1GetProjectResponse(rsp *http.Response) (*V1GetProjectResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &V1GetProjectResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest V1ProjectResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParseV1GetProjectApiKeysResponse parses an HTTP response from a V1GetProjectApiKeysWithResponse call func ParseV1GetProjectApiKeysResponse(rsp *http.Response) (*V1GetProjectApiKeysResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) From fcd8ea08e905dcf7508713c4d324376efd464b3a Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 9 Oct 2024 02:45:55 +0800 Subject: [PATCH 066/305] fix: update path separator for windows glob (#2735) --- pkg/config/config.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 0b2468224..80270124c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -14,6 +14,7 @@ import ( "net/http" "net/url" "os" + "path" "path/filepath" "regexp" "sort" @@ -1061,8 +1062,10 @@ func (c *seed) loadSeedPaths(basePath string, fsys fs.FS) error { } set := make(map[string]struct{}) for _, pattern := range c.GlobPatterns { + // Glob expects / as path separator on windows + pattern = filepath.ToSlash(pattern) if !filepath.IsAbs(pattern) { - pattern = filepath.Join(basePath, pattern) + pattern = path.Join(basePath, pattern) } matches, err := fs.Glob(fsys, pattern) if err != nil { From 5c98d66fce46a28d3a2880e5fae90abfac9e0197 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 04:52:46 +0000 Subject: [PATCH 067/305] chore(deps): bump google.golang.org/grpc from 1.66.2 to 1.67.1 (#2739) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.66.2 to 1.67.1. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.66.2...v1.67.1) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index aff55f8eb..d1756a3c8 100644 --- a/go.mod +++ b/go.mod @@ -53,7 +53,7 @@ require ( golang.org/x/mod v0.21.0 golang.org/x/oauth2 v0.23.0 golang.org/x/term v0.24.0 - google.golang.org/grpc v1.66.2 + google.golang.org/grpc v1.67.1 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.12.0 ) @@ -340,8 +340,8 @@ require ( golang.org/x/sys v0.25.0 // indirect golang.org/x/text v0.17.0 // indirect golang.org/x/tools v0.24.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect diff --git a/go.sum b/go.sum index 43131167a..07832e774 100644 --- a/go.sum +++ b/go.sum @@ -1462,10 +1462,10 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094 h1:0+ozOGcrp+Y8Aq8TLNN2Aliibms5LEzsq99ZZmAGYm0= -google.golang.org/genproto/googleapis/api v0.0.0-20240701130421-f6361c86f094/go.mod h1:fJ/e3If/Q67Mj99hin0hMhiNyCRmt6BQ2aWIJshUSJw= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 h1:BwIjyKYGsK9dMCBOorzRri8MQwmi7mT9rGHsCEinZkA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.0.5/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -1479,8 +1479,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.66.2 h1:3QdXkuq3Bkh7w+ywLdLvM56cmGvQHUMZpiCzt6Rqaoo= -google.golang.org/grpc v1.66.2/go.mod h1:s3/l6xSSCURdVfAnL+TqCNMyTDAGN6+lZeVxnZR128Y= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From d5cb75f2e52315dbe07d50469a737527463fdfed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 04:57:09 +0000 Subject: [PATCH 068/305] chore(deps): bump github.com/docker/cli from 27.2.1+incompatible to 27.3.1+incompatible (#2740) chore(deps): bump github.com/docker/cli Bumps [github.com/docker/cli](https://github.com/docker/cli) from 27.2.1+incompatible to 27.3.1+incompatible. - [Commits](https://github.com/docker/cli/compare/v27.2.1...v27.3.1) --- updated-dependencies: - dependency-name: github.com/docker/cli dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d1756a3c8..7b7552fe9 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/containers/common v0.60.4 github.com/danieljoos/wincred v1.2.1 github.com/deepmap/oapi-codegen/v2 v2.2.0 - github.com/docker/cli v27.2.1+incompatible + github.com/docker/cli v27.3.1+incompatible github.com/docker/docker v27.2.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 diff --git a/go.sum b/go.sum index 07832e774..ddb0428d2 100644 --- a/go.sum +++ b/go.sum @@ -234,8 +234,8 @@ github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk= github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE= -github.com/docker/cli v27.2.1+incompatible h1:U5BPtiD0viUzjGAjV1p0MGB8eVA3L3cbIrnyWmSJI70= -github.com/docker/cli v27.2.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v27.3.1+incompatible h1:qEGdFBF3Xu6SCvCYhc7CzaQTlBmqDuzxPDpigSyeKQQ= +github.com/docker/cli v27.3.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= From 6fb25bc0bf100272d136f90a0902d6fd14f4a3d1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 05:01:28 +0000 Subject: [PATCH 069/305] chore(deps): bump github.com/docker/docker from 27.2.1+incompatible to 27.3.1+incompatible (#2741) chore(deps): bump github.com/docker/docker Bumps [github.com/docker/docker](https://github.com/docker/docker) from 27.2.1+incompatible to 27.3.1+incompatible. - [Release notes](https://github.com/docker/docker/releases) - [Commits](https://github.com/docker/docker/compare/v27.2.1...v27.3.1) --- updated-dependencies: - dependency-name: github.com/docker/docker dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7b7552fe9..75fde9770 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/danieljoos/wincred v1.2.1 github.com/deepmap/oapi-codegen/v2 v2.2.0 github.com/docker/cli v27.3.1+incompatible - github.com/docker/docker v27.2.1+incompatible + github.com/docker/docker v27.3.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 github.com/getsentry/sentry-go v0.28.1 diff --git a/go.sum b/go.sum index ddb0428d2..b55cc5fc9 100644 --- a/go.sum +++ b/go.sum @@ -239,8 +239,8 @@ github.com/docker/cli v27.3.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvM github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v27.2.1+incompatible h1:fQdiLfW7VLscyoeYEBz7/J8soYFDZV1u6VW6gJEjNMI= -github.com/docker/docker v27.2.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.3.1+incompatible h1:KttF0XoteNTicmUtBO0L2tP+J7FGRFTjaEF4k6WdhfI= +github.com/docker/docker v27.3.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo= github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0= From dd8ee93bdd0b57c8b1a23653d60a7fbd779aa6cb Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 9 Oct 2024 15:34:00 +0800 Subject: [PATCH 070/305] fix(storage): update default storage version to 1.11.13 (#2743) --- internal/db/start/start.go | 1 + pkg/config/constants.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/db/start/start.go b/internal/db/start/start.go index 822e9aff6..826d46c86 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -263,6 +263,7 @@ func initStorageJob(host string) utils.DockerJob { fmt.Sprintf("DATABASE_URL=postgresql://supabase_storage_admin:%s@%s:5432/postgres", utils.Config.Db.Password, host), fmt.Sprintf("FILE_SIZE_LIMIT=%v", utils.Config.Storage.FileSizeLimit), "STORAGE_BACKEND=file", + "STORAGE_FILE_BACKEND_PATH=/mnt", "TENANT_ID=stub", // TODO: https://github.com/supabase/storage-api/issues/55 "REGION=stub", diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 6240c5b5d..51f7a0f99 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -17,7 +17,7 @@ const ( supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.158.1" realtimeImage = "supabase/realtime:v2.30.34" - storageImage = "supabase/storage-api:v1.10.1" + storageImage = "supabase/storage-api:v1.11.13" logflareImage = "supabase/logflare:1.4.0" // Append to JobImages when adding new dependencies below DifferImage = "supabase/pgadmin-schema-diff:cli-0.0.5" From bd0955ca5d322f83bd27e0b03fc55e3fa6b69759 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 9 Oct 2024 19:12:00 +0800 Subject: [PATCH 071/305] fix(migration): handle null value when fetching migration name (#2746) --- pkg/migration/history.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/migration/history.go b/pkg/migration/history.go index 5ff77ae6b..2ca14167b 100644 --- a/pkg/migration/history.go +++ b/pkg/migration/history.go @@ -19,7 +19,7 @@ const ( DELETE_MIGRATION_VERSION = "DELETE FROM supabase_migrations.schema_migrations WHERE version = ANY($1)" DELETE_MIGRATION_BEFORE = "DELETE FROM supabase_migrations.schema_migrations WHERE version <= $1" TRUNCATE_VERSION_TABLE = "TRUNCATE supabase_migrations.schema_migrations" - SELECT_VERSION_TABLE = "SELECT * FROM supabase_migrations.schema_migrations" + SELECT_VERSION_TABLE = "SELECT version, coalesce(name, '') as name, statements FROM supabase_migrations.schema_migrations" LIST_MIGRATION_VERSION = "SELECT version FROM supabase_migrations.schema_migrations ORDER BY version" CREATE_SEED_TABLE = "CREATE TABLE IF NOT EXISTS supabase_migrations.seed_files (path text NOT NULL PRIMARY KEY, hash text NOT NULL)" UPSERT_SEED_FILE = "INSERT INTO supabase_migrations.seed_files(path, hash) VALUES($1, $2) ON CONFLICT (path) DO UPDATE SET hash = EXCLUDED.hash" From 5794fd935df7f44e6f8ba14b84d553de7e665ab9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2024 04:31:49 +0000 Subject: [PATCH 072/305] chore(deps): bump github.com/andybalholm/brotli from 1.1.0 to 1.1.1 (#2756) Bumps [github.com/andybalholm/brotli](https://github.com/andybalholm/brotli) from 1.1.0 to 1.1.1. - [Commits](https://github.com/andybalholm/brotli/compare/v1.1.0...v1.1.1) --- updated-dependencies: - dependency-name: github.com/andybalholm/brotli dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 75fde9770..8e955d0cb 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,7 @@ go 1.22.4 require ( github.com/BurntSushi/toml v1.4.0 github.com/Netflix/go-env v0.0.0-20220526054621-78278af1949d - github.com/andybalholm/brotli v1.1.0 + github.com/andybalholm/brotli v1.1.1 github.com/cenkalti/backoff/v4 v4.3.0 github.com/charmbracelet/bubbles v0.18.0 github.com/charmbracelet/bubbletea v0.25.0 diff --git a/go.sum b/go.sum index b55cc5fc9..1fe441a6e 100644 --- a/go.sum +++ b/go.sum @@ -95,8 +95,8 @@ github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pO github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQRnw= github.com/alingse/asasalint v0.0.11/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= -github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M= -github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY= +github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= +github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= @@ -992,6 +992,8 @@ github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17 github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xen0n/gosmopolitan v1.2.2 h1:/p2KTnMzwRexIW8GlKawsTWOxn7UHA+jCMF/V8HHtvU= github.com/xen0n/gosmopolitan v1.2.2/go.mod h1:7XX7Mj61uLYrj0qmeN0zi7XDon9JRAEhYQqAPLVNTeg= +github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU= +github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E= github.com/yagipy/maintidx v1.0.0 h1:h5NvIsCz+nRDapQ0exNv4aJ0yXSI0420omVANTv3GJM= github.com/yagipy/maintidx v1.0.0/go.mod h1:0qNf/I/CCZXSMhsRsrEPDZ+DkekpKLXAJfsTACwgXLk= github.com/yeya24/promlinter v0.3.0 h1:JVDbMp08lVCP7Y6NP3qHroGAO6z2yGKQtS5JsjqtoFs= From 8e518914fb6721a8e438611c8d5b6530a7d5fc6a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 01:17:31 +0800 Subject: [PATCH 073/305] chore(deps): bump github.com/Netflix/go-env from 0.0.0-20220526054621-78278af1949d to 0.1.0 (#2755) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 8e955d0cb..663659572 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.22.4 require ( github.com/BurntSushi/toml v1.4.0 - github.com/Netflix/go-env v0.0.0-20220526054621-78278af1949d + github.com/Netflix/go-env v0.1.0 github.com/andybalholm/brotli v1.1.1 github.com/cenkalti/backoff/v4 v4.3.0 github.com/charmbracelet/bubbles v0.18.0 diff --git a/go.sum b/go.sum index 1fe441a6e..6fb5e191b 100644 --- a/go.sum +++ b/go.sum @@ -65,8 +65,8 @@ github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYr github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/Netflix/go-env v0.0.0-20220526054621-78278af1949d h1:wvStE9wLpws31NiWUx+38wny1msZ/tm+eL5xmm4Y7So= -github.com/Netflix/go-env v0.0.0-20220526054621-78278af1949d/go.mod h1:9XMFaCeRyW7fC9XJOWQ+NdAv8VLG7ys7l3x4ozEGLUQ= +github.com/Netflix/go-env v0.1.0 h1:qSMk2A4D6urE/YqOKpLeOkaATGmFmMLo56E7kNNKypk= +github.com/Netflix/go-env v0.1.0/go.mod h1:9IRTAm+pQDPMpUtMLR26JOrjHnAWz3KUbhaegqTdhfY= github.com/OpenPeeDeeP/depguard/v2 v2.2.0 h1:vDfG60vDtIuf0MEOhmLlLLSzqaRM8EMcgJPdp74zmpA= github.com/OpenPeeDeeP/depguard/v2 v2.2.0/go.mod h1:CIzddKRvLBC4Au5aYP/i3nyaWQ+ClszLIuVocRiCYFQ= github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= From 87116d59dbd9082912363a42328dcd97fde7c2a1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 01:17:45 +0800 Subject: [PATCH 074/305] chore(deps): bump golang.org/x/term from 0.24.0 to 0.25.0 (#2757) --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 663659572..0cdb11ba0 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( go.opentelemetry.io/otel v1.30.0 golang.org/x/mod v0.21.0 golang.org/x/oauth2 v0.23.0 - golang.org/x/term v0.24.0 + golang.org/x/term v0.25.0 google.golang.org/grpc v1.67.1 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.12.0 @@ -337,7 +337,7 @@ require ( golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.25.0 // indirect + golang.org/x/sys v0.26.0 // indirect golang.org/x/text v0.17.0 // indirect golang.org/x/tools v0.24.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect diff --git a/go.sum b/go.sum index 6fb5e191b..9fdb5c2d2 100644 --- a/go.sum +++ b/go.sum @@ -1293,8 +1293,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= +golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1309,8 +1309,8 @@ golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= -golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= -golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= +golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= +golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 4d8e3e61d9ace427228b01bc47ed7901a6d1b917 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Thu, 10 Oct 2024 12:03:46 +0800 Subject: [PATCH 075/305] chore: update openapi client --- api/beta.yaml | 277 ++++++++++++++++++++++- pkg/api/client.gen.go | 509 +++++++++++++++++++++++++++++++++++++++--- pkg/api/types.gen.go | 152 +++++++++++-- 3 files changed, 875 insertions(+), 63 deletions(-) diff --git a/api/beta.yaml b/api/beta.yaml index cba870c1e..f4b0c08c2 100644 --- a/api/beta.yaml +++ b/api/beta.yaml @@ -340,6 +340,98 @@ paths: type: array items: $ref: '#/components/schemas/ApiKeyResponse' + tags: + - Secrets + security: + - bearer: [] + post: + operationId: createApiKey + summary: '[Alpha] Creates a new API key for the project' + parameters: + - name: ref + required: true + in: path + description: Project ref + schema: + minLength: 20 + maxLength: 20 + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/CreateApiKeyBody' + responses: + '201': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ApiKeyResponse' + tags: + - Secrets + security: + - bearer: [] + /v1/projects/{ref}/api-keys/{id}: + patch: + operationId: updateApiKey + summary: '[Alpha] Updates an API key for the project' + parameters: + - name: ref + required: true + in: path + description: Project ref + schema: + minLength: 20 + maxLength: 20 + type: string + - name: id + required: true + in: path + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateApiKeyBody' + responses: + '200': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ApiKeyResponse' + tags: + - Secrets + security: + - bearer: [] + delete: + operationId: deleteApiKey + summary: '[Alpha] Deletes an API key for the project' + parameters: + - name: ref + required: true + in: path + description: Project ref + schema: + minLength: 20 + maxLength: 20 + type: string + - name: id + required: true + in: path + schema: + type: string + responses: + '200': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ApiKeyResponse' '403': description: '' tags: @@ -1217,7 +1309,7 @@ paths: - bearer: [] /v1/projects/{ref}/upgrade/eligibility: get: - operationId: v1-get-postgrest-upgrade-eligibility + operationId: v1-get-postgres-upgrade-eligibility summary: '[Beta] Returns the project''s eligibility for upgrades' parameters: - name: ref @@ -1245,7 +1337,7 @@ paths: - bearer: [] /v1/projects/{ref}/upgrade/status: get: - operationId: v1-get-postgrest-upgrade-status + operationId: v1-get-postgres-upgrade-status summary: '[Beta] Gets the latest status of the project''s upgrade' parameters: - name: ref @@ -1256,6 +1348,11 @@ paths: minLength: 20 maxLength: 20 type: string + - name: tracking_id + required: false + in: query + schema: + type: string responses: '200': description: '' @@ -1479,6 +1576,8 @@ paths: application/json: schema: $ref: '#/components/schemas/PostgresConfigResponse' + '403': + description: '' '500': description: Failed to update project's Postgres config tags: @@ -2426,6 +2525,10 @@ components: type: string postgres_version: type: string + postgres_engine: + type: string + release_channel: + type: string status: enum: - ACTIVE_HEALTHY @@ -2455,6 +2558,8 @@ components: - db_port - ref - postgres_version + - postgres_engine + - release_channel - status - db_host UpdateBranchBody: @@ -2547,9 +2652,17 @@ components: version: type: string description: Database version + postgres_engine: + type: string + description: Database engine + release_channel: + type: string + description: Release channel required: - host - version + - postgres_engine + - release_channel V1ProjectResponse: type: object properties: @@ -2609,6 +2722,21 @@ components: - 8xlarge - 12xlarge - 16xlarge + ReleaseChannel: + type: string + enum: + - internal + - alpha + - beta + - ga + - withdrawn + PostgresEngine: + type: string + description: >- + Postgres engine version. If not provided, the latest version will be + used. + enum: + - '15' V1CreateProjectBody: type: object properties: @@ -2635,6 +2763,7 @@ components: type: string enum: - us-east-1 + - us-east-2 - us-west-1 - us-west-2 - ap-east-1 @@ -2645,7 +2774,9 @@ components: - eu-west-1 - eu-west-2 - eu-west-3 + - eu-north-1 - eu-central-1 + - eu-central-2 - ca-central-1 - ap-south-1 - sa-east-1 @@ -2662,6 +2793,10 @@ components: description: Template URL used to create the project from the CLI. example: >- https://github.com/supabase/supabase/tree/master/examples/slack-clone/nextjs-slack-clone + release_channel: + $ref: '#/components/schemas/ReleaseChannel' + postgres_engine: + $ref: '#/components/schemas/PostgresEngine' required: - db_pass - name @@ -2851,6 +2986,13 @@ components: - owner - updated_by - content + ApiKeySecretJWTTemplate: + type: object + properties: + role: + type: string + required: + - role ApiKeyResponse: type: object properties: @@ -2858,14 +3000,70 @@ components: type: string api_key: type: string + id: + type: string + nullable: true + type: + nullable: true + type: object + prefix: + type: string + nullable: true + description: + type: string + nullable: true + hash: + type: string + nullable: true + secret_jwt_template: + nullable: true + allOf: + - $ref: '#/components/schemas/ApiKeySecretJWTTemplate' + inserted_at: + type: string + nullable: true + updated_at: + type: string + nullable: true required: - name - api_key + CreateApiKeyBody: + type: object + properties: + type: + enum: + - publishable + - secret + type: string + description: + type: string + nullable: true + secret_jwt_template: + nullable: true + allOf: + - $ref: '#/components/schemas/ApiKeySecretJWTTemplate' + required: + - type + UpdateApiKeyBody: + type: object + properties: + description: + type: string + nullable: true + secret_jwt_template: + nullable: true + allOf: + - $ref: '#/components/schemas/ApiKeySecretJWTTemplate' CreateBranchBody: type: object properties: desired_instance_size: $ref: '#/components/schemas/DesiredInstanceSize' + release_channel: + $ref: '#/components/schemas/ReleaseChannel' + postgres_engine: + $ref: '#/components/schemas/PostgresEngine' branch_name: type: string git_branch: @@ -3221,9 +3419,12 @@ components: UpgradeDatabaseBody: type: object properties: + release_channel: + $ref: '#/components/schemas/ReleaseChannel' target_version: - type: number + type: string required: + - release_channel - target_version ProjectUpgradeInitiateResponse: type: object @@ -3236,15 +3437,20 @@ components: type: object properties: postgres_version: - type: number + $ref: '#/components/schemas/PostgresEngine' + release_channel: + $ref: '#/components/schemas/ReleaseChannel' app_version: type: string required: - postgres_version + - release_channel - app_version ProjectUpgradeEligibilityResponse: type: object properties: + current_app_version_release_channel: + $ref: '#/components/schemas/ReleaseChannel' eligible: type: boolean current_app_version: @@ -3270,6 +3476,7 @@ components: items: type: string required: + - current_app_version_release_channel - eligible - current_app_version - latest_app_version @@ -3353,6 +3560,7 @@ components: type: string enum: - us-east-1 + - us-east-2 - us-west-1 - us-west-2 - ap-east-1 @@ -3363,7 +3571,9 @@ components: - eu-west-1 - eu-west-2 - eu-west-3 + - eu-north-1 - eu-central-1 + - eu-central-2 - ca-central-1 - ap-south-1 - sa-east-1 @@ -3437,10 +3647,10 @@ components: PostgresConfigResponse: type: object properties: - statement_timeout: - type: string effective_cache_size: type: string + logical_decoding_work_mem: + type: string maintenance_work_mem: type: string max_connections: @@ -3463,16 +3673,30 @@ components: type: integer minimum: 0 maximum: 1024 + max_replication_slots: + type: integer + max_slot_wal_keep_size: + type: string max_standby_archive_delay: type: string max_standby_streaming_delay: type: string + max_wal_size: + type: string + max_wal_senders: + type: integer max_worker_processes: type: integer minimum: 0 maximum: 262143 shared_buffers: type: string + statement_timeout: + type: string + wal_keep_size: + type: string + wal_sender_timeout: + type: string work_mem: type: string session_replication_role: @@ -3484,10 +3708,10 @@ components: UpdatePostgresConfigBody: type: object properties: - statement_timeout: - type: string effective_cache_size: type: string + logical_decoding_work_mem: + type: string maintenance_work_mem: type: string max_connections: @@ -3510,18 +3734,34 @@ components: type: integer minimum: 0 maximum: 1024 + max_replication_slots: + type: integer + max_slot_wal_keep_size: + type: string max_standby_archive_delay: type: string max_standby_streaming_delay: type: string + max_wal_size: + type: string + max_wal_senders: + type: integer max_worker_processes: type: integer minimum: 0 maximum: 262143 shared_buffers: type: string + statement_timeout: + type: string + wal_keep_size: + type: string + wal_sender_timeout: + type: string work_mem: type: string + restart_database: + type: boolean session_replication_role: enum: - origin @@ -3954,6 +4194,12 @@ components: mfa_phone_verify_enabled: type: boolean nullable: true + mfa_web_authn_enroll_enabled: + type: boolean + nullable: true + mfa_web_authn_verify_enabled: + type: boolean + nullable: true mfa_phone_otp_length: type: number mfa_phone_template: @@ -3998,6 +4244,9 @@ components: saml_external_url: type: string nullable: true + saml_allow_encrypted_assertions: + type: boolean + nullable: true security_captcha_enabled: type: boolean nullable: true @@ -4232,6 +4481,8 @@ components: - mfa_totp_verify_enabled - mfa_phone_enroll_enabled - mfa_phone_verify_enabled + - mfa_web_authn_enroll_enabled + - mfa_web_authn_verify_enabled - mfa_phone_otp_length - mfa_phone_template - mfa_phone_max_frequency @@ -4247,6 +4498,7 @@ components: - refresh_token_rotation_enabled - saml_enabled - saml_external_url + - saml_allow_encrypted_assertions - security_captcha_enabled - security_captcha_provider - security_captcha_secret @@ -4658,6 +4910,10 @@ components: type: boolean mfa_totp_verify_enabled: type: boolean + mfa_web_authn_enroll_enabled: + type: boolean + mfa_web_authn_verify_enabled: + type: boolean mfa_phone_enroll_enabled: type: boolean mfa_phone_verify_enabled: @@ -5113,11 +5369,16 @@ components: type: string enum: - AI_SQL_GENERATOR_OPT_IN + allowed_release_channels: + type: array + items: + $ref: '#/components/schemas/ReleaseChannel' id: type: string name: type: string required: - opt_in_tags + - allowed_release_channels - id - name diff --git a/pkg/api/client.gen.go b/pkg/api/client.gen.go index 151b764e7..b7c450896 100644 --- a/pkg/api/client.gen.go +++ b/pkg/api/client.gen.go @@ -142,6 +142,19 @@ type ClientInterface interface { // V1GetProjectApiKeys request V1GetProjectApiKeys(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + // CreateApiKeyWithBody request with any body + CreateApiKeyWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + CreateApiKey(ctx context.Context, ref string, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteApiKey request + DeleteApiKey(ctx context.Context, ref string, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateApiKeyWithBody request with any body + UpdateApiKeyWithBody(ctx context.Context, ref string, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UpdateApiKey(ctx context.Context, ref string, id string, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1DisablePreviewBranching request V1DisablePreviewBranching(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -351,11 +364,11 @@ type ClientInterface interface { V1UpgradePostgresVersion(ctx context.Context, ref string, body V1UpgradePostgresVersionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // V1GetPostgrestUpgradeEligibility request - V1GetPostgrestUpgradeEligibility(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1GetPostgresUpgradeEligibility request + V1GetPostgresUpgradeEligibility(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) - // V1GetPostgrestUpgradeStatus request - V1GetPostgrestUpgradeStatus(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1GetPostgresUpgradeStatus request + V1GetPostgresUpgradeStatus(ctx context.Context, ref string, params *V1GetPostgresUpgradeStatusParams, reqEditors ...RequestEditorFn) (*http.Response, error) // V1DeactivateVanitySubdomainConfig request V1DeactivateVanitySubdomainConfig(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -608,6 +621,66 @@ func (c *Client) V1GetProjectApiKeys(ctx context.Context, ref string, reqEditors return c.Client.Do(req) } +func (c *Client) CreateApiKeyWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateApiKeyRequestWithBody(c.Server, ref, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateApiKey(ctx context.Context, ref string, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateApiKeyRequest(c.Server, ref, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) DeleteApiKey(ctx context.Context, ref string, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteApiKeyRequest(c.Server, ref, id) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateApiKeyWithBody(ctx context.Context, ref string, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateApiKeyRequestWithBody(c.Server, ref, id, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpdateApiKey(ctx context.Context, ref string, id string, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateApiKeyRequest(c.Server, ref, id, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) V1DisablePreviewBranching(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewV1DisablePreviewBranchingRequest(c.Server, ref) if err != nil { @@ -1532,8 +1605,8 @@ func (c *Client) V1UpgradePostgresVersion(ctx context.Context, ref string, body return c.Client.Do(req) } -func (c *Client) V1GetPostgrestUpgradeEligibility(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewV1GetPostgrestUpgradeEligibilityRequest(c.Server, ref) +func (c *Client) V1GetPostgresUpgradeEligibility(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1GetPostgresUpgradeEligibilityRequest(c.Server, ref) if err != nil { return nil, err } @@ -1544,8 +1617,8 @@ func (c *Client) V1GetPostgrestUpgradeEligibility(ctx context.Context, ref strin return c.Client.Do(req) } -func (c *Client) V1GetPostgrestUpgradeStatus(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewV1GetPostgrestUpgradeStatusRequest(c.Server, ref) +func (c *Client) V1GetPostgresUpgradeStatus(ctx context.Context, ref string, params *V1GetPostgresUpgradeStatusParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1GetPostgresUpgradeStatusRequest(c.Server, ref, params) if err != nil { return nil, err } @@ -2294,6 +2367,148 @@ func NewV1GetProjectApiKeysRequest(server string, ref string) (*http.Request, er return req, nil } +// NewCreateApiKeyRequest calls the generic CreateApiKey builder with application/json body +func NewCreateApiKeyRequest(server string, ref string, body CreateApiKeyJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateApiKeyRequestWithBody(server, ref, "application/json", bodyReader) +} + +// NewCreateApiKeyRequestWithBody generates requests for CreateApiKey with any type of body +func NewCreateApiKeyRequestWithBody(server string, ref string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/api-keys", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewDeleteApiKeyRequest generates requests for DeleteApiKey +func NewDeleteApiKeyRequest(server string, ref string, id string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/api-keys/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewUpdateApiKeyRequest calls the generic UpdateApiKey builder with application/json body +func NewUpdateApiKeyRequest(server string, ref string, id string, body UpdateApiKeyJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateApiKeyRequestWithBody(server, ref, id, "application/json", bodyReader) +} + +// NewUpdateApiKeyRequestWithBody generates requests for UpdateApiKey with any type of body +func NewUpdateApiKeyRequestWithBody(server string, ref string, id string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/api-keys/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PATCH", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewV1DisablePreviewBranchingRequest generates requests for V1DisablePreviewBranching func NewV1DisablePreviewBranchingRequest(server string, ref string) (*http.Request, error) { var err error @@ -4773,8 +4988,8 @@ func NewV1UpgradePostgresVersionRequestWithBody(server string, ref string, conte return req, nil } -// NewV1GetPostgrestUpgradeEligibilityRequest generates requests for V1GetPostgrestUpgradeEligibility -func NewV1GetPostgrestUpgradeEligibilityRequest(server string, ref string) (*http.Request, error) { +// NewV1GetPostgresUpgradeEligibilityRequest generates requests for V1GetPostgresUpgradeEligibility +func NewV1GetPostgresUpgradeEligibilityRequest(server string, ref string) (*http.Request, error) { var err error var pathParam0 string @@ -4807,8 +5022,8 @@ func NewV1GetPostgrestUpgradeEligibilityRequest(server string, ref string) (*htt return req, nil } -// NewV1GetPostgrestUpgradeStatusRequest generates requests for V1GetPostgrestUpgradeStatus -func NewV1GetPostgrestUpgradeStatusRequest(server string, ref string) (*http.Request, error) { +// NewV1GetPostgresUpgradeStatusRequest generates requests for V1GetPostgresUpgradeStatus +func NewV1GetPostgresUpgradeStatusRequest(server string, ref string, params *V1GetPostgresUpgradeStatusParams) (*http.Request, error) { var err error var pathParam0 string @@ -4833,6 +5048,28 @@ func NewV1GetPostgrestUpgradeStatusRequest(server string, ref string) (*http.Req return nil, err } + if params != nil { + queryValues := queryURL.Query() + + if params.TrackingId != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "tracking_id", runtime.ParamLocationQuery, *params.TrackingId); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err @@ -5182,6 +5419,19 @@ type ClientWithResponsesInterface interface { // V1GetProjectApiKeysWithResponse request V1GetProjectApiKeysWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetProjectApiKeysResponse, error) + // CreateApiKeyWithBodyWithResponse request with any body + CreateApiKeyWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) + + CreateApiKeyWithResponse(ctx context.Context, ref string, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) + + // DeleteApiKeyWithResponse request + DeleteApiKeyWithResponse(ctx context.Context, ref string, id string, reqEditors ...RequestEditorFn) (*DeleteApiKeyResponse, error) + + // UpdateApiKeyWithBodyWithResponse request with any body + UpdateApiKeyWithBodyWithResponse(ctx context.Context, ref string, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) + + UpdateApiKeyWithResponse(ctx context.Context, ref string, id string, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) + // V1DisablePreviewBranchingWithResponse request V1DisablePreviewBranchingWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1DisablePreviewBranchingResponse, error) @@ -5391,11 +5641,11 @@ type ClientWithResponsesInterface interface { V1UpgradePostgresVersionWithResponse(ctx context.Context, ref string, body V1UpgradePostgresVersionJSONRequestBody, reqEditors ...RequestEditorFn) (*V1UpgradePostgresVersionResponse, error) - // V1GetPostgrestUpgradeEligibilityWithResponse request - V1GetPostgrestUpgradeEligibilityWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetPostgrestUpgradeEligibilityResponse, error) + // V1GetPostgresUpgradeEligibilityWithResponse request + V1GetPostgresUpgradeEligibilityWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetPostgresUpgradeEligibilityResponse, error) - // V1GetPostgrestUpgradeStatusWithResponse request - V1GetPostgrestUpgradeStatusWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetPostgrestUpgradeStatusResponse, error) + // V1GetPostgresUpgradeStatusWithResponse request + V1GetPostgresUpgradeStatusWithResponse(ctx context.Context, ref string, params *V1GetPostgresUpgradeStatusParams, reqEditors ...RequestEditorFn) (*V1GetPostgresUpgradeStatusResponse, error) // V1DeactivateVanitySubdomainConfigWithResponse request V1DeactivateVanitySubdomainConfigWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1DeactivateVanitySubdomainConfigResponse, error) @@ -5749,6 +5999,72 @@ func (r V1GetProjectApiKeysResponse) StatusCode() int { return 0 } +type CreateApiKeyResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *ApiKeyResponse +} + +// Status returns HTTPResponse.Status +func (r CreateApiKeyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r CreateApiKeyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type DeleteApiKeyResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ApiKeyResponse +} + +// Status returns HTTPResponse.Status +func (r DeleteApiKeyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteApiKeyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type UpdateApiKeyResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ApiKeyResponse +} + +// Status returns HTTPResponse.Status +func (r UpdateApiKeyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateApiKeyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type V1DisablePreviewBranchingResponse struct { Body []byte HTTPResponse *http.Response @@ -6948,14 +7264,14 @@ func (r V1UpgradePostgresVersionResponse) StatusCode() int { return 0 } -type V1GetPostgrestUpgradeEligibilityResponse struct { +type V1GetPostgresUpgradeEligibilityResponse struct { Body []byte HTTPResponse *http.Response JSON200 *ProjectUpgradeEligibilityResponse } // Status returns HTTPResponse.Status -func (r V1GetPostgrestUpgradeEligibilityResponse) Status() string { +func (r V1GetPostgresUpgradeEligibilityResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -6963,21 +7279,21 @@ func (r V1GetPostgrestUpgradeEligibilityResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r V1GetPostgrestUpgradeEligibilityResponse) StatusCode() int { +func (r V1GetPostgresUpgradeEligibilityResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type V1GetPostgrestUpgradeStatusResponse struct { +type V1GetPostgresUpgradeStatusResponse struct { Body []byte HTTPResponse *http.Response JSON200 *DatabaseUpgradeStatusResponse } // Status returns HTTPResponse.Status -func (r V1GetPostgrestUpgradeStatusResponse) Status() string { +func (r V1GetPostgresUpgradeStatusResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -6985,7 +7301,7 @@ func (r V1GetPostgrestUpgradeStatusResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r V1GetPostgrestUpgradeStatusResponse) StatusCode() int { +func (r V1GetPostgresUpgradeStatusResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } @@ -7290,6 +7606,49 @@ func (c *ClientWithResponses) V1GetProjectApiKeysWithResponse(ctx context.Contex return ParseV1GetProjectApiKeysResponse(rsp) } +// CreateApiKeyWithBodyWithResponse request with arbitrary body returning *CreateApiKeyResponse +func (c *ClientWithResponses) CreateApiKeyWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) { + rsp, err := c.CreateApiKeyWithBody(ctx, ref, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateApiKeyResponse(rsp) +} + +func (c *ClientWithResponses) CreateApiKeyWithResponse(ctx context.Context, ref string, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) { + rsp, err := c.CreateApiKey(ctx, ref, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateApiKeyResponse(rsp) +} + +// DeleteApiKeyWithResponse request returning *DeleteApiKeyResponse +func (c *ClientWithResponses) DeleteApiKeyWithResponse(ctx context.Context, ref string, id string, reqEditors ...RequestEditorFn) (*DeleteApiKeyResponse, error) { + rsp, err := c.DeleteApiKey(ctx, ref, id, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteApiKeyResponse(rsp) +} + +// UpdateApiKeyWithBodyWithResponse request with arbitrary body returning *UpdateApiKeyResponse +func (c *ClientWithResponses) UpdateApiKeyWithBodyWithResponse(ctx context.Context, ref string, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) { + rsp, err := c.UpdateApiKeyWithBody(ctx, ref, id, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateApiKeyResponse(rsp) +} + +func (c *ClientWithResponses) UpdateApiKeyWithResponse(ctx context.Context, ref string, id string, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) { + rsp, err := c.UpdateApiKey(ctx, ref, id, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateApiKeyResponse(rsp) +} + // V1DisablePreviewBranchingWithResponse request returning *V1DisablePreviewBranchingResponse func (c *ClientWithResponses) V1DisablePreviewBranchingWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1DisablePreviewBranchingResponse, error) { rsp, err := c.V1DisablePreviewBranching(ctx, ref, reqEditors...) @@ -7961,22 +8320,22 @@ func (c *ClientWithResponses) V1UpgradePostgresVersionWithResponse(ctx context.C return ParseV1UpgradePostgresVersionResponse(rsp) } -// V1GetPostgrestUpgradeEligibilityWithResponse request returning *V1GetPostgrestUpgradeEligibilityResponse -func (c *ClientWithResponses) V1GetPostgrestUpgradeEligibilityWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetPostgrestUpgradeEligibilityResponse, error) { - rsp, err := c.V1GetPostgrestUpgradeEligibility(ctx, ref, reqEditors...) +// V1GetPostgresUpgradeEligibilityWithResponse request returning *V1GetPostgresUpgradeEligibilityResponse +func (c *ClientWithResponses) V1GetPostgresUpgradeEligibilityWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetPostgresUpgradeEligibilityResponse, error) { + rsp, err := c.V1GetPostgresUpgradeEligibility(ctx, ref, reqEditors...) if err != nil { return nil, err } - return ParseV1GetPostgrestUpgradeEligibilityResponse(rsp) + return ParseV1GetPostgresUpgradeEligibilityResponse(rsp) } -// V1GetPostgrestUpgradeStatusWithResponse request returning *V1GetPostgrestUpgradeStatusResponse -func (c *ClientWithResponses) V1GetPostgrestUpgradeStatusWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetPostgrestUpgradeStatusResponse, error) { - rsp, err := c.V1GetPostgrestUpgradeStatus(ctx, ref, reqEditors...) +// V1GetPostgresUpgradeStatusWithResponse request returning *V1GetPostgresUpgradeStatusResponse +func (c *ClientWithResponses) V1GetPostgresUpgradeStatusWithResponse(ctx context.Context, ref string, params *V1GetPostgresUpgradeStatusParams, reqEditors ...RequestEditorFn) (*V1GetPostgresUpgradeStatusResponse, error) { + rsp, err := c.V1GetPostgresUpgradeStatus(ctx, ref, params, reqEditors...) if err != nil { return nil, err } - return ParseV1GetPostgrestUpgradeStatusResponse(rsp) + return ParseV1GetPostgresUpgradeStatusResponse(rsp) } // V1DeactivateVanitySubdomainConfigWithResponse request returning *V1DeactivateVanitySubdomainConfigResponse @@ -8429,6 +8788,84 @@ func ParseV1GetProjectApiKeysResponse(rsp *http.Response) (*V1GetProjectApiKeysR return response, nil } +// ParseCreateApiKeyResponse parses an HTTP response from a CreateApiKeyWithResponse call +func ParseCreateApiKeyResponse(rsp *http.Response) (*CreateApiKeyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateApiKeyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest ApiKeyResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + } + + return response, nil +} + +// ParseDeleteApiKeyResponse parses an HTTP response from a DeleteApiKeyWithResponse call +func ParseDeleteApiKeyResponse(rsp *http.Response) (*DeleteApiKeyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteApiKeyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ApiKeyResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseUpdateApiKeyResponse parses an HTTP response from a UpdateApiKeyWithResponse call +func ParseUpdateApiKeyResponse(rsp *http.Response) (*UpdateApiKeyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateApiKeyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ApiKeyResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParseV1DisablePreviewBranchingResponse parses an HTTP response from a V1DisablePreviewBranchingWithResponse call func ParseV1DisablePreviewBranchingResponse(rsp *http.Response) (*V1DisablePreviewBranchingResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -9749,15 +10186,15 @@ func ParseV1UpgradePostgresVersionResponse(rsp *http.Response) (*V1UpgradePostgr return response, nil } -// ParseV1GetPostgrestUpgradeEligibilityResponse parses an HTTP response from a V1GetPostgrestUpgradeEligibilityWithResponse call -func ParseV1GetPostgrestUpgradeEligibilityResponse(rsp *http.Response) (*V1GetPostgrestUpgradeEligibilityResponse, error) { +// ParseV1GetPostgresUpgradeEligibilityResponse parses an HTTP response from a V1GetPostgresUpgradeEligibilityWithResponse call +func ParseV1GetPostgresUpgradeEligibilityResponse(rsp *http.Response) (*V1GetPostgresUpgradeEligibilityResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &V1GetPostgrestUpgradeEligibilityResponse{ + response := &V1GetPostgresUpgradeEligibilityResponse{ Body: bodyBytes, HTTPResponse: rsp, } @@ -9775,15 +10212,15 @@ func ParseV1GetPostgrestUpgradeEligibilityResponse(rsp *http.Response) (*V1GetPo return response, nil } -// ParseV1GetPostgrestUpgradeStatusResponse parses an HTTP response from a V1GetPostgrestUpgradeStatusWithResponse call -func ParseV1GetPostgrestUpgradeStatusResponse(rsp *http.Response) (*V1GetPostgrestUpgradeStatusResponse, error) { +// ParseV1GetPostgresUpgradeStatusResponse parses an HTTP response from a V1GetPostgresUpgradeStatusWithResponse call +func ParseV1GetPostgresUpgradeStatusResponse(rsp *http.Response) (*V1GetPostgresUpgradeStatusResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &V1GetPostgrestUpgradeStatusResponse{ + response := &V1GetPostgresUpgradeStatusResponse{ Body: bodyBytes, HTTPResponse: rsp, } diff --git a/pkg/api/types.gen.go b/pkg/api/types.gen.go index c59dae1a5..77714f6c3 100644 --- a/pkg/api/types.gen.go +++ b/pkg/api/types.gen.go @@ -50,6 +50,12 @@ const ( BranchResponseStatusRUNNINGMIGRATIONS BranchResponseStatus = "RUNNING_MIGRATIONS" ) +// Defines values for CreateApiKeyBodyType. +const ( + Publishable CreateApiKeyBodyType = "publishable" + Secret CreateApiKeyBodyType = "secret" +) + // Defines values for CreateProviderBodyType. const ( Saml CreateProviderBodyType = "saml" @@ -148,6 +154,20 @@ const ( PostgresConfigResponseSessionReplicationRoleReplica PostgresConfigResponseSessionReplicationRole = "replica" ) +// Defines values for PostgresEngine. +const ( + N15 PostgresEngine = "15" +) + +// Defines values for ReleaseChannel. +const ( + Alpha ReleaseChannel = "alpha" + Beta ReleaseChannel = "beta" + Ga ReleaseChannel = "ga" + Internal ReleaseChannel = "internal" + Withdrawn ReleaseChannel = "withdrawn" +) + // Defines values for SetUpReadReplicaBodyReadReplicaRegion. const ( SetUpReadReplicaBodyReadReplicaRegionApEast1 SetUpReadReplicaBodyReadReplicaRegion = "ap-east-1" @@ -158,11 +178,14 @@ const ( SetUpReadReplicaBodyReadReplicaRegionApSoutheast2 SetUpReadReplicaBodyReadReplicaRegion = "ap-southeast-2" SetUpReadReplicaBodyReadReplicaRegionCaCentral1 SetUpReadReplicaBodyReadReplicaRegion = "ca-central-1" SetUpReadReplicaBodyReadReplicaRegionEuCentral1 SetUpReadReplicaBodyReadReplicaRegion = "eu-central-1" + SetUpReadReplicaBodyReadReplicaRegionEuCentral2 SetUpReadReplicaBodyReadReplicaRegion = "eu-central-2" + SetUpReadReplicaBodyReadReplicaRegionEuNorth1 SetUpReadReplicaBodyReadReplicaRegion = "eu-north-1" SetUpReadReplicaBodyReadReplicaRegionEuWest1 SetUpReadReplicaBodyReadReplicaRegion = "eu-west-1" SetUpReadReplicaBodyReadReplicaRegionEuWest2 SetUpReadReplicaBodyReadReplicaRegion = "eu-west-2" SetUpReadReplicaBodyReadReplicaRegionEuWest3 SetUpReadReplicaBodyReadReplicaRegion = "eu-west-3" SetUpReadReplicaBodyReadReplicaRegionSaEast1 SetUpReadReplicaBodyReadReplicaRegion = "sa-east-1" SetUpReadReplicaBodyReadReplicaRegionUsEast1 SetUpReadReplicaBodyReadReplicaRegion = "us-east-1" + SetUpReadReplicaBodyReadReplicaRegionUsEast2 SetUpReadReplicaBodyReadReplicaRegion = "us-east-2" SetUpReadReplicaBodyReadReplicaRegionUsWest1 SetUpReadReplicaBodyReadReplicaRegion = "us-west-1" SetUpReadReplicaBodyReadReplicaRegionUsWest2 SetUpReadReplicaBodyReadReplicaRegion = "us-west-2" ) @@ -277,11 +300,14 @@ const ( V1CreateProjectBodyRegionApSoutheast2 V1CreateProjectBodyRegion = "ap-southeast-2" V1CreateProjectBodyRegionCaCentral1 V1CreateProjectBodyRegion = "ca-central-1" V1CreateProjectBodyRegionEuCentral1 V1CreateProjectBodyRegion = "eu-central-1" + V1CreateProjectBodyRegionEuCentral2 V1CreateProjectBodyRegion = "eu-central-2" + V1CreateProjectBodyRegionEuNorth1 V1CreateProjectBodyRegion = "eu-north-1" V1CreateProjectBodyRegionEuWest1 V1CreateProjectBodyRegion = "eu-west-1" V1CreateProjectBodyRegionEuWest2 V1CreateProjectBodyRegion = "eu-west-2" V1CreateProjectBodyRegionEuWest3 V1CreateProjectBodyRegion = "eu-west-3" V1CreateProjectBodyRegionSaEast1 V1CreateProjectBodyRegion = "sa-east-1" V1CreateProjectBodyRegionUsEast1 V1CreateProjectBodyRegion = "us-east-1" + V1CreateProjectBodyRegionUsEast2 V1CreateProjectBodyRegion = "us-east-2" V1CreateProjectBodyRegionUsWest1 V1CreateProjectBodyRegion = "us-west-1" V1CreateProjectBodyRegionUsWest2 V1CreateProjectBodyRegion = "us-west-2" ) @@ -371,8 +397,21 @@ type ActivateVanitySubdomainResponse struct { // ApiKeyResponse defines model for ApiKeyResponse. type ApiKeyResponse struct { - ApiKey string `json:"api_key"` - Name string `json:"name"` + ApiKey string `json:"api_key"` + Description *string `json:"description"` + Hash *string `json:"hash"` + Id *string `json:"id"` + InsertedAt *string `json:"inserted_at"` + Name string `json:"name"` + Prefix *string `json:"prefix"` + SecretJwtTemplate *ApiKeySecretJWTTemplate `json:"secret_jwt_template"` + Type *map[string]interface{} `json:"type"` + UpdatedAt *string `json:"updated_at"` +} + +// ApiKeySecretJWTTemplate defines model for ApiKeySecretJWTTemplate. +type ApiKeySecretJWTTemplate struct { + Role string `json:"role"` } // AttributeMapping defines model for AttributeMapping. @@ -521,6 +560,8 @@ type AuthConfigResponse struct { MfaPhoneVerifyEnabled *bool `json:"mfa_phone_verify_enabled"` MfaTotpEnrollEnabled *bool `json:"mfa_totp_enroll_enabled"` MfaTotpVerifyEnabled *bool `json:"mfa_totp_verify_enabled"` + MfaWebAuthnEnrollEnabled *bool `json:"mfa_web_authn_enroll_enabled"` + MfaWebAuthnVerifyEnabled *bool `json:"mfa_web_authn_verify_enabled"` PasswordHibpEnabled *bool `json:"password_hibp_enabled"` PasswordMinLength *float32 `json:"password_min_length"` PasswordRequiredCharacters *string `json:"password_required_characters"` @@ -531,6 +572,7 @@ type AuthConfigResponse struct { RateLimitTokenRefresh *float32 `json:"rate_limit_token_refresh"` RateLimitVerify *float32 `json:"rate_limit_verify"` RefreshTokenRotationEnabled *bool `json:"refresh_token_rotation_enabled"` + SamlAllowEncryptedAssertions *bool `json:"saml_allow_encrypted_assertions"` SamlEnabled *bool `json:"saml_enabled"` SamlExternalUrl *string `json:"saml_external_url"` SecurityCaptchaEnabled *bool `json:"security_captcha_enabled"` @@ -598,8 +640,10 @@ type BranchDetailResponse struct { DbPort int `json:"db_port"` DbUser *string `json:"db_user,omitempty"` JwtSecret *string `json:"jwt_secret,omitempty"` + PostgresEngine string `json:"postgres_engine"` PostgresVersion string `json:"postgres_version"` Ref string `json:"ref"` + ReleaseChannel string `json:"release_channel"` Status BranchDetailResponseStatus `json:"status"` } @@ -639,13 +683,27 @@ type CfResponse struct { Success bool `json:"success"` } +// CreateApiKeyBody defines model for CreateApiKeyBody. +type CreateApiKeyBody struct { + Description *string `json:"description"` + SecretJwtTemplate *ApiKeySecretJWTTemplate `json:"secret_jwt_template"` + Type CreateApiKeyBodyType `json:"type"` +} + +// CreateApiKeyBodyType defines model for CreateApiKeyBody.Type. +type CreateApiKeyBodyType string + // CreateBranchBody defines model for CreateBranchBody. type CreateBranchBody struct { BranchName string `json:"branch_name"` DesiredInstanceSize *DesiredInstanceSize `json:"desired_instance_size,omitempty"` GitBranch *string `json:"git_branch,omitempty"` Persistent *bool `json:"persistent,omitempty"` - Region *string `json:"region,omitempty"` + + // PostgresEngine Postgres engine version. If not provided, the latest version will be used. + PostgresEngine *PostgresEngine `json:"postgres_engine,omitempty"` + Region *string `json:"region,omitempty"` + ReleaseChannel *ReleaseChannel `json:"release_channel,omitempty"` } // CreateOrganizationBodyV1 defines model for CreateOrganizationBodyV1. @@ -866,24 +924,34 @@ type PgsodiumConfigResponse struct { // PostgresConfigResponse defines model for PostgresConfigResponse. type PostgresConfigResponse struct { EffectiveCacheSize *string `json:"effective_cache_size,omitempty"` + LogicalDecodingWorkMem *string `json:"logical_decoding_work_mem,omitempty"` MaintenanceWorkMem *string `json:"maintenance_work_mem,omitempty"` MaxConnections *int `json:"max_connections,omitempty"` MaxLocksPerTransaction *int `json:"max_locks_per_transaction,omitempty"` MaxParallelMaintenanceWorkers *int `json:"max_parallel_maintenance_workers,omitempty"` MaxParallelWorkers *int `json:"max_parallel_workers,omitempty"` MaxParallelWorkersPerGather *int `json:"max_parallel_workers_per_gather,omitempty"` + MaxReplicationSlots *int `json:"max_replication_slots,omitempty"` + MaxSlotWalKeepSize *string `json:"max_slot_wal_keep_size,omitempty"` MaxStandbyArchiveDelay *string `json:"max_standby_archive_delay,omitempty"` MaxStandbyStreamingDelay *string `json:"max_standby_streaming_delay,omitempty"` + MaxWalSenders *int `json:"max_wal_senders,omitempty"` + MaxWalSize *string `json:"max_wal_size,omitempty"` MaxWorkerProcesses *int `json:"max_worker_processes,omitempty"` SessionReplicationRole *PostgresConfigResponseSessionReplicationRole `json:"session_replication_role,omitempty"` SharedBuffers *string `json:"shared_buffers,omitempty"` StatementTimeout *string `json:"statement_timeout,omitempty"` + WalKeepSize *string `json:"wal_keep_size,omitempty"` + WalSenderTimeout *string `json:"wal_sender_timeout,omitempty"` WorkMem *string `json:"work_mem,omitempty"` } // PostgresConfigResponseSessionReplicationRole defines model for PostgresConfigResponse.SessionReplicationRole. type PostgresConfigResponseSessionReplicationRole string +// PostgresEngine Postgres engine version. If not provided, the latest version will be used. +type PostgresEngine string + // PostgrestConfigWithJWTSecretResponse defines model for PostgrestConfigWithJWTSecretResponse. type PostgrestConfigWithJWTSecretResponse struct { DbExtraSearchPath string `json:"db_extra_search_path"` @@ -897,14 +965,15 @@ type PostgrestConfigWithJWTSecretResponse struct { // ProjectUpgradeEligibilityResponse defines model for ProjectUpgradeEligibilityResponse. type ProjectUpgradeEligibilityResponse struct { - CurrentAppVersion string `json:"current_app_version"` - DurationEstimateHours float32 `json:"duration_estimate_hours"` - Eligible bool `json:"eligible"` - ExtensionDependentObjects []string `json:"extension_dependent_objects"` - LatestAppVersion string `json:"latest_app_version"` - LegacyAuthCustomRoles []string `json:"legacy_auth_custom_roles"` - PotentialBreakingChanges []string `json:"potential_breaking_changes"` - TargetUpgradeVersions []ProjectVersion `json:"target_upgrade_versions"` + CurrentAppVersion string `json:"current_app_version"` + CurrentAppVersionReleaseChannel ReleaseChannel `json:"current_app_version_release_channel"` + DurationEstimateHours float32 `json:"duration_estimate_hours"` + Eligible bool `json:"eligible"` + ExtensionDependentObjects []string `json:"extension_dependent_objects"` + LatestAppVersion string `json:"latest_app_version"` + LegacyAuthCustomRoles []string `json:"legacy_auth_custom_roles"` + PotentialBreakingChanges []string `json:"potential_breaking_changes"` + TargetUpgradeVersions []ProjectVersion `json:"target_upgrade_versions"` } // ProjectUpgradeInitiateResponse defines model for ProjectUpgradeInitiateResponse. @@ -914,8 +983,11 @@ type ProjectUpgradeInitiateResponse struct { // ProjectVersion defines model for ProjectVersion. type ProjectVersion struct { - AppVersion string `json:"app_version"` - PostgresVersion float32 `json:"postgres_version"` + AppVersion string `json:"app_version"` + + // PostgresVersion Postgres engine version. If not provided, the latest version will be used. + PostgresVersion PostgresEngine `json:"postgres_version"` + ReleaseChannel ReleaseChannel `json:"release_channel"` } // Provider defines model for Provider. @@ -941,6 +1013,9 @@ type RealtimeHealthResponse struct { Healthy bool `json:"healthy"` } +// ReleaseChannel defines model for ReleaseChannel. +type ReleaseChannel string + // RemoveNetworkBanRequest defines model for RemoveNetworkBanRequest. type RemoveNetworkBanRequest struct { Ipv4Addresses []string `json:"ipv4_addresses"` @@ -1107,6 +1182,12 @@ type TypescriptResponse struct { Types string `json:"types"` } +// UpdateApiKeyBody defines model for UpdateApiKeyBody. +type UpdateApiKeyBody struct { + Description *string `json:"description"` + SecretJwtTemplate *ApiKeySecretJWTTemplate `json:"secret_jwt_template"` +} + // UpdateAuthConfigBody defines model for UpdateAuthConfigBody. type UpdateAuthConfigBody struct { ApiMaxRequestDuration *float32 `json:"api_max_request_duration,omitempty"` @@ -1223,6 +1304,8 @@ type UpdateAuthConfigBody struct { MfaPhoneVerifyEnabled *bool `json:"mfa_phone_verify_enabled,omitempty"` MfaTotpEnrollEnabled *bool `json:"mfa_totp_enroll_enabled,omitempty"` MfaTotpVerifyEnabled *bool `json:"mfa_totp_verify_enabled,omitempty"` + MfaWebAuthnEnrollEnabled *bool `json:"mfa_web_authn_enroll_enabled,omitempty"` + MfaWebAuthnVerifyEnabled *bool `json:"mfa_web_authn_verify_enabled,omitempty"` PasswordHibpEnabled *bool `json:"password_hibp_enabled,omitempty"` PasswordMinLength *float32 `json:"password_min_length,omitempty"` PasswordRequiredCharacters *UpdateAuthConfigBodyPasswordRequiredCharacters `json:"password_required_characters,omitempty"` @@ -1316,18 +1399,26 @@ type UpdatePgsodiumConfigBody struct { // UpdatePostgresConfigBody defines model for UpdatePostgresConfigBody. type UpdatePostgresConfigBody struct { EffectiveCacheSize *string `json:"effective_cache_size,omitempty"` + LogicalDecodingWorkMem *string `json:"logical_decoding_work_mem,omitempty"` MaintenanceWorkMem *string `json:"maintenance_work_mem,omitempty"` MaxConnections *int `json:"max_connections,omitempty"` MaxLocksPerTransaction *int `json:"max_locks_per_transaction,omitempty"` MaxParallelMaintenanceWorkers *int `json:"max_parallel_maintenance_workers,omitempty"` MaxParallelWorkers *int `json:"max_parallel_workers,omitempty"` MaxParallelWorkersPerGather *int `json:"max_parallel_workers_per_gather,omitempty"` + MaxReplicationSlots *int `json:"max_replication_slots,omitempty"` + MaxSlotWalKeepSize *string `json:"max_slot_wal_keep_size,omitempty"` MaxStandbyArchiveDelay *string `json:"max_standby_archive_delay,omitempty"` MaxStandbyStreamingDelay *string `json:"max_standby_streaming_delay,omitempty"` + MaxWalSenders *int `json:"max_wal_senders,omitempty"` + MaxWalSize *string `json:"max_wal_size,omitempty"` MaxWorkerProcesses *int `json:"max_worker_processes,omitempty"` + RestartDatabase *bool `json:"restart_database,omitempty"` SessionReplicationRole *UpdatePostgresConfigBodySessionReplicationRole `json:"session_replication_role,omitempty"` SharedBuffers *string `json:"shared_buffers,omitempty"` StatementTimeout *string `json:"statement_timeout,omitempty"` + WalKeepSize *string `json:"wal_keep_size,omitempty"` + WalSenderTimeout *string `json:"wal_sender_timeout,omitempty"` WorkMem *string `json:"work_mem,omitempty"` } @@ -1382,7 +1473,8 @@ type UpdateSupavisorConfigResponsePoolMode string // UpgradeDatabaseBody defines model for UpgradeDatabaseBody. type UpgradeDatabaseBody struct { - TargetVersion float32 `json:"target_version"` + ReleaseChannel ReleaseChannel `json:"release_channel"` + TargetVersion string `json:"target_version"` } // V1Backup defines model for V1Backup. @@ -1432,8 +1524,12 @@ type V1CreateProjectBody struct { // Deprecated: Plan *V1CreateProjectBodyPlan `json:"plan,omitempty"` + // PostgresEngine Postgres engine version. If not provided, the latest version will be used. + PostgresEngine *PostgresEngine `json:"postgres_engine,omitempty"` + // Region Region you want your server to reside in - Region V1CreateProjectBodyRegion `json:"region"` + Region V1CreateProjectBodyRegion `json:"region"` + ReleaseChannel *ReleaseChannel `json:"release_channel,omitempty"` // TemplateUrl Template URL used to create the project from the CLI. TemplateUrl *string `json:"template_url,omitempty"` @@ -1450,6 +1546,12 @@ type V1DatabaseResponse struct { // Host Database host Host string `json:"host"` + // PostgresEngine Database engine + PostgresEngine string `json:"postgres_engine"` + + // ReleaseChannel Release channel + ReleaseChannel string `json:"release_channel"` + // Version Database version Version string `json:"version"` } @@ -1465,10 +1567,11 @@ type V1OrganizationMemberResponse struct { // V1OrganizationSlugResponse defines model for V1OrganizationSlugResponse. type V1OrganizationSlugResponse struct { - Id string `json:"id"` - Name string `json:"name"` - OptInTags []V1OrganizationSlugResponseOptInTags `json:"opt_in_tags"` - Plan *BillingPlanId `json:"plan,omitempty"` + AllowedReleaseChannels []ReleaseChannel `json:"allowed_release_channels"` + Id string `json:"id"` + Name string `json:"name"` + OptInTags []V1OrganizationSlugResponseOptInTags `json:"opt_in_tags"` + Plan *BillingPlanId `json:"plan,omitempty"` } // V1OrganizationSlugResponseOptInTags defines model for V1OrganizationSlugResponse.OptInTags. @@ -1662,6 +1765,11 @@ type V1GenerateTypescriptTypesParams struct { IncludedSchemas *string `form:"included_schemas,omitempty" json:"included_schemas,omitempty"` } +// V1GetPostgresUpgradeStatusParams defines parameters for V1GetPostgresUpgradeStatus. +type V1GetPostgresUpgradeStatusParams struct { + TrackingId *string `form:"tracking_id,omitempty" json:"tracking_id,omitempty"` +} + // V1ListAllSnippetsParams defines parameters for V1ListAllSnippets. type V1ListAllSnippetsParams struct { ProjectRef *string `form:"project_ref,omitempty" json:"project_ref,omitempty"` @@ -1679,6 +1787,12 @@ type V1CreateAnOrganizationJSONRequestBody = CreateOrganizationBodyV1 // V1CreateAProjectJSONRequestBody defines body for V1CreateAProject for application/json ContentType. type V1CreateAProjectJSONRequestBody = V1CreateProjectBody +// CreateApiKeyJSONRequestBody defines body for CreateApiKey for application/json ContentType. +type CreateApiKeyJSONRequestBody = CreateApiKeyBody + +// UpdateApiKeyJSONRequestBody defines body for UpdateApiKey for application/json ContentType. +type UpdateApiKeyJSONRequestBody = UpdateApiKeyBody + // V1CreateABranchJSONRequestBody defines body for V1CreateABranch for application/json ContentType. type V1CreateABranchJSONRequestBody = CreateBranchBody From 3c5c827b39450c5c48f7cf9889e703e12f8d148b Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Thu, 10 Oct 2024 12:07:50 +0800 Subject: [PATCH 076/305] feat: support postgres config update without restart --- cmd/postgres.go | 9 ++++++--- internal/postgresConfig/update/update.go | 5 ++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cmd/postgres.go b/cmd/postgres.go index 784b0aca4..1c2e0e127 100644 --- a/cmd/postgres.go +++ b/cmd/postgres.go @@ -29,12 +29,13 @@ var ( Long: `Overriding the default Postgres config could result in unstable database behavior. Custom configuration also overrides the optimizations generated based on the compute add-ons in use.`, RunE: func(cmd *cobra.Command, args []string) error { - return update.Run(cmd.Context(), flags.ProjectRef, postgresConfigValues, postgresConfigUpdateReplaceMode, afero.NewOsFs()) + return update.Run(cmd.Context(), flags.ProjectRef, postgresConfigValues, postgresConfigUpdateReplaceMode, noRestart, afero.NewOsFs()) }, } postgresConfigValues []string postgresConfigUpdateReplaceMode bool + noRestart bool ) func init() { @@ -42,8 +43,10 @@ func init() { postgresCmd.AddCommand(postgresConfigGetCmd) postgresCmd.AddCommand(postgresConfigUpdateCmd) - postgresConfigUpdateCmd.Flags().StringSliceVar(&postgresConfigValues, "config", []string{}, "Config overrides specified as a 'key=value' pair") - postgresConfigUpdateCmd.Flags().BoolVar(&postgresConfigUpdateReplaceMode, "replace-existing-overrides", false, "If true, replaces all existing overrides with the ones provided. If false (default), merges existing overrides with the ones provided.") + updateFlags := postgresConfigUpdateCmd.Flags() + updateFlags.StringSliceVar(&postgresConfigValues, "config", []string{}, "Config overrides specified as a 'key=value' pair") + updateFlags.BoolVar(&postgresConfigUpdateReplaceMode, "replace-existing-overrides", false, "If true, replaces all existing overrides with the ones provided. If false (default), merges existing overrides with the ones provided.") + updateFlags.BoolVar(&noRestart, "no-restart", false, "Do not restart the database after updating config.") rootCmd.AddCommand(postgresCmd) } diff --git a/internal/postgresConfig/update/update.go b/internal/postgresConfig/update/update.go index 00a9766f8..09db6504a 100644 --- a/internal/postgresConfig/update/update.go +++ b/internal/postgresConfig/update/update.go @@ -13,7 +13,7 @@ import ( "github.com/supabase/cli/internal/utils" ) -func Run(ctx context.Context, projectRef string, values []string, replaceOverrides bool, fsys afero.Fs) error { +func Run(ctx context.Context, projectRef string, values []string, replaceOverrides, noRestart bool, fsys afero.Fs) error { // 1. Prepare config overrides newConfigOverrides := make(map[string]string) for _, config := range values { @@ -49,6 +49,9 @@ func Run(ctx context.Context, projectRef string, values []string, replaceOverrid } // 4. update config overrides and print out final result { + if noRestart { + finalOverrides["restart_database"] = false + } bts, err := json.Marshal(finalOverrides) if err != nil { return errors.Errorf("failed to serialize config overrides: %w", err) From 54c9d208e50264852a61e6f77f0fca54060229f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 04:46:05 +0000 Subject: [PATCH 077/305] chore(deps): bump github.com/danieljoos/wincred from 1.2.1 to 1.2.2 (#2759) Bumps [github.com/danieljoos/wincred](https://github.com/danieljoos/wincred) from 1.2.1 to 1.2.2. - [Release notes](https://github.com/danieljoos/wincred/releases) - [Commits](https://github.com/danieljoos/wincred/compare/v1.2.1...v1.2.2) --- updated-dependencies: - dependency-name: github.com/danieljoos/wincred dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0cdb11ba0..237f6e624 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/charmbracelet/glamour v0.7.0 github.com/charmbracelet/lipgloss v0.12.1 github.com/containers/common v0.60.4 - github.com/danieljoos/wincred v1.2.1 + github.com/danieljoos/wincred v1.2.2 github.com/deepmap/oapi-codegen/v2 v2.2.0 github.com/docker/cli v27.3.1+incompatible github.com/docker/docker v27.3.1+incompatible diff --git a/go.sum b/go.sum index 9fdb5c2d2..f71d91b6e 100644 --- a/go.sum +++ b/go.sum @@ -217,8 +217,8 @@ github.com/cyphar/filepath-securejoin v0.3.1 h1:1V7cHiaW+C+39wEfpH6XlLBQo3j/PciW github.com/cyphar/filepath-securejoin v0.3.1/go.mod h1:F7i41x/9cBF7lzCrVsYs9fuzwRZm4NQsGTBdpp6mETc= github.com/daixiang0/gci v0.13.4 h1:61UGkmpoAcxHM2hhNkZEf5SzwQtWJXTSws7jaPyqwlw= github.com/daixiang0/gci v0.13.4/go.mod h1:12etP2OniiIdP4q+kjUGrC/rUagga7ODbqsom5Eo5Yk= -github.com/danieljoos/wincred v1.2.1 h1:dl9cBrupW8+r5250DYkYxocLeZ1Y4vB1kxgtjxw8GQs= -github.com/danieljoos/wincred v1.2.1/go.mod h1:uGaFL9fDn3OLTvzCGulzE+SzjEe5NGlh5FdCcyfPwps= +github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0= +github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= From 13923337f0c7c6d3328d25d82c5c61746bf8ac85 Mon Sep 17 00:00:00 2001 From: Julien Goux Date: Fri, 11 Oct 2024 10:15:01 +0200 Subject: [PATCH 078/305] read env in auth.additional_redirect_urls values --- pkg/config/config.go | 5 +++++ pkg/config/config_test.go | 5 +++++ pkg/config/testdata/config.toml | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 80270124c..5fbd4661f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -833,6 +833,11 @@ func (c *baseConfig) Validate(fsys fs.FS) error { if c.Auth.SiteUrl, err = maybeLoadEnv(c.Auth.SiteUrl); err != nil { return err } + for i, url := range c.Auth.AdditionalRedirectUrls { + if c.Auth.AdditionalRedirectUrls[i], err = maybeLoadEnv(url); err != nil { + return errors.Errorf("Invalid config for auth.additional_redirect_urls[%d]: %v", i, err) + } + } // Validate email config for name, tmpl := range c.Auth.Email.Template { if len(tmpl.ContentPath) > 0 { diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 7d31d77ae..68077058a 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -41,10 +41,15 @@ func TestConfigParsing(t *testing.T) { t.Setenv("AZURE_SECRET", "this is cool") t.Setenv("AUTH_SEND_SMS_SECRETS", "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw==") t.Setenv("SENDGRID_API_KEY", "sendgrid") + t.Setenv("AUTH_CALLBACK_URL", "http://localhost:3000/auth/callback") assert.NoError(t, config.Load("", fsys)) // Check error assert.Equal(t, "hello", config.Auth.External["azure"].ClientId) assert.Equal(t, "this is cool", config.Auth.External["azure"].Secret) + assert.Equal(t, []string{ + "https://127.0.0.1:3000", + "http://localhost:3000/auth/callback", + }, config.Auth.AdditionalRedirectUrls) }) t.Run("config file with environment variables fails when unset", func(t *testing.T) { diff --git a/pkg/config/testdata/config.toml b/pkg/config/testdata/config.toml index 76e070c60..0d591d979 100644 --- a/pkg/config/testdata/config.toml +++ b/pkg/config/testdata/config.toml @@ -94,7 +94,7 @@ enabled = true # in emails. site_url = "http://127.0.0.1:3000" # A list of *exact* URLs that auth providers are permitted to redirect to post authentication. -additional_redirect_urls = ["https://127.0.0.1:3000"] +additional_redirect_urls = ["https://127.0.0.1:3000", "env(AUTH_CALLBACK_URL)"] # How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 (1 week). jwt_expiry = 3600 # If disabled, the refresh token will never expire. From d69776ffd0fb2055fbdee146190769a625d8185c Mon Sep 17 00:00:00 2001 From: Julien Goux Date: Fri, 11 Oct 2024 10:24:15 +0200 Subject: [PATCH 079/305] fix failing test --- pkg/config/config_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 68077058a..af3ab9563 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -75,6 +75,7 @@ func TestConfigParsing(t *testing.T) { t.Setenv("AZURE_SECRET", "this is cool") t.Setenv("AUTH_SEND_SMS_SECRETS", "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw==") t.Setenv("SENDGRID_API_KEY", "sendgrid") + t.Setenv("AUTH_CALLBACK_URL", "http://localhost:3000/auth/callback") assert.NoError(t, config.Load("", fsys)) // Check the default value in the config assert.Equal(t, "http://127.0.0.1:3000", config.Auth.SiteUrl) From b40723b16678b40fa0f96173e22f1fc8d4a396a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 11 Oct 2024 18:35:15 +0800 Subject: [PATCH 080/305] chore(deps): bump github.com/getsentry/sentry-go from 0.28.1 to 0.29.0 (#2758) Bumps [github.com/getsentry/sentry-go](https://github.com/getsentry/sentry-go) from 0.28.1 to 0.29.0. - [Release notes](https://github.com/getsentry/sentry-go/releases) - [Changelog](https://github.com/getsentry/sentry-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-go/compare/v0.28.1...v0.29.0) --- updated-dependencies: - dependency-name: github.com/getsentry/sentry-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 237f6e624..38ae8c75b 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/docker/docker v27.3.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 - github.com/getsentry/sentry-go v0.28.1 + github.com/getsentry/sentry-go v0.29.0 github.com/gin-gonic/gin v1.10.0 github.com/go-errors/errors v1.5.1 github.com/go-git/go-git/v5 v5.12.0 diff --git a/go.sum b/go.sum index f71d91b6e..498c5f0e6 100644 --- a/go.sum +++ b/go.sum @@ -290,8 +290,8 @@ github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uq github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj9kz/M= github.com/getkin/kin-openapi v0.124.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM= -github.com/getsentry/sentry-go v0.28.1 h1:zzaSm/vHmGllRM6Tpx1492r0YDzauArdBfkJRtY6P5k= -github.com/getsentry/sentry-go v0.28.1/go.mod h1:1fQZ+7l7eeJ3wYi82q5Hg8GqAPgefRq+FP/QhafYVgg= +github.com/getsentry/sentry-go v0.29.0 h1:YtWluuCFg9OfcqnaujpY918N/AhCCwarIDWOYSBAjCA= +github.com/getsentry/sentry-go v0.29.0/go.mod h1:jhPesDAL0Q0W2+2YEuVOvdWmVtdsr1+jtBrlDEVWwLY= github.com/ghostiam/protogetter v0.3.6 h1:R7qEWaSgFCsy20yYHNIJsU9ZOb8TziSRRxuAOTVKeOk= github.com/ghostiam/protogetter v0.3.6/go.mod h1:7lpeDnEJ1ZjL/YtyoN99ljO4z0pd3H0d18/t2dPBxHw= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= From e5444940bf7177ee62488381f1749eb140aa64cd Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Oct 2024 04:49:28 +0000 Subject: [PATCH 081/305] chore(deps): bump go.opentelemetry.io/otel from 1.30.0 to 1.31.0 (#2764) Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.30.0 to 1.31.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.30.0...v1.31.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/otel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 38ae8c75b..71209c5e1 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( github.com/stripe/pg-schema-diff v0.7.0 github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 github.com/zalando/go-keyring v0.2.5 - go.opentelemetry.io/otel v1.30.0 + go.opentelemetry.io/otel v1.31.0 golang.org/x/mod v0.21.0 golang.org/x/oauth2 v0.23.0 golang.org/x/term v0.25.0 @@ -322,10 +322,10 @@ require ( go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect - go.opentelemetry.io/otel/metric v1.30.0 // indirect + go.opentelemetry.io/otel/metric v1.31.0 // indirect go.opentelemetry.io/otel/sdk v1.28.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect - go.opentelemetry.io/otel/trace v1.30.0 // indirect + go.opentelemetry.io/otel/trace v1.31.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/automaxprocs v1.5.3 // indirect diff --git a/go.sum b/go.sum index 498c5f0e6..eef04ae19 100644 --- a/go.sum +++ b/go.sum @@ -1030,8 +1030,8 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= -go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts= -go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc= +go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= +go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 h1:U2guen0GhqH8o/G2un8f/aG/y++OuW6MyCo6hT9prXk= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0/go.mod h1:yeGZANgEcpdx/WK0IvvRFC+2oLiMS2u4L/0Rj2M2Qr0= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY= @@ -1040,14 +1040,14 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 h1:R3X6Z go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0/go.mod h1:QWFXnDavXWwMx2EEcZsf3yxgEKAqsxQ+Syjp+seyInw= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 h1:j9+03ymgYhPKmeXGk5Zu+cIZOlVzd9Zv7QIiyItjFBU= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0/go.mod h1:Y5+XiUG4Emn1hTfciPzGPJaSI+RpDts6BnCIir0SLqk= -go.opentelemetry.io/otel/metric v1.30.0 h1:4xNulvn9gjzo4hjg+wzIKG7iNFEaBMX00Qd4QIZs7+w= -go.opentelemetry.io/otel/metric v1.30.0/go.mod h1:aXTfST94tswhWEb+5QjlSqG+cZlmyXy/u8jFpor3WqQ= +go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE= +go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY= go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= -go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc= -go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o= +go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= +go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= From 5c58ef7fac8f0a27f56baa52dbb6d1e413636255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Mon, 14 Oct 2024 14:28:53 +0900 Subject: [PATCH 082/305] fix: bump edge-runtime to 1.58.13 (#2762) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 51f7a0f99..cb4605b64 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.83.2" studioImage = "supabase/studio:20240930-16f2b8e" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.58.12" + edgeRuntimeImage = "supabase/edge-runtime:v1.58.13" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.158.1" From 67274d750375462b7849045779f9b8dbb1719d6c Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Mon, 14 Oct 2024 11:35:32 +0200 Subject: [PATCH 083/305] fix(studio): upgrade studio image to latest (#2765) chore(studio): upgrade studio image to latest Allow to deploy this bugfix for local dev: https://github.com/supabase/supabase/pull/29646 --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index cb4605b64..bc675282f 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -10,7 +10,7 @@ const ( inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" pgmetaImage = "supabase/postgres-meta:v0.83.2" - studioImage = "supabase/studio:20240930-16f2b8e" + studioImage = "supabase/studio:20241014-353d054" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.58.13" vectorImage = "timberio/vector:0.28.1-alpine" From 4431fb65c3a26b5d74a1bb5308a442cc58b0470d Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Mon, 14 Oct 2024 14:07:55 +0200 Subject: [PATCH 084/305] fix: Bump studio to the latest image version 20241014 (#2766) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index bc675282f..55bd94002 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -10,7 +10,7 @@ const ( inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" pgmetaImage = "supabase/postgres-meta:v0.83.2" - studioImage = "supabase/studio:20241014-353d054" + studioImage = "supabase/studio:20241014-c083b3b" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.58.13" vectorImage = "timberio/vector:0.28.1-alpine" From d4ceedac577571000593392787cc99b240d646e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 05:58:48 +0000 Subject: [PATCH 085/305] chore(deps): bump github.com/getsentry/sentry-go from 0.29.0 to 0.29.1 (#2768) Bumps [github.com/getsentry/sentry-go](https://github.com/getsentry/sentry-go) from 0.29.0 to 0.29.1. - [Release notes](https://github.com/getsentry/sentry-go/releases) - [Changelog](https://github.com/getsentry/sentry-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-go/compare/v0.29.0...v0.29.1) --- updated-dependencies: - dependency-name: github.com/getsentry/sentry-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 71209c5e1..cc65595b2 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/docker/docker v27.3.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 - github.com/getsentry/sentry-go v0.29.0 + github.com/getsentry/sentry-go v0.29.1 github.com/gin-gonic/gin v1.10.0 github.com/go-errors/errors v1.5.1 github.com/go-git/go-git/v5 v5.12.0 diff --git a/go.sum b/go.sum index eef04ae19..7a1c99e73 100644 --- a/go.sum +++ b/go.sum @@ -290,8 +290,8 @@ github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uq github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj9kz/M= github.com/getkin/kin-openapi v0.124.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM= -github.com/getsentry/sentry-go v0.29.0 h1:YtWluuCFg9OfcqnaujpY918N/AhCCwarIDWOYSBAjCA= -github.com/getsentry/sentry-go v0.29.0/go.mod h1:jhPesDAL0Q0W2+2YEuVOvdWmVtdsr1+jtBrlDEVWwLY= +github.com/getsentry/sentry-go v0.29.1 h1:DyZuChN8Hz3ARxGVV8ePaNXh1dQ7d76AiB117xcREwA= +github.com/getsentry/sentry-go v0.29.1/go.mod h1:x3AtIzN01d6SiWkderzaH28Tm0lgkafpJ5Bm3li39O0= github.com/ghostiam/protogetter v0.3.6 h1:R7qEWaSgFCsy20yYHNIJsU9ZOb8TziSRRxuAOTVKeOk= github.com/ghostiam/protogetter v0.3.6/go.mod h1:7lpeDnEJ1ZjL/YtyoN99ljO4z0pd3H0d18/t2dPBxHw= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= From a64e8d0e703837d7e18aac3e8c7d024f0b14a3a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 15 Oct 2024 14:33:48 +0800 Subject: [PATCH 086/305] chore(deps): bump github.com/slack-go/slack from 0.14.0 to 0.15.0 (#2769) Bumps [github.com/slack-go/slack](https://github.com/slack-go/slack) from 0.14.0 to 0.15.0. - [Release notes](https://github.com/slack-go/slack/releases) - [Changelog](https://github.com/slack-go/slack/blob/master/CHANGELOG.md) - [Commits](https://github.com/slack-go/slack/compare/v0.14.0...v0.15.0) --- updated-dependencies: - dependency-name: github.com/slack-go/slack dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index cc65595b2..acdccd10a 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 github.com/muesli/reflow v0.3.0 github.com/oapi-codegen/runtime v1.1.1 - github.com/slack-go/slack v0.14.0 + github.com/slack-go/slack v0.15.0 github.com/spf13/afero v1.11.0 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 diff --git a/go.sum b/go.sum index 7a1c99e73..95e137d0f 100644 --- a/go.sum +++ b/go.sum @@ -900,8 +900,8 @@ github.com/sivchari/tenv v1.7.1 h1:PSpuD4bu6fSmtWMxSGWcvqUUgIn7k3yOJhOIzVWn8Ak= github.com/sivchari/tenv v1.7.1/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg= github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= -github.com/slack-go/slack v0.14.0 h1:6c0UTfbRnvRssZUsZ2qe0Iu07VAMPjRqOa6oX8ewF4k= -github.com/slack-go/slack v0.14.0/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= +github.com/slack-go/slack v0.15.0 h1:LE2lj2y9vqqiOf+qIIy0GvEoxgF1N5yLGZffmEZykt0= +github.com/slack-go/slack v0.15.0/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= github.com/sonatard/noctx v0.0.2 h1:L7Dz4De2zDQhW8S0t+KUjY0MAQJd6SgVwhzNIc4ok00= github.com/sonatard/noctx v0.0.2/go.mod h1:kzFz+CzWSjQ2OzIm46uJZoXuBpa2+0y3T36U18dWqIo= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= From fe0097e905b8ff221ed6efb0628f82a12508ceba Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 16 Oct 2024 08:31:23 +0800 Subject: [PATCH 087/305] fix: skip upserting disabled function (#2770) * chore: refactor function enabled check * fix: skip upserting disabled function --- internal/functions/deploy/deploy.go | 24 +++++------------------- internal/functions/serve/serve.go | 9 +++++---- pkg/config/config.go | 5 +++++ pkg/function/batch.go | 4 ++++ 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index fbed1313c..25ad3372a 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -16,7 +16,6 @@ import ( func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bool, importMapPath string, fsys afero.Fs) error { // Load function config and project id - var skippedFunctions []string if err := utils.LoadConfigFS(fsys); err != nil { return err } else if len(slugs) > 0 { @@ -25,12 +24,9 @@ func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bo return err } } - } else if slugs, skippedFunctions, err = GetFunctionSlugs(fsys); err != nil { + } else if slugs, err = GetFunctionSlugs(fsys); err != nil { return err } - if len(skippedFunctions) > 0 { - fmt.Fprintf(utils.GetDebugLogger(), "Skipped deploying the following functions: %s\n", strings.Join(skippedFunctions, ", ")) - } // TODO: require all functions to be deployed from config for v2 if len(slugs) == 0 { return errors.Errorf("No Functions specified or found in %s", utils.Bold(utils.FunctionsDir)) @@ -49,23 +45,19 @@ func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bo return nil } -func GetFunctionSlugs(fsys afero.Fs) (slugs []string, disabledSlugs []string, err error) { +func GetFunctionSlugs(fsys afero.Fs) (slugs []string, err error) { pattern := filepath.Join(utils.FunctionsDir, "*", "index.ts") paths, err := afero.Glob(fsys, pattern) if err != nil { - return nil, nil, errors.Errorf("failed to glob function slugs: %w", err) + return nil, errors.Errorf("failed to glob function slugs: %w", err) } for _, path := range paths { slug := filepath.Base(filepath.Dir(path)) if utils.FuncSlugPattern.MatchString(slug) { - if isFunctionEnabled(slug) { - slugs = append(slugs, slug) - } else { - disabledSlugs = append(disabledSlugs, slug) - } + slugs = append(slugs, slug) } } - return slugs, disabledSlugs, nil + return slugs, nil } func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, fsys afero.Fs) (config.FunctionConfig, error) { @@ -100,9 +92,3 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, } return functionConfig, nil } - -func isFunctionEnabled(slug string) bool { - functionConfig := utils.Config.Functions[slug] - // If the function config Enabled is not defined, or defined and set to true - return functionConfig.Enabled == nil || *functionConfig.Enabled -} diff --git a/internal/functions/serve/serve.go b/internal/functions/serve/serve.go index 316f7c4a6..15320171d 100644 --- a/internal/functions/serve/serve.go +++ b/internal/functions/serve/serve.go @@ -209,19 +209,20 @@ func parseEnvFile(envFilePath string, fsys afero.Fs) ([]string, error) { } func populatePerFunctionConfigs(cwd, importMapPath string, noVerifyJWT *bool, fsys afero.Fs) ([]string, string, error) { - slugs, skippedFunctions, err := deploy.GetFunctionSlugs(fsys) + slugs, err := deploy.GetFunctionSlugs(fsys) if err != nil { return nil, "", err } - if len(skippedFunctions) > 0 { - fmt.Fprintf(utils.GetDebugLogger(), "Skipped serving the following functions: %s\n", strings.Join(skippedFunctions, ", ")) - } functionsConfig, err := deploy.GetFunctionConfig(slugs, importMapPath, noVerifyJWT, fsys) if err != nil { return nil, "", err } binds := []string{} for slug, fc := range functionsConfig { + if !fc.IsEnabled() { + fmt.Fprintln(os.Stderr, "Skipped serving Function:", slug) + continue + } modules, err := deploy.GetBindMounts(cwd, utils.FunctionsDir, "", fc.Entrypoint, fc.ImportMap, fsys) if err != nil { return nil, "", err diff --git a/pkg/config/config.go b/pkg/config/config.go index 5fbd4661f..82b9d0a46 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -450,6 +450,11 @@ type ( } ) +func (f function) IsEnabled() bool { + // If Enabled is not defined, or defined and set to true + return f.Enabled == nil || *f.Enabled +} + func (c *baseConfig) Clone() baseConfig { copy := *c copy.Storage.Buckets = maps.Clone(c.Storage.Buckets) diff --git a/pkg/function/batch.go b/pkg/function/batch.go index 424a8a8cd..cf5a2f161 100644 --- a/pkg/function/batch.go +++ b/pkg/function/batch.go @@ -35,6 +35,10 @@ func (s *EdgeRuntimeAPI) UpsertFunctions(ctx context.Context, functionConfig con exists[f.Slug] = struct{}{} } for slug, function := range functionConfig { + if !function.IsEnabled() { + fmt.Fprintln(os.Stderr, "Skipped deploying Function:", slug) + continue + } for _, keep := range filter { if !keep(slug) { continue From c7bdbc20a96a4b8bbb924ba96a2b6eff5977b345 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Wed, 16 Oct 2024 10:47:20 +0200 Subject: [PATCH 088/305] feat(config): add api config for branching override (#2761) * feat: add remote utils for api config * chore: split api and remote api * Revert "chore: split api and remote api" This reverts commit 23173ec9830d8ae97b43d0fa12c183b1d99f7069. * chore: make api public * Revert "Revert "chore: split api and remote api"" This reverts commit 65bc6d32004a3fb25fee19a246cf9231f726e45d. * chore: handle api enable * chore: make convert whitespace resilient * feat: add some errors handling for remotes config * chore: move diff into own package * chore: add some diff tests * chore: fix golint casting lints * Update internal/utils/cast/cast.go Co-authored-by: Han Qiao * chore: use Errorf remote config error * chore: move diff and cast to pkg * chore: minor refactor * feat: implement remote config updater * chore: minor style changes * chore: refactor duplicate project ref check to getter * chore: update error message for consistency * chore: validate duplicate remote early --------- Co-authored-by: Han Qiao Co-authored-by: Qiao Han --- internal/link/link.go | 30 +++--- pkg/cast/cast.go | 25 +++++ pkg/config/api.go | 101 ++++++++++++++++++++ pkg/config/api_test.go | 143 ++++++++++++++++++++++++++++ pkg/config/config.go | 62 ++++++++---- pkg/config/updater.go | 49 ++++++++++ pkg/config/updater_test.go | 65 +++++++++++++ {internal/link => pkg/diff}/diff.go | 2 +- pkg/parser/token.go | 3 +- 9 files changed, 442 insertions(+), 38 deletions(-) create mode 100644 pkg/cast/cast.go create mode 100644 pkg/config/api.go create mode 100644 pkg/config/api_test.go create mode 100644 pkg/config/updater.go create mode 100644 pkg/config/updater_test.go rename {internal/link => pkg/diff}/diff.go (99%) diff --git a/internal/link/link.go b/internal/link/link.go index 0c2aa1de4..8a75a8d3d 100644 --- a/internal/link/link.go +++ b/internal/link/link.go @@ -1,7 +1,6 @@ package link import ( - "bytes" "context" "fmt" "os" @@ -9,7 +8,6 @@ import ( "strings" "sync" - "github.com/BurntSushi/toml" "github.com/go-errors/errors" "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" @@ -20,15 +18,20 @@ import ( "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/internal/utils/tenant" "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" cliConfig "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/pkg/diff" "github.com/supabase/cli/pkg/migration" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { - original := toTomlBytes(map[string]interface{}{ + original, err := cliConfig.ToTomlBytes(map[string]interface{}{ "api": utils.Config.Api, "db": utils.Config.Db, }) + if err != nil { + fmt.Fprintln(utils.GetDebugLogger(), err) + } if err := checkRemoteProjectStatus(ctx, projectRef); err != nil { return err @@ -60,28 +63,21 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func( fmt.Fprintln(os.Stdout, "Finished "+utils.Aqua("supabase link")+".") // 4. Suggest config update - updated := toTomlBytes(map[string]interface{}{ + updated, err := cliConfig.ToTomlBytes(map[string]interface{}{ "api": utils.Config.Api, "db": utils.Config.Db, }) - // if lineDiff := cmp.Diff(original, updated); len(lineDiff) > 0 { - if lineDiff := Diff(utils.ConfigPath, original, projectRef, updated); len(lineDiff) > 0 { + if err != nil { + fmt.Fprintln(utils.GetDebugLogger(), err) + } + + if lineDiff := diff.Diff(utils.ConfigPath, original, projectRef, updated); len(lineDiff) > 0 { fmt.Fprintln(os.Stderr, utils.Yellow("WARNING:"), "Local config differs from linked project. Try updating", utils.Bold(utils.ConfigPath)) fmt.Println(string(lineDiff)) } return nil } -func toTomlBytes(config any) []byte { - var buf bytes.Buffer - enc := toml.NewEncoder(&buf) - enc.Indent = "" - if err := enc.Encode(config); err != nil { - fmt.Fprintln(utils.GetDebugLogger(), "failed to marshal toml config:", err) - } - return buf.Bytes() -} - func LinkServices(ctx context.Context, projectRef, anonKey string, fsys afero.Fs) { // Ignore non-fatal errors linking services var wg sync.WaitGroup @@ -147,7 +143,7 @@ func linkPostgrestVersion(ctx context.Context, api tenant.TenantAPI, fsys afero. } func updateApiConfig(config api.PostgrestConfigWithJWTSecretResponse) { - utils.Config.Api.MaxRows = uint(config.MaxRows) + utils.Config.Api.MaxRows = cast.IntToUint(config.MaxRows) utils.Config.Api.ExtraSearchPath = readCsv(config.DbExtraSearchPath) utils.Config.Api.Schemas = readCsv(config.DbSchema) } diff --git a/pkg/cast/cast.go b/pkg/cast/cast.go new file mode 100644 index 000000000..b72cadbbf --- /dev/null +++ b/pkg/cast/cast.go @@ -0,0 +1,25 @@ +package cast + +import "math" + +// UintToInt converts a uint to an int, handling potential overflow +func UintToInt(value uint) int { + if value <= math.MaxInt { + result := int(value) + return result + } + maxInt := math.MaxInt + return maxInt +} + +// IntToUint converts an int to a uint, handling negative values +func IntToUint(value int) uint { + if value < 0 { + return 0 + } + return uint(value) +} + +func Ptr[T any](v T) *T { + return &v +} diff --git a/pkg/config/api.go b/pkg/config/api.go new file mode 100644 index 000000000..403e290e5 --- /dev/null +++ b/pkg/config/api.go @@ -0,0 +1,101 @@ +package config + +import ( + "strings" + + v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/diff" +) + +type ( + api struct { + Enabled bool `toml:"enabled"` + Schemas []string `toml:"schemas"` + ExtraSearchPath []string `toml:"extra_search_path"` + MaxRows uint `toml:"max_rows"` + // Local only config + Image string `toml:"-"` + KongImage string `toml:"-"` + Port uint16 `toml:"port"` + Tls tlsKong `toml:"tls"` + // TODO: replace [auth|studio].api_url + ExternalUrl string `toml:"external_url"` + } + + tlsKong struct { + Enabled bool `toml:"enabled"` + } +) + +func (a *api) ToUpdatePostgrestConfigBody() v1API.UpdatePostgrestConfigBody { + body := v1API.UpdatePostgrestConfigBody{} + + // When the api is disabled, remote side it just set the dbSchema to an empty value + if !a.Enabled { + body.DbSchema = cast.Ptr("") + return body + } + + // Convert Schemas to a comma-separated string + if len(a.Schemas) > 0 { + schemas := strings.Join(a.Schemas, ",") + body.DbSchema = &schemas + } + + // Convert ExtraSearchPath to a comma-separated string + if len(a.ExtraSearchPath) > 0 { + extraSearchPath := strings.Join(a.ExtraSearchPath, ",") + body.DbExtraSearchPath = &extraSearchPath + } + + // Convert MaxRows to int pointer + if a.MaxRows > 0 { + body.MaxRows = cast.Ptr(cast.UintToInt(a.MaxRows)) + } + + // Note: DbPool is not present in the Api struct, so it's not set here + return body +} + +func (a *api) fromRemoteApiConfig(remoteConfig v1API.PostgrestConfigWithJWTSecretResponse) api { + result := *a + if remoteConfig.DbSchema == "" { + result.Enabled = false + return result + } + + result.Enabled = true + // Update Schemas if present in remoteConfig + schemas := strings.Split(remoteConfig.DbSchema, ",") + result.Schemas = make([]string, len(schemas)) + // TODO: use slices.Map when upgrade go version + for i, schema := range schemas { + result.Schemas[i] = strings.TrimSpace(schema) + } + + // Update ExtraSearchPath if present in remoteConfig + extraSearchPath := strings.Split(remoteConfig.DbExtraSearchPath, ",") + result.ExtraSearchPath = make([]string, len(extraSearchPath)) + for i, path := range extraSearchPath { + result.ExtraSearchPath[i] = strings.TrimSpace(path) + } + + // Update MaxRows if present in remoteConfig + result.MaxRows = cast.IntToUint(remoteConfig.MaxRows) + + return result +} + +func (a *api) DiffWithRemote(remoteConfig v1API.PostgrestConfigWithJWTSecretResponse) ([]byte, error) { + // Convert the config values into easily comparable remoteConfig values + currentValue, err := ToTomlBytes(a) + if err != nil { + return nil, err + } + remoteCompare, err := ToTomlBytes(a.fromRemoteApiConfig(remoteConfig)) + if err != nil { + return nil, err + } + return diff.Diff("remote[api]", remoteCompare, "local[api]", currentValue), nil +} diff --git a/pkg/config/api_test.go b/pkg/config/api_test.go new file mode 100644 index 000000000..d48001244 --- /dev/null +++ b/pkg/config/api_test.go @@ -0,0 +1,143 @@ +package config + +import ( + "testing" + + "github.com/stretchr/testify/assert" + v1API "github.com/supabase/cli/pkg/api" +) + +func TestApiToUpdatePostgrestConfigBody(t *testing.T) { + t.Run("converts all fields correctly", func(t *testing.T) { + api := &api{ + Enabled: true, + Schemas: []string{"public", "private"}, + ExtraSearchPath: []string{"extensions", "public"}, + MaxRows: 1000, + } + + body := api.ToUpdatePostgrestConfigBody() + + assert.Equal(t, "public,private", *body.DbSchema) + assert.Equal(t, "extensions,public", *body.DbExtraSearchPath) + assert.Equal(t, 1000, *body.MaxRows) + }) + + t.Run("handles empty fields", func(t *testing.T) { + api := &api{} + + body := api.ToUpdatePostgrestConfigBody() + + // remote api will be false by default, leading to an empty schema on api side + assert.Equal(t, "", *body.DbSchema) + }) +} + +func TestApiDiffWithRemote(t *testing.T) { + t.Run("detects differences", func(t *testing.T) { + api := &api{ + Enabled: true, + Schemas: []string{"public", "private"}, + ExtraSearchPath: []string{"extensions", "public"}, + MaxRows: 1000, + } + + remoteConfig := v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "public", + DbExtraSearchPath: "public", + MaxRows: 500, + } + + diff, err := api.DiffWithRemote(remoteConfig) + assert.NoError(t, err, string(diff)) + + assert.Contains(t, string(diff), "-schemas = [\"public\"]") + assert.Contains(t, string(diff), "+schemas = [\"public\", \"private\"]") + assert.Contains(t, string(diff), "-extra_search_path = [\"public\"]") + assert.Contains(t, string(diff), "+extra_search_path = [\"extensions\", \"public\"]") + assert.Contains(t, string(diff), "-max_rows = 500") + assert.Contains(t, string(diff), "+max_rows = 1000") + }) + + t.Run("handles no differences", func(t *testing.T) { + api := &api{ + Enabled: true, + Schemas: []string{"public"}, + ExtraSearchPath: []string{"public"}, + MaxRows: 500, + } + + remoteConfig := v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "public", + DbExtraSearchPath: "public", + MaxRows: 500, + } + + diff, err := api.DiffWithRemote(remoteConfig) + assert.NoError(t, err) + + assert.Empty(t, diff) + }) + + t.Run("handles multiple schemas and search paths with spaces", func(t *testing.T) { + api := &api{ + Enabled: true, + Schemas: []string{"public", "private"}, + ExtraSearchPath: []string{"extensions", "public"}, + MaxRows: 500, + } + + remoteConfig := v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "public, private", + DbExtraSearchPath: "extensions, public", + MaxRows: 500, + } + + diff, err := api.DiffWithRemote(remoteConfig) + assert.NoError(t, err) + + assert.Empty(t, diff) + }) + + t.Run("handles api disabled on remote side", func(t *testing.T) { + api := &api{ + Enabled: true, + Schemas: []string{"public", "private"}, + ExtraSearchPath: []string{"extensions", "public"}, + MaxRows: 500, + } + + remoteConfig := v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "", + DbExtraSearchPath: "", + MaxRows: 0, + } + + diff, err := api.DiffWithRemote(remoteConfig) + assert.NoError(t, err, string(diff)) + + assert.Contains(t, string(diff), "-enabled = false") + assert.Contains(t, string(diff), "+enabled = true") + }) + + t.Run("handles api disabled on local side", func(t *testing.T) { + api := &api{ + Enabled: false, + Schemas: []string{"public"}, + ExtraSearchPath: []string{"public"}, + MaxRows: 500, + } + + remoteConfig := v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "public", + DbExtraSearchPath: "public", + MaxRows: 500, + } + + diff, err := api.DiffWithRemote(remoteConfig) + assert.NoError(t, err, string(diff)) + + assert.Contains(t, string(diff), "-enabled = true") + assert.Contains(t, string(diff), "+enabled = false") + }) +} diff --git a/pkg/config/config.go b/pkg/config/config.go index 82b9d0a46..3bf566bb1 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -145,23 +145,6 @@ type ( Remotes map[string]baseConfig `toml:"-"` } - api struct { - Enabled bool `toml:"enabled"` - Image string `toml:"-"` - KongImage string `toml:"-"` - Port uint16 `toml:"port"` - Schemas []string `toml:"schemas"` - ExtraSearchPath []string `toml:"extra_search_path"` - MaxRows uint `toml:"max_rows"` - Tls tlsKong `toml:"tls"` - // TODO: replace [auth|studio].api_url - ExternalUrl string `toml:"external_url"` - } - - tlsKong struct { - Enabled bool `toml:"enabled"` - } - db struct { Image string `toml:"-"` Port uint16 `toml:"port"` @@ -723,6 +706,7 @@ func (c *config) Load(path string, fsys fs.FS) error { if err := c.baseConfig.Validate(fsys); err != nil { return err } + idToName := map[string]string{} c.Remotes = make(map[string]baseConfig, len(c.Overrides)) for name, remote := range c.Overrides { base := c.baseConfig.Clone() @@ -735,10 +719,18 @@ func (c *config) Load(path string, fsys fs.FS) error { if metadata, err := toml.NewDecoder(&buf).Decode(&base); err != nil { return errors.Errorf("failed to decode remote config: %w", err) } else if undecoded := metadata.Undecoded(); len(undecoded) > 0 { - fmt.Fprintf(os.Stderr, "Unknown config fields: %+v\n", undecoded) + fmt.Fprintf(os.Stderr, "WARN: unknown config fields: %+v\n", undecoded) + } + // Cross validate remote project id + if base.ProjectId == c.baseConfig.ProjectId { + fmt.Fprintf(os.Stderr, "WARN: project_id is missing for [remotes.%s]\n", name) + } else if other, exists := idToName[base.ProjectId]; exists { + return errors.Errorf("duplicate project_id for [remotes.%s] and [remotes.%s]", other, name) + } else { + idToName[base.ProjectId] = name } if err := base.Validate(fsys); err != nil { - return err + return errors.Errorf("invalid config for [remotes.%s]: %w", name, err) } c.Remotes[name] = base } @@ -1332,3 +1324,35 @@ func (a *auth) ResolveJWKS(ctx context.Context) (string, error) { return string(jwksEncoded), nil } + +// Retrieve the final base config to use taking into account the remotes override +func (c *config) GetRemoteByProjectRef(projectRef string) (baseConfig, error) { + var result []string + // Iterate over all the config.Remotes + for name, remoteConfig := range c.Remotes { + // Check if there is one matching project_id + if remoteConfig.ProjectId == projectRef { + // Check for duplicate project IDs across remotes + result = append(result, name) + } + } + // If no matching remote config is found, return the base config + if len(result) == 0 { + return c.baseConfig, errors.Errorf("no remote found for project_id: %s", projectRef) + } + remote := c.Remotes[result[0]] + if len(result) > 1 { + return remote, errors.Errorf("multiple remotes %v have the same project_id: %s", result, projectRef) + } + return remote, nil +} + +func ToTomlBytes(config any) ([]byte, error) { + var buf bytes.Buffer + enc := toml.NewEncoder(&buf) + enc.Indent = "" + if err := enc.Encode(config); err != nil { + return nil, errors.Errorf("failed to marshal toml config: %w", err) + } + return buf.Bytes(), nil +} diff --git a/pkg/config/updater.go b/pkg/config/updater.go new file mode 100644 index 000000000..467b7bb63 --- /dev/null +++ b/pkg/config/updater.go @@ -0,0 +1,49 @@ +package config + +import ( + "context" + "fmt" + "os" + + "github.com/go-errors/errors" + v1API "github.com/supabase/cli/pkg/api" +) + +type ConfigUpdater struct { + client v1API.ClientWithResponses +} + +func NewConfigUpdater(client v1API.ClientWithResponses) ConfigUpdater { + return ConfigUpdater{client: client} +} + +func (u *ConfigUpdater) UpdateRemoteConfig(ctx context.Context, remote baseConfig) error { + if err := u.UpdateApiConfig(ctx, remote.ProjectId, remote.Api); err != nil { + return err + } + // TODO: implement other service configs, ie. auth + return nil +} + +func (u *ConfigUpdater) UpdateApiConfig(ctx context.Context, projectRef string, c api) error { + apiConfig, err := u.client.V1GetPostgrestServiceConfigWithResponse(ctx, projectRef) + if err != nil { + return errors.Errorf("failed to read API config: %w", err) + } else if apiConfig.JSON200 == nil { + return errors.Errorf("unexpected status %d: %s", apiConfig.StatusCode(), string(apiConfig.Body)) + } + apiDiff, err := c.DiffWithRemote(*apiConfig.JSON200) + if err != nil { + return err + } else if len(apiDiff) == 0 { + fmt.Fprintln(os.Stderr, "Remote API config is up to date.") + return nil + } + fmt.Fprintln(os.Stderr, "Updating API service with config:", string(apiDiff)) + if resp, err := u.client.V1UpdatePostgrestServiceConfigWithResponse(ctx, projectRef, c.ToUpdatePostgrestConfigBody()); err != nil { + return errors.Errorf("failed to update API config: %w", err) + } else if resp.JSON200 == nil { + return errors.Errorf("unexpected status %d: %s", resp.StatusCode(), string(resp.Body)) + } + return nil +} diff --git a/pkg/config/updater_test.go b/pkg/config/updater_test.go new file mode 100644 index 000000000..241d612e9 --- /dev/null +++ b/pkg/config/updater_test.go @@ -0,0 +1,65 @@ +package config + +import ( + "context" + "net/http" + "testing" + + "github.com/h2non/gock" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + v1API "github.com/supabase/cli/pkg/api" +) + +func TestUpdateApi(t *testing.T) { + server := "http://localhost" + client, err := v1API.NewClientWithResponses(server) + require.NoError(t, err) + + t.Run("updates remote config", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Setup mock server + defer gock.Off() + gock.New(server). + Get("/v1/projects/test-project/postgrest"). + Reply(http.StatusOK). + JSON(v1API.PostgrestConfigWithJWTSecretResponse{}) + gock.New(server). + Patch("/v1/projects/test-project/postgrest"). + Reply(http.StatusOK). + JSON(v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "public,graphql_public", + DbExtraSearchPath: "public,extensions", + MaxRows: 1000, + }) + // Run test + err := updater.UpdateApiConfig(context.Background(), "test-project", api{ + Enabled: true, + Schemas: []string{"public", "graphql_public"}, + ExtraSearchPath: []string{"public", "extensions"}, + MaxRows: 1000, + }) + // Check result + assert.NoError(t, err) + assert.True(t, gock.IsDone()) + }) + + t.Run("skips update if no diff", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Setup mock server + defer gock.Off() + gock.New(server). + Get("/v1/projects/test-project/postgrest"). + Reply(http.StatusOK). + JSON(v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "", + DbExtraSearchPath: "public,extensions", + MaxRows: 1000, + }) + // Run test + err := updater.UpdateApiConfig(context.Background(), "test-project", api{}) + // Check result + assert.NoError(t, err) + assert.True(t, gock.IsDone()) + }) +} diff --git a/internal/link/diff.go b/pkg/diff/diff.go similarity index 99% rename from internal/link/diff.go rename to pkg/diff/diff.go index 84f2e3494..6a40b23fc 100644 --- a/internal/link/diff.go +++ b/pkg/diff/diff.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -package link +package diff import ( "bytes" diff --git a/pkg/parser/token.go b/pkg/parser/token.go index 018a6f5d4..db0084342 100644 --- a/pkg/parser/token.go +++ b/pkg/parser/token.go @@ -8,6 +8,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/viper" + "github.com/supabase/cli/pkg/cast" ) // Equal to `startBufSize` from `bufio/scan.go` @@ -83,7 +84,7 @@ func Split(sql io.Reader, transform ...func(string) string) (stats []string, err // Increase scanner capacity to support very long lines containing e.g. geodata buf := make([]byte, startBufSize) - maxbuf := int(viper.GetSizeInBytes("SCANNER_BUFFER_SIZE")) + maxbuf := cast.UintToInt(viper.GetSizeInBytes("SCANNER_BUFFER_SIZE")) if maxbuf == 0 { maxbuf = MaxScannerCapacity } From eb5a512f726338ba9f2c5129f52574dd3f4ee75b Mon Sep 17 00:00:00 2001 From: Ankesh Verma Date: Thu, 17 Oct 2024 19:13:13 +0530 Subject: [PATCH 089/305] chore(docs): correct CLI linking to /usr/bin/supabase (#2776) fix: correct CLI linking to /usr/bin/supabase --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 750bd8895..7da7ff569 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ For Bun versions below v1.0.17, you must add `supabase` as a [trusted dependency Add a symlink to the binary in `$PATH` for easier access: ```sh - ln -s "$(go env GOPATH)/cli" /usr/bin/supabase + ln -s "$(go env GOPATH)/bin/cli" /usr/bin/supabase ``` This works on other non-standard Linux distros. From 9d30b96849849613d48696419c5e8a590cc2f69b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Thu, 17 Oct 2024 22:43:46 +0900 Subject: [PATCH 090/305] fix: bump edge-runtime to 1.59.0 (#2775) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 55bd94002..90d1b821f 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.83.2" studioImage = "supabase/studio:20241014-c083b3b" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.58.13" + edgeRuntimeImage = "supabase/edge-runtime:v1.59.0" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.158.1" From adda496b91217c5fb66a45e74d235e510ecb217b Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Fri, 18 Oct 2024 02:32:51 +0800 Subject: [PATCH 091/305] fix: squash base config with mapstructure (#2777) * fix: squash base config with mapstructure * fix: move env load settings to one place * chore: remove unused string replacer --- cmd/root.go | 13 +------------ pkg/config/config.go | 37 ++++++++++++++++++++++++++++++------- pkg/config/config_test.go | 12 ++++++++++++ 3 files changed, 43 insertions(+), 19 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index f7caa54fd..d3ef3fce9 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,7 +12,6 @@ import ( "github.com/getsentry/sentry-go" "github.com/go-errors/errors" - "github.com/mitchellh/mapstructure" "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -223,18 +222,8 @@ func recoverAndExit() { func init() { cobra.OnInitialize(func() { - // Allow overriding config object with automatic env - // Ref: https://github.com/spf13/viper/issues/761 - envKeysMap := map[string]interface{}{} - dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ - Result: &envKeysMap, - IgnoreUntaggedFields: true, - }) - cobra.CheckErr(err) - cobra.CheckErr(dec.Decode(utils.Config)) - cobra.CheckErr(viper.MergeConfigMap(envKeysMap)) viper.SetEnvPrefix("SUPABASE") - viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_")) + viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) viper.AutomaticEnv() }) diff --git a/pkg/config/config.go b/pkg/config/config.go index 3bf566bb1..8914dcac0 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -28,6 +28,7 @@ import ( "github.com/go-errors/errors" "github.com/golang-jwt/jwt/v5" "github.com/joho/godotenv" + "github.com/mitchellh/mapstructure" "github.com/spf13/viper" "golang.org/x/mod/semver" @@ -136,13 +137,13 @@ type ( EdgeRuntime edgeRuntime `toml:"edge_runtime"` Functions FunctionConfig `toml:"functions"` Analytics analytics `toml:"analytics"` - Experimental experimental `toml:"experimental" mapstructure:"-"` + Experimental experimental `toml:"experimental"` } config struct { - baseConfig - Overrides map[string]interface{} `toml:"remotes"` - Remotes map[string]baseConfig `toml:"-"` + baseConfig `mapstructure:",squash"` + Overrides map[string]interface{} `toml:"remotes"` + Remotes map[string]baseConfig `toml:"-"` } db struct { @@ -587,6 +588,29 @@ func (c *config) Eject(w io.Writer) error { return nil } +func (c *config) loadFromEnv() error { + // Allow overriding base config object with automatic env + // Ref: https://github.com/spf13/viper/issues/761 + envKeysMap := map[string]interface{}{} + if dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ + Result: &envKeysMap, + IgnoreUntaggedFields: true, + }); err != nil { + return errors.Errorf("failed to create decoder: %w", err) + } else if err := dec.Decode(c.baseConfig); err != nil { + return errors.Errorf("failed to decode env: %w", err) + } + v := viper.New() + v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) + v.AutomaticEnv() + if err := v.MergeConfigMap(envKeysMap); err != nil { + return errors.Errorf("failed to merge config: %w", err) + } else if err := v.Unmarshal(c); err != nil { + return errors.Errorf("failed to parse env to config: %w", err) + } + return nil +} + func (c *config) Load(path string, fsys fs.FS) error { builder := NewPathBuilder(path) // Load default values @@ -614,9 +638,8 @@ func (c *config) Load(path string, fsys fs.FS) error { // Load secrets from .env file if err := loadDefaultEnv(); err != nil { return err - } - if err := viper.Unmarshal(c); err != nil { - return errors.Errorf("failed to parse env to config: %w", err) + } else if err := c.loadFromEnv(); err != nil { + return err } // Generate JWT tokens if len(c.Auth.AnonKey) == 0 { diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index af3ab9563..bef3df123 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -341,3 +341,15 @@ func TestLoadSeedPaths(t *testing.T) { assert.Empty(t, config.SqlPaths) }) } + +func TestLoadEnv(t *testing.T) { + t.Setenv("AUTH_JWT_SECRET", "test-secret") + t.Setenv("DB_ROOT_KEY", "test-root-key") + config := NewConfig() + // Run test + err := config.loadFromEnv() + // Check error + assert.NoError(t, err) + assert.Equal(t, "test-secret", config.Auth.JwtSecret) + assert.Equal(t, "test-root-key", config.Db.RootKey) +} From 5f8587b154bcf54bd4404bc28d547c54a2ed2684 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Thu, 17 Oct 2024 20:52:28 +0200 Subject: [PATCH 092/305] fix(config): use SUPABASE env prefix (#2778) * fix(config): use SUPABASE env prefix * fix: tests --- pkg/config/config.go | 1 + pkg/config/config_test.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 8914dcac0..f6329f459 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -601,6 +601,7 @@ func (c *config) loadFromEnv() error { return errors.Errorf("failed to decode env: %w", err) } v := viper.New() + v.SetEnvPrefix("SUPABASE") v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) v.AutomaticEnv() if err := v.MergeConfigMap(envKeysMap); err != nil { diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index bef3df123..c10669350 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -343,8 +343,8 @@ func TestLoadSeedPaths(t *testing.T) { } func TestLoadEnv(t *testing.T) { - t.Setenv("AUTH_JWT_SECRET", "test-secret") - t.Setenv("DB_ROOT_KEY", "test-root-key") + t.Setenv("SUPABASE_AUTH_JWT_SECRET", "test-secret") + t.Setenv("SUPABASE_DB_ROOT_KEY", "test-root-key") config := NewConfig() // Run test err := config.loadFromEnv() From 8d4d6db39898e53bbb3f311299a71f44c8bb6aa5 Mon Sep 17 00:00:00 2001 From: Bobbie Soedirgo Date: Fri, 18 Oct 2024 16:11:48 +0800 Subject: [PATCH 093/305] fix: pg-meta v0.84.1 --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 90d1b821f..11be00252 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -9,7 +9,7 @@ const ( kongImage = "library/kong:2.8.1" inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" - pgmetaImage = "supabase/postgres-meta:v0.83.2" + pgmetaImage = "supabase/postgres-meta:v0.84.1" studioImage = "supabase/studio:20241014-c083b3b" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.59.0" From 2da3861348bba06c43d34a53bb05b813b5e860b0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 04:09:44 +0000 Subject: [PATCH 094/305] chore(deps): bump github.com/jackc/pgtype from 1.14.3 to 1.14.4 (#2785) Bumps [github.com/jackc/pgtype](https://github.com/jackc/pgtype) from 1.14.3 to 1.14.4. - [Changelog](https://github.com/jackc/pgtype/blob/master/CHANGELOG.md) - [Commits](https://github.com/jackc/pgtype/compare/v1.14.3...v1.14.4) --- updated-dependencies: - dependency-name: github.com/jackc/pgtype dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index acdccd10a..846a3306c 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438 github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 github.com/jackc/pgproto3/v2 v2.3.3 - github.com/jackc/pgtype v1.14.3 + github.com/jackc/pgtype v1.14.4 github.com/jackc/pgx/v4 v4.18.3 github.com/joho/godotenv v1.5.1 github.com/matoous/go-nanoid/v2 v2.1.0 diff --git a/go.sum b/go.sum index 95e137d0f..d9153dd90 100644 --- a/go.sum +++ b/go.sum @@ -562,8 +562,8 @@ github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCM github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= github.com/jackc/pgtype v1.14.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= -github.com/jackc/pgtype v1.14.3 h1:h6W9cPuHsRWQFTWUZMAKMgG5jSwQI0Zurzdvlx3Plus= -github.com/jackc/pgtype v1.14.3/go.mod h1:aKeozOde08iifGosdJpz9MBZonJOUJxqNpPBcMJTlVA= +github.com/jackc/pgtype v1.14.4 h1:fKuNiCumbKTAIxQwXfB/nsrnkEI6bPJrrSiMKgbJ2j8= +github.com/jackc/pgtype v1.14.4/go.mod h1:aKeozOde08iifGosdJpz9MBZonJOUJxqNpPBcMJTlVA= github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= From ce904a1e2ecc145855d385fe3346108480b49fed Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Tue, 22 Oct 2024 00:02:12 +0800 Subject: [PATCH 095/305] fix: empty array is valid api config (#2788) * fix: empty array is valid api config * chore: revert weird api schema update * Update api.go --- pkg/config/api.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/config/api.go b/pkg/config/api.go index 403e290e5..51f516506 100644 --- a/pkg/config/api.go +++ b/pkg/config/api.go @@ -44,10 +44,7 @@ func (a *api) ToUpdatePostgrestConfigBody() v1API.UpdatePostgrestConfigBody { } // Convert ExtraSearchPath to a comma-separated string - if len(a.ExtraSearchPath) > 0 { - extraSearchPath := strings.Join(a.ExtraSearchPath, ",") - body.DbExtraSearchPath = &extraSearchPath - } + body.DbExtraSearchPath = cast.Ptr(strings.Join(a.ExtraSearchPath, ",")) // Convert MaxRows to int pointer if a.MaxRows > 0 { From 68e3663ccb5ee7712d4f282f042e527607d95580 Mon Sep 17 00:00:00 2001 From: Bobbie Soedirgo <31685197+soedirgo@users.noreply.github.com> Date: Tue, 22 Oct 2024 00:03:45 +0800 Subject: [PATCH 096/305] fix: pg-meta v0.84.2 (#2783) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 11be00252..0b2edfcf3 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -9,7 +9,7 @@ const ( kongImage = "library/kong:2.8.1" inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" - pgmetaImage = "supabase/postgres-meta:v0.84.1" + pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241014-c083b3b" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.59.0" From 47b7e9a8d877b0ac96f9ce00d348f4b495af11da Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Mon, 21 Oct 2024 16:07:36 +0000 Subject: [PATCH 097/305] fix: prune volumes without all flag for pre-Docker v1.42 (#2781) fix: prune volumes without all for pre-Docker 1.42 Before Docker API version 1.42, the `all` flag in Docker.VolumePrune` is not required. Podman prints an error like the following when the `all` flag is passed ([Podman's only compatible with Docker API v1.41][1]): ``` failed to parse filters for all=true&label=com.supabase.cli.project%3Dtest: "all" is an invalid volume filter ``` [1]: https://github.com/containers/podman/blob/290d94d3c00857dd582ffbee6bd0677a0904c783/version/version.go#L46 Fixes: bec537e98d0c2491442d44eb04b5d0407f88406c Fixes: https://github.com/supabase/cli/issues/2348#issuecomment-2149936472 --- internal/stop/stop_test.go | 19 +++++++++++++++++++ internal/testing/apitest/docker.go | 8 ++++++++ internal/utils/docker.go | 9 ++++++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/internal/stop/stop_test.go b/internal/stop/stop_test.go index da571330b..b607d87d7 100644 --- a/internal/stop/stop_test.go +++ b/internal/stop/stop_test.go @@ -13,6 +13,7 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/volume" + "github.com/docker/docker/client" "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" @@ -206,6 +207,24 @@ func TestStopServices(t *testing.T) { assert.Empty(t, apitest.ListUnmatchedRequests()) }) + t.Run("skips all filter when removing data volumes with Docker version pre-v1.42", func(t *testing.T) { + utils.DbId = "test-db" + utils.ConfigId = "test-config" + utils.StorageId = "test-storage" + utils.EdgeRuntimeId = "test-functions" + utils.InbucketId = "test-inbucket" + // Setup mock docker + require.NoError(t, apitest.MockDocker(utils.Docker)) + require.NoError(t, client.WithVersion("1.41")(utils.Docker)) + defer gock.OffAll() + apitest.MockDockerStop(utils.Docker) + // Run test + err := stop(context.Background(), false, io.Discard, utils.Config.ProjectId) + // Check error + assert.NoError(t, err) + assert.Empty(t, apitest.ListUnmatchedRequests()) + }) + t.Run("throws error on prune failure", func(t *testing.T) { // Setup mock docker require.NoError(t, apitest.MockDocker(utils.Docker)) diff --git a/internal/testing/apitest/docker.go b/internal/testing/apitest/docker.go index 21a4d7dd2..556756dfd 100644 --- a/internal/testing/apitest/docker.go +++ b/internal/testing/apitest/docker.go @@ -9,9 +9,11 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/volume" "github.com/docker/docker/client" "github.com/docker/docker/pkg/stdcopy" + "github.com/go-errors/errors" "github.com/h2non/gock" ) @@ -64,6 +66,12 @@ func MockDockerStop(docker *client.Client) { Post("/v" + docker.ClientVersion() + "/containers/prune"). Reply(http.StatusOK). JSON(container.PruneReport{}) + if !versions.GreaterThanOrEqualTo(docker.ClientVersion(), "1.42") { + gock.New(docker.DaemonHost()). + Post("/v"+docker.ClientVersion()+"/volumes/prune"). + MatchParam("filters", `"all":{"true":true}`). + ReplyError(errors.New(`failed to parse filters for all=true&label=com.supabase.cli.project%3Dtest: "all" is an invalid volume filter`)) + } gock.New(docker.DaemonHost()). Post("/v" + docker.ClientVersion() + "/volumes/prune"). Reply(http.StatusOK). diff --git a/internal/utils/docker.go b/internal/utils/docker.go index 6264c4056..84911d07f 100644 --- a/internal/utils/docker.go +++ b/internal/utils/docker.go @@ -25,6 +25,7 @@ import ( "github.com/docker/docker/api/types/image" "github.com/docker/docker/api/types/mount" "github.com/docker/docker/api/types/network" + "github.com/docker/docker/api/types/versions" "github.com/docker/docker/api/types/volume" "github.com/docker/docker/client" "github.com/docker/docker/errdefs" @@ -125,10 +126,12 @@ func DockerRemoveAll(ctx context.Context, w io.Writer, projectId string) error { } // Remove named volumes if NoBackupVolume { - // Since docker engine 25.0.3, all flag is required to include named volumes. - // https://github.com/docker/cli/blob/master/cli/command/volume/prune.go#L76 vargs := args.Clone() - vargs.Add("all", "true") + if versions.GreaterThanOrEqualTo(Docker.ClientVersion(), "1.42") { + // Since docker engine 25.0.3, all flag is required to include named volumes. + // https://github.com/docker/cli/blob/master/cli/command/volume/prune.go#L76 + vargs.Add("all", "true") + } if report, err := Docker.VolumesPrune(ctx, vargs); err != nil { return errors.Errorf("failed to prune volumes: %w", err) } else if viper.GetBool("DEBUG") { From 1a1e908dd9a89a2887a26250c70726332256fafa Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Tue, 22 Oct 2024 00:27:42 +0800 Subject: [PATCH 098/305] fix: drop user created publications during reset (#2789) Co-authored-by: billysutomo --- pkg/migration/queries/drop.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/migration/queries/drop.sql b/pkg/migration/queries/drop.sql index 368ee7228..14d1803e2 100644 --- a/pkg/migration/queries/drop.sql +++ b/pkg/migration/queries/drop.sql @@ -74,4 +74,14 @@ begin loop execute format('drop policy if exists %I on %I.%I cascade', rec.policyname, rec.schemaname, rec.tablename); end loop; + + -- publications + for rec in + select * + from pg_publication p + where + p.pubname != 'supabase_realtime' + loop + execute format('drop publication if exists %I', rec.pubname); + end loop; end $$; From 7adbe9be87f7643a73870ec29dd191d5d900d4af Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Oct 2024 08:24:30 +0000 Subject: [PATCH 099/305] chore(deps): bump github.com/golangci/golangci-lint from 1.59.1 to 1.61.0 (#2692) chore(deps): bump github.com/golangci/golangci-lint Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.59.1 to 1.61.0. - [Release notes](https://github.com/golangci/golangci-lint/releases) - [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md) - [Commits](https://github.com/golangci/golangci-lint/compare/v1.59.1...v1.61.0) --- updated-dependencies: - dependency-name: github.com/golangci/golangci-lint dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Han Qiao --- go.mod | 69 +++++++++++++------------ go.sum | 158 ++++++++++++++++++++++++++++----------------------------- 2 files changed, 112 insertions(+), 115 deletions(-) diff --git a/go.mod b/go.mod index 846a3306c..cc84666d5 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/supabase/cli go 1.22.4 require ( - github.com/BurntSushi/toml v1.4.0 + github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c github.com/Netflix/go-env v0.1.0 github.com/andybalholm/brotli v1.1.1 github.com/cenkalti/backoff/v4 v4.3.0 @@ -24,7 +24,7 @@ require ( github.com/go-git/go-git/v5 v5.12.0 github.com/go-xmlfmt/xmlfmt v1.1.2 github.com/golang-jwt/jwt/v5 v5.2.1 - github.com/golangci/golangci-lint v1.59.1 + github.com/golangci/golangci-lint v1.61.0 github.com/google/go-github/v62 v62.0.0 github.com/google/go-querystring v1.1.0 github.com/google/uuid v1.6.0 @@ -63,15 +63,15 @@ require ( 4d63.com/gochecknoglobals v0.2.1 // indirect dario.cat/mergo v1.0.0 // indirect github.com/4meepo/tagalign v1.3.4 // indirect - github.com/Abirdcfly/dupword v0.0.14 // indirect + github.com/Abirdcfly/dupword v0.1.1 // indirect github.com/Antonboom/errname v0.1.13 // indirect github.com/Antonboom/nilnil v0.1.9 // indirect - github.com/Antonboom/testifylint v1.3.1 // indirect + github.com/Antonboom/testifylint v1.4.3 // indirect github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect - github.com/Crocmagnon/fatcontext v0.2.2 // indirect + github.com/Crocmagnon/fatcontext v0.5.2 // indirect github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect - github.com/GaijinEntertainment/go-exhaustruct/v3 v3.2.0 // indirect - github.com/Masterminds/semver/v3 v3.2.1 // indirect + github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.0 // indirect + github.com/Masterminds/semver/v3 v3.3.0 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/OpenPeeDeeP/depguard/v2 v2.2.0 // indirect github.com/ProtonMail/go-crypto v1.0.0 // indirect @@ -91,7 +91,7 @@ require ( github.com/bitfield/gotestdox v0.2.2 // indirect github.com/bkielbasa/cyclop v1.2.1 // indirect github.com/blizzy78/varnamelen v0.8.0 // indirect - github.com/bombsimon/wsl/v4 v4.2.1 // indirect + github.com/bombsimon/wsl/v4 v4.4.1 // indirect github.com/breml/bidichk v0.2.7 // indirect github.com/breml/errchkjson v0.3.6 // indirect github.com/butuzov/ireturn v0.3.0 // indirect @@ -105,7 +105,7 @@ require ( github.com/charmbracelet/harmonica v0.2.0 // indirect github.com/charmbracelet/x/ansi v0.1.4 // indirect github.com/chavacava/garif v0.1.0 // indirect - github.com/ckaznocha/intrange v0.1.2 // indirect + github.com/ckaznocha/intrange v0.2.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/iasm v0.2.0 // indirect @@ -114,7 +114,7 @@ require ( github.com/containers/storage v1.55.0 // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/cyphar/filepath-securejoin v0.3.1 // indirect - github.com/daixiang0/gci v0.13.4 // indirect + github.com/daixiang0/gci v0.13.5 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/denis-tingaikin/go-header v0.5.0 // indirect github.com/distribution/reference v0.6.0 // indirect @@ -154,16 +154,16 @@ require ( github.com/go-toolsmith/astp v1.1.0 // indirect github.com/go-toolsmith/strparse v1.1.0 // indirect github.com/go-toolsmith/typep v1.1.0 // indirect - github.com/go-viper/mapstructure/v2 v2.0.0 // indirect + github.com/go-viper/mapstructure/v2 v2.1.0 // indirect github.com/gobwas/glob v0.2.3 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect - github.com/gofrs/flock v0.8.1 // indirect + github.com/gofrs/flock v0.12.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect - github.com/golangci/gofmt v0.0.0-20231018234816-f50ced29576e // indirect + github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9 // indirect github.com/golangci/misspell v0.6.0 // indirect github.com/golangci/modinfo v0.3.4 // indirect github.com/golangci/plugin-module-register v0.1.1 // indirect @@ -194,7 +194,7 @@ require ( github.com/jgautheron/goconst v1.7.1 // indirect github.com/jingyugao/rowserrcheck v1.1.1 // indirect github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect - github.com/jjti/go-spancheck v0.6.1 // indirect + github.com/jjti/go-spancheck v0.6.2 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/julz/importas v0.1.0 // indirect @@ -227,7 +227,7 @@ require ( github.com/mattn/go-localereader v0.0.1 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/mgechev/revive v1.3.7 // indirect + github.com/mgechev/revive v1.3.9 // indirect github.com/microcosm-cc/bluemonday v1.0.25 // indirect github.com/miekg/pkcs11 v1.1.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect @@ -238,7 +238,7 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect - github.com/moricho/tparallel v0.3.1 // indirect + github.com/moricho/tparallel v0.3.2 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect github.com/muesli/cancelreader v0.2.2 // indirect @@ -250,24 +250,24 @@ require ( github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect - github.com/pelletier/go-toml/v2 v2.2.2 // indirect + github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/perimeterx/marshmallow v1.1.5 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/polyfloyd/go-errorlint v1.5.2 // indirect + github.com/polyfloyd/go-errorlint v1.6.0 // indirect github.com/prometheus/client_golang v1.12.1 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/procfs v0.7.3 // indirect - github.com/quasilyte/go-ruleguard v0.4.2 // indirect + github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1 // indirect github.com/quasilyte/go-ruleguard/dsl v0.3.22 // indirect github.com/quasilyte/gogrep v0.5.0 // indirect github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect - github.com/ryancurrah/gomodguard v1.3.2 // indirect + github.com/ryancurrah/gomodguard v1.3.5 // indirect github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect @@ -275,13 +275,13 @@ require ( github.com/sanposhiho/wastedassign/v2 v2.0.7 // indirect github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect github.com/sashamelentyev/interfacebloat v1.1.0 // indirect - github.com/sashamelentyev/usestdlibvars v1.26.0 // indirect - github.com/securego/gosec/v2 v2.20.1-0.20240525090044-5f0084eb01a9 // indirect + github.com/sashamelentyev/usestdlibvars v1.27.0 // indirect + github.com/securego/gosec/v2 v2.21.2 // indirect github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/sivchari/containedctx v1.0.3 // indirect - github.com/sivchari/tenv v1.7.1 // indirect + github.com/sivchari/tenv v1.10.0 // indirect github.com/skeema/knownhosts v1.2.2 // indirect github.com/sonatard/noctx v0.0.2 // indirect github.com/sourcegraph/conc v0.3.0 // indirect @@ -291,19 +291,18 @@ require ( github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect - github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c // indirect github.com/tdakkota/asciicheck v0.2.0 // indirect - github.com/tetafro/godot v1.4.16 // indirect + github.com/tetafro/godot v1.4.17 // indirect github.com/theupdateframework/notary v0.7.0 // indirect github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 // indirect github.com/timonwong/loggercheck v0.9.4 // indirect - github.com/tomarrell/wrapcheck/v2 v2.8.3 // indirect + github.com/tomarrell/wrapcheck/v2 v2.9.0 // indirect github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect github.com/ultraware/funlen v0.1.0 // indirect github.com/ultraware/whitespace v0.1.1 // indirect - github.com/uudashr/gocognit v1.1.2 // indirect + github.com/uudashr/gocognit v1.1.3 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect @@ -316,8 +315,8 @@ require ( github.com/yuin/goldmark-emoji v1.0.2 // indirect gitlab.com/bosi/decorder v0.4.2 // indirect go-simpler.org/musttag v0.12.2 // indirect - go-simpler.org/sloglint v0.7.1 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect + go-simpler.org/sloglint v0.7.2 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 // indirect @@ -332,21 +331,21 @@ require ( go.uber.org/multierr v1.9.0 // indirect go.uber.org/zap v1.24.0 // indirect golang.org/x/arch v0.8.0 // indirect - golang.org/x/crypto v0.26.0 // indirect - golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect + golang.org/x/crypto v0.27.0 // indirect + golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect golang.org/x/net v0.28.0 // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.26.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/text v0.18.0 // indirect golang.org/x/tools v0.24.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - honnef.co/go/tools v0.4.7 // indirect - mvdan.cc/gofumpt v0.6.0 // indirect + honnef.co/go/tools v0.5.1 // indirect + mvdan.cc/gofumpt v0.7.0 // indirect mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f // indirect ) diff --git a/go.sum b/go.sum index d9153dd90..ec11ef74c 100644 --- a/go.sum +++ b/go.sum @@ -39,29 +39,29 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/4meepo/tagalign v1.3.4 h1:P51VcvBnf04YkHzjfclN6BbsopfJR5rxs1n+5zHt+w8= github.com/4meepo/tagalign v1.3.4/go.mod h1:M+pnkHH2vG8+qhE5bVc/zeP7HS/j910Fwa9TUSyZVI0= -github.com/Abirdcfly/dupword v0.0.14 h1:3U4ulkc8EUo+CaT105/GJ1BQwtgyj6+VaBVbAX11Ba8= -github.com/Abirdcfly/dupword v0.0.14/go.mod h1:VKDAbxdY8YbKUByLGg8EETzYSuC4crm9WwI6Y3S0cLI= +github.com/Abirdcfly/dupword v0.1.1 h1:Bsxe0fIw6OwBtXMIncaTxCLHYO5BB+3mcsR5E8VXloY= +github.com/Abirdcfly/dupword v0.1.1/go.mod h1:B49AcJdTYYkpd4HjgAcutNGG9HZ2JWwKunH9Y2BA6sM= github.com/Antonboom/errname v0.1.13 h1:JHICqsewj/fNckzrfVSe+T33svwQxmjC+1ntDsHOVvM= github.com/Antonboom/errname v0.1.13/go.mod h1:uWyefRYRN54lBg6HseYCFhs6Qjcy41Y3Jl/dVhA87Ns= github.com/Antonboom/nilnil v0.1.9 h1:eKFMejSxPSA9eLSensFmjW2XTgTwJMjZ8hUHtV4s/SQ= github.com/Antonboom/nilnil v0.1.9/go.mod h1:iGe2rYwCq5/Me1khrysB4nwI7swQvjclR8/YRPl5ihQ= -github.com/Antonboom/testifylint v1.3.1 h1:Uam4q1Q+2b6H7gvk9RQFw6jyVDdpzIirFOOrbs14eG4= -github.com/Antonboom/testifylint v1.3.1/go.mod h1:NV0hTlteCkViPW9mSR4wEMfwp+Hs1T3dY60bkvSfhpM= +github.com/Antonboom/testifylint v1.4.3 h1:ohMt6AHuHgttaQ1xb6SSnxCeK4/rnK7KKzbvs7DmEck= +github.com/Antonboom/testifylint v1.4.3/go.mod h1:+8Q9+AOLsz5ZiQiiYujJKs9mNz398+M6UgslP4qgJLA= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= -github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs= +github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/Crocmagnon/fatcontext v0.2.2 h1:OrFlsDdOj9hW/oBEJBNSuH7QWf+E9WPVHw+x52bXVbk= -github.com/Crocmagnon/fatcontext v0.2.2/go.mod h1:WSn/c/+MMNiD8Pri0ahRj0o9jVpeowzavOQplBJw6u0= +github.com/Crocmagnon/fatcontext v0.5.2 h1:vhSEg8Gqng8awhPju2w7MKHqMlg4/NI+gSDHtR3xgwA= +github.com/Crocmagnon/fatcontext v0.5.2/go.mod h1:87XhRMaInHP44Q7Tlc7jkgKKB7kZAOPiDkFMdKCC+74= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= -github.com/GaijinEntertainment/go-exhaustruct/v3 v3.2.0 h1:sATXp1x6/axKxz2Gjxv8MALP0bXaNRfQinEwyfMcx8c= -github.com/GaijinEntertainment/go-exhaustruct/v3 v3.2.0/go.mod h1:Nl76DrGNJTA1KJ0LePKBw/vznBX1EHbAZX8mwjR82nI= +github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.0 h1:/fTUt5vmbkAcMBt4YQiuC23cV0kEsN1MVMNqeOW43cU= +github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.0/go.mod h1:ONJg5sxcbsdQQ4pOW8TGdTidT2TMAUy/2Xhr8mrYaao= github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= -github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0= -github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ= +github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0= +github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= @@ -130,8 +130,8 @@ github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= -github.com/bombsimon/wsl/v4 v4.2.1 h1:Cxg6u+XDWff75SIFFmNsqnIOgob+Q9hG6y/ioKbRFiM= -github.com/bombsimon/wsl/v4 v4.2.1/go.mod h1:Xu/kDxGZTofQcDGCtQe9KCzhHphIe0fDuyWTxER9Feo= +github.com/bombsimon/wsl/v4 v4.4.1 h1:jfUaCkN+aUpobrMO24zwyAMwMAV5eSziCkOKEauOLdw= +github.com/bombsimon/wsl/v4 v4.4.1/go.mod h1:Xu/kDxGZTofQcDGCtQe9KCzhHphIe0fDuyWTxER9Feo= github.com/breml/bidichk v0.2.7 h1:dAkKQPLl/Qrk7hnP6P+E0xOodrq8Us7+U0o4UBOAlQY= github.com/breml/bidichk v0.2.7/go.mod h1:YodjipAGI9fGcYM7II6wFvGhdMYsC5pHDlGzqvEW3tQ= github.com/breml/errchkjson v0.3.6 h1:VLhVkqSBH96AvXEyclMR37rZslRrY2kcyq+31HCsVrA= @@ -181,8 +181,8 @@ github.com/chavacava/garif v0.1.0/go.mod h1:XMyYCkEL58DF0oyW4qDjjnPWONs2HBqYKI+U github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/ckaznocha/intrange v0.1.2 h1:3Y4JAxcMntgb/wABQ6e8Q8leMd26JbX2790lIss9MTI= -github.com/ckaznocha/intrange v0.1.2/go.mod h1:RWffCw/vKBwHeOEwWdCikAtY0q4gGt8VhJZEEA5n+RE= +github.com/ckaznocha/intrange v0.2.0 h1:FykcZuJ8BD7oX93YbO1UY9oZtkRbp+1/kJcDjkefYLs= +github.com/ckaznocha/intrange v0.2.0/go.mod h1:r5I7nUlAAG56xmkOpw4XVr16BXhwYTUdcuRFeevn1oE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004 h1:lkAMpLVBDaj17e85keuznYcH5rqI438v41pKcBl4ZxQ= github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON2oQp+43nFtAV/uvKQIFpSPerB57DCt9t8sSA= @@ -215,8 +215,8 @@ github.com/curioswitch/go-reassign v0.2.0 h1:G9UZyOcpk/d7Gd6mqYgd8XYWFMw/znxwGDU github.com/curioswitch/go-reassign v0.2.0/go.mod h1:x6OpXuWvgfQaMGks2BZybTngWjT84hqJfKoO8Tt/Roc= github.com/cyphar/filepath-securejoin v0.3.1 h1:1V7cHiaW+C+39wEfpH6XlLBQo3j/PciWFrgfCLS8XrE= github.com/cyphar/filepath-securejoin v0.3.1/go.mod h1:F7i41x/9cBF7lzCrVsYs9fuzwRZm4NQsGTBdpp6mETc= -github.com/daixiang0/gci v0.13.4 h1:61UGkmpoAcxHM2hhNkZEf5SzwQtWJXTSws7jaPyqwlw= -github.com/daixiang0/gci v0.13.4/go.mod h1:12etP2OniiIdP4q+kjUGrC/rUagga7ODbqsom5Eo5Yk= +github.com/daixiang0/gci v0.13.5 h1:kThgmH1yBmZSBCh1EJVxQ7JsHpm5Oms0AMed/0LaH4c= +github.com/daixiang0/gci v0.13.5/go.mod h1:12etP2OniiIdP4q+kjUGrC/rUagga7ODbqsom5Eo5Yk= github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0= github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -338,6 +338,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= +github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= +github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= github.com/go-sql-driver/mysql v1.3.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= @@ -366,8 +368,8 @@ github.com/go-toolsmith/strparse v1.1.0 h1:GAioeZUK9TGxnLS+qfdqNbA4z0SSm5zVNtCQi github.com/go-toolsmith/strparse v1.1.0/go.mod h1:7ksGy58fsaQkGQlY8WVoBFNyEPMGuJin1rfoPS4lBSQ= github.com/go-toolsmith/typep v1.1.0 h1:fIRYDyF+JywLfqzyhdiHzRop/GQDxxNhLGQ6gFUNHus= github.com/go-toolsmith/typep v1.1.0/go.mod h1:fVIw+7zjdsMxDA3ITWnH1yOiw1rnTQKCsF/sk2H/qig= -github.com/go-viper/mapstructure/v2 v2.0.0 h1:dhn8MZ1gZ0mzeodTG3jt5Vj/o87xZKuNAprG2mQfMfc= -github.com/go-viper/mapstructure/v2 v2.0.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/go-viper/mapstructure/v2 v2.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpGyP1XxdC/w= +github.com/go-viper/mapstructure/v2 v2.1.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/go-xmlfmt/xmlfmt v1.1.2 h1:Nea7b4icn8s57fTx1M5AI4qQT5HEM3rVUO8MuE6g80U= github.com/go-xmlfmt/xmlfmt v1.1.2/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= @@ -376,8 +378,8 @@ github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= -github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= +github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= +github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0= github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/protobuf v1.0.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -420,10 +422,10 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a h1:w8hkcTqaFpzKqonE9uMCefW1WDie15eSP/4MssdenaM= github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk= -github.com/golangci/gofmt v0.0.0-20231018234816-f50ced29576e h1:ULcKCDV1LOZPFxGZaA6TlQbiM3J2GCPnkx/bGF6sX/g= -github.com/golangci/gofmt v0.0.0-20231018234816-f50ced29576e/go.mod h1:Pm5KhLPA8gSnQwrQ6ukebRcapGb/BG9iUkdaiCcGHJM= -github.com/golangci/golangci-lint v1.59.1 h1:CRRLu1JbhK5avLABFJ/OHVSQ0Ie5c4ulsOId1h3TTks= -github.com/golangci/golangci-lint v1.59.1/go.mod h1:jX5Oif4C7P0j9++YB2MMJmoNrb01NJ8ITqKWNLewThg= +github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9 h1:/1322Qns6BtQxUZDTAT4SdcoxknUki7IAoK4SAXr8ME= +github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9/go.mod h1:Oesb/0uFAyWoaw1U1qS5zyjCg5NP9C9iwjnI4tIsXEE= +github.com/golangci/golangci-lint v1.61.0 h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8= +github.com/golangci/golangci-lint v1.61.0/go.mod h1:e4lztIrJJgLPhWvFPDkhiMwEFRrWlmFbrZea3FsJyN8= github.com/golangci/misspell v0.6.0 h1:JCle2HUTNWirNlDIAUO44hUsKhOFqGPoC4LZxlaSXDs= github.com/golangci/misspell v0.6.0/go.mod h1:keMNyY6R9isGaSAu+4Q8NMBwMPkh15Gtc8UCVoDtAWo= github.com/golangci/modinfo v0.3.4 h1:oU5huX3fbxqQXdfspamej74DFX0kyGLkw1ppvXoJ8GA= @@ -468,8 +470,8 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8 h1:FKHo8hFI3A+7w0aUQuYXQ+6EN5stWmeY/AZqtM8xk9k= -github.com/google/pprof v0.0.0-20240727154555-813a5fbdbec8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= +github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA= +github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= @@ -588,8 +590,8 @@ github.com/jinzhu/inflection v0.0.0-20170102125226-1c35d901db3d/go.mod h1:h+uFLl github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af h1:KA9BjwUk7KlCh6S9EAGWBt1oExIUv9WyNCiRz5amv48= github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af/go.mod h1:HEWGJkRDzjJY2sqdDwxccsGicWEf9BQOZsq2tV+xzM0= -github.com/jjti/go-spancheck v0.6.1 h1:ZK/wE5Kyi1VX3PJpUO2oEgeoI4FWOUm7Shb2Gbv5obI= -github.com/jjti/go-spancheck v0.6.1/go.mod h1:vF1QkOO159prdo6mHRxak2CpzDpHAfKiPUDP/NeRnX8= +github.com/jjti/go-spancheck v0.6.2 h1:iYtoxqPMzHUPp7St+5yA8+cONdyXD3ug6KK15n7Pklk= +github.com/jjti/go-spancheck v0.6.2/go.mod h1:+X7lvIrR5ZdUTkxFYqzJ0abr8Sb5LOo80uOhWNqIrYA= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= @@ -702,8 +704,8 @@ github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh github.com/mattn/go-sqlite3 v1.6.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mgechev/revive v1.3.7 h1:502QY0vQGe9KtYJ9FpxMz9rL+Fc/P13CI5POL4uHCcE= -github.com/mgechev/revive v1.3.7/go.mod h1:RJ16jUbF0OWC3co/+XTxmFNgEpUPwnnA0BRllX2aDNA= +github.com/mgechev/revive v1.3.9 h1:18Y3R4a2USSBF+QZKFQwVkBROUda7uoBlkEuBD+YD1A= +github.com/mgechev/revive v1.3.9/go.mod h1:+uxEIr5UH0TjXWHTno3xh4u7eg6jDpXKzQccA9UGhHU= github.com/microcosm-cc/bluemonday v1.0.25 h1:4NEwSfiJ+Wva0VxN5B8OwMicaJvD8r9tlJWm9rtloEg= github.com/microcosm-cc/bluemonday v1.0.25/go.mod h1:ZIOjCQp1OrzBBPIJmfX4qDYFuhU02nx4bn030ixfHLE= github.com/miekg/pkcs11 v1.0.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= @@ -731,8 +733,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= -github.com/moricho/tparallel v0.3.1 h1:fQKD4U1wRMAYNngDonW5XupoB/ZGJHdpzrWqgyg9krA= -github.com/moricho/tparallel v0.3.1/go.mod h1:leENX2cUv7Sv2qDgdi0D0fCftN8fRC67Bcn8pqzeYNI= +github.com/moricho/tparallel v0.3.2 h1:odr8aZVFA3NZrNybggMkYO3rgPRcqjeQUlBBFVxKHTI= +github.com/moricho/tparallel v0.3.2/go.mod h1:OQ+K3b4Ln3l2TZveGCywybl68glfLEwFGqvnjok8b+U= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b h1:1XF24mVaiu7u+CFywTdcDo2ie1pzzhwjt6RHqzpMU34= @@ -763,12 +765,12 @@ github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU= github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= -github.com/onsi/ginkgo/v2 v2.20.0 h1:PE84V2mHqoT1sglvHc8ZdQtPcwmvvt29WLEEO3xmdZw= -github.com/onsi/ginkgo/v2 v2.20.0/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI= +github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= +github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= -github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= -github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= +github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8= +github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc= github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= @@ -784,8 +786,8 @@ github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJ github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= -github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= -github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= +github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M= +github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc= github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX50IvK2s= github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= @@ -800,8 +802,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/polyfloyd/go-errorlint v1.5.2 h1:SJhVik3Umsjh7mte1vE0fVZ5T1gznasQG3PV7U5xFdA= -github.com/polyfloyd/go-errorlint v1.5.2/go.mod h1:sH1QC1pxxi0fFecsVIzBmxtrgd9IF/SkJpA6wqyKAJs= +github.com/polyfloyd/go-errorlint v1.6.0 h1:tftWV9DE7txiFzPpztTAwyoRLKNj9gpVm2cg8/OwcYY= +github.com/polyfloyd/go-errorlint v1.6.0/go.mod h1:HR7u8wuP1kb1NeN1zqTd1ZMlqUKPPHF+Id4vIPvDqVw= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/prometheus/client_golang v0.9.0-pre1.0.20180209125602-c332b6f63c06/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -833,8 +835,8 @@ github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/quasilyte/go-ruleguard v0.4.2 h1:htXcXDK6/rO12kiTHKfHuqR4kr3Y4M0J0rOL6CH/BYs= -github.com/quasilyte/go-ruleguard v0.4.2/go.mod h1:GJLgqsLeo4qgavUoL8JeGFNS7qcisx3awV/w9eWTmNI= +github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1 h1:+Wl/0aFp0hpuHM3H//KMft64WQ1yX9LdJY64Qm/gFCo= +github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1/go.mod h1:GJLgqsLeo4qgavUoL8JeGFNS7qcisx3awV/w9eWTmNI= github.com/quasilyte/go-ruleguard/dsl v0.3.22 h1:wd8zkOhSNr+I+8Qeciml08ivDt1pSXe60+5DqOpCjPE= github.com/quasilyte/go-ruleguard/dsl v0.3.22/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= github.com/quasilyte/gogrep v0.5.0 h1:eTKODPXbI8ffJMN+W2aE0+oL0z/nh8/5eNdiO34SOAo= @@ -856,8 +858,8 @@ github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/ryancurrah/gomodguard v1.3.2 h1:CuG27ulzEB1Gu5Dk5gP8PFxSOZ3ptSdP5iI/3IXxM18= -github.com/ryancurrah/gomodguard v1.3.2/go.mod h1:LqdemiFomEjcxOqirbQCb3JFvSxH2JUYMerTFd3sF2o= +github.com/ryancurrah/gomodguard v1.3.5 h1:cShyguSwUEeC0jS7ylOiG/idnd1TpJ1LfHGpV3oJmPU= +github.com/ryancurrah/gomodguard v1.3.5/go.mod h1:MXlEPQRxgfPQa62O8wzK3Ozbkv9Rkqr+wKjSxTdsNJE= github.com/ryanrolds/sqlclosecheck v0.5.1 h1:dibWW826u0P8jNLsLN+En7+RqWWTYrjCB9fJfSfdyCU= github.com/ryanrolds/sqlclosecheck v0.5.1/go.mod h1:2g3dUjoS6AL4huFdv6wn55WpLIDjY7ZgUR4J8HOO/XQ= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= @@ -872,11 +874,11 @@ github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6Ng github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= github.com/sashamelentyev/interfacebloat v1.1.0 h1:xdRdJp0irL086OyW1H/RTZTr1h/tMEOsumirXcOJqAw= github.com/sashamelentyev/interfacebloat v1.1.0/go.mod h1:+Y9yU5YdTkrNvoX0xHc84dxiN1iBi9+G8zZIhPVoNjQ= -github.com/sashamelentyev/usestdlibvars v1.26.0 h1:LONR2hNVKxRmzIrZR0PhSF3mhCAzvnr+DcUiHgREfXE= -github.com/sashamelentyev/usestdlibvars v1.26.0/go.mod h1:9nl0jgOfHKWNFS43Ojw0i7aRoS4j6EBye3YBhmAIRF8= +github.com/sashamelentyev/usestdlibvars v1.27.0 h1:t/3jZpSXtRPRf2xr0m63i32ZrusyurIGT9E5wAvXQnI= +github.com/sashamelentyev/usestdlibvars v1.27.0/go.mod h1:9nl0jgOfHKWNFS43Ojw0i7aRoS4j6EBye3YBhmAIRF8= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/securego/gosec/v2 v2.20.1-0.20240525090044-5f0084eb01a9 h1:rnO6Zp1YMQwv8AyxzuwsVohljJgp4L0ZqiCgtACsPsc= -github.com/securego/gosec/v2 v2.20.1-0.20240525090044-5f0084eb01a9/go.mod h1:dg7lPlu/xK/Ut9SedURCoZbVCR4yC7fM65DtH9/CDHs= +github.com/securego/gosec/v2 v2.21.2 h1:deZp5zmYf3TWwU7A7cR2+SolbTpZ3HQiwFqnzQyEl3M= +github.com/securego/gosec/v2 v2.21.2/go.mod h1:au33kg78rNseF5PwPnTWhuYBFf534bvJRvOrgZ/bFzU= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c h1:W65qqJCIOVP4jpqPQ0YvHYKwcMEMVWIzWC5iNQQfBTU= @@ -896,8 +898,8 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sivchari/containedctx v1.0.3 h1:x+etemjbsh2fB5ewm5FeLNi5bUjK0V8n0RB+Wwfd0XE= github.com/sivchari/containedctx v1.0.3/go.mod h1:c1RDvCbnJLtH4lLcYD/GqwiBSSf4F5Qk0xld2rBqzJ4= -github.com/sivchari/tenv v1.7.1 h1:PSpuD4bu6fSmtWMxSGWcvqUUgIn7k3yOJhOIzVWn8Ak= -github.com/sivchari/tenv v1.7.1/go.mod h1:64yStXKSOxDfX47NlhVwND4dHwfZDdbp2Lyl018Icvg= +github.com/sivchari/tenv v1.10.0 h1:g/hzMA+dBCKqGXgW8AV/1xIWhAvDrx0zFKNR48NFMg0= +github.com/sivchari/tenv v1.10.0/go.mod h1:tdY24masnVoZFxYrHv/nD6Tc8FbkEtAQEEziXpyMgqY= github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/slack-go/slack v0.15.0 h1:LE2lj2y9vqqiOf+qIIy0GvEoxgF1N5yLGZffmEZykt0= @@ -950,24 +952,22 @@ github.com/stripe/pg-schema-diff v0.7.0 h1:00Z+LGGe9GhMsN5gLtx/ZwF/+xPOMgod/g8x8 github.com/stripe/pg-schema-diff v0.7.0/go.mod h1:HuTBuWLuvnY9g9nptbSD58xugN19zSJNkF4w/sYRtdU= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= -github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c h1:+aPplBwWcHBo6q9xrfWdMrT9o4kltkmmvpemgIjep/8= -github.com/t-yuki/gocover-cobertura v0.0.0-20180217150009-aaee18c8195c/go.mod h1:SbErYREK7xXdsRiigaQiQkI9McGRzYMvlKYaP3Nimdk= github.com/tdakkota/asciicheck v0.2.0 h1:o8jvnUANo0qXtnslk2d3nMKTFNlOnJjRrNcj0j9qkHM= github.com/tdakkota/asciicheck v0.2.0/go.mod h1:Qb7Y9EgjCLJGup51gDHFzbI08/gbGhL/UVhYIPWG2rg= github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA= github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= -github.com/tetafro/godot v1.4.16 h1:4ChfhveiNLk4NveAZ9Pu2AN8QZ2nkUGFuadM9lrr5D0= -github.com/tetafro/godot v1.4.16/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= +github.com/tetafro/godot v1.4.17 h1:pGzu+Ye7ZUEFx7LHU0dAKmCOXWsPjl7qA6iMGndsjPs= +github.com/tetafro/godot v1.4.17/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= github.com/theupdateframework/notary v0.7.0 h1:QyagRZ7wlSpjT5N2qQAh/pN+DVqgekv4DzbAiAiEL3c= github.com/theupdateframework/notary v0.7.0/go.mod h1:c9DRxcmhHmVLDay4/2fUYdISnHqbFDGRSlXPO0AhYWw= github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 h1:quvGphlmUVU+nhpFa4gg4yJyTRJ13reZMDHrKwYw53M= github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966/go.mod h1:27bSVNWSBOHm+qRp1T9qzaIpsWEP6TbUnei/43HK+PQ= github.com/timonwong/loggercheck v0.9.4 h1:HKKhqrjcVj8sxL7K77beXh0adEm6DLjV/QOGeMXEVi4= github.com/timonwong/loggercheck v0.9.4/go.mod h1:caz4zlPcgvpEkXgVnAJGowHAMW2NwHaNlpS8xDbVhTg= -github.com/tomarrell/wrapcheck/v2 v2.8.3 h1:5ov+Cbhlgi7s/a42BprYoxsr73CbdMUTzE3bRDFASUs= -github.com/tomarrell/wrapcheck/v2 v2.8.3/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo= +github.com/tomarrell/wrapcheck/v2 v2.9.0 h1:801U2YCAjLhdN8zhZ/7tdjB3EnAoRlJHt/s+9hijLQ4= +github.com/tomarrell/wrapcheck/v2 v2.9.0/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo= github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= @@ -978,8 +978,8 @@ github.com/ultraware/funlen v0.1.0 h1:BuqclbkY6pO+cvxoq7OsktIXZpgBSkYTQtmwhAK81v github.com/ultraware/funlen v0.1.0/go.mod h1:XJqmOQja6DpxarLj6Jj1U7JuoS8PvL4nEqDaQhy22p4= github.com/ultraware/whitespace v0.1.1 h1:bTPOGejYFulW3PkcrqkeQwOd6NKOOXvmGD9bo/Gk8VQ= github.com/ultraware/whitespace v0.1.1/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= -github.com/uudashr/gocognit v1.1.2 h1:l6BAEKJqQH2UpKAPKdMfZf5kE4W/2xk8pfU1OVLvniI= -github.com/uudashr/gocognit v1.1.2/go.mod h1:aAVdLURqcanke8h3vg35BC++eseDm66Z7KmchI5et4k= +github.com/uudashr/gocognit v1.1.3 h1:l+a111VcDbKfynh+airAy/DJQKaXh2m9vkoysMPSZyM= +github.com/uudashr/gocognit v1.1.3/go.mod h1:aKH8/e8xbTRBwjbCkwZ8qt4l2EpKXl31KMHgSS+lZ2U= github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 h1:MzD3XeOOSO3mAjOPpF07jFteSKZxsRHvlIcAR9RQzKM= github.com/withfig/autocomplete-tools/packages/cobra v1.2.0/go.mod h1:RoXh7+7qknOXL65uTzdzE1mPxqcPwS7FLCE9K5GfmKo= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= @@ -1021,15 +1021,15 @@ go-simpler.org/assert v0.9.0 h1:PfpmcSvL7yAnWyChSjOz6Sp6m9j5lyK8Ok9pEL31YkQ= go-simpler.org/assert v0.9.0/go.mod h1:74Eqh5eI6vCK6Y5l3PI8ZYFXG4Sa+tkr70OIPJAUr28= go-simpler.org/musttag v0.12.2 h1:J7lRc2ysXOq7eM8rwaTYnNrHd5JwjppzB6mScysB2Cs= go-simpler.org/musttag v0.12.2/go.mod h1:uN1DVIasMTQKk6XSik7yrJoEysGtR2GRqvWnI9S7TYM= -go-simpler.org/sloglint v0.7.1 h1:qlGLiqHbN5islOxjeLXoPtUdZXb669RW+BDQ+xOSNoU= -go-simpler.org/sloglint v0.7.1/go.mod h1:OlaVDRh/FKKd4X4sIMbsz8st97vomydceL146Fthh/c= +go-simpler.org/sloglint v0.7.2 h1:Wc9Em/Zeuu7JYpl+oKoYOsQSy2X560aVueCW/m6IijY= +go-simpler.org/sloglint v0.7.2/go.mod h1:US+9C80ppl7VsThQclkM7BkCHQAzuz8kHLsW3ppuluo= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8= go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 h1:U2guen0GhqH8o/G2un8f/aG/y++OuW6MyCo6hT9prXk= @@ -1098,8 +1098,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= -golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54= +golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= +golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1110,8 +1110,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= -golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= +golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j7kNfw6uvuiNxUBfcBk= +golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f h1:phY1HzDcf18Aq9A8KkmRtY9WvOFIxN8wgfvy6Zm1DV8= @@ -1277,7 +1277,6 @@ golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211105183446-c75c47738b0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220702020025-31831981b65f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1327,13 +1326,13 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= -golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= +golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -1396,7 +1395,6 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= -golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= @@ -1466,8 +1464,8 @@ google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.0.5/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -1542,10 +1540,10 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.4.7 h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs= -honnef.co/go/tools v0.4.7/go.mod h1:+rnGS1THNh8zMwnd2oVOTL9QF6vmfyG6ZXBULae2uc0= -mvdan.cc/gofumpt v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo= -mvdan.cc/gofumpt v0.6.0/go.mod h1:4L0wf+kgIPZtcCWXynNS2e6bhmj73umwnuXSZarixzA= +honnef.co/go/tools v0.5.1 h1:4bH5o3b5ZULQ4UrBmP+63W9r7qIkqJClEA9ko5YKx+I= +honnef.co/go/tools v0.5.1/go.mod h1:e9irvo83WDG9/irijV44wr3tbhcFeRnfpVlRqVwpzMs= +mvdan.cc/gofumpt v0.7.0 h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU= +mvdan.cc/gofumpt v0.7.0/go.mod h1:txVFJy/Sc/mvaycET54pV8SW8gWxTlUuGHVEcncmNUo= mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f h1:lMpcwN6GxNbWtbpI1+xzFLSW8XzX0u72NttUGVFjO3U= mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f/go.mod h1:RSLa7mKKCNeTTMHBw5Hsy2rfJmd6O2ivt9Dw9ZqCQpQ= nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= From 0377d4730f5f9ba3a8c7c64cfef37584a9d82150 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Tue, 22 Oct 2024 18:35:39 +0800 Subject: [PATCH 100/305] fix: ignore project not found error on linking (#2790) * fix: ignore project not found error on linking * chore: update unit tests --- internal/link/link.go | 16 ++++++++++++---- internal/link/link_test.go | 28 +++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/internal/link/link.go b/internal/link/link.go index 8a75a8d3d..04e5c565b 100644 --- a/internal/link/link.go +++ b/internal/link/link.go @@ -3,6 +3,7 @@ package link import ( "context" "fmt" + "net/http" "os" "strconv" "strings" @@ -238,24 +239,31 @@ func updatePoolerConfig(config api.SupavisorConfigResponse) { } } +var errProjectPaused = errors.New("project is paused") + func checkRemoteProjectStatus(ctx context.Context, projectRef string) error { resp, err := utils.GetSupabase().V1GetProjectWithResponse(ctx, projectRef) if err != nil { return errors.Errorf("failed to retrieve remote project status: %w", err) } - if resp.JSON200 == nil { + switch resp.StatusCode() { + case http.StatusNotFound: + // Ignore not found error to support linking branch projects + return nil + case http.StatusOK: + // resp.JSON200 is not nil, proceed + default: return errors.New("Unexpected error retrieving remote project status: " + string(resp.Body)) } switch resp.JSON200.Status { case api.V1ProjectResponseStatusINACTIVE: utils.CmdSuggestion = fmt.Sprintf("An admin must unpause it from the Supabase dashboard at %s", utils.Aqua(fmt.Sprintf("%s/project/%s", utils.GetSupabaseDashboardURL(), projectRef))) - return errors.New("project is paused") + return errors.New(errProjectPaused) case api.V1ProjectResponseStatusACTIVEHEALTHY: // Project is in the desired state, do nothing - return nil default: - fmt.Fprintf(os.Stderr, "%s: Project status is %s instead of Active Healthy. Some operations might fail.\n", utils.Yellow("Warning"), resp.JSON200.Status) + fmt.Fprintf(os.Stderr, "%s: Project status is %s instead of Active Healthy. Some operations might fail.\n", utils.Yellow("WARNING"), resp.JSON200.Status) } return nil diff --git a/internal/link/link_test.go b/internal/link/link_test.go index f39388bfd..c8a867f6b 100644 --- a/internal/link/link_test.go +++ b/internal/link/link_test.go @@ -3,6 +3,7 @@ package link import ( "context" "errors" + "net/http" "testing" "github.com/h2non/gock" @@ -209,20 +210,37 @@ func TestLinkCommand(t *testing.T) { assert.NoError(t, err) assert.False(t, exists) }) +} + +func TestStatusCheck(t *testing.T) { + project := "test-project" + + t.Run("ignores project not found", func(t *testing.T) { + // Flush pending mocks after test execution + defer gock.OffAll() + // Mock project status + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project). + Reply(http.StatusNotFound) + // Run test + err := checkRemoteProjectStatus(context.Background(), project) + // Check error + assert.NoError(t, err) + assert.Empty(t, apitest.ListUnmatchedRequests()) + }) + t.Run("throws error on project inactive", func(t *testing.T) { - // Setup in-memory fs - fsys := afero.NewReadOnlyFs(afero.NewMemMapFs()) // Flush pending mocks after test execution defer gock.OffAll() // Mock project status gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project). - Reply(200). + Reply(http.StatusOK). JSON(api.V1ProjectResponse{Status: api.V1ProjectResponseStatusINACTIVE}) // Run test - err := Run(context.Background(), project, fsys) + err := checkRemoteProjectStatus(context.Background(), project) // Check error - assert.ErrorContains(t, err, "project is paused") + assert.ErrorIs(t, err, errProjectPaused) assert.Empty(t, apitest.ListUnmatchedRequests()) }) } From 3148ebaa2e1219e537d9d79a6408ac2ff18d2abf Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Wed, 23 Oct 2024 11:00:30 +0200 Subject: [PATCH 101/305] feat: add db postgres settings to config (#2787) * feat: add db postgres settings to config * no comment * fix: add updater logic * chore: fix golang lint * chore: apply review comments * chore: refactor and apply PR comments * Apply suggestions from code review Co-authored-by: Han Qiao --------- Co-authored-by: Han Qiao --- pkg/cast/cast.go | 14 ++++ pkg/config/config.go | 43 ++---------- pkg/config/db.go | 160 ++++++++++++++++++++++++++++++++++++++++++ pkg/config/db_test.go | 155 ++++++++++++++++++++++++++++++++++++++++ pkg/config/updater.go | 42 ++++++++++- 5 files changed, 376 insertions(+), 38 deletions(-) create mode 100644 pkg/config/db.go create mode 100644 pkg/config/db_test.go diff --git a/pkg/cast/cast.go b/pkg/cast/cast.go index b72cadbbf..3c7067163 100644 --- a/pkg/cast/cast.go +++ b/pkg/cast/cast.go @@ -20,6 +20,20 @@ func IntToUint(value int) uint { return uint(value) } +func UintToIntPtr(value *uint) *int { + if value == nil { + return nil + } + return Ptr(UintToInt(*value)) +} + +func IntToUintPtr(value *int) *uint { + if value == nil { + return nil + } + return Ptr(IntToUint(*value)) +} + func Ptr[T any](v T) *T { return &v } diff --git a/pkg/config/config.go b/pkg/config/config.go index f6329f459..6e548111a 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -57,13 +57,6 @@ const ( LogflareBigQuery LogflareBackend = "bigquery" ) -type PoolMode string - -const ( - TransactionMode PoolMode = "transaction" - SessionMode PoolMode = "session" -) - type AddressFamily string const ( @@ -146,36 +139,6 @@ type ( Remotes map[string]baseConfig `toml:"-"` } - db struct { - Image string `toml:"-"` - Port uint16 `toml:"port"` - ShadowPort uint16 `toml:"shadow_port"` - MajorVersion uint `toml:"major_version"` - Password string `toml:"-"` - RootKey string `toml:"-" mapstructure:"root_key"` - Pooler pooler `toml:"pooler"` - Seed seed `toml:"seed"` - } - - seed struct { - Enabled bool `toml:"enabled"` - GlobPatterns []string `toml:"sql_paths"` - SqlPaths []string `toml:"-"` - } - - pooler struct { - Enabled bool `toml:"enabled"` - Image string `toml:"-"` - Port uint16 `toml:"port"` - PoolMode PoolMode `toml:"pool_mode"` - DefaultPoolSize uint `toml:"default_pool_size"` - MaxClientConn uint `toml:"max_client_conn"` - ConnectionString string `toml:"-"` - TenantId string `toml:"-"` - EncryptionKey string `toml:"-"` - SecretKeyBase string `toml:"-"` - } - realtime struct { Enabled bool `toml:"enabled"` Image string `toml:"-"` @@ -775,6 +738,12 @@ func (c *baseConfig) Validate(fsys fs.FS) error { } } // Validate db config + if c.Db.Settings.SessionReplicationRole != nil { + allowedRoles := []SessionReplicationRole{SessionReplicationRoleOrigin, SessionReplicationRoleReplica, SessionReplicationRoleLocal} + if !sliceContains(allowedRoles, *c.Db.Settings.SessionReplicationRole) { + return errors.Errorf("Invalid config for db.session_replication_role: %s. Must be one of: %v", *c.Db.Settings.SessionReplicationRole, allowedRoles) + } + } if c.Db.Port == 0 { return errors.New("Missing required field in config: db.port") } diff --git a/pkg/config/db.go b/pkg/config/db.go new file mode 100644 index 000000000..89e5bfd24 --- /dev/null +++ b/pkg/config/db.go @@ -0,0 +1,160 @@ +package config + +import ( + "github.com/google/go-cmp/cmp" + v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/diff" +) + +type PoolMode string + +const ( + TransactionMode PoolMode = "transaction" + SessionMode PoolMode = "session" +) + +type SessionReplicationRole string + +const ( + SessionReplicationRoleOrigin SessionReplicationRole = "origin" + SessionReplicationRoleReplica SessionReplicationRole = "replica" + SessionReplicationRoleLocal SessionReplicationRole = "local" +) + +type ( + settings struct { + EffectiveCacheSize *string `toml:"effective_cache_size"` + LogicalDecodingWorkMem *string `toml:"logical_decoding_work_mem"` + MaintenanceWorkMem *string `toml:"maintenance_work_mem"` + MaxConnections *uint `toml:"max_connections"` + MaxLocksPerTransaction *uint `toml:"max_locks_per_transaction"` + MaxParallelMaintenanceWorkers *uint `toml:"max_parallel_maintenance_workers"` + MaxParallelWorkers *uint `toml:"max_parallel_workers"` + MaxParallelWorkersPerGather *uint `toml:"max_parallel_workers_per_gather"` + MaxReplicationSlots *uint `toml:"max_replication_slots"` + MaxSlotWalKeepSize *string `toml:"max_slot_wal_keep_size"` + MaxStandbyArchiveDelay *string `toml:"max_standby_archive_delay"` + MaxStandbyStreamingDelay *string `toml:"max_standby_streaming_delay"` + MaxWalSize *string `toml:"max_wal_size"` + MaxWalSenders *uint `toml:"max_wal_senders"` + MaxWorkerProcesses *uint `toml:"max_worker_processes"` + SessionReplicationRole *SessionReplicationRole `toml:"session_replication_role"` + SharedBuffers *string `toml:"shared_buffers"` + StatementTimeout *string `toml:"statement_timeout"` + WalKeepSize *string `toml:"wal_keep_size"` + WalSenderTimeout *string `toml:"wal_sender_timeout"` + WorkMem *string `toml:"work_mem"` + } + + db struct { + Image string `toml:"-"` + Port uint16 `toml:"port"` + ShadowPort uint16 `toml:"shadow_port"` + MajorVersion uint `toml:"major_version"` + Password string `toml:"-"` + RootKey string `toml:"-" mapstructure:"root_key"` + Pooler pooler `toml:"pooler"` + Seed seed `toml:"seed"` + Settings settings `toml:"settings"` + } + + seed struct { + Enabled bool `toml:"enabled"` + GlobPatterns []string `toml:"sql_paths"` + SqlPaths []string `toml:"-"` + } + + pooler struct { + Enabled bool `toml:"enabled"` + Image string `toml:"-"` + Port uint16 `toml:"port"` + PoolMode PoolMode `toml:"pool_mode"` + DefaultPoolSize uint `toml:"default_pool_size"` + MaxClientConn uint `toml:"max_client_conn"` + ConnectionString string `toml:"-"` + TenantId string `toml:"-"` + EncryptionKey string `toml:"-"` + SecretKeyBase string `toml:"-"` + } +) + +// Compare two db config, if changes requires restart return true, return false otherwise +func (a settings) requireDbRestart(b settings) bool { + return !cmp.Equal(a.MaxConnections, b.MaxConnections) || + !cmp.Equal(a.MaxWorkerProcesses, b.MaxWorkerProcesses) || + !cmp.Equal(a.MaxParallelWorkers, b.MaxParallelWorkers) || + !cmp.Equal(a.MaxWalSenders, b.MaxWalSenders) || + !cmp.Equal(a.MaxReplicationSlots, b.MaxReplicationSlots) || + !cmp.Equal(a.SharedBuffers, b.SharedBuffers) +} + +func (a *settings) ToUpdatePostgresConfigBody() v1API.UpdatePostgresConfigBody { + body := v1API.UpdatePostgresConfigBody{} + + // Parameters that require restart + body.MaxConnections = cast.UintToIntPtr(a.MaxConnections) + body.MaxWorkerProcesses = cast.UintToIntPtr(a.MaxWorkerProcesses) + body.MaxParallelWorkers = cast.UintToIntPtr(a.MaxParallelWorkers) + body.MaxWalSenders = cast.UintToIntPtr(a.MaxWalSenders) + body.MaxReplicationSlots = cast.UintToIntPtr(a.MaxReplicationSlots) + body.SharedBuffers = a.SharedBuffers + + // Parameters that can be changed without restart + body.EffectiveCacheSize = a.EffectiveCacheSize + body.LogicalDecodingWorkMem = a.LogicalDecodingWorkMem + body.MaintenanceWorkMem = a.MaintenanceWorkMem + body.MaxLocksPerTransaction = cast.UintToIntPtr(a.MaxLocksPerTransaction) + body.MaxParallelMaintenanceWorkers = cast.UintToIntPtr(a.MaxParallelMaintenanceWorkers) + body.MaxParallelWorkersPerGather = cast.UintToIntPtr(a.MaxParallelWorkersPerGather) + body.MaxSlotWalKeepSize = a.MaxSlotWalKeepSize + body.MaxStandbyArchiveDelay = a.MaxStandbyArchiveDelay + body.MaxStandbyStreamingDelay = a.MaxStandbyStreamingDelay + body.MaxWalSize = a.MaxWalSize + body.SessionReplicationRole = (*v1API.UpdatePostgresConfigBodySessionReplicationRole)(a.SessionReplicationRole) + body.StatementTimeout = a.StatementTimeout + body.WalKeepSize = a.WalKeepSize + body.WalSenderTimeout = a.WalSenderTimeout + body.WorkMem = a.WorkMem + return body +} + +func (a *settings) fromRemoteConfig(remoteConfig v1API.PostgresConfigResponse) settings { + result := *a + + result.EffectiveCacheSize = remoteConfig.EffectiveCacheSize + result.LogicalDecodingWorkMem = remoteConfig.LogicalDecodingWorkMem + result.MaintenanceWorkMem = remoteConfig.MaintenanceWorkMem + result.MaxConnections = cast.IntToUintPtr(remoteConfig.MaxConnections) + result.MaxLocksPerTransaction = cast.IntToUintPtr(remoteConfig.MaxLocksPerTransaction) + result.MaxParallelMaintenanceWorkers = cast.IntToUintPtr(remoteConfig.MaxParallelMaintenanceWorkers) + result.MaxParallelWorkers = cast.IntToUintPtr(remoteConfig.MaxParallelWorkers) + result.MaxParallelWorkersPerGather = cast.IntToUintPtr(remoteConfig.MaxParallelWorkersPerGather) + result.MaxReplicationSlots = cast.IntToUintPtr(remoteConfig.MaxReplicationSlots) + result.MaxSlotWalKeepSize = remoteConfig.MaxSlotWalKeepSize + result.MaxStandbyArchiveDelay = remoteConfig.MaxStandbyArchiveDelay + result.MaxStandbyStreamingDelay = remoteConfig.MaxStandbyStreamingDelay + result.MaxWalSenders = cast.IntToUintPtr(remoteConfig.MaxWalSenders) + result.MaxWalSize = remoteConfig.MaxWalSize + result.MaxWorkerProcesses = cast.IntToUintPtr(remoteConfig.MaxWorkerProcesses) + result.SessionReplicationRole = (*SessionReplicationRole)(remoteConfig.SessionReplicationRole) + result.SharedBuffers = remoteConfig.SharedBuffers + result.StatementTimeout = remoteConfig.StatementTimeout + result.WalKeepSize = remoteConfig.WalKeepSize + result.WalSenderTimeout = remoteConfig.WalSenderTimeout + result.WorkMem = remoteConfig.WorkMem + return result +} + +func (a *settings) DiffWithRemote(remoteConfig v1API.PostgresConfigResponse) ([]byte, error) { + // Convert the config values into easily comparable remoteConfig values + currentValue, err := ToTomlBytes(a) + if err != nil { + return nil, err + } + remoteCompare, err := ToTomlBytes(a.fromRemoteConfig(remoteConfig)) + if err != nil { + return nil, err + } + return diff.Diff("remote[db.settings]", remoteCompare, "local[db.settings]", currentValue), nil +} diff --git a/pkg/config/db_test.go b/pkg/config/db_test.go new file mode 100644 index 000000000..e7c573475 --- /dev/null +++ b/pkg/config/db_test.go @@ -0,0 +1,155 @@ +package config + +import ( + "testing" + + "github.com/stretchr/testify/assert" + v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" +) + +func TestDbSettingsToUpdatePostgresConfigBody(t *testing.T) { + t.Run("converts all fields correctly", func(t *testing.T) { + db := &db{ + Settings: settings{ + EffectiveCacheSize: cast.Ptr("4GB"), + MaxConnections: cast.Ptr(uint(100)), + SharedBuffers: cast.Ptr("1GB"), + StatementTimeout: cast.Ptr("30s"), + SessionReplicationRole: cast.Ptr(SessionReplicationRoleReplica), + }, + } + + body := db.Settings.ToUpdatePostgresConfigBody() + + assert.Equal(t, "4GB", *body.EffectiveCacheSize) + assert.Equal(t, 100, *body.MaxConnections) + assert.Equal(t, "1GB", *body.SharedBuffers) + assert.Equal(t, "30s", *body.StatementTimeout) + assert.Equal(t, v1API.UpdatePostgresConfigBodySessionReplicationRoleReplica, *body.SessionReplicationRole) + }) + + t.Run("handles empty fields", func(t *testing.T) { + db := &db{} + + body := db.Settings.ToUpdatePostgresConfigBody() + + assert.Nil(t, body.EffectiveCacheSize) + assert.Nil(t, body.MaxConnections) + assert.Nil(t, body.SharedBuffers) + assert.Nil(t, body.StatementTimeout) + assert.Nil(t, body.SessionReplicationRole) + }) +} + +func TestDbSettingsDiffWithRemote(t *testing.T) { + t.Run("detects differences", func(t *testing.T) { + db := &db{ + Settings: settings{ + EffectiveCacheSize: cast.Ptr("4GB"), + MaxConnections: cast.Ptr(uint(100)), + SharedBuffers: cast.Ptr("1GB"), + }, + } + + remoteConfig := v1API.PostgresConfigResponse{ + EffectiveCacheSize: cast.Ptr("8GB"), + MaxConnections: cast.Ptr(200), + SharedBuffers: cast.Ptr("2GB"), + } + + diff, err := db.Settings.DiffWithRemote(remoteConfig) + assert.NoError(t, err) + + assert.Contains(t, string(diff), "-effective_cache_size = \"8GB\"") + assert.Contains(t, string(diff), "+effective_cache_size = \"4GB\"") + assert.Contains(t, string(diff), "-max_connections = 200") + assert.Contains(t, string(diff), "+max_connections = 100") + assert.Contains(t, string(diff), "-shared_buffers = \"2GB\"") + assert.Contains(t, string(diff), "+shared_buffers = \"1GB\"") + }) + + t.Run("handles no differences", func(t *testing.T) { + db := &db{ + Settings: settings{ + EffectiveCacheSize: cast.Ptr("4GB"), + MaxConnections: cast.Ptr(uint(100)), + SharedBuffers: cast.Ptr("1GB"), + }, + } + + remoteConfig := v1API.PostgresConfigResponse{ + EffectiveCacheSize: cast.Ptr("4GB"), + MaxConnections: cast.Ptr(100), + SharedBuffers: cast.Ptr("1GB"), + } + + diff, err := db.Settings.DiffWithRemote(remoteConfig) + assert.NoError(t, err) + + assert.Empty(t, diff) + }) + + t.Run("handles multiple schemas and search paths with spaces", func(t *testing.T) { + db := &db{ + Settings: settings{ + EffectiveCacheSize: cast.Ptr("4GB"), + MaxConnections: cast.Ptr(uint(100)), + SharedBuffers: cast.Ptr("1GB"), + }, + } + + remoteConfig := v1API.PostgresConfigResponse{ + EffectiveCacheSize: cast.Ptr("4GB"), + MaxConnections: cast.Ptr(100), + SharedBuffers: cast.Ptr("1GB"), + } + + diff, err := db.Settings.DiffWithRemote(remoteConfig) + assert.NoError(t, err) + + assert.Empty(t, diff) + }) + + t.Run("handles api disabled on remote side", func(t *testing.T) { + db := &db{ + Settings: settings{ + EffectiveCacheSize: cast.Ptr("4GB"), + MaxConnections: cast.Ptr(uint(100)), + SharedBuffers: cast.Ptr("1GB"), + }, + } + + remoteConfig := v1API.PostgresConfigResponse{ + // All fields are nil to simulate disabled API + } + + diff, err := db.Settings.DiffWithRemote(remoteConfig) + assert.NoError(t, err) + + assert.Contains(t, string(diff), "+effective_cache_size = \"4GB\"") + assert.Contains(t, string(diff), "+max_connections = 100") + assert.Contains(t, string(diff), "+shared_buffers = \"1GB\"") + }) + + t.Run("handles api disabled on local side", func(t *testing.T) { + db := &db{ + Settings: settings{ + // All fields are nil to simulate disabled API + }, + } + + remoteConfig := v1API.PostgresConfigResponse{ + EffectiveCacheSize: cast.Ptr("4GB"), + MaxConnections: cast.Ptr(100), + SharedBuffers: cast.Ptr("1GB"), + } + + diff, err := db.Settings.DiffWithRemote(remoteConfig) + assert.NoError(t, err) + + assert.Contains(t, string(diff), "-effective_cache_size = \"4GB\"") + assert.Contains(t, string(diff), "-max_connections = 100") + assert.Contains(t, string(diff), "-shared_buffers = \"1GB\"") + }) +} diff --git a/pkg/config/updater.go b/pkg/config/updater.go index 467b7bb63..ac97cc63d 100644 --- a/pkg/config/updater.go +++ b/pkg/config/updater.go @@ -21,7 +21,9 @@ func (u *ConfigUpdater) UpdateRemoteConfig(ctx context.Context, remote baseConfi if err := u.UpdateApiConfig(ctx, remote.ProjectId, remote.Api); err != nil { return err } - // TODO: implement other service configs, ie. auth + if err := u.UpdateDbConfig(ctx, remote.ProjectId, remote.Db); err != nil { + return err + } return nil } @@ -40,6 +42,7 @@ func (u *ConfigUpdater) UpdateApiConfig(ctx context.Context, projectRef string, return nil } fmt.Fprintln(os.Stderr, "Updating API service with config:", string(apiDiff)) + if resp, err := u.client.V1UpdatePostgrestServiceConfigWithResponse(ctx, projectRef, c.ToUpdatePostgrestConfigBody()); err != nil { return errors.Errorf("failed to update API config: %w", err) } else if resp.JSON200 == nil { @@ -47,3 +50,40 @@ func (u *ConfigUpdater) UpdateApiConfig(ctx context.Context, projectRef string, } return nil } + +func (u *ConfigUpdater) UpdateDbSettingsConfig(ctx context.Context, projectRef string, s settings) error { + dbConfig, err := u.client.V1GetPostgresConfigWithResponse(ctx, projectRef) + if err != nil { + return errors.Errorf("failed to read DB config: %w", err) + } else if dbConfig.JSON200 == nil { + return errors.Errorf("unexpected status %d: %s", dbConfig.StatusCode(), string(dbConfig.Body)) + } + dbDiff, err := s.DiffWithRemote(*dbConfig.JSON200) + if err != nil { + return err + } else if len(dbDiff) == 0 { + fmt.Fprintln(os.Stderr, "Remote DB config is up to date.") + return nil + } + fmt.Fprintln(os.Stderr, "Updating DB service with config:", string(dbDiff)) + remoteConfig := s.fromRemoteConfig(*dbConfig.JSON200) + restartRequired := s.requireDbRestart(remoteConfig) + if restartRequired { + fmt.Fprintln(os.Stderr, "Database will be restarted to apply config updates...") + } + updateBody := s.ToUpdatePostgresConfigBody() + updateBody.RestartDatabase = &restartRequired + if resp, err := u.client.V1UpdatePostgresConfigWithResponse(ctx, projectRef, updateBody); err != nil { + return errors.Errorf("failed to update DB config: %w", err) + } else if resp.JSON200 == nil { + return errors.Errorf("unexpected status %d: %s", resp.StatusCode(), string(resp.Body)) + } + return nil +} + +func (u *ConfigUpdater) UpdateDbConfig(ctx context.Context, projectRef string, c db) error { + if err := u.UpdateDbSettingsConfig(ctx, projectRef, c.Settings); err != nil { + return err + } + return nil +} From aaa0d7f619f48de373ef7dea28d396d7cd128660 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Wed, 23 Oct 2024 11:22:18 +0200 Subject: [PATCH 102/305] chore: refactor use cast ptr (#2793) * go mod tidy * chore: refactor use cast.Ptr --- cmd/functions.go | 5 +++-- go.mod | 2 +- internal/branches/create/create_test.go | 7 ++++--- internal/functions/deploy/deploy.go | 3 ++- internal/functions/deploy/deploy_test.go | 3 ++- internal/functions/serve/serve_test.go | 3 ++- internal/init/init_test.go | 9 +++++---- internal/storage/cp/cp_test.go | 9 +++++---- internal/storage/ls/ls_test.go | 9 +++++---- internal/storage/mv/mv_test.go | 9 +++++---- internal/storage/rm/rm_test.go | 9 +++++---- internal/utils/api.go | 3 ++- internal/utils/console.go | 5 +++-- internal/utils/misc.go | 4 ---- internal/utils/release_test.go | 3 ++- 15 files changed, 46 insertions(+), 37 deletions(-) diff --git a/cmd/functions.go b/cmd/functions.go index 6555bae9b..36dc47f94 100644 --- a/cmd/functions.go +++ b/cmd/functions.go @@ -13,6 +13,7 @@ import ( "github.com/supabase/cli/internal/functions/serve" "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/cast" ) var ( @@ -106,9 +107,9 @@ var ( } if len(inspectMode.Value) > 0 { - runtimeOption.InspectMode = utils.Ptr(serve.InspectMode(inspectMode.Value)) + runtimeOption.InspectMode = cast.Ptr(serve.InspectMode(inspectMode.Value)) } else if inspectBrk { - runtimeOption.InspectMode = utils.Ptr(serve.InspectModeBrk) + runtimeOption.InspectMode = cast.Ptr(serve.InspectModeBrk) } if runtimeOption.InspectMode == nil && runtimeOption.InspectMain { return fmt.Errorf("--inspect-main must be used together with one of these flags: [inspect inspect-mode]") diff --git a/go.mod b/go.mod index cc84666d5..6f813394d 100644 --- a/go.mod +++ b/go.mod @@ -25,6 +25,7 @@ require ( github.com/go-xmlfmt/xmlfmt v1.1.2 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/golangci/golangci-lint v1.61.0 + github.com/google/go-cmp v0.6.0 github.com/google/go-github/v62 v62.0.0 github.com/google/go-querystring v1.1.0 github.com/google/uuid v1.6.0 @@ -169,7 +170,6 @@ require ( github.com/golangci/plugin-module-register v0.1.1 // indirect github.com/golangci/revgrep v0.5.3 // indirect github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect - github.com/google/go-cmp v0.6.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/gordonklaus/ineffassign v0.1.0 // indirect github.com/gorilla/css v1.0.0 // indirect diff --git a/internal/branches/create/create_test.go b/internal/branches/create/create_test.go index 6f56b586f..e07e10387 100644 --- a/internal/branches/create/create_test.go +++ b/internal/branches/create/create_test.go @@ -14,6 +14,7 @@ import ( "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" ) func TestCreateCommand(t *testing.T) { @@ -36,7 +37,7 @@ func TestCreateCommand(t *testing.T) { }) // Run test err := Run(context.Background(), api.CreateBranchBody{ - Region: utils.Ptr("sin"), + Region: cast.Ptr("sin"), }, fsys) // Check error assert.NoError(t, err) @@ -53,7 +54,7 @@ func TestCreateCommand(t *testing.T) { ReplyError(net.ErrClosed) // Run test err := Run(context.Background(), api.CreateBranchBody{ - Region: utils.Ptr("sin"), + Region: cast.Ptr("sin"), }, fsys) // Check error assert.ErrorIs(t, err, net.ErrClosed) @@ -70,7 +71,7 @@ func TestCreateCommand(t *testing.T) { Reply(http.StatusServiceUnavailable) // Run test err := Run(context.Background(), api.CreateBranchBody{ - Region: utils.Ptr("sin"), + Region: cast.Ptr("sin"), }, fsys) // Check error assert.ErrorContains(t, err, "Unexpected error creating preview branch:") diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index 25ad3372a..b18565d20 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -10,6 +10,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/cast" "github.com/supabase/cli/pkg/config" "github.com/supabase/cli/pkg/function" ) @@ -86,7 +87,7 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, function.ImportMap = utils.FallbackImportMapPath } if noVerifyJWT != nil { - function.VerifyJWT = utils.Ptr(!*noVerifyJWT) + function.VerifyJWT = cast.Ptr(!*noVerifyJWT) } functionConfig[name] = function } diff --git a/internal/functions/deploy/deploy_test.go b/internal/functions/deploy/deploy_test.go index adf49e63f..c92f210cc 100644 --- a/internal/functions/deploy/deploy_test.go +++ b/internal/functions/deploy/deploy_test.go @@ -15,6 +15,7 @@ import ( "github.com/supabase/cli/internal/testing/apitest" "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" "github.com/supabase/cli/pkg/config" ) @@ -323,7 +324,7 @@ func TestImportMapPath(t *testing.T) { fsys := afero.NewMemMapFs() require.NoError(t, afero.WriteFile(fsys, utils.FallbackImportMapPath, []byte("{}"), 0644)) // Run test - fc, err := GetFunctionConfig([]string{slug}, utils.FallbackImportMapPath, utils.Ptr(false), fsys) + fc, err := GetFunctionConfig([]string{slug}, utils.FallbackImportMapPath, cast.Ptr(false), fsys) // Check error assert.NoError(t, err) assert.Equal(t, utils.FallbackImportMapPath, fc[slug].ImportMap) diff --git a/internal/functions/serve/serve_test.go b/internal/functions/serve/serve_test.go index 5b98ece87..570c4b927 100644 --- a/internal/functions/serve/serve_test.go +++ b/internal/functions/serve/serve_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/require" "github.com/supabase/cli/internal/testing/apitest" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/cast" ) func TestServeCommand(t *testing.T) { @@ -100,7 +101,7 @@ func TestServeCommand(t *testing.T) { Reply(http.StatusOK). JSON(types.ContainerJSON{}) // Run test - err := Run(context.Background(), ".env", utils.Ptr(true), "import_map.json", RuntimeOption{}, fsys) + err := Run(context.Background(), ".env", cast.Ptr(true), "import_map.json", RuntimeOption{}, fsys) // Check error assert.ErrorIs(t, err, os.ErrNotExist) }) diff --git a/internal/init/init_test.go b/internal/init/init_test.go index 47e35b89e..99a96dce5 100644 --- a/internal/init/init_test.go +++ b/internal/init/init_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" "github.com/supabase/cli/internal/testing/fstest" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/cast" ) func TestInitCommand(t *testing.T) { @@ -70,7 +71,7 @@ func TestInitCommand(t *testing.T) { // Setup in-memory fs fsys := &afero.MemMapFs{} // Run test - assert.NoError(t, Run(context.Background(), fsys, utils.Ptr(true), nil, utils.InitParams{})) + assert.NoError(t, Run(context.Background(), fsys, cast.Ptr(true), nil, utils.InitParams{})) // Validate generated vscode settings exists, err := afero.Exists(fsys, settingsPath) assert.NoError(t, err) @@ -84,7 +85,7 @@ func TestInitCommand(t *testing.T) { // Setup in-memory fs fsys := &afero.MemMapFs{} // Run test - assert.NoError(t, Run(context.Background(), fsys, utils.Ptr(false), nil, utils.InitParams{})) + assert.NoError(t, Run(context.Background(), fsys, cast.Ptr(false), nil, utils.InitParams{})) // Validate vscode settings file isn't generated exists, err := afero.Exists(fsys, settingsPath) assert.NoError(t, err) @@ -98,7 +99,7 @@ func TestInitCommand(t *testing.T) { // Setup in-memory fs fsys := &afero.MemMapFs{} // Run test - assert.NoError(t, Run(context.Background(), fsys, nil, utils.Ptr(true), utils.InitParams{})) + assert.NoError(t, Run(context.Background(), fsys, nil, cast.Ptr(true), utils.InitParams{})) // Validate generated intellij deno config exists, err := afero.Exists(fsys, denoPath) assert.NoError(t, err) @@ -109,7 +110,7 @@ func TestInitCommand(t *testing.T) { // Setup in-memory fs fsys := &afero.MemMapFs{} // Run test - assert.NoError(t, Run(context.Background(), fsys, nil, utils.Ptr(false), utils.InitParams{})) + assert.NoError(t, Run(context.Background(), fsys, nil, cast.Ptr(false), utils.InitParams{})) // Validate intellij deno config file isn't generated exists, err := afero.Exists(fsys, denoPath) assert.NoError(t, err) diff --git a/internal/storage/cp/cp_test.go b/internal/storage/cp/cp_test.go index fe988c21c..75a0cf3cd 100644 --- a/internal/storage/cp/cp_test.go +++ b/internal/storage/cp/cp_test.go @@ -14,16 +14,17 @@ import ( "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" "github.com/supabase/cli/pkg/fetcher" "github.com/supabase/cli/pkg/storage" ) var mockFile = storage.ObjectResponse{ Name: "abstract.pdf", - Id: utils.Ptr("9b7f9f48-17a6-4ca8-b14a-39b0205a63e9"), - UpdatedAt: utils.Ptr("2023-10-13T18:08:22.068Z"), - CreatedAt: utils.Ptr("2023-10-13T18:08:22.068Z"), - LastAccessedAt: utils.Ptr("2023-10-13T18:08:22.068Z"), + Id: cast.Ptr("9b7f9f48-17a6-4ca8-b14a-39b0205a63e9"), + UpdatedAt: cast.Ptr("2023-10-13T18:08:22.068Z"), + CreatedAt: cast.Ptr("2023-10-13T18:08:22.068Z"), + LastAccessedAt: cast.Ptr("2023-10-13T18:08:22.068Z"), Metadata: &storage.ObjectMetadata{ ETag: `"887ea9be3c68e6f2fca7fd2d7c77d8fe"`, Size: 82702, diff --git a/internal/storage/ls/ls_test.go b/internal/storage/ls/ls_test.go index f1682759c..e0e2cd207 100644 --- a/internal/storage/ls/ls_test.go +++ b/internal/storage/ls/ls_test.go @@ -14,16 +14,17 @@ import ( "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" "github.com/supabase/cli/pkg/fetcher" "github.com/supabase/cli/pkg/storage" ) var mockFile = storage.ObjectResponse{ Name: "abstract.pdf", - Id: utils.Ptr("9b7f9f48-17a6-4ca8-b14a-39b0205a63e9"), - UpdatedAt: utils.Ptr("2023-10-13T18:08:22.068Z"), - CreatedAt: utils.Ptr("2023-10-13T18:08:22.068Z"), - LastAccessedAt: utils.Ptr("2023-10-13T18:08:22.068Z"), + Id: cast.Ptr("9b7f9f48-17a6-4ca8-b14a-39b0205a63e9"), + UpdatedAt: cast.Ptr("2023-10-13T18:08:22.068Z"), + CreatedAt: cast.Ptr("2023-10-13T18:08:22.068Z"), + LastAccessedAt: cast.Ptr("2023-10-13T18:08:22.068Z"), Metadata: &storage.ObjectMetadata{ ETag: `"887ea9be3c68e6f2fca7fd2d7c77d8fe"`, Size: 82702, diff --git a/internal/storage/mv/mv_test.go b/internal/storage/mv/mv_test.go index 2cb1c57e5..fd8ecfbcc 100644 --- a/internal/storage/mv/mv_test.go +++ b/internal/storage/mv/mv_test.go @@ -12,16 +12,17 @@ import ( "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" "github.com/supabase/cli/pkg/fetcher" "github.com/supabase/cli/pkg/storage" ) var mockFile = storage.ObjectResponse{ Name: "abstract.pdf", - Id: utils.Ptr("9b7f9f48-17a6-4ca8-b14a-39b0205a63e9"), - UpdatedAt: utils.Ptr("2023-10-13T18:08:22.068Z"), - CreatedAt: utils.Ptr("2023-10-13T18:08:22.068Z"), - LastAccessedAt: utils.Ptr("2023-10-13T18:08:22.068Z"), + Id: cast.Ptr("9b7f9f48-17a6-4ca8-b14a-39b0205a63e9"), + UpdatedAt: cast.Ptr("2023-10-13T18:08:22.068Z"), + CreatedAt: cast.Ptr("2023-10-13T18:08:22.068Z"), + LastAccessedAt: cast.Ptr("2023-10-13T18:08:22.068Z"), Metadata: &storage.ObjectMetadata{ ETag: `"887ea9be3c68e6f2fca7fd2d7c77d8fe"`, Size: 82702, diff --git a/internal/storage/rm/rm_test.go b/internal/storage/rm/rm_test.go index 6032c5b9b..46d204cf0 100644 --- a/internal/storage/rm/rm_test.go +++ b/internal/storage/rm/rm_test.go @@ -13,16 +13,17 @@ import ( "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" "github.com/supabase/cli/pkg/fetcher" "github.com/supabase/cli/pkg/storage" ) var mockFile = storage.ObjectResponse{ Name: "abstract.pdf", - Id: utils.Ptr("9b7f9f48-17a6-4ca8-b14a-39b0205a63e9"), - UpdatedAt: utils.Ptr("2023-10-13T18:08:22.068Z"), - CreatedAt: utils.Ptr("2023-10-13T18:08:22.068Z"), - LastAccessedAt: utils.Ptr("2023-10-13T18:08:22.068Z"), + Id: cast.Ptr("9b7f9f48-17a6-4ca8-b14a-39b0205a63e9"), + UpdatedAt: cast.Ptr("2023-10-13T18:08:22.068Z"), + CreatedAt: cast.Ptr("2023-10-13T18:08:22.068Z"), + LastAccessedAt: cast.Ptr("2023-10-13T18:08:22.068Z"), Metadata: &storage.ObjectMetadata{ ETag: `"887ea9be3c68e6f2fca7fd2d7c77d8fe"`, Size: 82702, diff --git a/internal/utils/api.go b/internal/utils/api.go index 3dc63d30d..7dc59a088 100644 --- a/internal/utils/api.go +++ b/internal/utils/api.go @@ -16,6 +16,7 @@ import ( "github.com/spf13/viper" "github.com/supabase/cli/internal/utils/cloudflare" supabase "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" ) const ( @@ -60,7 +61,7 @@ func FallbackLookupIP(ctx context.Context, host string) ([]string, error) { func ResolveCNAME(ctx context.Context, host string) (string, error) { // Ref: https://developers.cloudflare.com/1.1.1.1/encryption/dns-over-https/make-api-requests/dns-json cf := cloudflare.NewCloudflareAPI() - data, err := cf.DNSQuery(ctx, cloudflare.DNSParams{Name: host, Type: Ptr(cloudflare.TypeCNAME)}) + data, err := cf.DNSQuery(ctx, cloudflare.DNSParams{Name: host, Type: cast.Ptr(cloudflare.TypeCNAME)}) if err != nil { return "", err } diff --git a/internal/utils/console.go b/internal/utils/console.go index dfd014afc..85bebdc1e 100644 --- a/internal/utils/console.go +++ b/internal/utils/console.go @@ -10,6 +10,7 @@ import ( "time" "github.com/go-errors/errors" + "github.com/supabase/cli/pkg/cast" "golang.org/x/term" ) @@ -78,10 +79,10 @@ func (c *Console) PromptYesNo(ctx context.Context, label string, def bool) (bool func parseYesNo(s string) *bool { s = strings.ToLower(s) if s == "y" || s == "yes" { - return Ptr(true) + return cast.Ptr(true) } if s == "n" || s == "no" { - return Ptr(false) + return cast.Ptr(false) } return nil } diff --git a/internal/utils/misc.go b/internal/utils/misc.go index adb0efa9c..0993ae806 100644 --- a/internal/utils/misc.go +++ b/internal/utils/misc.go @@ -295,10 +295,6 @@ func ValidateFunctionSlug(slug string) error { return nil } -func Ptr[T any](v T) *T { - return &v -} - func GetHostname() string { host := Docker.DaemonHost() if parsed, err := client.ParseHostURL(host); err == nil && parsed.Scheme == "tcp" { diff --git a/internal/utils/release_test.go b/internal/utils/release_test.go index 00b44f49d..25aa920e8 100644 --- a/internal/utils/release_test.go +++ b/internal/utils/release_test.go @@ -10,6 +10,7 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/pkg/cast" ) func TestLatestRelease(t *testing.T) { @@ -19,7 +20,7 @@ func TestLatestRelease(t *testing.T) { gock.New("https://api.github.com"). Get("/repos/supabase/cli/releases/latest"). Reply(http.StatusOK). - JSON(github.RepositoryRelease{TagName: Ptr("v2")}) + JSON(github.RepositoryRelease{TagName: cast.Ptr("v2")}) // Run test version, err := GetLatestRelease(context.Background()) // Check error From 56c2cc464eb08249c347e30d1d089cf16416cbbc Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Thu, 24 Oct 2024 11:12:13 +0200 Subject: [PATCH 103/305] fix(config): default value for seed remote (#2797) --- pkg/config/config.go | 2 ++ pkg/config/config_test.go | 3 +++ pkg/config/testdata/config.toml | 3 +++ 3 files changed, 8 insertions(+) diff --git a/pkg/config/config.go b/pkg/config/config.go index 6e548111a..7f0acf72c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -697,6 +697,8 @@ func (c *config) Load(path string, fsys fs.FS) error { c.Remotes = make(map[string]baseConfig, len(c.Overrides)) for name, remote := range c.Overrides { base := c.baseConfig.Clone() + // On remotes branches set seed as disabled by default + base.Db.Seed.Enabled = false // Encode a toml file with only config overrides var buf bytes.Buffer if err := toml.NewEncoder(&buf).Encode(remote); err != nil { diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index c10669350..8e8f6a2e1 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -93,9 +93,12 @@ func TestConfigParsing(t *testing.T) { assert.Equal(t, false, production.Auth.EnableSignup) assert.Equal(t, false, production.Auth.External["azure"].Enabled) assert.Equal(t, "nope", production.Auth.External["azure"].ClientId) + // Check seed should be disabled by default for remote configs + assert.Equal(t, false, production.Db.Seed.Enabled) // Check the values for the staging override assert.Equal(t, "staging-project", staging.ProjectId) assert.Equal(t, []string{"image/png"}, staging.Storage.Buckets["images"].AllowedMimeTypes) + assert.Equal(t, true, staging.Db.Seed.Enabled) }) } diff --git a/pkg/config/testdata/config.toml b/pkg/config/testdata/config.toml index 0d591d979..2f1a8e90d 100644 --- a/pkg/config/testdata/config.toml +++ b/pkg/config/testdata/config.toml @@ -237,5 +237,8 @@ client_id = "nope" [remotes.staging] project_id = "staging-project" +[remotes.staging.db.seed] +enabled = true + [remotes.staging.storage.buckets.images] allowed_mime_types = ["image/png"] From 78bc7f795ab11fdcfe901901bb8db434fb39fee2 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Thu, 24 Oct 2024 15:02:11 +0200 Subject: [PATCH 104/305] feat(config): allow local postgres configuration (#2796) * feat(cli): allow local postgres.conf configuration Closes: #2611 * chore: test ToPostgresConfig * chore: add start runtime test * chore: use less max_connections * fix: db start tests * chore: add prefix to postgres config * fix: test * chore: serialise postgres conf as toml --------- Co-authored-by: Qiao Han --- internal/db/start/start.go | 18 +++++++---- internal/db/start/start_test.go | 53 +++++++++++++++++++++++++++++++++ pkg/config/db.go | 13 ++++++++ pkg/config/db_test.go | 38 +++++++++++++++++++++++ 4 files changed, 116 insertions(+), 6 deletions(-) diff --git a/internal/db/start/start.go b/internal/db/start/start.go index 826d46c86..a300f5594 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -56,7 +56,6 @@ func NewContainerConfig() container.Config { env := []string{ "POSTGRES_PASSWORD=" + utils.Config.Db.Password, "POSTGRES_HOST=/var/run/postgresql", - "POSTGRES_INITDB_ARGS=--lc-ctype=C.UTF-8", "JWT_SECRET=" + utils.Config.Auth.JwtSecret, fmt.Sprintf("JWT_EXP=%d", utils.Config.Auth.JwtExpiry), } @@ -81,13 +80,18 @@ func NewContainerConfig() container.Config { Timeout: 2 * time.Second, Retries: 3, }, - Entrypoint: []string{"sh", "-c", `cat <<'EOF' > /etc/postgresql.schema.sql && cat <<'EOF' > /etc/postgresql-custom/pgsodium_root.key && docker-entrypoint.sh postgres -D /etc/postgresql + Entrypoint: []string{"sh", "-c", ` +cat <<'EOF' > /etc/postgresql.schema.sql && \ +cat <<'EOF' > /etc/postgresql-custom/pgsodium_root.key && \ +cat <<'EOF' >> /etc/postgresql/postgresql.conf && \ +docker-entrypoint.sh postgres -D /etc/postgresql ` + initialSchema + ` ` + _supabaseSchema + ` EOF ` + utils.Config.Db.RootKey + ` EOF -`}, +` + utils.Config.Db.Settings.ToPostgresConfig() + ` +EOF`}, } if utils.Config.Db.MajorVersion >= 14 { config.Cmd = []string{"postgres", @@ -124,11 +128,13 @@ func StartDatabase(ctx context.Context, fsys afero.Fs, w io.Writer, options ...f } if utils.Config.Db.MajorVersion <= 14 { config.Entrypoint = []string{"sh", "-c", ` - cat <<'EOF' > /docker-entrypoint-initdb.d/supabase_schema.sql +cat <<'EOF' > /docker-entrypoint-initdb.d/supabase_schema.sql && \ +cat <<'EOF' >> /etc/postgresql/postgresql.conf && \ +docker-entrypoint.sh postgres -D /etc/postgresql ` + _supabaseSchema + ` EOF - docker-entrypoint.sh postgres -D /etc/postgresql - `} +` + utils.Config.Db.Settings.ToPostgresConfig() + ` +EOF`} hostConfig.Tmpfs = map[string]string{"/docker-entrypoint-initdb.d": ""} } // Creating volume will not override existing volume, so we must inspect explicitly diff --git a/internal/db/start/start_test.go b/internal/db/start/start_test.go index 96d97da8c..475562f2f 100644 --- a/internal/db/start/start_test.go +++ b/internal/db/start/start_test.go @@ -17,6 +17,7 @@ import ( "github.com/supabase/cli/internal/testing/apitest" "github.com/supabase/cli/internal/testing/fstest" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/cast" "github.com/supabase/cli/pkg/pgtest" ) @@ -308,3 +309,55 @@ func TestSetupDatabase(t *testing.T) { assert.Empty(t, apitest.ListUnmatchedRequests()) }) } +func TestStartDatabaseWithCustomSettings(t *testing.T) { + t.Run("starts database with custom MaxConnections", func(t *testing.T) { + // Setup + utils.Config.Db.MajorVersion = 15 + utils.DbId = "supabase_db_test" + utils.ConfigId = "supabase_config_test" + utils.Config.Db.Port = 5432 + utils.Config.Db.Settings.MaxConnections = cast.Ptr(uint(50)) + + // Setup in-memory fs + fsys := afero.NewMemMapFs() + + // Setup mock docker + require.NoError(t, apitest.MockDocker(utils.Docker)) + defer gock.OffAll() + gock.New(utils.Docker.DaemonHost()). + Get("/v" + utils.Docker.ClientVersion() + "/volumes/" + utils.DbId). + Reply(http.StatusNotFound). + JSON(volume.Volume{}) + apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Db.Image), utils.DbId) + gock.New(utils.Docker.DaemonHost()). + Get("/v" + utils.Docker.ClientVersion() + "/containers/" + utils.DbId + "/json"). + Reply(http.StatusOK). + JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ + State: &types.ContainerState{ + Running: true, + Health: &types.Health{Status: types.Healthy}, + }, + }}) + + apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Realtime.Image), "test-realtime") + require.NoError(t, apitest.MockDockerLogs(utils.Docker, "test-realtime", "")) + apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Storage.Image), "test-storage") + require.NoError(t, apitest.MockDockerLogs(utils.Docker, "test-storage", "")) + apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Auth.Image), "test-auth") + require.NoError(t, apitest.MockDockerLogs(utils.Docker, "test-auth", "")) + // Setup mock postgres + conn := pgtest.NewConn() + defer conn.Close(t) + + // Run test + err := StartDatabase(context.Background(), fsys, io.Discard, conn.Intercept) + + // Check error + assert.NoError(t, err) + assert.Empty(t, apitest.ListUnmatchedRequests()) + + // Check if the custom MaxConnections setting was applied + config := NewContainerConfig() + assert.Contains(t, config.Entrypoint[2], "max_connections = 50") + }) +} diff --git a/pkg/config/db.go b/pkg/config/db.go index 89e5bfd24..e7c5f820b 100644 --- a/pkg/config/db.go +++ b/pkg/config/db.go @@ -1,6 +1,8 @@ package config import ( + "bytes" + "github.com/google/go-cmp/cmp" v1API "github.com/supabase/cli/pkg/api" "github.com/supabase/cli/pkg/cast" @@ -146,6 +148,17 @@ func (a *settings) fromRemoteConfig(remoteConfig v1API.PostgresConfigResponse) s return result } +const pgConfHeader = "\n# supabase [db.settings] configuration\n" + +// create a valid string to append to /etc/postgresql/postgresql.conf +func (a *settings) ToPostgresConfig() string { + // Assuming postgres settings is always a flat struct, we can serialise + // using toml, then replace double quotes with single. + data, _ := ToTomlBytes(*a) + body := bytes.ReplaceAll(data, []byte{'"'}, []byte{'\''}) + return pgConfHeader + string(body) +} + func (a *settings) DiffWithRemote(remoteConfig v1API.PostgresConfigResponse) ([]byte, error) { // Convert the config values into easily comparable remoteConfig values currentValue, err := ToTomlBytes(a) diff --git a/pkg/config/db_test.go b/pkg/config/db_test.go index e7c573475..8d70ec21b 100644 --- a/pkg/config/db_test.go +++ b/pkg/config/db_test.go @@ -153,3 +153,41 @@ func TestDbSettingsDiffWithRemote(t *testing.T) { assert.Contains(t, string(diff), "-shared_buffers = \"1GB\"") }) } + +func TestSettingsToPostgresConfig(t *testing.T) { + t.Run("Only set values should appear", func(t *testing.T) { + settings := settings{ + MaxConnections: cast.Ptr(uint(100)), + MaxLocksPerTransaction: cast.Ptr(uint(64)), + SharedBuffers: cast.Ptr("128MB"), + WorkMem: cast.Ptr("4MB"), + } + got := settings.ToPostgresConfig() + + assert.Contains(t, got, "max_connections = 100") + assert.Contains(t, got, "max_locks_per_transaction = 64") + assert.Contains(t, got, "shared_buffers = '128MB'") + assert.Contains(t, got, "work_mem = '4MB'") + + assert.NotContains(t, got, "effective_cache_size") + assert.NotContains(t, got, "maintenance_work_mem") + assert.NotContains(t, got, "max_parallel_workers") + }) + + t.Run("SessionReplicationRole should be handled correctly", func(t *testing.T) { + settings := settings{ + SessionReplicationRole: cast.Ptr(SessionReplicationRoleOrigin), + } + got := settings.ToPostgresConfig() + + assert.Contains(t, got, "session_replication_role = 'origin'") + }) + + t.Run("Empty settings should result in empty string", func(t *testing.T) { + settings := settings{} + got := settings.ToPostgresConfig() + + assert.Equal(t, got, "\n# supabase [db.settings] configuration\n") + assert.NotContains(t, got, "=") + }) +} From 8611ace19bc1fd62f5e4e96154402a208194940f Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Fri, 25 Oct 2024 07:15:10 +0200 Subject: [PATCH 105/305] feat(config): experimental config webhooks (#2794) --- pkg/config/config.go | 27 +++++-- pkg/config/updater.go | 16 ++++ pkg/config/updater_test.go | 153 +++++++++++++++++++++++++++++++++++++ 3 files changed, 191 insertions(+), 5 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 7f0acf72c..7fc8942b5 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -388,12 +388,17 @@ type ( VectorPort uint16 `toml:"vector_port"` } + webhooks struct { + Enabled bool `toml:"enabled"` + } + experimental struct { - OrioleDBVersion string `toml:"orioledb_version"` - S3Host string `toml:"s3_host"` - S3Region string `toml:"s3_region"` - S3AccessKey string `toml:"s3_access_key"` - S3SecretKey string `toml:"s3_secret_key"` + OrioleDBVersion string `toml:"orioledb_version"` + S3Host string `toml:"s3_host"` + S3Region string `toml:"s3_region"` + S3AccessKey string `toml:"s3_access_key"` + S3SecretKey string `toml:"s3_secret_key"` + Webhooks *webhooks `toml:"webhooks"` } ) @@ -986,6 +991,9 @@ func (c *baseConfig) Validate(fsys fs.FS) error { return errors.Errorf("Invalid config for analytics.backend. Must be one of: %v", allowed) } } + if err := c.Experimental.validateWebhooks(); err != nil { + return err + } return nil } @@ -1351,3 +1359,12 @@ func ToTomlBytes(config any) ([]byte, error) { } return buf.Bytes(), nil } + +func (e *experimental) validateWebhooks() error { + if e.Webhooks != nil { + if !e.Webhooks.Enabled { + return errors.Errorf("Webhooks cannot be deactivated. [experimental.webhooks] enabled can either be true or left undefined") + } + } + return nil +} diff --git a/pkg/config/updater.go b/pkg/config/updater.go index ac97cc63d..c7739eded 100644 --- a/pkg/config/updater.go +++ b/pkg/config/updater.go @@ -24,6 +24,9 @@ func (u *ConfigUpdater) UpdateRemoteConfig(ctx context.Context, remote baseConfi if err := u.UpdateDbConfig(ctx, remote.ProjectId, remote.Db); err != nil { return err } + if err := u.UpdateExperimentalConfig(ctx, remote.ProjectId, remote.Experimental); err != nil { + return err + } return nil } @@ -87,3 +90,16 @@ func (u *ConfigUpdater) UpdateDbConfig(ctx context.Context, projectRef string, c } return nil } + +func (u *ConfigUpdater) UpdateExperimentalConfig(ctx context.Context, projectRef string, exp experimental) error { + if exp.Webhooks != nil && exp.Webhooks.Enabled { + fmt.Fprintln(os.Stderr, "Enabling webhooks for the project...") + + if resp, err := u.client.V1EnableDatabaseWebhookWithResponse(ctx, projectRef); err != nil { + return errors.Errorf("failed to enable webhooks: %w", err) + } else if resp.StatusCode() < 200 || resp.StatusCode() >= 300 { + return errors.Errorf("unexpected enable webhook status %d: %s", resp.StatusCode(), string(resp.Body)) + } + } + return nil +} diff --git a/pkg/config/updater_test.go b/pkg/config/updater_test.go index 241d612e9..2ad07c998 100644 --- a/pkg/config/updater_test.go +++ b/pkg/config/updater_test.go @@ -9,6 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" ) func TestUpdateApi(t *testing.T) { @@ -63,3 +64,155 @@ func TestUpdateApi(t *testing.T) { assert.True(t, gock.IsDone()) }) } + +func TestUpdateDbConfig(t *testing.T) { + server := "http://localhost" + client, err := v1API.NewClientWithResponses(server) + require.NoError(t, err) + + t.Run("updates remote DB config", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Setup mock server + defer gock.Off() + gock.New(server). + Get("/v1/projects/test-project/config/database"). + Reply(http.StatusOK). + JSON(v1API.PostgresConfigResponse{}) + gock.New(server). + Put("/v1/projects/test-project/config/database"). + Reply(http.StatusOK). + JSON(v1API.PostgresConfigResponse{ + MaxConnections: cast.Ptr(cast.UintToInt(100)), + }) + // Run test + err := updater.UpdateDbConfig(context.Background(), "test-project", db{ + Settings: settings{ + MaxConnections: cast.Ptr(cast.IntToUint(100)), + }, + }) + // Check result + assert.NoError(t, err) + assert.True(t, gock.IsDone()) + }) + + t.Run("skips update if no diff in DB config", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Setup mock server + defer gock.Off() + gock.New(server). + Get("/v1/projects/test-project/config/database"). + Reply(http.StatusOK). + JSON(v1API.PostgresConfigResponse{ + MaxConnections: cast.Ptr(cast.UintToInt(100)), + }) + // Run test + err := updater.UpdateDbConfig(context.Background(), "test-project", db{ + Settings: settings{ + MaxConnections: cast.Ptr(cast.IntToUint(100)), + }, + }) + // Check result + assert.NoError(t, err) + assert.True(t, gock.IsDone()) + }) +} + +func TestUpdateExperimentalConfig(t *testing.T) { + server := "http://localhost" + client, err := v1API.NewClientWithResponses(server) + require.NoError(t, err) + + t.Run("enables webhooks", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Setup mock server + defer gock.Off() + gock.New(server). + Post("/v1/projects/test-project/database/webhooks/enable"). + Reply(http.StatusOK). + JSON(map[string]interface{}{}) + // Run test + err := updater.UpdateExperimentalConfig(context.Background(), "test-project", experimental{ + Webhooks: &webhooks{ + Enabled: true, + }, + }) + // Check result + assert.NoError(t, err) + assert.True(t, gock.IsDone()) + }) + + t.Run("skips update if webhooks not enabled", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Run test + err := updater.UpdateExperimentalConfig(context.Background(), "test-project", experimental{ + Webhooks: &webhooks{ + Enabled: false, + }, + }) + // Check result + assert.NoError(t, err) + assert.True(t, gock.IsDone()) + }) +} + +func TestUpdateRemoteConfig(t *testing.T) { + server := "http://localhost" + client, err := v1API.NewClientWithResponses(server) + require.NoError(t, err) + + t.Run("updates all configs", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Setup mock server + defer gock.Off() + // API config + gock.New(server). + Get("/v1/projects/test-project/postgrest"). + Reply(http.StatusOK). + JSON(v1API.PostgrestConfigWithJWTSecretResponse{}) + gock.New(server). + Patch("/v1/projects/test-project/postgrest"). + Reply(http.StatusOK). + JSON(v1API.PostgrestConfigWithJWTSecretResponse{ + DbSchema: "public", + MaxRows: 1000, + }) + // DB config + gock.New(server). + Get("/v1/projects/test-project/config/database"). + Reply(http.StatusOK). + JSON(v1API.PostgresConfigResponse{}) + gock.New(server). + Put("/v1/projects/test-project/config/database"). + Reply(http.StatusOK). + JSON(v1API.PostgresConfigResponse{ + MaxConnections: cast.Ptr(cast.UintToInt(100)), + }) + // Experimental config + gock.New(server). + Post("/v1/projects/test-project/database/webhooks/enable"). + Reply(http.StatusOK). + JSON(map[string]interface{}{}) + // Run test + err := updater.UpdateRemoteConfig(context.Background(), baseConfig{ + ProjectId: "test-project", + Api: api{ + Enabled: true, + Schemas: []string{"public", "private"}, + MaxRows: 1000, + }, + Db: db{ + Settings: settings{ + MaxConnections: cast.Ptr(cast.IntToUint(100)), + }, + }, + Experimental: experimental{ + Webhooks: &webhooks{ + Enabled: true, + }, + }, + }) + // Check result + assert.NoError(t, err) + assert.True(t, gock.IsDone()) + }) +} From 2fe2da67b0bff1bafe075aac3e65ae6a596af773 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Fri, 25 Oct 2024 13:56:49 +0200 Subject: [PATCH 106/305] chore: upgrade keyring use package DeleteAll method (#2800) --- go.mod | 6 ++-- go.sum | 8 ++--- internal/utils/credentials/keyring_darwin.go | 34 ------------------- internal/utils/credentials/keyring_linux.go | 33 ------------------ internal/utils/credentials/keyring_test.go | 4 +-- internal/utils/credentials/keyring_windows.go | 25 -------------- internal/utils/credentials/store.go | 11 +++++- 7 files changed, 19 insertions(+), 102 deletions(-) delete mode 100644 internal/utils/credentials/keyring_darwin.go delete mode 100644 internal/utils/credentials/keyring_linux.go delete mode 100644 internal/utils/credentials/keyring_windows.go diff --git a/go.mod b/go.mod index 6f813394d..2abddb9f5 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,6 @@ require ( github.com/charmbracelet/glamour v0.7.0 github.com/charmbracelet/lipgloss v0.12.1 github.com/containers/common v0.60.4 - github.com/danieljoos/wincred v1.2.2 github.com/deepmap/oapi-codegen/v2 v2.2.0 github.com/docker/cli v27.3.1+incompatible github.com/docker/docker v27.3.1+incompatible @@ -49,7 +48,7 @@ require ( github.com/stretchr/testify v1.9.0 github.com/stripe/pg-schema-diff v0.7.0 github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 - github.com/zalando/go-keyring v0.2.5 + github.com/zalando/go-keyring v0.2.6 go.opentelemetry.io/otel v1.31.0 golang.org/x/mod v0.21.0 golang.org/x/oauth2 v0.23.0 @@ -62,6 +61,7 @@ require ( require ( 4d63.com/gocheckcompilerdirectives v1.2.1 // indirect 4d63.com/gochecknoglobals v0.2.1 // indirect + al.essio.dev/pkg/shellescape v1.5.1 // indirect dario.cat/mergo v1.0.0 // indirect github.com/4meepo/tagalign v1.3.4 // indirect github.com/Abirdcfly/dupword v0.1.1 // indirect @@ -78,7 +78,6 @@ require ( github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/alecthomas/chroma/v2 v2.8.0 // indirect github.com/alecthomas/go-check-sumtype v0.1.4 // indirect - github.com/alessio/shellescape v1.4.1 // indirect github.com/alexkohler/nakedret/v2 v2.0.4 // indirect github.com/alexkohler/prealloc v1.0.0 // indirect github.com/alingse/asasalint v0.0.11 // indirect @@ -116,6 +115,7 @@ require ( github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/cyphar/filepath-securejoin v0.3.1 // indirect github.com/daixiang0/gci v0.13.5 // indirect + github.com/danieljoos/wincred v1.2.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/denis-tingaikin/go-header v0.5.0 // indirect github.com/distribution/reference v0.6.0 // indirect diff --git a/go.sum b/go.sum index ec11ef74c..3814c1303 100644 --- a/go.sum +++ b/go.sum @@ -2,6 +2,8 @@ 4d63.com/gocheckcompilerdirectives v1.2.1/go.mod h1:yjDJSxmDTtIHHCqX0ufRYZDL6vQtMG7tJdKVeWwsqvs= 4d63.com/gochecknoglobals v0.2.1 h1:1eiorGsgHOFOuoOiJDy2psSrQbRdIHrlge0IJIkUgDc= 4d63.com/gochecknoglobals v0.2.1/go.mod h1:KRE8wtJB3CXCsb1xy421JfTHIIbmT3U5ruxw2Qu8fSU= +al.essio.dev/pkg/shellescape v1.5.1 h1:86HrALUujYS/h+GtqoB26SBEdkWfmMI6FubjXlsXyho= +al.essio.dev/pkg/shellescape v1.5.1/go.mod h1:6sIqp7X2P6mThCQ7twERpZTuigpr6KbZWtls1U8I890= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -87,8 +89,6 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/alessio/shellescape v1.4.1 h1:V7yhSDDn8LP4lc4jS8pFkt0zCnzVJlG5JXy9BVKJUX0= -github.com/alessio/shellescape v1.4.1/go.mod h1:PZAiSCk0LJaZkiCSkPv8qIobYglO3FPpyFjDCtHLS30= github.com/alexkohler/nakedret/v2 v2.0.4 h1:yZuKmjqGi0pSmjGpOC016LtPJysIL0WEUiaXW5SUnNg= github.com/alexkohler/nakedret/v2 v2.0.4/go.mod h1:bF5i0zF2Wo2o4X4USt9ntUWve6JbFv02Ff4vlkmS/VU= github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pOcUuw= @@ -1012,8 +1012,8 @@ github.com/yuin/goldmark v1.5.4 h1:2uY/xC0roWy8IBEGLgB1ywIoEJFGmRrX21YQcvGZzjU= github.com/yuin/goldmark v1.5.4/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark-emoji v1.0.2 h1:c/RgTShNgHTtc6xdz2KKI74jJr6rWi7FPgnP9GAsO5s= github.com/yuin/goldmark-emoji v1.0.2/go.mod h1:RhP/RWpexdp+KHs7ghKnifRoIs/Bq4nDS7tRbCkOwKY= -github.com/zalando/go-keyring v0.2.5 h1:Bc2HHpjALryKD62ppdEzaFG6VxL6Bc+5v0LYpN8Lba8= -github.com/zalando/go-keyring v0.2.5/go.mod h1:HL4k+OXQfJUWaMnqyuSOc0drfGPX2b51Du6K+MRgZMk= +github.com/zalando/go-keyring v0.2.6 h1:r7Yc3+H+Ux0+M72zacZoItR3UDxeWfKTcabvkI8ua9s= +github.com/zalando/go-keyring v0.2.6/go.mod h1:2TCrxYrbUNYfNS/Kgy/LSrkSQzZ5UPVH85RwfczwvcI= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= gitlab.com/bosi/decorder v0.4.2 h1:qbQaV3zgwnBZ4zPMhGLW4KZe7A7NwxEhJx39R3shffo= gitlab.com/bosi/decorder v0.4.2/go.mod h1:muuhHoaJkA9QLcYHq4Mj8FJUwDZ+EirSHRiaTcTf6T8= diff --git a/internal/utils/credentials/keyring_darwin.go b/internal/utils/credentials/keyring_darwin.go deleted file mode 100644 index cca5d72fa..000000000 --- a/internal/utils/credentials/keyring_darwin.go +++ /dev/null @@ -1,34 +0,0 @@ -//go:build darwin - -package credentials - -import ( - "os/exec" - - "github.com/go-errors/errors" -) - -const execPathKeychain = "/usr/bin/security" - -func deleteAll(service string) error { - if len(service) == 0 { - return errors.New("missing service name") - } - // Delete each secret in a while loop until there is no more left - for { - if err := exec.Command( - execPathKeychain, - "delete-generic-password", - "-s", service, - ).Run(); err == nil { - continue - } else if errors.Is(err, exec.ErrNotFound) { - return errors.New(ErrNotSupported) - } else if exitError, ok := err.(*exec.ExitError); ok && exitError.ExitCode() == 44 { - // Exit 44 means no item exists for this service name - return nil - } else { - return errors.Errorf("failed to delete all credentials: %w", err) - } - } -} diff --git a/internal/utils/credentials/keyring_linux.go b/internal/utils/credentials/keyring_linux.go deleted file mode 100644 index 08095cfb7..000000000 --- a/internal/utils/credentials/keyring_linux.go +++ /dev/null @@ -1,33 +0,0 @@ -//go:build linux - -package credentials - -import ( - "github.com/go-errors/errors" - ss "github.com/zalando/go-keyring/secret_service" -) - -func deleteAll(service string) error { - svc, err := ss.NewSecretService() - if err != nil { - return errors.Errorf("failed to create secret service: %w", err) - } - - collection := svc.GetLoginCollection() - if err := svc.Unlock(collection.Path()); err != nil { - return errors.Errorf("failed to unlock collection: %w", err) - } - - search := map[string]string{"service": service} - results, err := svc.SearchItems(collection, search) - if err != nil { - return errors.Errorf("failed to search items: %w", err) - } - - for _, item := range results { - if err := svc.Delete(item); err != nil { - return errors.Errorf("failed to delete all credentials: %w", err) - } - } - return nil -} diff --git a/internal/utils/credentials/keyring_test.go b/internal/utils/credentials/keyring_test.go index 0569276aa..4f450078f 100644 --- a/internal/utils/credentials/keyring_test.go +++ b/internal/utils/credentials/keyring_test.go @@ -10,7 +10,7 @@ import ( func TestDeleteAll(t *testing.T) { service := "test-cli" // Nothing to delete - err := deleteAll(service) + err := keyring.DeleteAll(service) assert.NoError(t, err) // Setup 2 items err = keyring.Set(service, "key1", "value") @@ -18,7 +18,7 @@ func TestDeleteAll(t *testing.T) { err = keyring.Set(service, "key2", "value") assert.NoError(t, err) // Delete all items - err = deleteAll(service) + err = keyring.DeleteAll(service) assert.NoError(t, err) // Check items are gone _, err = keyring.Get(service, "key1") diff --git a/internal/utils/credentials/keyring_windows.go b/internal/utils/credentials/keyring_windows.go deleted file mode 100644 index 0366a686d..000000000 --- a/internal/utils/credentials/keyring_windows.go +++ /dev/null @@ -1,25 +0,0 @@ -//go:build windows - -package credentials - -import ( - "github.com/danieljoos/wincred" - "github.com/go-errors/errors" -) - -func deleteAll(service string) error { - if err := assertKeyringSupported(); err != nil { - return err - } - creds, err := wincred.FilteredList(service + ":") - if err != nil { - return errors.Errorf("failed to list credentials: %w", err) - } - for _, c := range creds { - gc := wincred.GenericCredential{Credential: *c} - if err := gc.Delete(); err != nil { - return errors.Errorf("failed to delete all credentials: %w", err) - } - } - return nil -} diff --git a/internal/utils/credentials/store.go b/internal/utils/credentials/store.go index 02f97e200..d7bf9d2b2 100644 --- a/internal/utils/credentials/store.go +++ b/internal/utils/credentials/store.go @@ -65,7 +65,16 @@ func (ks *KeyringStore) Delete(project string) error { } func (ks *KeyringStore) DeleteAll() error { - return deleteAll(namespace) + if err := assertKeyringSupported(); err != nil { + return err + } + if err := keyring.DeleteAll(namespace); err != nil { + if errors.Is(err, exec.ErrNotFound) { + return ErrNotSupported + } + return errors.Errorf("failed to delete all credentials in %s: %w", namespace, err) + } + return nil } func assertKeyringSupported() error { From b322db703a2bb97dafa4ed3f89bbb88221d425b8 Mon Sep 17 00:00:00 2001 From: Li Yuxuan Date: Sat, 26 Oct 2024 09:50:15 +0800 Subject: [PATCH 107/305] fix: node-fetch hanging issue when fetching checksum after fetching binary (#2804) --- scripts/postinstall.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/scripts/postinstall.js b/scripts/postinstall.js index cc28b12fe..76b759046 100755 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -98,45 +98,53 @@ async function main() { throw errUnsupported; } + // Read from package.json and prepare for the installation. const pkg = await readPackageJson(); if (platform === "windows") { // Update bin path in package.json pkg.bin[pkg.name] += ".exe"; } + // Prepare the installation path by creating the directory if it doesn't exist. const binPath = pkg.bin[pkg.name]; const binDir = path.dirname(binPath); await fs.promises.mkdir(binDir, { recursive: true }); - // First we will Un-GZip, then we will untar. - const ungz = zlib.createGunzip(); - const binName = path.basename(binPath); - const untar = extract({ cwd: binDir }, [binName]); - - const url = getDownloadUrl(pkg); - console.info("Downloading", url); + // Create the agent that will be used for all the fetch requests later. const proxyUrl = process.env.npm_config_https_proxy || process.env.npm_config_http_proxy || process.env.npm_config_proxy; - // Keeps the TCP connection alive when sending multiple requests // Ref: https://github.com/node-fetch/node-fetch/issues/1735 const agent = proxyUrl ? new HttpsProxyAgent(proxyUrl, { keepAlive: true }) : new Agent({ keepAlive: true }); - const resp = await fetch(url, { agent }); + // First, fetch the checksum map. + const checksumMap = await fetchAndParseCheckSumFile(pkg, agent); + + // Then, download the binary. + const url = getDownloadUrl(pkg); + console.info("Downloading", url); + const resp = await fetch(url, { agent }); const hash = createHash("sha256"); const pkgNameWithPlatform = `${pkg.name}_${platform}_${arch}.tar.gz`; - const checksumMap = await fetchAndParseCheckSumFile(pkg, agent); + // Then, decompress the binary -- we will first Un-GZip, then we will untar. + const ungz = zlib.createGunzip(); + const binName = path.basename(binPath); + const untar = extract({ cwd: binDir }, [binName]); + + // Update the hash with the binary data as it's being downloaded. resp.body .on("data", (chunk) => { hash.update(chunk); }) + // Pipe the data to the ungz stream. .pipe(ungz); + // After the ungz stream has ended, verify the checksum. ungz .on("end", () => { const expectedChecksum = checksumMap?.[pkgNameWithPlatform]; @@ -151,8 +159,10 @@ async function main() { } console.info("Checksum verified."); }) + // Pipe the data to the untar stream. .pipe(untar); + // Wait for the untar stream to finish. await new Promise((resolve, reject) => { untar.on("error", reject); untar.on("end", () => resolve()); From 813d6a76c7d1fb4a3b7e8194559db69041c3323f Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Tue, 29 Oct 2024 11:52:04 +0100 Subject: [PATCH 108/305] fix: Bump studio to the latest image version 20241029 (#2815) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 0b2edfcf3..f7eb20ae4 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -10,7 +10,7 @@ const ( inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" pgmetaImage = "supabase/postgres-meta:v0.84.2" - studioImage = "supabase/studio:20241014-c083b3b" + studioImage = "supabase/studio:20241029-46e1e40" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.59.0" vectorImage = "timberio/vector:0.28.1-alpine" From 25fd4e78081ce21995f44094624db887e0f69eef Mon Sep 17 00:00:00 2001 From: Joel Lee Date: Tue, 29 Oct 2024 19:33:04 +0800 Subject: [PATCH 109/305] feat(auth): add mfa webauthn config variables (#2812) --- internal/start/start.go | 2 ++ pkg/config/config.go | 1 + pkg/config/constants.go | 2 +- pkg/config/templates/config.toml | 5 +++++ pkg/config/testdata/config.toml | 5 +++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/internal/start/start.go b/internal/start/start.go index 72f34b8e7..5814d209c 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -518,6 +518,8 @@ EOF fmt.Sprintf("GOTRUE_MFA_PHONE_VERIFY_ENABLED=%v", utils.Config.Auth.MFA.Phone.VerifyEnabled), fmt.Sprintf("GOTRUE_MFA_TOTP_ENROLL_ENABLED=%v", utils.Config.Auth.MFA.TOTP.EnrollEnabled), fmt.Sprintf("GOTRUE_MFA_TOTP_VERIFY_ENABLED=%v", utils.Config.Auth.MFA.TOTP.VerifyEnabled), + fmt.Sprintf("GOTRUE_MFA_WEB_AUTHN_ENROLL_ENABLED=%v", utils.Config.Auth.MFA.WebAuthn.EnrollEnabled), + fmt.Sprintf("GOTRUE_MFA_WEB_AUTHN_VERIFY_ENABLED=%v", utils.Config.Auth.MFA.WebAuthn.VerifyEnabled), fmt.Sprintf("GOTRUE_MFA_MAX_ENROLLED_FACTORS=%v", utils.Config.Auth.MFA.MaxEnrolledFactors), } diff --git a/pkg/config/config.go b/pkg/config/config.go index 7fc8942b5..51be3c122 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -309,6 +309,7 @@ type ( mfa struct { TOTP factorTypeConfiguration `toml:"totp"` Phone phoneFactorTypeConfiguration `toml:"phone"` + WebAuthn factorTypeConfiguration `toml:"web_authn"` MaxEnrolledFactors uint `toml:"max_enrolled_factors"` } diff --git a/pkg/config/constants.go b/pkg/config/constants.go index f7eb20ae4..ce291b465 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -15,7 +15,7 @@ const ( edgeRuntimeImage = "supabase/edge-runtime:v1.59.0" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" - gotrueImage = "supabase/gotrue:v2.158.1" + gotrueImage = "supabase/gotrue:v2.163.2" realtimeImage = "supabase/realtime:v2.30.34" storageImage = "supabase/storage-api:v1.11.13" logflareImage = "supabase/logflare:1.4.0" diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index 112237748..5c8dedadc 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -187,6 +187,11 @@ verify_enabled = true # template = "Your code is {{ `{{ .Code }}` }} ." # max_frequency = "10s" +# Configure Multi-factor-authentication via WebAuthn +# [auth.mfa.web_authn] +# enroll_enabled = true +# verify_enabled = true + # Use an external OAuth provider. The full list of providers are: `apple`, `azure`, `bitbucket`, # `discord`, `facebook`, `github`, `gitlab`, `google`, `keycloak`, `linkedin_oidc`, `notion`, `twitch`, # `twitter`, `slack`, `spotify`, `workos`, `zoom`. diff --git a/pkg/config/testdata/config.toml b/pkg/config/testdata/config.toml index 2f1a8e90d..b956abe76 100644 --- a/pkg/config/testdata/config.toml +++ b/pkg/config/testdata/config.toml @@ -187,6 +187,11 @@ otp_length = 6 template = "Your code is {{ `{{ .Code }}` }} ." max_frequency = "10s" +# Configure Multi-factor-authentication via Phone Messaging +[auth.mfa.web_authn] +enroll_enabled = true +verify_enabled = true + # Use an external OAuth provider. The full list of providers are: `apple`, `azure`, `bitbucket`, # `discord`, `facebook`, `github`, `gitlab`, `google`, `keycloak`, `linkedin_oidc`, `notion`, `twitch`, # `twitter`, `slack`, `spotify`, `workos`, `zoom`. From 1250951900f88075f151baccf0bb899317558899 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Tue, 29 Oct 2024 19:33:15 +0800 Subject: [PATCH 110/305] fix(auth): support email otp length and expiry (#2810) --- internal/start/start.go | 2 ++ pkg/config/config.go | 2 ++ pkg/config/templates/config.toml | 4 ++++ pkg/config/testdata/config.toml | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/internal/start/start.go b/internal/start/start.go index 5814d209c..ebddb6d40 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -485,6 +485,8 @@ EOF fmt.Sprintf("GOTRUE_EXTERNAL_EMAIL_ENABLED=%v", utils.Config.Auth.Email.EnableSignup), fmt.Sprintf("GOTRUE_MAILER_SECURE_EMAIL_CHANGE_ENABLED=%v", utils.Config.Auth.Email.DoubleConfirmChanges), fmt.Sprintf("GOTRUE_MAILER_AUTOCONFIRM=%v", !utils.Config.Auth.Email.EnableConfirmations), + fmt.Sprintf("GOTRUE_MAILER_OTP_LENGTH=%v", utils.Config.Auth.Email.OtpLength), + fmt.Sprintf("GOTRUE_MAILER_OTP_EXP=%v", utils.Config.Auth.Email.OtpExpiry), fmt.Sprintf("GOTRUE_EXTERNAL_ANONYMOUS_USERS_ENABLED=%v", utils.Config.Auth.EnableAnonymousSignIns), diff --git a/pkg/config/config.go b/pkg/config/config.go index 51be3c122..9c2210608 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -258,6 +258,8 @@ type ( Template map[string]emailTemplate `toml:"template"` Smtp smtp `toml:"smtp"` MaxFrequency time.Duration `toml:"max_frequency"` + OtpLength uint `toml:"otp_length"` + OtpExpiry uint `toml:"otp_expiry"` } smtp struct { diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index 5c8dedadc..e47487c21 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -121,6 +121,10 @@ enable_confirmations = false secure_password_change = false # Controls the minimum amount of time that must pass before sending another signup confirmation or password reset email. max_frequency = "1s" +# Number of characters used in the email OTP. +otp_length = 6 +# Number of seconds before the email OTP expires (defaults to 1 hour). +otp_expiry = 3600 # Use a production-ready SMTP server # [auth.email.smtp] diff --git a/pkg/config/testdata/config.toml b/pkg/config/testdata/config.toml index b956abe76..b8314644d 100644 --- a/pkg/config/testdata/config.toml +++ b/pkg/config/testdata/config.toml @@ -117,6 +117,10 @@ double_confirm_changes = true enable_confirmations = false # Controls the minimum amount of time that must pass before sending another signup confirmation or password reset email. max_frequency = "1s" +# Number of characters used in the email OTP. +otp_length = 6 +# Number of seconds before the email OTP expires. +otp_expiry = 300 # Use a production-ready SMTP server [auth.email.smtp] From 074cbb66834a8c1597acfca552f28c980eda20c3 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Tue, 29 Oct 2024 14:58:25 +0800 Subject: [PATCH 111/305] chore: generate openapi client --- api/beta.yaml | 95 ++++++++++++- pkg/api/client.gen.go | 300 ++++++++++++++++++++++++++++++++++++++---- pkg/api/types.gen.go | 38 +++++- pkg/function/batch.go | 2 +- 4 files changed, 400 insertions(+), 35 deletions(-) diff --git a/api/beta.yaml b/api/beta.yaml index f4b0c08c2..62557ab25 100644 --- a/api/beta.yaml +++ b/api/beta.yaml @@ -1525,6 +1525,63 @@ paths: - Projects security: - bearer: [] + /v1/projects/{ref}/config/storage: + get: + operationId: v1-get-storage-config + summary: Gets project's storage config + parameters: + - name: ref + required: true + in: path + description: Project ref + schema: + minLength: 20 + maxLength: 20 + type: string + responses: + '200': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/StorageConfigResponse' + '403': + description: '' + '500': + description: Failed to retrieve project's storage config + tags: + - Storage + security: + - bearer: [] + patch: + operationId: v1-update-storage-config + summary: Updates project's storage config + parameters: + - name: ref + required: true + in: path + description: Project ref + schema: + minLength: 20 + maxLength: 20 + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateStorageConfigBody' + responses: + '200': + description: '' + '403': + description: '' + '500': + description: Failed to update project's storage config + tags: + - Storage + security: + - bearer: [] /v1/projects/{ref}/config/database/postgres: get: operationId: v1-get-postgres-config @@ -1910,7 +1967,7 @@ paths: - bearer: [] /v1/projects/{ref}/functions: post: - operationId: createFunction + operationId: v1-create-a-function summary: Create a function description: Creates a function and adds it to the specified project. parameters: @@ -2545,6 +2602,7 @@ components: - RESTORING - RESTORE_FAILED - PAUSE_FAILED + - RESIZING type: string db_host: type: string @@ -2639,9 +2697,12 @@ components: BranchResetResponse: type: object properties: + workflow_run_id: + type: string message: type: string required: + - workflow_run_id - message V1DatabaseResponse: type: object @@ -2701,6 +2762,7 @@ components: - RESTORING - RESTORE_FAILED - PAUSE_FAILED + - RESIZING type: string required: - id @@ -3644,6 +3706,37 @@ components: - name - healthy - status + StorageFeatureImageTransformation: + type: object + properties: + enabled: + type: boolean + required: + - enabled + StorageFeatures: + type: object + properties: + imageTransformation: + $ref: '#/components/schemas/StorageFeatureImageTransformation' + required: + - imageTransformation + StorageConfigResponse: + type: object + properties: + fileSizeLimit: + type: number + features: + $ref: '#/components/schemas/StorageFeatures' + required: + - fileSizeLimit + - features + UpdateStorageConfigBody: + type: object + properties: + fileSizeLimit: + type: number + features: + $ref: '#/components/schemas/StorageFeatures' PostgresConfigResponse: type: object properties: diff --git a/pkg/api/client.gen.go b/pkg/api/client.gen.go index b7c450896..05ed76708 100644 --- a/pkg/api/client.gen.go +++ b/pkg/api/client.gen.go @@ -226,6 +226,14 @@ type ClientInterface interface { V1UpdatePostgresConfig(ctx context.Context, ref string, body V1UpdatePostgresConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1GetStorageConfig request + V1GetStorageConfig(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // V1UpdateStorageConfigWithBody request with any body + V1UpdateStorageConfigWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + V1UpdateStorageConfig(ctx context.Context, ref string, body V1UpdateStorageConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1DeleteHostnameConfig request V1DeleteHostnameConfig(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -262,10 +270,10 @@ type ClientInterface interface { // V1ListAllFunctions request V1ListAllFunctions(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) - // CreateFunctionWithBody request with any body - CreateFunctionWithBody(ctx context.Context, ref string, params *CreateFunctionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1CreateAFunctionWithBody request with any body + V1CreateAFunctionWithBody(ctx context.Context, ref string, params *V1CreateAFunctionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - CreateFunction(ctx context.Context, ref string, params *CreateFunctionParams, body CreateFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + V1CreateAFunction(ctx context.Context, ref string, params *V1CreateAFunctionParams, body V1CreateAFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) // V1DeleteAFunction request V1DeleteAFunction(ctx context.Context, ref string, functionSlug string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -993,6 +1001,42 @@ func (c *Client) V1UpdatePostgresConfig(ctx context.Context, ref string, body V1 return c.Client.Do(req) } +func (c *Client) V1GetStorageConfig(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1GetStorageConfigRequest(c.Server, ref) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) V1UpdateStorageConfigWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1UpdateStorageConfigRequestWithBody(c.Server, ref, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) V1UpdateStorageConfig(ctx context.Context, ref string, body V1UpdateStorageConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1UpdateStorageConfigRequest(c.Server, ref, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) V1DeleteHostnameConfig(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewV1DeleteHostnameConfigRequest(c.Server, ref) if err != nil { @@ -1149,8 +1193,8 @@ func (c *Client) V1ListAllFunctions(ctx context.Context, ref string, reqEditors return c.Client.Do(req) } -func (c *Client) CreateFunctionWithBody(ctx context.Context, ref string, params *CreateFunctionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateFunctionRequestWithBody(c.Server, ref, params, contentType, body) +func (c *Client) V1CreateAFunctionWithBody(ctx context.Context, ref string, params *V1CreateAFunctionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1CreateAFunctionRequestWithBody(c.Server, ref, params, contentType, body) if err != nil { return nil, err } @@ -1161,8 +1205,8 @@ func (c *Client) CreateFunctionWithBody(ctx context.Context, ref string, params return c.Client.Do(req) } -func (c *Client) CreateFunction(ctx context.Context, ref string, params *CreateFunctionParams, body CreateFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateFunctionRequest(c.Server, ref, params, body) +func (c *Client) V1CreateAFunction(ctx context.Context, ref string, params *V1CreateAFunctionParams, body V1CreateAFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1CreateAFunctionRequest(c.Server, ref, params, body) if err != nil { return nil, err } @@ -3281,6 +3325,87 @@ func NewV1UpdatePostgresConfigRequestWithBody(server string, ref string, content return req, nil } +// NewV1GetStorageConfigRequest generates requests for V1GetStorageConfig +func NewV1GetStorageConfigRequest(server string, ref string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/config/storage", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewV1UpdateStorageConfigRequest calls the generic V1UpdateStorageConfig builder with application/json body +func NewV1UpdateStorageConfigRequest(server string, ref string, body V1UpdateStorageConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewV1UpdateStorageConfigRequestWithBody(server, ref, "application/json", bodyReader) +} + +// NewV1UpdateStorageConfigRequestWithBody generates requests for V1UpdateStorageConfig with any type of body +func NewV1UpdateStorageConfigRequestWithBody(server string, ref string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/config/storage", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PATCH", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewV1DeleteHostnameConfigRequest generates requests for V1DeleteHostnameConfig func NewV1DeleteHostnameConfigRequest(server string, ref string) (*http.Request, error) { var err error @@ -3660,19 +3785,19 @@ func NewV1ListAllFunctionsRequest(server string, ref string) (*http.Request, err return req, nil } -// NewCreateFunctionRequest calls the generic CreateFunction builder with application/json body -func NewCreateFunctionRequest(server string, ref string, params *CreateFunctionParams, body CreateFunctionJSONRequestBody) (*http.Request, error) { +// NewV1CreateAFunctionRequest calls the generic V1CreateAFunction builder with application/json body +func NewV1CreateAFunctionRequest(server string, ref string, params *V1CreateAFunctionParams, body V1CreateAFunctionJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewCreateFunctionRequestWithBody(server, ref, params, "application/json", bodyReader) + return NewV1CreateAFunctionRequestWithBody(server, ref, params, "application/json", bodyReader) } -// NewCreateFunctionRequestWithBody generates requests for CreateFunction with any type of body -func NewCreateFunctionRequestWithBody(server string, ref string, params *CreateFunctionParams, contentType string, body io.Reader) (*http.Request, error) { +// NewV1CreateAFunctionRequestWithBody generates requests for V1CreateAFunction with any type of body +func NewV1CreateAFunctionRequestWithBody(server string, ref string, params *V1CreateAFunctionParams, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -5503,6 +5628,14 @@ type ClientWithResponsesInterface interface { V1UpdatePostgresConfigWithResponse(ctx context.Context, ref string, body V1UpdatePostgresConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*V1UpdatePostgresConfigResponse, error) + // V1GetStorageConfigWithResponse request + V1GetStorageConfigWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetStorageConfigResponse, error) + + // V1UpdateStorageConfigWithBodyWithResponse request with any body + V1UpdateStorageConfigWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1UpdateStorageConfigResponse, error) + + V1UpdateStorageConfigWithResponse(ctx context.Context, ref string, body V1UpdateStorageConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*V1UpdateStorageConfigResponse, error) + // V1DeleteHostnameConfigWithResponse request V1DeleteHostnameConfigWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1DeleteHostnameConfigResponse, error) @@ -5539,10 +5672,10 @@ type ClientWithResponsesInterface interface { // V1ListAllFunctionsWithResponse request V1ListAllFunctionsWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1ListAllFunctionsResponse, error) - // CreateFunctionWithBodyWithResponse request with any body - CreateFunctionWithBodyWithResponse(ctx context.Context, ref string, params *CreateFunctionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateFunctionResponse, error) + // V1CreateAFunctionWithBodyWithResponse request with any body + V1CreateAFunctionWithBodyWithResponse(ctx context.Context, ref string, params *V1CreateAFunctionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1CreateAFunctionResponse, error) - CreateFunctionWithResponse(ctx context.Context, ref string, params *CreateFunctionParams, body CreateFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateFunctionResponse, error) + V1CreateAFunctionWithResponse(ctx context.Context, ref string, params *V1CreateAFunctionParams, body V1CreateAFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*V1CreateAFunctionResponse, error) // V1DeleteAFunctionWithResponse request V1DeleteAFunctionWithResponse(ctx context.Context, ref string, functionSlug string, reqEditors ...RequestEditorFn) (*V1DeleteAFunctionResponse, error) @@ -6482,6 +6615,49 @@ func (r V1UpdatePostgresConfigResponse) StatusCode() int { return 0 } +type V1GetStorageConfigResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *StorageConfigResponse +} + +// Status returns HTTPResponse.Status +func (r V1GetStorageConfigResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r V1GetStorageConfigResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type V1UpdateStorageConfigResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r V1UpdateStorageConfigResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r V1UpdateStorageConfigResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type V1DeleteHostnameConfigResponse struct { Body []byte HTTPResponse *http.Response @@ -6699,14 +6875,14 @@ func (r V1ListAllFunctionsResponse) StatusCode() int { return 0 } -type CreateFunctionResponse struct { +type V1CreateAFunctionResponse struct { Body []byte HTTPResponse *http.Response JSON201 *FunctionResponse } // Status returns HTTPResponse.Status -func (r CreateFunctionResponse) Status() string { +func (r V1CreateAFunctionResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -6714,7 +6890,7 @@ func (r CreateFunctionResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r CreateFunctionResponse) StatusCode() int { +func (r V1CreateAFunctionResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } @@ -7876,6 +8052,32 @@ func (c *ClientWithResponses) V1UpdatePostgresConfigWithResponse(ctx context.Con return ParseV1UpdatePostgresConfigResponse(rsp) } +// V1GetStorageConfigWithResponse request returning *V1GetStorageConfigResponse +func (c *ClientWithResponses) V1GetStorageConfigWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetStorageConfigResponse, error) { + rsp, err := c.V1GetStorageConfig(ctx, ref, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1GetStorageConfigResponse(rsp) +} + +// V1UpdateStorageConfigWithBodyWithResponse request with arbitrary body returning *V1UpdateStorageConfigResponse +func (c *ClientWithResponses) V1UpdateStorageConfigWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1UpdateStorageConfigResponse, error) { + rsp, err := c.V1UpdateStorageConfigWithBody(ctx, ref, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1UpdateStorageConfigResponse(rsp) +} + +func (c *ClientWithResponses) V1UpdateStorageConfigWithResponse(ctx context.Context, ref string, body V1UpdateStorageConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*V1UpdateStorageConfigResponse, error) { + rsp, err := c.V1UpdateStorageConfig(ctx, ref, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1UpdateStorageConfigResponse(rsp) +} + // V1DeleteHostnameConfigWithResponse request returning *V1DeleteHostnameConfigResponse func (c *ClientWithResponses) V1DeleteHostnameConfigWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1DeleteHostnameConfigResponse, error) { rsp, err := c.V1DeleteHostnameConfig(ctx, ref, reqEditors...) @@ -7990,21 +8192,21 @@ func (c *ClientWithResponses) V1ListAllFunctionsWithResponse(ctx context.Context return ParseV1ListAllFunctionsResponse(rsp) } -// CreateFunctionWithBodyWithResponse request with arbitrary body returning *CreateFunctionResponse -func (c *ClientWithResponses) CreateFunctionWithBodyWithResponse(ctx context.Context, ref string, params *CreateFunctionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateFunctionResponse, error) { - rsp, err := c.CreateFunctionWithBody(ctx, ref, params, contentType, body, reqEditors...) +// V1CreateAFunctionWithBodyWithResponse request with arbitrary body returning *V1CreateAFunctionResponse +func (c *ClientWithResponses) V1CreateAFunctionWithBodyWithResponse(ctx context.Context, ref string, params *V1CreateAFunctionParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1CreateAFunctionResponse, error) { + rsp, err := c.V1CreateAFunctionWithBody(ctx, ref, params, contentType, body, reqEditors...) if err != nil { return nil, err } - return ParseCreateFunctionResponse(rsp) + return ParseV1CreateAFunctionResponse(rsp) } -func (c *ClientWithResponses) CreateFunctionWithResponse(ctx context.Context, ref string, params *CreateFunctionParams, body CreateFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateFunctionResponse, error) { - rsp, err := c.CreateFunction(ctx, ref, params, body, reqEditors...) +func (c *ClientWithResponses) V1CreateAFunctionWithResponse(ctx context.Context, ref string, params *V1CreateAFunctionParams, body V1CreateAFunctionJSONRequestBody, reqEditors ...RequestEditorFn) (*V1CreateAFunctionResponse, error) { + rsp, err := c.V1CreateAFunction(ctx, ref, params, body, reqEditors...) if err != nil { return nil, err } - return ParseCreateFunctionResponse(rsp) + return ParseV1CreateAFunctionResponse(rsp) } // V1DeleteAFunctionWithResponse request returning *V1DeleteAFunctionResponse @@ -9350,6 +9552,48 @@ func ParseV1UpdatePostgresConfigResponse(rsp *http.Response) (*V1UpdatePostgresC return response, nil } +// ParseV1GetStorageConfigResponse parses an HTTP response from a V1GetStorageConfigWithResponse call +func ParseV1GetStorageConfigResponse(rsp *http.Response) (*V1GetStorageConfigResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &V1GetStorageConfigResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest StorageConfigResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseV1UpdateStorageConfigResponse parses an HTTP response from a V1UpdateStorageConfigWithResponse call +func ParseV1UpdateStorageConfigResponse(rsp *http.Response) (*V1UpdateStorageConfigResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &V1UpdateStorageConfigResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + // ParseV1DeleteHostnameConfigResponse parses an HTTP response from a V1DeleteHostnameConfigWithResponse call func ParseV1DeleteHostnameConfigResponse(rsp *http.Response) (*V1DeleteHostnameConfigResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -9580,15 +9824,15 @@ func ParseV1ListAllFunctionsResponse(rsp *http.Response) (*V1ListAllFunctionsRes return response, nil } -// ParseCreateFunctionResponse parses an HTTP response from a CreateFunctionWithResponse call -func ParseCreateFunctionResponse(rsp *http.Response) (*CreateFunctionResponse, error) { +// ParseV1CreateAFunctionResponse parses an HTTP response from a V1CreateAFunctionWithResponse call +func ParseV1CreateAFunctionResponse(rsp *http.Response) (*V1CreateAFunctionResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CreateFunctionResponse{ + response := &V1CreateAFunctionResponse{ Body: bodyBytes, HTTPResponse: rsp, } diff --git a/pkg/api/types.gen.go b/pkg/api/types.gen.go index 77714f6c3..a7376d51e 100644 --- a/pkg/api/types.gen.go +++ b/pkg/api/types.gen.go @@ -33,6 +33,7 @@ const ( BranchDetailResponseStatusPAUSEFAILED BranchDetailResponseStatus = "PAUSE_FAILED" BranchDetailResponseStatusPAUSING BranchDetailResponseStatus = "PAUSING" BranchDetailResponseStatusREMOVED BranchDetailResponseStatus = "REMOVED" + BranchDetailResponseStatusRESIZING BranchDetailResponseStatus = "RESIZING" BranchDetailResponseStatusRESTARTING BranchDetailResponseStatus = "RESTARTING" BranchDetailResponseStatusRESTOREFAILED BranchDetailResponseStatus = "RESTORE_FAILED" BranchDetailResponseStatusRESTORING BranchDetailResponseStatus = "RESTORING" @@ -335,6 +336,7 @@ const ( V1ProjectResponseStatusPAUSEFAILED V1ProjectResponseStatus = "PAUSE_FAILED" V1ProjectResponseStatusPAUSING V1ProjectResponseStatus = "PAUSING" V1ProjectResponseStatusREMOVED V1ProjectResponseStatus = "REMOVED" + V1ProjectResponseStatusRESIZING V1ProjectResponseStatus = "RESIZING" V1ProjectResponseStatusRESTARTING V1ProjectResponseStatus = "RESTARTING" V1ProjectResponseStatusRESTOREFAILED V1ProjectResponseStatus = "RESTORE_FAILED" V1ProjectResponseStatusRESTORING V1ProjectResponseStatus = "RESTORING" @@ -652,7 +654,8 @@ type BranchDetailResponseStatus string // BranchResetResponse defines model for BranchResetResponse. type BranchResetResponse struct { - Message string `json:"message"` + Message string `json:"message"` + WorkflowRunId string `json:"workflow_run_id"` } // BranchResponse defines model for BranchResponse. @@ -1138,6 +1141,22 @@ type SslValidation struct { ValidationRecords []ValidationRecord `json:"validation_records"` } +// StorageConfigResponse defines model for StorageConfigResponse. +type StorageConfigResponse struct { + Features StorageFeatures `json:"features"` + FileSizeLimit float32 `json:"fileSizeLimit"` +} + +// StorageFeatureImageTransformation defines model for StorageFeatureImageTransformation. +type StorageFeatureImageTransformation struct { + Enabled bool `json:"enabled"` +} + +// StorageFeatures defines model for StorageFeatures. +type StorageFeatures struct { + ImageTransformation StorageFeatureImageTransformation `json:"imageTransformation"` +} + // SubdomainAvailabilityResponse defines model for SubdomainAvailabilityResponse. type SubdomainAvailabilityResponse struct { Available bool `json:"available"` @@ -1450,6 +1469,12 @@ type UpdateProviderResponse struct { UpdatedAt *string `json:"updated_at,omitempty"` } +// UpdateStorageConfigBody defines model for UpdateStorageConfigBody. +type UpdateStorageConfigBody struct { + Features *StorageFeatures `json:"features,omitempty"` + FileSizeLimit *float32 `json:"fileSizeLimit,omitempty"` +} + // UpdateSupavisorConfigBody defines model for UpdateSupavisorConfigBody. type UpdateSupavisorConfigBody struct { DefaultPoolSize *int `json:"default_pool_size"` @@ -1725,8 +1750,8 @@ type V1AuthorizeUserParamsResponseType string // V1AuthorizeUserParamsCodeChallengeMethod defines parameters for V1AuthorizeUser. type V1AuthorizeUserParamsCodeChallengeMethod string -// CreateFunctionParams defines parameters for CreateFunction. -type CreateFunctionParams struct { +// V1CreateAFunctionParams defines parameters for V1CreateAFunction. +type V1CreateAFunctionParams struct { Slug *string `form:"slug,omitempty" json:"slug,omitempty"` Name *string `form:"name,omitempty" json:"name,omitempty"` VerifyJwt *bool `form:"verify_jwt,omitempty" json:"verify_jwt,omitempty"` @@ -1814,6 +1839,9 @@ type V1UpdateSupavisorConfigJSONRequestBody = UpdateSupavisorConfigBody // V1UpdatePostgresConfigJSONRequestBody defines body for V1UpdatePostgresConfig for application/json ContentType. type V1UpdatePostgresConfigJSONRequestBody = UpdatePostgresConfigBody +// V1UpdateStorageConfigJSONRequestBody defines body for V1UpdateStorageConfig for application/json ContentType. +type V1UpdateStorageConfigJSONRequestBody = UpdateStorageConfigBody + // V1UpdateHostnameConfigJSONRequestBody defines body for V1UpdateHostnameConfig for application/json ContentType. type V1UpdateHostnameConfigJSONRequestBody = UpdateCustomHostnameBody @@ -1823,8 +1851,8 @@ type V1RestorePitrBackupJSONRequestBody = V1RestorePitrBody // V1RunAQueryJSONRequestBody defines body for V1RunAQuery for application/json ContentType. type V1RunAQueryJSONRequestBody = V1RunQueryBody -// CreateFunctionJSONRequestBody defines body for CreateFunction for application/json ContentType. -type CreateFunctionJSONRequestBody = V1CreateFunctionBody +// V1CreateAFunctionJSONRequestBody defines body for V1CreateAFunction for application/json ContentType. +type V1CreateAFunctionJSONRequestBody = V1CreateFunctionBody // V1UpdateAFunctionJSONRequestBody defines body for V1UpdateAFunction for application/json ContentType. type V1UpdateAFunctionJSONRequestBody = V1UpdateFunctionBody diff --git a/pkg/function/batch.go b/pkg/function/batch.go index cf5a2f161..1d52bace4 100644 --- a/pkg/function/batch.go +++ b/pkg/function/batch.go @@ -61,7 +61,7 @@ func (s *EdgeRuntimeAPI) UpsertFunctions(ctx context.Context, functionConfig con return errors.Errorf("unexpected status %d: %s", resp.StatusCode(), string(resp.Body)) } } else { - if resp, err := s.client.CreateFunctionWithBodyWithResponse(ctx, s.project, &api.CreateFunctionParams{ + if resp, err := s.client.V1CreateAFunctionWithBodyWithResponse(ctx, s.project, &api.V1CreateAFunctionParams{ Slug: &slug, Name: &slug, VerifyJwt: function.VerifyJWT, From bf9f40e5c9ba3a4b806ab582fa964702b1df387b Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Tue, 29 Oct 2024 15:13:26 +0800 Subject: [PATCH 112/305] fix(config): resolve objects path when loading buckets config --- internal/seed/buckets/buckets.go | 11 +---------- pkg/config/config.go | 3 +++ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/internal/seed/buckets/buckets.go b/internal/seed/buckets/buckets.go index 2af80b43d..365c3a395 100644 --- a/internal/seed/buckets/buckets.go +++ b/internal/seed/buckets/buckets.go @@ -3,12 +3,10 @@ package buckets import ( "context" "fmt" - "path/filepath" "github.com/spf13/afero" "github.com/supabase/cli/internal/storage/client" "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/config" ) func Run(ctx context.Context, projectRef string, interactive bool, fsys afero.Fs) error { @@ -31,12 +29,5 @@ func Run(ctx context.Context, projectRef string, interactive bool, fsys afero.Fs if err := api.UpsertBuckets(ctx, utils.Config.Storage.Buckets, filter); err != nil { return err } - resolved := config.BucketConfig{} - for name, bucket := range utils.Config.Storage.Buckets { - if len(bucket.ObjectsPath) > 0 && !filepath.IsAbs(bucket.ObjectsPath) { - bucket.ObjectsPath = filepath.Join(utils.SupabaseDirPath, bucket.ObjectsPath) - } - resolved[name] = bucket - } - return api.UpsertObjects(ctx, resolved, utils.NewRootFS(fsys)) + return api.UpsertObjects(ctx, utils.Config.Storage.Buckets, utils.NewRootFS(fsys)) } diff --git a/pkg/config/config.go b/pkg/config/config.go index 9c2210608..01b0390df 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -678,6 +678,9 @@ func (c *config) Load(path string, fsys fs.FS) error { if bucket.FileSizeLimit == 0 { bucket.FileSizeLimit = c.Storage.FileSizeLimit } + if len(bucket.ObjectsPath) > 0 && !filepath.IsAbs(bucket.ObjectsPath) { + bucket.ObjectsPath = filepath.Join(builder.SupabaseDirPath, bucket.ObjectsPath) + } c.Storage.Buckets[name] = bucket } for slug, function := range c.Functions { From 398b7b7c20dee66e21f1a87cb47607f4a514e4f0 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 30 Oct 2024 10:42:42 +0800 Subject: [PATCH 113/305] feat(functions): allow custom functions entrypoint path (#2813) * feat(functions): allow custom functions entrypoint path * fix: convert entrypoint path to file url --- internal/functions/deploy/bundle.go | 6 +++--- internal/functions/deploy/deploy.go | 4 ++++ internal/functions/serve/serve.go | 10 ++++------ internal/functions/serve/templates/main.ts | 11 ++++++++--- pkg/config/config.go | 4 ++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/internal/functions/deploy/bundle.go b/internal/functions/deploy/bundle.go index 0b178b0f7..0119a559c 100644 --- a/internal/functions/deploy/bundle.go +++ b/internal/functions/deploy/bundle.go @@ -44,8 +44,7 @@ func (b *dockerBundler) Bundle(ctx context.Context, entrypoint string, importMap } }() // Create bind mounts - hostEntrypointDir := filepath.Dir(entrypoint) - binds, err := GetBindMounts(cwd, utils.FunctionsDir, hostOutputDir, hostEntrypointDir, importMap, b.fsys) + binds, err := GetBindMounts(cwd, utils.FunctionsDir, hostOutputDir, entrypoint, importMap, b.fsys) if err != nil { return err } @@ -86,7 +85,7 @@ func (b *dockerBundler) Bundle(ctx context.Context, entrypoint string, importMap return function.Compress(eszipBytes, output) } -func GetBindMounts(cwd, hostFuncDir, hostOutputDir, hostEntrypointDir, hostImportMapPath string, fsys afero.Fs) ([]string, error) { +func GetBindMounts(cwd, hostFuncDir, hostOutputDir, hostEntrypointPath, hostImportMapPath string, fsys afero.Fs) ([]string, error) { sep := string(filepath.Separator) // Docker requires all host paths to be absolute if !filepath.IsAbs(hostFuncDir) { @@ -116,6 +115,7 @@ func GetBindMounts(cwd, hostFuncDir, hostOutputDir, hostEntrypointDir, hostImpor } } // Allow entrypoints outside the functions directory + hostEntrypointDir := filepath.Dir(hostEntrypointPath) if len(hostEntrypointDir) > 0 { if !filepath.IsAbs(hostEntrypointDir) { hostEntrypointDir = filepath.Join(cwd, hostEntrypointDir) diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index b18565d20..855d44537 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -58,6 +58,10 @@ func GetFunctionSlugs(fsys afero.Fs) (slugs []string, err error) { slugs = append(slugs, slug) } } + // Add all function slugs declared in config file + for slug := range utils.Config.Functions { + slugs = append(slugs, slug) + } return slugs, nil } diff --git a/internal/functions/serve/serve.go b/internal/functions/serve/serve.go index 15320171d..62811d769 100644 --- a/internal/functions/serve/serve.go +++ b/internal/functions/serve/serve.go @@ -109,11 +109,6 @@ func ServeFunctions(ctx context.Context, envFilePath string, noVerifyJWT *bool, if err != nil { return err } - cwd, err := os.Getwd() - if err != nil { - return errors.Errorf("failed to get working directory: %w", err) - } - dockerFuncDir := utils.ToDockerPath(filepath.Join(cwd, utils.FunctionsDir)) env = append(env, fmt.Sprintf("SUPABASE_URL=http://%s:8000", utils.KongAliases[0]), "SUPABASE_ANON_KEY="+utils.Config.Auth.AnonKey, @@ -121,7 +116,6 @@ func ServeFunctions(ctx context.Context, envFilePath string, noVerifyJWT *bool, "SUPABASE_DB_URL="+dbUrl, "SUPABASE_INTERNAL_JWT_SECRET="+utils.Config.Auth.JwtSecret, fmt.Sprintf("SUPABASE_INTERNAL_HOST_PORT=%d", utils.Config.Api.Port), - "SUPABASE_INTERNAL_FUNCTIONS_PATH="+dockerFuncDir, ) if viper.GetBool("DEBUG") { env = append(env, "SUPABASE_INTERNAL_DEBUG=true") @@ -130,6 +124,10 @@ func ServeFunctions(ctx context.Context, envFilePath string, noVerifyJWT *bool, env = append(env, "SUPABASE_INTERNAL_WALLCLOCK_LIMIT_SEC=0") } // 3. Parse custom import map + cwd, err := os.Getwd() + if err != nil { + return errors.Errorf("failed to get working directory: %w", err) + } binds, functionsConfigString, err := populatePerFunctionConfigs(cwd, importMapPath, noVerifyJWT, fsys) if err != nil { return err diff --git a/internal/functions/serve/templates/main.ts b/internal/functions/serve/templates/main.ts index c96847e3e..e94b183ac 100644 --- a/internal/functions/serve/templates/main.ts +++ b/internal/functions/serve/templates/main.ts @@ -2,6 +2,7 @@ import { STATUS_CODE, STATUS_TEXT, } from "https://deno.land/std/http/status.ts"; +import * as posix from "https://deno.land/std/path/posix/mod.ts"; import * as jose from "https://deno.land/x/jose@v4.13.1/index.ts"; @@ -28,7 +29,6 @@ const EXCLUDED_ENVS = ["HOME", "HOSTNAME", "PATH", "PWD"]; const JWT_SECRET = Deno.env.get("SUPABASE_INTERNAL_JWT_SECRET")!; const HOST_PORT = Deno.env.get("SUPABASE_INTERNAL_HOST_PORT")!; -const FUNCTIONS_PATH = Deno.env.get("SUPABASE_INTERNAL_FUNCTIONS_PATH")!; const DEBUG = Deno.env.get("SUPABASE_INTERNAL_DEBUG") === "true"; const FUNCTIONS_CONFIG_STRING = Deno.env.get( "SUPABASE_INTERNAL_FUNCTIONS_CONFIG", @@ -43,6 +43,7 @@ const DENO_SB_ERROR_MAP = new Map([ ]); interface FunctionConfig { + entrypointPath: string; importMapPath: string; verifyJWT: boolean; } @@ -144,7 +145,7 @@ Deno.serve({ } } - const servicePath = `${FUNCTIONS_PATH}/${functionName}`; + const servicePath = posix.dirname(functionsConfig[functionName].entrypointPath); console.error(`serving the request with ${servicePath}`); // Ref: https://supabase.com/docs/guides/functions/limits @@ -167,6 +168,9 @@ Deno.serve({ // point, as their migration process will not be easy. const decoratorType = "tc39"; + const absEntrypoint = posix.join(Deno.cwd(), functionsConfig[functionName].entrypointPath); + const maybeEntrypoint = posix.toFileUrl(absEntrypoint).href; + try { const worker = await EdgeRuntime.userWorkers.create({ servicePath, @@ -179,7 +183,8 @@ Deno.serve({ customModuleRoot, cpuTimeSoftLimitMs, cpuTimeHardLimitMs, - decoratorType + decoratorType, + maybeEntrypoint }); const controller = new AbortController(); diff --git a/pkg/config/config.go b/pkg/config/config.go index 01b0390df..8f57a21bd 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -371,10 +371,10 @@ type ( FunctionConfig map[string]function function struct { - Enabled *bool `toml:"enabled"` + Enabled *bool `toml:"enabled" json:"-"` VerifyJWT *bool `toml:"verify_jwt" json:"verifyJWT"` ImportMap string `toml:"import_map" json:"importMapPath,omitempty"` - Entrypoint string `json:"-"` + Entrypoint string `toml:"entrypoint" json:"entrypointPath,omitempty"` } analytics struct { From 4d2e5c3129c630cf5d9db49d32cfa89202546b47 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:07:52 +0800 Subject: [PATCH 114/305] chore(deps): bump github.com/Netflix/go-env from 0.1.0 to 0.1.2 (#2809) * chore(deps): bump github.com/Netflix/go-env from 0.1.0 to 0.1.2 Bumps [github.com/Netflix/go-env](https://github.com/Netflix/go-env) from 0.1.0 to 0.1.2. - [Release notes](https://github.com/Netflix/go-env/releases) - [Commits](https://github.com/Netflix/go-env/compare/v0.1.0...v0.1.2) --- updated-dependencies: - dependency-name: github.com/Netflix/go-env dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * chore: bump golang to 1.23 --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Qiao Han --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 2abddb9f5..b1f94ae6b 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/supabase/cli -go 1.22.4 +go 1.23.2 require ( github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c - github.com/Netflix/go-env v0.1.0 + github.com/Netflix/go-env v0.1.2 github.com/andybalholm/brotli v1.1.1 github.com/cenkalti/backoff/v4 v4.3.0 github.com/charmbracelet/bubbles v0.18.0 diff --git a/go.sum b/go.sum index 3814c1303..224110f05 100644 --- a/go.sum +++ b/go.sum @@ -67,8 +67,8 @@ github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lpr github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY= github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY= github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= -github.com/Netflix/go-env v0.1.0 h1:qSMk2A4D6urE/YqOKpLeOkaATGmFmMLo56E7kNNKypk= -github.com/Netflix/go-env v0.1.0/go.mod h1:9IRTAm+pQDPMpUtMLR26JOrjHnAWz3KUbhaegqTdhfY= +github.com/Netflix/go-env v0.1.2 h1:0DRoLR9lECQ9Zqvkswuebm3jJ/2enaDX6Ei8/Z+EnK0= +github.com/Netflix/go-env v0.1.2/go.mod h1:WlIhYi++8FlKNJtrop1mjXYAJMzv1f43K4MqCoh0yGE= github.com/OpenPeeDeeP/depguard/v2 v2.2.0 h1:vDfG60vDtIuf0MEOhmLlLLSzqaRM8EMcgJPdp74zmpA= github.com/OpenPeeDeeP/depguard/v2 v2.2.0/go.mod h1:CIzddKRvLBC4Au5aYP/i3nyaWQ+ClszLIuVocRiCYFQ= github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= From 0109975921928ad295889d03e7453218fd5c1552 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 30 Oct 2024 17:44:56 +0800 Subject: [PATCH 115/305] feat(config): implement storage config update (#2817) * feat(config): implement storage config update * chore: update unit tests --- api/beta.yaml | 5 ++- pkg/api/types.gen.go | 2 +- pkg/config/config.go | 29 ----------------- pkg/config/storage.go | 65 ++++++++++++++++++++++++++++++++++++++ pkg/config/updater.go | 37 ++++++++++++++++++++-- pkg/config/updater_test.go | 61 +++++++++++++++++++++++++++++++++++ 6 files changed, 165 insertions(+), 34 deletions(-) create mode 100644 pkg/config/storage.go diff --git a/api/beta.yaml b/api/beta.yaml index 62557ab25..51df80999 100644 --- a/api/beta.yaml +++ b/api/beta.yaml @@ -3734,7 +3734,10 @@ components: type: object properties: fileSizeLimit: - type: number + type: integer + minimum: 0 + maximum: 53687091200 + format: int64 features: $ref: '#/components/schemas/StorageFeatures' PostgresConfigResponse: diff --git a/pkg/api/types.gen.go b/pkg/api/types.gen.go index a7376d51e..26f73c43d 100644 --- a/pkg/api/types.gen.go +++ b/pkg/api/types.gen.go @@ -1472,7 +1472,7 @@ type UpdateProviderResponse struct { // UpdateStorageConfigBody defines model for UpdateStorageConfigBody. type UpdateStorageConfigBody struct { Features *StorageFeatures `json:"features,omitempty"` - FileSizeLimit *float32 `json:"fileSizeLimit,omitempty"` + FileSizeLimit *int64 `json:"fileSizeLimit,omitempty"` } // UpdateSupavisorConfigBody defines model for UpdateSupavisorConfigBody. diff --git a/pkg/config/config.go b/pkg/config/config.go index 8f57a21bd..7fb78cd62 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -166,35 +166,6 @@ type ( Pop3Port uint16 `toml:"pop3_port"` } - storage struct { - Enabled bool `toml:"enabled"` - Image string `toml:"-"` - FileSizeLimit sizeInBytes `toml:"file_size_limit"` - S3Credentials storageS3Credentials `toml:"-"` - ImageTransformation imageTransformation `toml:"image_transformation"` - Buckets BucketConfig `toml:"buckets"` - } - - BucketConfig map[string]bucket - - bucket struct { - Public *bool `toml:"public"` - FileSizeLimit sizeInBytes `toml:"file_size_limit"` - AllowedMimeTypes []string `toml:"allowed_mime_types"` - ObjectsPath string `toml:"objects_path"` - } - - imageTransformation struct { - Enabled bool `toml:"enabled"` - Image string `toml:"-"` - } - - storageS3Credentials struct { - AccessKeyId string `toml:"-"` - SecretAccessKey string `toml:"-"` - Region string `toml:"-"` - } - auth struct { Enabled bool `toml:"enabled"` Image string `toml:"-"` diff --git a/pkg/config/storage.go b/pkg/config/storage.go new file mode 100644 index 000000000..d2799ce04 --- /dev/null +++ b/pkg/config/storage.go @@ -0,0 +1,65 @@ +package config + +import ( + v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/diff" +) + +type ( + storage struct { + Enabled bool `toml:"enabled"` + Image string `toml:"-"` + FileSizeLimit sizeInBytes `toml:"file_size_limit"` + S3Credentials storageS3Credentials `toml:"-"` + ImageTransformation imageTransformation `toml:"image_transformation"` + Buckets BucketConfig `toml:"buckets"` + } + + imageTransformation struct { + Enabled bool `toml:"enabled"` + Image string `toml:"-"` + } + + storageS3Credentials struct { + AccessKeyId string `toml:"-"` + SecretAccessKey string `toml:"-"` + Region string `toml:"-"` + } + + BucketConfig map[string]bucket + + bucket struct { + Public *bool `toml:"public"` + FileSizeLimit sizeInBytes `toml:"file_size_limit"` + AllowedMimeTypes []string `toml:"allowed_mime_types"` + ObjectsPath string `toml:"objects_path"` + } +) + +func (s *storage) ToUpdateStorageConfigBody() v1API.UpdateStorageConfigBody { + body := v1API.UpdateStorageConfigBody{Features: &v1API.StorageFeatures{}} + body.FileSizeLimit = cast.Ptr(int64(s.FileSizeLimit)) + body.Features.ImageTransformation.Enabled = s.ImageTransformation.Enabled + return body +} + +func (s *storage) fromRemoteStorageConfig(remoteConfig v1API.StorageConfigResponse) storage { + result := *s + result.FileSizeLimit = sizeInBytes(remoteConfig.FileSizeLimit) + result.ImageTransformation.Enabled = remoteConfig.Features.ImageTransformation.Enabled + return result +} + +func (s *storage) DiffWithRemote(remoteConfig v1API.StorageConfigResponse) ([]byte, error) { + // Convert the config values into easily comparable remoteConfig values + currentValue, err := ToTomlBytes(s) + if err != nil { + return nil, err + } + remoteCompare, err := ToTomlBytes(s.fromRemoteStorageConfig(remoteConfig)) + if err != nil { + return nil, err + } + return diff.Diff("remote[storage]", remoteCompare, "local[storage]", currentValue), nil +} diff --git a/pkg/config/updater.go b/pkg/config/updater.go index c7739eded..04924124a 100644 --- a/pkg/config/updater.go +++ b/pkg/config/updater.go @@ -24,6 +24,9 @@ func (u *ConfigUpdater) UpdateRemoteConfig(ctx context.Context, remote baseConfi if err := u.UpdateDbConfig(ctx, remote.ProjectId, remote.Db); err != nil { return err } + if err := u.UpdateStorageConfig(ctx, remote.ProjectId, remote.Storage); err != nil { + return err + } if err := u.UpdateExperimentalConfig(ctx, remote.ProjectId, remote.Experimental); err != nil { return err } @@ -69,6 +72,7 @@ func (u *ConfigUpdater) UpdateDbSettingsConfig(ctx context.Context, projectRef s return nil } fmt.Fprintln(os.Stderr, "Updating DB service with config:", string(dbDiff)) + remoteConfig := s.fromRemoteConfig(*dbConfig.JSON200) restartRequired := s.requireDbRestart(remoteConfig) if restartRequired { @@ -91,14 +95,41 @@ func (u *ConfigUpdater) UpdateDbConfig(ctx context.Context, projectRef string, c return nil } +func (u *ConfigUpdater) UpdateStorageConfig(ctx context.Context, projectRef string, c storage) error { + if !c.Enabled { + return nil + } + storageConfig, err := u.client.V1GetStorageConfigWithResponse(ctx, projectRef) + if err != nil { + return errors.Errorf("failed to read Storage config: %w", err) + } else if storageConfig.JSON200 == nil { + return errors.Errorf("unexpected status %d: %s", storageConfig.StatusCode(), string(storageConfig.Body)) + } + storageDiff, err := c.DiffWithRemote(*storageConfig.JSON200) + if err != nil { + return err + } else if len(storageDiff) == 0 { + fmt.Fprintln(os.Stderr, "Remote Storage config is up to date.") + return nil + } + fmt.Fprintln(os.Stderr, "Updating Storage service with config:", string(storageDiff)) + + if resp, err := u.client.V1UpdateStorageConfigWithResponse(ctx, projectRef, c.ToUpdateStorageConfigBody()); err != nil { + return errors.Errorf("failed to update Storage config: %w", err) + } else if status := resp.StatusCode(); status < 200 || status >= 300 { + return errors.Errorf("unexpected status %d: %s", status, string(resp.Body)) + } + return nil +} + func (u *ConfigUpdater) UpdateExperimentalConfig(ctx context.Context, projectRef string, exp experimental) error { if exp.Webhooks != nil && exp.Webhooks.Enabled { - fmt.Fprintln(os.Stderr, "Enabling webhooks for the project...") + fmt.Fprintln(os.Stderr, "Enabling webhooks for project:", projectRef) if resp, err := u.client.V1EnableDatabaseWebhookWithResponse(ctx, projectRef); err != nil { return errors.Errorf("failed to enable webhooks: %w", err) - } else if resp.StatusCode() < 200 || resp.StatusCode() >= 300 { - return errors.Errorf("unexpected enable webhook status %d: %s", resp.StatusCode(), string(resp.Body)) + } else if status := resp.StatusCode(); status < 200 || status >= 300 { + return errors.Errorf("unexpected enable webhook status %d: %s", status, string(resp.Body)) } } return nil diff --git a/pkg/config/updater_test.go b/pkg/config/updater_test.go index 2ad07c998..e0507dbde 100644 --- a/pkg/config/updater_test.go +++ b/pkg/config/updater_test.go @@ -155,6 +155,52 @@ func TestUpdateExperimentalConfig(t *testing.T) { }) } +func TestUpdateStorageConfig(t *testing.T) { + server := "http://localhost" + client, err := v1API.NewClientWithResponses(server) + require.NoError(t, err) + + t.Run("updates remote Storage config", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Setup mock server + defer gock.Off() + gock.New(server). + Get("/v1/projects/test-project/config/storage"). + Reply(http.StatusOK). + JSON(v1API.StorageConfigResponse{ + FileSizeLimit: 100, + Features: v1API.StorageFeatures{ + ImageTransformation: v1API.StorageFeatureImageTransformation{ + Enabled: true, + }, + }, + }) + gock.New(server). + Patch("/v1/projects/test-project/config/storage"). + Reply(http.StatusOK) + // Run test + err := updater.UpdateStorageConfig(context.Background(), "test-project", storage{Enabled: true}) + // Check result + assert.NoError(t, err) + assert.True(t, gock.IsDone()) + }) + + t.Run("skips update if no diff in Storage config", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Setup mock server + defer gock.Off() + gock.New(server). + Get("/v1/projects/test-project/config/storage"). + Reply(http.StatusOK). + JSON(v1API.StorageConfigResponse{}) + // Run test + err := updater.UpdateStorageConfig(context.Background(), "test-project", storage{Enabled: true}) + // Check result + assert.NoError(t, err) + assert.True(t, gock.IsDone()) + }) +} + func TestUpdateRemoteConfig(t *testing.T) { server := "http://localhost" client, err := v1API.NewClientWithResponses(server) @@ -187,6 +233,14 @@ func TestUpdateRemoteConfig(t *testing.T) { JSON(v1API.PostgresConfigResponse{ MaxConnections: cast.Ptr(cast.UintToInt(100)), }) + // Storage config + gock.New(server). + Get("/v1/projects/test-project/config/storage"). + Reply(http.StatusOK). + JSON(v1API.StorageConfigResponse{}) + gock.New(server). + Patch("/v1/projects/test-project/config/storage"). + Reply(http.StatusOK) // Experimental config gock.New(server). Post("/v1/projects/test-project/database/webhooks/enable"). @@ -205,6 +259,13 @@ func TestUpdateRemoteConfig(t *testing.T) { MaxConnections: cast.Ptr(cast.IntToUint(100)), }, }, + Storage: storage{ + Enabled: true, + FileSizeLimit: 100, + ImageTransformation: imageTransformation{ + Enabled: true, + }, + }, Experimental: experimental{ Webhooks: &webhooks{ Enabled: true, From cf2136a66bb0df86994e410fb98b817e83c5b1aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Thu, 31 Oct 2024 15:17:27 +0900 Subject: [PATCH 116/305] fix: bump edge-runtime to 1.59.1 (#2819) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index ce291b465..cd7befff5 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241029-46e1e40" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.59.0" + edgeRuntimeImage = "supabase/edge-runtime:v1.59.1" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.163.2" From 68f9c56241a011809f571e2f47e4c81bdeb97587 Mon Sep 17 00:00:00 2001 From: Chris Gwilliams <517923+encima@users.noreply.github.com> Date: Thu, 31 Oct 2024 08:56:48 +0200 Subject: [PATCH 117/305] feat(inspect): add role-configs command to list db roles with custom settings (#2818) * added role-configs command to list users with custom settings * Update internal/inspect/role_configs/role_configs.go --------- Co-authored-by: Han Qiao --- cmd/inspect.go | 10 ++++ internal/inspect/report_test.go | 5 +- internal/inspect/role_configs/role_configs.go | 46 +++++++++++++++++++ .../inspect/role_configs/role_configs.sql | 5 ++ .../inspect/role_configs/role_configs_test.go | 38 +++++++++++++++ 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 internal/inspect/role_configs/role_configs.go create mode 100644 internal/inspect/role_configs/role_configs.sql create mode 100644 internal/inspect/role_configs/role_configs_test.go diff --git a/cmd/inspect.go b/cmd/inspect.go index 299524fbe..2b55c3876 100644 --- a/cmd/inspect.go +++ b/cmd/inspect.go @@ -22,6 +22,7 @@ import ( "github.com/supabase/cli/internal/inspect/long_running_queries" "github.com/supabase/cli/internal/inspect/outliers" "github.com/supabase/cli/internal/inspect/replication_slots" + "github.com/supabase/cli/internal/inspect/role_configs" "github.com/supabase/cli/internal/inspect/role_connections" "github.com/supabase/cli/internal/inspect/seq_scans" "github.com/supabase/cli/internal/inspect/table_index_sizes" @@ -194,6 +195,14 @@ var ( }, } + inspectRoleConfigsCmd = &cobra.Command{ + Use: "role-configs", + Short: "Show configuration settings for database roles when they have been modified", + RunE: func(cmd *cobra.Command, args []string) error { + return role_configs.Run(cmd.Context(), flags.DbConfig, afero.NewOsFs()) + }, + } + inspectRoleConnectionsCmd = &cobra.Command{ Use: "role-connections", Short: "Show number of active connections for all database roles", @@ -247,6 +256,7 @@ func init() { inspectDBCmd.AddCommand(inspectTableRecordCountsCmd) inspectDBCmd.AddCommand(inspectBloatCmd) inspectDBCmd.AddCommand(inspectVacuumStatsCmd) + inspectDBCmd.AddCommand(inspectRoleConfigsCmd) inspectDBCmd.AddCommand(inspectRoleConnectionsCmd) inspectCmd.AddCommand(inspectDBCmd) reportCmd.Flags().StringVar(&outputDir, "output-dir", "", "Path to save CSV files in") diff --git a/internal/inspect/report_test.go b/internal/inspect/report_test.go index 4de1ab602..6b4220451 100644 --- a/internal/inspect/report_test.go +++ b/internal/inspect/report_test.go @@ -18,6 +18,7 @@ import ( "github.com/supabase/cli/internal/inspect/long_running_queries" "github.com/supabase/cli/internal/inspect/outliers" "github.com/supabase/cli/internal/inspect/replication_slots" + "github.com/supabase/cli/internal/inspect/role_configs" "github.com/supabase/cli/internal/inspect/role_connections" "github.com/supabase/cli/internal/inspect/seq_scans" "github.com/supabase/cli/internal/inspect/table_index_sizes" @@ -65,6 +66,8 @@ func TestReportCommand(t *testing.T) { Reply("COPY 0"). Query(wrapQuery(replication_slots.ReplicationSlotsQuery)). Reply("COPY 0"). + Query(wrapQuery(role_configs.RoleConfigsQuery)). + Reply("COPY 0"). Query(wrapQuery(role_connections.RoleConnectionsQuery)). Reply("COPY 0"). Query(wrapQuery(seq_scans.SeqScansQuery)). @@ -89,7 +92,7 @@ func TestReportCommand(t *testing.T) { assert.NoError(t, err) matches, err := afero.Glob(fsys, "*.csv") assert.NoError(t, err) - assert.Len(t, matches, 19) + assert.Len(t, matches, 20) }) } diff --git a/internal/inspect/role_configs/role_configs.go b/internal/inspect/role_configs/role_configs.go new file mode 100644 index 000000000..f4fb79382 --- /dev/null +++ b/internal/inspect/role_configs/role_configs.go @@ -0,0 +1,46 @@ +package role_configs + +import ( + "context" + _ "embed" + "fmt" + + "github.com/go-errors/errors" + "github.com/jackc/pgconn" + "github.com/jackc/pgx/v4" + "github.com/spf13/afero" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" +) + +//go:embed role_configs.sql +var RoleConfigsQuery string + +type Result struct { + Role_name string + Custom_config string +} + +func Run(ctx context.Context, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { + conn, err := utils.ConnectByConfig(ctx, config, options...) + if err != nil { + return err + } + defer conn.Close(context.Background()) + rows, err := conn.Query(ctx, RoleConfigsQuery) + if err != nil { + return errors.Errorf("failed to query rows: %w", err) + } + result, err := pgxv5.CollectRows[Result](rows) + if err != nil { + return err + } + + table := "|Role name|Custom config|\n|-|-|\n" + for _, r := range result { + table += fmt.Sprintf("|`%s`|`%s`|\n", r.Role_name, r.Custom_config) + } + + return list.RenderTable(table) +} diff --git a/internal/inspect/role_configs/role_configs.sql b/internal/inspect/role_configs/role_configs.sql new file mode 100644 index 000000000..d568d6862 --- /dev/null +++ b/internal/inspect/role_configs/role_configs.sql @@ -0,0 +1,5 @@ +select + rolname as role_name, + array_to_string(rolconfig, ',', '*') as custom_config +from + pg_roles where rolconfig is not null; diff --git a/internal/inspect/role_configs/role_configs_test.go b/internal/inspect/role_configs/role_configs_test.go new file mode 100644 index 000000000..554a12526 --- /dev/null +++ b/internal/inspect/role_configs/role_configs_test.go @@ -0,0 +1,38 @@ +package role_configs + +import ( + "context" + "testing" + + "github.com/jackc/pgconn" + "github.com/spf13/afero" + "github.com/stretchr/testify/assert" + "github.com/supabase/cli/pkg/pgtest" +) + +var dbConfig = pgconn.Config{ + Host: "127.0.0.1", + Port: 5432, + User: "admin", + Password: "password", + Database: "postgres", +} + +func TestRoleCommand(t *testing.T) { + t.Run("inspects role connections", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewMemMapFs() + // Setup mock postgres + conn := pgtest.NewConn() + defer conn.Close(t) + conn.Query(RoleConfigsQuery). + Reply("SELECT 1", Result{ + Role_name: "postgres", + Custom_config: "statement_timeout=3s", + }) + // Run test + err := Run(context.Background(), dbConfig, fsys, conn.Intercept) + // Check error + assert.NoError(t, err) + }) +} From 9aec8f2c59100e7014e567474bafaca52ed72024 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Sat, 2 Nov 2024 12:11:34 +0800 Subject: [PATCH 118/305] chore: update generated v1 api client (#2825) --- api/beta.yaml | 467 ++++++++++++++++---------------- internal/functions/list/list.go | 4 +- internal/link/link.go | 4 +- pkg/api/types.gen.go | 454 ++++++++++++++++--------------- 4 files changed, 469 insertions(+), 460 deletions(-) diff --git a/api/beta.yaml b/api/beta.yaml index 51df80999..ff547903e 100644 --- a/api/beta.yaml +++ b/api/beta.yaml @@ -2643,6 +2643,12 @@ components: BranchResponse: type: object properties: + pr_number: + type: integer + format: int32 + latest_check_run_id: + type: integer + format: int64 id: type: string name: @@ -2655,10 +2661,6 @@ components: type: boolean git_branch: type: string - pr_number: - type: number - latest_check_run_id: - type: number reset_on_push: type: boolean persistent: @@ -2908,6 +2910,9 @@ components: OAuthTokenResponse: type: object properties: + expires_in: + type: integer + format: int64 token_type: type: string enum: @@ -2916,18 +2921,17 @@ components: type: string refresh_token: type: string - expires_in: - type: number required: + - expires_in - token_type - access_token - refresh_token - - expires_in SnippetProject: type: object properties: id: - type: number + type: integer + format: int64 name: type: string required: @@ -2937,7 +2941,8 @@ components: type: object properties: id: - type: number + type: integer + format: int64 username: type: string required: @@ -3379,7 +3384,8 @@ components: type: object properties: id: - type: number + type: integer + format: int64 ref: type: string name: @@ -3513,6 +3519,8 @@ components: properties: current_app_version_release_channel: $ref: '#/components/schemas/ReleaseChannel' + duration_estimate_hours: + type: integer eligible: type: boolean current_app_version: @@ -3527,8 +3535,6 @@ components: type: array items: type: string - duration_estimate_hours: - type: number legacy_auth_custom_roles: type: array items: @@ -3539,23 +3545,29 @@ components: type: string required: - current_app_version_release_channel + - duration_estimate_hours - eligible - current_app_version - latest_app_version - target_upgrade_versions - potential_breaking_changes - - duration_estimate_hours - legacy_auth_custom_roles - extension_dependent_objects DatabaseUpgradeStatus: type: object properties: + target_version: + type: integer + status: + enum: + - 0 + - 1 + - 2 + type: integer initiated_at: type: string latest_status_at: type: string - target_version: - type: number error: type: string enum: @@ -3582,17 +3594,11 @@ components: - 8_attached_volume_to_upgraded_instance - 9_completed_upgrade - 10_completed_post_physical_backup - status: - type: number - enum: - - 0 - - 1 - - 2 required: - - initiated_at - - latest_status_at - target_version - status + - initiated_at + - latest_status_at DatabaseUpgradeStatusResponse: type: object properties: @@ -3655,26 +3661,16 @@ components: properties: name: type: string - version: - type: string - description: - type: string + enum: + - GoTrue required: - name - - version - - description RealtimeHealthResponse: type: object properties: - healthy: - type: boolean - db_connected: - type: boolean connected_cluster: - type: number + type: integer required: - - healthy - - db_connected - connected_cluster V1ServiceHealthResponse: type: object @@ -3724,7 +3720,8 @@ components: type: object properties: fileSizeLimit: - type: number + type: integer + format: int64 features: $ref: '#/components/schemas/StorageFeatures' required: @@ -3884,6 +3881,14 @@ components: SupavisorConfigResponse: type: object properties: + db_port: + type: integer + default_pool_size: + type: integer + nullable: true + max_client_conn: + type: integer + nullable: true identifier: type: string database_type: @@ -3897,34 +3902,26 @@ components: type: string db_host: type: string - db_port: - type: number db_name: type: string connectionString: type: string - default_pool_size: - type: number - nullable: true - max_client_conn: - type: number - nullable: true pool_mode: enum: - transaction - session type: string required: + - db_port + - default_pool_size + - max_client_conn - identifier - database_type - is_using_scram_auth - db_user - db_host - - db_port - db_name - connectionString - - default_pool_size - - max_client_conn - pool_mode UpdateSupavisorConfigBody: type: object @@ -3945,7 +3942,7 @@ components: type: object properties: default_pool_size: - type: number + type: integer nullable: true pool_mode: enum: @@ -3959,10 +3956,67 @@ components: type: object properties: api_max_request_duration: - type: number + type: integer nullable: true db_max_pool_size: - type: number + type: integer + nullable: true + jwt_exp: + type: integer + nullable: true + mailer_otp_exp: + type: integer + mailer_otp_length: + type: integer + nullable: true + mfa_max_enrolled_factors: + type: integer + nullable: true + mfa_phone_otp_length: + type: integer + mfa_phone_max_frequency: + type: integer + nullable: true + password_min_length: + type: integer + nullable: true + rate_limit_anonymous_users: + type: integer + nullable: true + rate_limit_email_sent: + type: integer + nullable: true + rate_limit_sms_sent: + type: integer + nullable: true + rate_limit_token_refresh: + type: integer + nullable: true + rate_limit_verify: + type: integer + nullable: true + rate_limit_otp: + type: integer + nullable: true + security_refresh_token_reuse_interval: + type: integer + nullable: true + sessions_inactivity_timeout: + type: integer + nullable: true + sessions_timebox: + type: integer + nullable: true + sms_max_frequency: + type: integer + nullable: true + sms_otp_exp: + type: integer + nullable: true + sms_otp_length: + type: integer + smtp_max_frequency: + type: integer nullable: true disable_signup: type: boolean @@ -4222,20 +4276,12 @@ components: hook_send_email_secrets: type: string nullable: true - jwt_exp: - type: number - nullable: true mailer_allow_unverified_email_sign_ins: type: boolean nullable: true mailer_autoconfirm: type: boolean nullable: true - mailer_otp_exp: - type: number - mailer_otp_length: - type: number - nullable: true mailer_secure_email_change_enabled: type: boolean nullable: true @@ -4275,9 +4321,6 @@ components: mailer_templates_recovery_content: type: string nullable: true - mfa_max_enrolled_factors: - type: number - nullable: true mfa_totp_enroll_enabled: type: boolean nullable: true @@ -4296,41 +4339,15 @@ components: mfa_web_authn_verify_enabled: type: boolean nullable: true - mfa_phone_otp_length: - type: number mfa_phone_template: type: string nullable: true - mfa_phone_max_frequency: - type: number - nullable: true password_hibp_enabled: type: boolean nullable: true - password_min_length: - type: number - nullable: true password_required_characters: type: string nullable: true - rate_limit_anonymous_users: - type: number - nullable: true - rate_limit_email_sent: - type: number - nullable: true - rate_limit_sms_sent: - type: number - nullable: true - rate_limit_token_refresh: - type: number - nullable: true - rate_limit_verify: - type: number - nullable: true - rate_limit_otp: - type: number - nullable: true refresh_token_rotation_enabled: type: boolean nullable: true @@ -4355,44 +4372,27 @@ components: security_manual_linking_enabled: type: boolean nullable: true - security_refresh_token_reuse_interval: - type: number - nullable: true security_update_password_require_reauthentication: type: boolean nullable: true - sessions_inactivity_timeout: - type: number - nullable: true sessions_single_per_user: type: boolean nullable: true sessions_tags: type: string nullable: true - sessions_timebox: - type: number - nullable: true site_url: type: string nullable: true sms_autoconfirm: type: boolean nullable: true - sms_max_frequency: - type: number - nullable: true sms_messagebird_access_key: type: string nullable: true sms_messagebird_originator: type: string nullable: true - sms_otp_exp: - type: number - nullable: true - sms_otp_length: - type: number sms_provider: type: string nullable: true @@ -4447,9 +4447,6 @@ components: smtp_host: type: string nullable: true - smtp_max_frequency: - type: number - nullable: true smtp_pass: type: string nullable: true @@ -4468,6 +4465,26 @@ components: required: - api_max_request_duration - db_max_pool_size + - jwt_exp + - mailer_otp_exp + - mailer_otp_length + - mfa_max_enrolled_factors + - mfa_phone_otp_length + - mfa_phone_max_frequency + - password_min_length + - rate_limit_anonymous_users + - rate_limit_email_sent + - rate_limit_sms_sent + - rate_limit_token_refresh + - rate_limit_verify + - rate_limit_otp + - security_refresh_token_reuse_interval + - sessions_inactivity_timeout + - sessions_timebox + - sms_max_frequency + - sms_otp_exp + - sms_otp_length + - smtp_max_frequency - disable_signup - external_anonymous_users_enabled - external_apple_additional_client_ids @@ -4554,11 +4571,8 @@ components: - hook_send_email_enabled - hook_send_email_uri - hook_send_email_secrets - - jwt_exp - mailer_allow_unverified_email_sign_ins - mailer_autoconfirm - - mailer_otp_exp - - mailer_otp_length - mailer_secure_email_change_enabled - mailer_subjects_confirmation - mailer_subjects_email_change @@ -4572,25 +4586,15 @@ components: - mailer_templates_magic_link_content - mailer_templates_reauthentication_content - mailer_templates_recovery_content - - mfa_max_enrolled_factors - mfa_totp_enroll_enabled - mfa_totp_verify_enabled - mfa_phone_enroll_enabled - mfa_phone_verify_enabled - mfa_web_authn_enroll_enabled - mfa_web_authn_verify_enabled - - mfa_phone_otp_length - mfa_phone_template - - mfa_phone_max_frequency - password_hibp_enabled - - password_min_length - password_required_characters - - rate_limit_anonymous_users - - rate_limit_email_sent - - rate_limit_sms_sent - - rate_limit_token_refresh - - rate_limit_verify - - rate_limit_otp - refresh_token_rotation_enabled - saml_enabled - saml_external_url @@ -4599,19 +4603,13 @@ components: - security_captcha_provider - security_captcha_secret - security_manual_linking_enabled - - security_refresh_token_reuse_interval - security_update_password_require_reauthentication - - sessions_inactivity_timeout - sessions_single_per_user - sessions_tags - - sessions_timebox - site_url - sms_autoconfirm - - sms_max_frequency - sms_messagebird_access_key - sms_messagebird_originator - - sms_otp_exp - - sms_otp_length - sms_provider - sms_template - sms_test_otp @@ -4630,7 +4628,6 @@ components: - sms_vonage_from - smtp_admin_email - smtp_host - - smtp_max_frequency - smtp_pass - smtp_port - smtp_sender_name @@ -4639,15 +4636,93 @@ components: UpdateAuthConfigBody: type: object properties: + jwt_exp: + type: integer + minimum: 0 + maximum: 604800 + smtp_max_frequency: + type: integer + minimum: 0 + maximum: 32767 + mfa_max_enrolled_factors: + type: integer + minimum: 0 + maximum: 2147483647 + sessions_timebox: + type: integer + minimum: 0 + sessions_inactivity_timeout: + type: integer + minimum: 0 + rate_limit_anonymous_users: + type: integer + minimum: 1 + maximum: 2147483647 + rate_limit_email_sent: + type: integer + minimum: 1 + maximum: 2147483647 + rate_limit_sms_sent: + type: integer + minimum: 1 + maximum: 2147483647 + rate_limit_verify: + type: integer + minimum: 1 + maximum: 2147483647 + rate_limit_token_refresh: + type: integer + minimum: 1 + maximum: 2147483647 + rate_limit_otp: + type: integer + minimum: 1 + maximum: 2147483647 + password_min_length: + type: integer + minimum: 6 + maximum: 32767 + security_refresh_token_reuse_interval: + type: integer + minimum: 0 + maximum: 2147483647 + mailer_otp_exp: + type: integer + minimum: 0 + maximum: 2147483647 + mailer_otp_length: + type: integer + minimum: 6 + maximum: 10 + sms_max_frequency: + type: integer + minimum: 0 + maximum: 32767 + sms_otp_exp: + type: integer + minimum: 0 + maximum: 2147483647 + sms_otp_length: + type: integer + minimum: 0 + maximum: 32767 + db_max_pool_size: + type: integer + api_max_request_duration: + type: integer + mfa_phone_max_frequency: + type: integer + minimum: 0 + maximum: 32767 + mfa_phone_otp_length: + type: integer + minimum: 0 + maximum: 32767 site_url: type: string pattern: /^[^,]+$/ disable_signup: type: boolean - jwt_exp: - type: number - minimum: 0 - maximum: 604800 smtp_admin_email: type: string smtp_host: @@ -4658,10 +4733,6 @@ components: type: string smtp_pass: type: string - smtp_max_frequency: - type: number - minimum: 0 - maximum: 32767 smtp_sender_name: type: string mailer_allow_unverified_email_sign_ins: @@ -4692,10 +4763,6 @@ components: type: string mailer_templates_reauthentication_content: type: string - mfa_max_enrolled_factors: - type: number - minimum: 0 - maximum: 2147483647 uri_allow_list: type: string external_anonymous_users_enabled: @@ -4715,51 +4782,17 @@ components: type: string security_captcha_secret: type: string - sessions_timebox: - type: number - minimum: 0 - sessions_inactivity_timeout: - type: number - minimum: 0 sessions_single_per_user: type: boolean sessions_tags: type: string pattern: /^\s*([a-z0-9_-]+(\s*,+\s*)?)*\s*$/i - rate_limit_anonymous_users: - type: number - minimum: 1 - maximum: 2147483647 - rate_limit_email_sent: - type: number - minimum: 1 - maximum: 2147483647 - rate_limit_sms_sent: - type: number - minimum: 1 - maximum: 2147483647 - rate_limit_verify: - type: number - minimum: 1 - maximum: 2147483647 - rate_limit_token_refresh: - type: number - minimum: 1 - maximum: 2147483647 - rate_limit_otp: - type: number - minimum: 1 - maximum: 2147483647 mailer_secure_email_change_enabled: type: boolean refresh_token_rotation_enabled: type: boolean password_hibp_enabled: type: boolean - password_min_length: - type: number - minimum: 6 - maximum: 32767 password_required_characters: type: string enum: @@ -4771,32 +4804,8 @@ components: type: boolean security_update_password_require_reauthentication: type: boolean - security_refresh_token_reuse_interval: - type: number - minimum: 0 - maximum: 2147483647 - mailer_otp_exp: - type: number - minimum: 0 - maximum: 2147483647 - mailer_otp_length: - type: number - minimum: 6 - maximum: 10 sms_autoconfirm: type: boolean - sms_max_frequency: - type: number - minimum: 0 - maximum: 32767 - sms_otp_exp: - type: number - minimum: 0 - maximum: 2147483647 - sms_otp_length: - type: number - minimum: 0 - maximum: 32767 sms_provider: type: string sms_messagebird_access_key: @@ -4998,10 +5007,6 @@ components: type: string external_zoom_secret: type: string - db_max_pool_size: - type: number - api_max_request_duration: - type: number mfa_totp_enroll_enabled: type: boolean mfa_totp_verify_enabled: @@ -5014,14 +5019,6 @@ components: type: boolean mfa_phone_verify_enabled: type: boolean - mfa_phone_max_frequency: - type: number - minimum: 0 - maximum: 32767 - mfa_phone_otp_length: - type: number - minimum: 0 - maximum: 32767 mfa_phone_template: type: string CreateThirdPartyAuthBody: @@ -5090,6 +5087,14 @@ components: FunctionResponse: type: object properties: + version: + type: integer + created_at: + type: integer + format: int64 + updated_at: + type: integer + format: int64 id: type: string slug: @@ -5102,12 +5107,6 @@ components: - REMOVED - THROTTLED type: string - version: - type: number - created_at: - type: number - updated_at: - type: number verify_jwt: type: boolean import_map: @@ -5117,16 +5116,24 @@ components: import_map_path: type: string required: + - version + - created_at + - updated_at - id - slug - name - status - - version - - created_at - - updated_at FunctionSlugResponse: type: object properties: + version: + type: integer + created_at: + type: integer + format: int64 + updated_at: + type: integer + format: int64 id: type: string slug: @@ -5139,12 +5146,6 @@ components: - REMOVED - THROTTLED type: string - version: - type: number - created_at: - type: number - updated_at: - type: number verify_jwt: type: boolean import_map: @@ -5154,13 +5155,13 @@ components: import_map_path: type: string required: + - version + - created_at + - updated_at - id - slug - name - status - - version - - created_at - - updated_at V1UpdateFunctionBody: type: object properties: @@ -5398,9 +5399,11 @@ components: type: object properties: earliest_physical_backup_date_unix: - type: number + type: integer + format: int64 latest_physical_backup_date_unix: - type: number + type: integer + format: int64 V1BackupsResponse: type: object properties: @@ -5426,7 +5429,9 @@ components: type: object properties: recovery_time_target_unix: - type: number + type: integer + minimum: 0 + format: int64 required: - recovery_time_target_unix V1OrganizationMemberResponse: diff --git a/internal/functions/list/list.go b/internal/functions/list/list.go index aeb17f2cd..d0d2d9ecc 100644 --- a/internal/functions/list/list.go +++ b/internal/functions/list/list.go @@ -25,14 +25,14 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { |-|-|-|-|-|-| ` for _, function := range *resp.JSON200 { - t := time.UnixMilli(int64(function.UpdatedAt)) + t := time.UnixMilli(function.UpdatedAt) table += fmt.Sprintf( "|`%s`|`%s`|`%s`|`%s`|`%d`|`%s`|\n", function.Id, function.Name, function.Slug, function.Status, - uint64(function.Version), + function.Version, t.UTC().Format("2006-01-02 15:04:05"), ) } diff --git a/internal/link/link.go b/internal/link/link.go index 04e5c565b..9d72302c4 100644 --- a/internal/link/link.go +++ b/internal/link/link.go @@ -232,10 +232,10 @@ func updatePoolerConfig(config api.SupavisorConfigResponse) { utils.Config.Db.Pooler.ConnectionString = config.ConnectionString utils.Config.Db.Pooler.PoolMode = cliConfig.PoolMode(config.PoolMode) if config.DefaultPoolSize != nil { - utils.Config.Db.Pooler.DefaultPoolSize = uint(*config.DefaultPoolSize) + utils.Config.Db.Pooler.DefaultPoolSize = cast.IntToUint(*config.DefaultPoolSize) } if config.MaxClientConn != nil { - utils.Config.Db.Pooler.MaxClientConn = uint(*config.MaxClientConn) + utils.Config.Db.Pooler.MaxClientConn = cast.IntToUint(*config.MaxClientConn) } } diff --git a/pkg/api/types.gen.go b/pkg/api/types.gen.go index 26f73c43d..66d467611 100644 --- a/pkg/api/types.gen.go +++ b/pkg/api/types.gen.go @@ -14,6 +14,11 @@ const ( Oauth2Scopes = "oauth2.Scopes" ) +// Defines values for AuthHealthResponseName. +const ( + GoTrue AuthHealthResponseName = "GoTrue" +) + // Defines values for BillingPlanId. const ( BillingPlanIdEnterprise BillingPlanId = "enterprise" @@ -448,185 +453,186 @@ type AttributeValue_Default struct { // AuthConfigResponse defines model for AuthConfigResponse. type AuthConfigResponse struct { - ApiMaxRequestDuration *float32 `json:"api_max_request_duration"` - DbMaxPoolSize *float32 `json:"db_max_pool_size"` - DisableSignup *bool `json:"disable_signup"` - ExternalAnonymousUsersEnabled *bool `json:"external_anonymous_users_enabled"` - ExternalAppleAdditionalClientIds *string `json:"external_apple_additional_client_ids"` - ExternalAppleClientId *string `json:"external_apple_client_id"` - ExternalAppleEnabled *bool `json:"external_apple_enabled"` - ExternalAppleSecret *string `json:"external_apple_secret"` - ExternalAzureClientId *string `json:"external_azure_client_id"` - ExternalAzureEnabled *bool `json:"external_azure_enabled"` - ExternalAzureSecret *string `json:"external_azure_secret"` - ExternalAzureUrl *string `json:"external_azure_url"` - ExternalBitbucketClientId *string `json:"external_bitbucket_client_id"` - ExternalBitbucketEnabled *bool `json:"external_bitbucket_enabled"` - ExternalBitbucketSecret *string `json:"external_bitbucket_secret"` - ExternalDiscordClientId *string `json:"external_discord_client_id"` - ExternalDiscordEnabled *bool `json:"external_discord_enabled"` - ExternalDiscordSecret *string `json:"external_discord_secret"` - ExternalEmailEnabled *bool `json:"external_email_enabled"` - ExternalFacebookClientId *string `json:"external_facebook_client_id"` - ExternalFacebookEnabled *bool `json:"external_facebook_enabled"` - ExternalFacebookSecret *string `json:"external_facebook_secret"` - ExternalFigmaClientId *string `json:"external_figma_client_id"` - ExternalFigmaEnabled *bool `json:"external_figma_enabled"` - ExternalFigmaSecret *string `json:"external_figma_secret"` - ExternalGithubClientId *string `json:"external_github_client_id"` - ExternalGithubEnabled *bool `json:"external_github_enabled"` - ExternalGithubSecret *string `json:"external_github_secret"` - ExternalGitlabClientId *string `json:"external_gitlab_client_id"` - ExternalGitlabEnabled *bool `json:"external_gitlab_enabled"` - ExternalGitlabSecret *string `json:"external_gitlab_secret"` - ExternalGitlabUrl *string `json:"external_gitlab_url"` - ExternalGoogleAdditionalClientIds *string `json:"external_google_additional_client_ids"` - ExternalGoogleClientId *string `json:"external_google_client_id"` - ExternalGoogleEnabled *bool `json:"external_google_enabled"` - ExternalGoogleSecret *string `json:"external_google_secret"` - ExternalGoogleSkipNonceCheck *bool `json:"external_google_skip_nonce_check"` - ExternalKakaoClientId *string `json:"external_kakao_client_id"` - ExternalKakaoEnabled *bool `json:"external_kakao_enabled"` - ExternalKakaoSecret *string `json:"external_kakao_secret"` - ExternalKeycloakClientId *string `json:"external_keycloak_client_id"` - ExternalKeycloakEnabled *bool `json:"external_keycloak_enabled"` - ExternalKeycloakSecret *string `json:"external_keycloak_secret"` - ExternalKeycloakUrl *string `json:"external_keycloak_url"` - ExternalLinkedinOidcClientId *string `json:"external_linkedin_oidc_client_id"` - ExternalLinkedinOidcEnabled *bool `json:"external_linkedin_oidc_enabled"` - ExternalLinkedinOidcSecret *string `json:"external_linkedin_oidc_secret"` - ExternalNotionClientId *string `json:"external_notion_client_id"` - ExternalNotionEnabled *bool `json:"external_notion_enabled"` - ExternalNotionSecret *string `json:"external_notion_secret"` - ExternalPhoneEnabled *bool `json:"external_phone_enabled"` - ExternalSlackClientId *string `json:"external_slack_client_id"` - ExternalSlackEnabled *bool `json:"external_slack_enabled"` - ExternalSlackOidcClientId *string `json:"external_slack_oidc_client_id"` - ExternalSlackOidcEnabled *bool `json:"external_slack_oidc_enabled"` - ExternalSlackOidcSecret *string `json:"external_slack_oidc_secret"` - ExternalSlackSecret *string `json:"external_slack_secret"` - ExternalSpotifyClientId *string `json:"external_spotify_client_id"` - ExternalSpotifyEnabled *bool `json:"external_spotify_enabled"` - ExternalSpotifySecret *string `json:"external_spotify_secret"` - ExternalTwitchClientId *string `json:"external_twitch_client_id"` - ExternalTwitchEnabled *bool `json:"external_twitch_enabled"` - ExternalTwitchSecret *string `json:"external_twitch_secret"` - ExternalTwitterClientId *string `json:"external_twitter_client_id"` - ExternalTwitterEnabled *bool `json:"external_twitter_enabled"` - ExternalTwitterSecret *string `json:"external_twitter_secret"` - ExternalWorkosClientId *string `json:"external_workos_client_id"` - ExternalWorkosEnabled *bool `json:"external_workos_enabled"` - ExternalWorkosSecret *string `json:"external_workos_secret"` - ExternalWorkosUrl *string `json:"external_workos_url"` - ExternalZoomClientId *string `json:"external_zoom_client_id"` - ExternalZoomEnabled *bool `json:"external_zoom_enabled"` - ExternalZoomSecret *string `json:"external_zoom_secret"` - HookCustomAccessTokenEnabled *bool `json:"hook_custom_access_token_enabled"` - HookCustomAccessTokenSecrets *string `json:"hook_custom_access_token_secrets"` - HookCustomAccessTokenUri *string `json:"hook_custom_access_token_uri"` - HookMfaVerificationAttemptEnabled *bool `json:"hook_mfa_verification_attempt_enabled"` - HookMfaVerificationAttemptSecrets *string `json:"hook_mfa_verification_attempt_secrets"` - HookMfaVerificationAttemptUri *string `json:"hook_mfa_verification_attempt_uri"` - HookPasswordVerificationAttemptEnabled *bool `json:"hook_password_verification_attempt_enabled"` - HookPasswordVerificationAttemptSecrets *string `json:"hook_password_verification_attempt_secrets"` - HookPasswordVerificationAttemptUri *string `json:"hook_password_verification_attempt_uri"` - HookSendEmailEnabled *bool `json:"hook_send_email_enabled"` - HookSendEmailSecrets *string `json:"hook_send_email_secrets"` - HookSendEmailUri *string `json:"hook_send_email_uri"` - HookSendSmsEnabled *bool `json:"hook_send_sms_enabled"` - HookSendSmsSecrets *string `json:"hook_send_sms_secrets"` - HookSendSmsUri *string `json:"hook_send_sms_uri"` - JwtExp *float32 `json:"jwt_exp"` - MailerAllowUnverifiedEmailSignIns *bool `json:"mailer_allow_unverified_email_sign_ins"` - MailerAutoconfirm *bool `json:"mailer_autoconfirm"` - MailerOtpExp float32 `json:"mailer_otp_exp"` - MailerOtpLength *float32 `json:"mailer_otp_length"` - MailerSecureEmailChangeEnabled *bool `json:"mailer_secure_email_change_enabled"` - MailerSubjectsConfirmation *string `json:"mailer_subjects_confirmation"` - MailerSubjectsEmailChange *string `json:"mailer_subjects_email_change"` - MailerSubjectsInvite *string `json:"mailer_subjects_invite"` - MailerSubjectsMagicLink *string `json:"mailer_subjects_magic_link"` - MailerSubjectsReauthentication *string `json:"mailer_subjects_reauthentication"` - MailerSubjectsRecovery *string `json:"mailer_subjects_recovery"` - MailerTemplatesConfirmationContent *string `json:"mailer_templates_confirmation_content"` - MailerTemplatesEmailChangeContent *string `json:"mailer_templates_email_change_content"` - MailerTemplatesInviteContent *string `json:"mailer_templates_invite_content"` - MailerTemplatesMagicLinkContent *string `json:"mailer_templates_magic_link_content"` - MailerTemplatesReauthenticationContent *string `json:"mailer_templates_reauthentication_content"` - MailerTemplatesRecoveryContent *string `json:"mailer_templates_recovery_content"` - MfaMaxEnrolledFactors *float32 `json:"mfa_max_enrolled_factors"` - MfaPhoneEnrollEnabled *bool `json:"mfa_phone_enroll_enabled"` - MfaPhoneMaxFrequency *float32 `json:"mfa_phone_max_frequency"` - MfaPhoneOtpLength float32 `json:"mfa_phone_otp_length"` - MfaPhoneTemplate *string `json:"mfa_phone_template"` - MfaPhoneVerifyEnabled *bool `json:"mfa_phone_verify_enabled"` - MfaTotpEnrollEnabled *bool `json:"mfa_totp_enroll_enabled"` - MfaTotpVerifyEnabled *bool `json:"mfa_totp_verify_enabled"` - MfaWebAuthnEnrollEnabled *bool `json:"mfa_web_authn_enroll_enabled"` - MfaWebAuthnVerifyEnabled *bool `json:"mfa_web_authn_verify_enabled"` - PasswordHibpEnabled *bool `json:"password_hibp_enabled"` - PasswordMinLength *float32 `json:"password_min_length"` - PasswordRequiredCharacters *string `json:"password_required_characters"` - RateLimitAnonymousUsers *float32 `json:"rate_limit_anonymous_users"` - RateLimitEmailSent *float32 `json:"rate_limit_email_sent"` - RateLimitOtp *float32 `json:"rate_limit_otp"` - RateLimitSmsSent *float32 `json:"rate_limit_sms_sent"` - RateLimitTokenRefresh *float32 `json:"rate_limit_token_refresh"` - RateLimitVerify *float32 `json:"rate_limit_verify"` - RefreshTokenRotationEnabled *bool `json:"refresh_token_rotation_enabled"` - SamlAllowEncryptedAssertions *bool `json:"saml_allow_encrypted_assertions"` - SamlEnabled *bool `json:"saml_enabled"` - SamlExternalUrl *string `json:"saml_external_url"` - SecurityCaptchaEnabled *bool `json:"security_captcha_enabled"` - SecurityCaptchaProvider *string `json:"security_captcha_provider"` - SecurityCaptchaSecret *string `json:"security_captcha_secret"` - SecurityManualLinkingEnabled *bool `json:"security_manual_linking_enabled"` - SecurityRefreshTokenReuseInterval *float32 `json:"security_refresh_token_reuse_interval"` - SecurityUpdatePasswordRequireReauthentication *bool `json:"security_update_password_require_reauthentication"` - SessionsInactivityTimeout *float32 `json:"sessions_inactivity_timeout"` - SessionsSinglePerUser *bool `json:"sessions_single_per_user"` - SessionsTags *string `json:"sessions_tags"` - SessionsTimebox *float32 `json:"sessions_timebox"` - SiteUrl *string `json:"site_url"` - SmsAutoconfirm *bool `json:"sms_autoconfirm"` - SmsMaxFrequency *float32 `json:"sms_max_frequency"` - SmsMessagebirdAccessKey *string `json:"sms_messagebird_access_key"` - SmsMessagebirdOriginator *string `json:"sms_messagebird_originator"` - SmsOtpExp *float32 `json:"sms_otp_exp"` - SmsOtpLength float32 `json:"sms_otp_length"` - SmsProvider *string `json:"sms_provider"` - SmsTemplate *string `json:"sms_template"` - SmsTestOtp *string `json:"sms_test_otp"` - SmsTestOtpValidUntil *string `json:"sms_test_otp_valid_until"` - SmsTextlocalApiKey *string `json:"sms_textlocal_api_key"` - SmsTextlocalSender *string `json:"sms_textlocal_sender"` - SmsTwilioAccountSid *string `json:"sms_twilio_account_sid"` - SmsTwilioAuthToken *string `json:"sms_twilio_auth_token"` - SmsTwilioContentSid *string `json:"sms_twilio_content_sid"` - SmsTwilioMessageServiceSid *string `json:"sms_twilio_message_service_sid"` - SmsTwilioVerifyAccountSid *string `json:"sms_twilio_verify_account_sid"` - SmsTwilioVerifyAuthToken *string `json:"sms_twilio_verify_auth_token"` - SmsTwilioVerifyMessageServiceSid *string `json:"sms_twilio_verify_message_service_sid"` - SmsVonageApiKey *string `json:"sms_vonage_api_key"` - SmsVonageApiSecret *string `json:"sms_vonage_api_secret"` - SmsVonageFrom *string `json:"sms_vonage_from"` - SmtpAdminEmail *string `json:"smtp_admin_email"` - SmtpHost *string `json:"smtp_host"` - SmtpMaxFrequency *float32 `json:"smtp_max_frequency"` - SmtpPass *string `json:"smtp_pass"` - SmtpPort *string `json:"smtp_port"` - SmtpSenderName *string `json:"smtp_sender_name"` - SmtpUser *string `json:"smtp_user"` - UriAllowList *string `json:"uri_allow_list"` + ApiMaxRequestDuration *int `json:"api_max_request_duration"` + DbMaxPoolSize *int `json:"db_max_pool_size"` + DisableSignup *bool `json:"disable_signup"` + ExternalAnonymousUsersEnabled *bool `json:"external_anonymous_users_enabled"` + ExternalAppleAdditionalClientIds *string `json:"external_apple_additional_client_ids"` + ExternalAppleClientId *string `json:"external_apple_client_id"` + ExternalAppleEnabled *bool `json:"external_apple_enabled"` + ExternalAppleSecret *string `json:"external_apple_secret"` + ExternalAzureClientId *string `json:"external_azure_client_id"` + ExternalAzureEnabled *bool `json:"external_azure_enabled"` + ExternalAzureSecret *string `json:"external_azure_secret"` + ExternalAzureUrl *string `json:"external_azure_url"` + ExternalBitbucketClientId *string `json:"external_bitbucket_client_id"` + ExternalBitbucketEnabled *bool `json:"external_bitbucket_enabled"` + ExternalBitbucketSecret *string `json:"external_bitbucket_secret"` + ExternalDiscordClientId *string `json:"external_discord_client_id"` + ExternalDiscordEnabled *bool `json:"external_discord_enabled"` + ExternalDiscordSecret *string `json:"external_discord_secret"` + ExternalEmailEnabled *bool `json:"external_email_enabled"` + ExternalFacebookClientId *string `json:"external_facebook_client_id"` + ExternalFacebookEnabled *bool `json:"external_facebook_enabled"` + ExternalFacebookSecret *string `json:"external_facebook_secret"` + ExternalFigmaClientId *string `json:"external_figma_client_id"` + ExternalFigmaEnabled *bool `json:"external_figma_enabled"` + ExternalFigmaSecret *string `json:"external_figma_secret"` + ExternalGithubClientId *string `json:"external_github_client_id"` + ExternalGithubEnabled *bool `json:"external_github_enabled"` + ExternalGithubSecret *string `json:"external_github_secret"` + ExternalGitlabClientId *string `json:"external_gitlab_client_id"` + ExternalGitlabEnabled *bool `json:"external_gitlab_enabled"` + ExternalGitlabSecret *string `json:"external_gitlab_secret"` + ExternalGitlabUrl *string `json:"external_gitlab_url"` + ExternalGoogleAdditionalClientIds *string `json:"external_google_additional_client_ids"` + ExternalGoogleClientId *string `json:"external_google_client_id"` + ExternalGoogleEnabled *bool `json:"external_google_enabled"` + ExternalGoogleSecret *string `json:"external_google_secret"` + ExternalGoogleSkipNonceCheck *bool `json:"external_google_skip_nonce_check"` + ExternalKakaoClientId *string `json:"external_kakao_client_id"` + ExternalKakaoEnabled *bool `json:"external_kakao_enabled"` + ExternalKakaoSecret *string `json:"external_kakao_secret"` + ExternalKeycloakClientId *string `json:"external_keycloak_client_id"` + ExternalKeycloakEnabled *bool `json:"external_keycloak_enabled"` + ExternalKeycloakSecret *string `json:"external_keycloak_secret"` + ExternalKeycloakUrl *string `json:"external_keycloak_url"` + ExternalLinkedinOidcClientId *string `json:"external_linkedin_oidc_client_id"` + ExternalLinkedinOidcEnabled *bool `json:"external_linkedin_oidc_enabled"` + ExternalLinkedinOidcSecret *string `json:"external_linkedin_oidc_secret"` + ExternalNotionClientId *string `json:"external_notion_client_id"` + ExternalNotionEnabled *bool `json:"external_notion_enabled"` + ExternalNotionSecret *string `json:"external_notion_secret"` + ExternalPhoneEnabled *bool `json:"external_phone_enabled"` + ExternalSlackClientId *string `json:"external_slack_client_id"` + ExternalSlackEnabled *bool `json:"external_slack_enabled"` + ExternalSlackOidcClientId *string `json:"external_slack_oidc_client_id"` + ExternalSlackOidcEnabled *bool `json:"external_slack_oidc_enabled"` + ExternalSlackOidcSecret *string `json:"external_slack_oidc_secret"` + ExternalSlackSecret *string `json:"external_slack_secret"` + ExternalSpotifyClientId *string `json:"external_spotify_client_id"` + ExternalSpotifyEnabled *bool `json:"external_spotify_enabled"` + ExternalSpotifySecret *string `json:"external_spotify_secret"` + ExternalTwitchClientId *string `json:"external_twitch_client_id"` + ExternalTwitchEnabled *bool `json:"external_twitch_enabled"` + ExternalTwitchSecret *string `json:"external_twitch_secret"` + ExternalTwitterClientId *string `json:"external_twitter_client_id"` + ExternalTwitterEnabled *bool `json:"external_twitter_enabled"` + ExternalTwitterSecret *string `json:"external_twitter_secret"` + ExternalWorkosClientId *string `json:"external_workos_client_id"` + ExternalWorkosEnabled *bool `json:"external_workos_enabled"` + ExternalWorkosSecret *string `json:"external_workos_secret"` + ExternalWorkosUrl *string `json:"external_workos_url"` + ExternalZoomClientId *string `json:"external_zoom_client_id"` + ExternalZoomEnabled *bool `json:"external_zoom_enabled"` + ExternalZoomSecret *string `json:"external_zoom_secret"` + HookCustomAccessTokenEnabled *bool `json:"hook_custom_access_token_enabled"` + HookCustomAccessTokenSecrets *string `json:"hook_custom_access_token_secrets"` + HookCustomAccessTokenUri *string `json:"hook_custom_access_token_uri"` + HookMfaVerificationAttemptEnabled *bool `json:"hook_mfa_verification_attempt_enabled"` + HookMfaVerificationAttemptSecrets *string `json:"hook_mfa_verification_attempt_secrets"` + HookMfaVerificationAttemptUri *string `json:"hook_mfa_verification_attempt_uri"` + HookPasswordVerificationAttemptEnabled *bool `json:"hook_password_verification_attempt_enabled"` + HookPasswordVerificationAttemptSecrets *string `json:"hook_password_verification_attempt_secrets"` + HookPasswordVerificationAttemptUri *string `json:"hook_password_verification_attempt_uri"` + HookSendEmailEnabled *bool `json:"hook_send_email_enabled"` + HookSendEmailSecrets *string `json:"hook_send_email_secrets"` + HookSendEmailUri *string `json:"hook_send_email_uri"` + HookSendSmsEnabled *bool `json:"hook_send_sms_enabled"` + HookSendSmsSecrets *string `json:"hook_send_sms_secrets"` + HookSendSmsUri *string `json:"hook_send_sms_uri"` + JwtExp *int `json:"jwt_exp"` + MailerAllowUnverifiedEmailSignIns *bool `json:"mailer_allow_unverified_email_sign_ins"` + MailerAutoconfirm *bool `json:"mailer_autoconfirm"` + MailerOtpExp int `json:"mailer_otp_exp"` + MailerOtpLength *int `json:"mailer_otp_length"` + MailerSecureEmailChangeEnabled *bool `json:"mailer_secure_email_change_enabled"` + MailerSubjectsConfirmation *string `json:"mailer_subjects_confirmation"` + MailerSubjectsEmailChange *string `json:"mailer_subjects_email_change"` + MailerSubjectsInvite *string `json:"mailer_subjects_invite"` + MailerSubjectsMagicLink *string `json:"mailer_subjects_magic_link"` + MailerSubjectsReauthentication *string `json:"mailer_subjects_reauthentication"` + MailerSubjectsRecovery *string `json:"mailer_subjects_recovery"` + MailerTemplatesConfirmationContent *string `json:"mailer_templates_confirmation_content"` + MailerTemplatesEmailChangeContent *string `json:"mailer_templates_email_change_content"` + MailerTemplatesInviteContent *string `json:"mailer_templates_invite_content"` + MailerTemplatesMagicLinkContent *string `json:"mailer_templates_magic_link_content"` + MailerTemplatesReauthenticationContent *string `json:"mailer_templates_reauthentication_content"` + MailerTemplatesRecoveryContent *string `json:"mailer_templates_recovery_content"` + MfaMaxEnrolledFactors *int `json:"mfa_max_enrolled_factors"` + MfaPhoneEnrollEnabled *bool `json:"mfa_phone_enroll_enabled"` + MfaPhoneMaxFrequency *int `json:"mfa_phone_max_frequency"` + MfaPhoneOtpLength int `json:"mfa_phone_otp_length"` + MfaPhoneTemplate *string `json:"mfa_phone_template"` + MfaPhoneVerifyEnabled *bool `json:"mfa_phone_verify_enabled"` + MfaTotpEnrollEnabled *bool `json:"mfa_totp_enroll_enabled"` + MfaTotpVerifyEnabled *bool `json:"mfa_totp_verify_enabled"` + MfaWebAuthnEnrollEnabled *bool `json:"mfa_web_authn_enroll_enabled"` + MfaWebAuthnVerifyEnabled *bool `json:"mfa_web_authn_verify_enabled"` + PasswordHibpEnabled *bool `json:"password_hibp_enabled"` + PasswordMinLength *int `json:"password_min_length"` + PasswordRequiredCharacters *string `json:"password_required_characters"` + RateLimitAnonymousUsers *int `json:"rate_limit_anonymous_users"` + RateLimitEmailSent *int `json:"rate_limit_email_sent"` + RateLimitOtp *int `json:"rate_limit_otp"` + RateLimitSmsSent *int `json:"rate_limit_sms_sent"` + RateLimitTokenRefresh *int `json:"rate_limit_token_refresh"` + RateLimitVerify *int `json:"rate_limit_verify"` + RefreshTokenRotationEnabled *bool `json:"refresh_token_rotation_enabled"` + SamlAllowEncryptedAssertions *bool `json:"saml_allow_encrypted_assertions"` + SamlEnabled *bool `json:"saml_enabled"` + SamlExternalUrl *string `json:"saml_external_url"` + SecurityCaptchaEnabled *bool `json:"security_captcha_enabled"` + SecurityCaptchaProvider *string `json:"security_captcha_provider"` + SecurityCaptchaSecret *string `json:"security_captcha_secret"` + SecurityManualLinkingEnabled *bool `json:"security_manual_linking_enabled"` + SecurityRefreshTokenReuseInterval *int `json:"security_refresh_token_reuse_interval"` + SecurityUpdatePasswordRequireReauthentication *bool `json:"security_update_password_require_reauthentication"` + SessionsInactivityTimeout *int `json:"sessions_inactivity_timeout"` + SessionsSinglePerUser *bool `json:"sessions_single_per_user"` + SessionsTags *string `json:"sessions_tags"` + SessionsTimebox *int `json:"sessions_timebox"` + SiteUrl *string `json:"site_url"` + SmsAutoconfirm *bool `json:"sms_autoconfirm"` + SmsMaxFrequency *int `json:"sms_max_frequency"` + SmsMessagebirdAccessKey *string `json:"sms_messagebird_access_key"` + SmsMessagebirdOriginator *string `json:"sms_messagebird_originator"` + SmsOtpExp *int `json:"sms_otp_exp"` + SmsOtpLength int `json:"sms_otp_length"` + SmsProvider *string `json:"sms_provider"` + SmsTemplate *string `json:"sms_template"` + SmsTestOtp *string `json:"sms_test_otp"` + SmsTestOtpValidUntil *string `json:"sms_test_otp_valid_until"` + SmsTextlocalApiKey *string `json:"sms_textlocal_api_key"` + SmsTextlocalSender *string `json:"sms_textlocal_sender"` + SmsTwilioAccountSid *string `json:"sms_twilio_account_sid"` + SmsTwilioAuthToken *string `json:"sms_twilio_auth_token"` + SmsTwilioContentSid *string `json:"sms_twilio_content_sid"` + SmsTwilioMessageServiceSid *string `json:"sms_twilio_message_service_sid"` + SmsTwilioVerifyAccountSid *string `json:"sms_twilio_verify_account_sid"` + SmsTwilioVerifyAuthToken *string `json:"sms_twilio_verify_auth_token"` + SmsTwilioVerifyMessageServiceSid *string `json:"sms_twilio_verify_message_service_sid"` + SmsVonageApiKey *string `json:"sms_vonage_api_key"` + SmsVonageApiSecret *string `json:"sms_vonage_api_secret"` + SmsVonageFrom *string `json:"sms_vonage_from"` + SmtpAdminEmail *string `json:"smtp_admin_email"` + SmtpHost *string `json:"smtp_host"` + SmtpMaxFrequency *int `json:"smtp_max_frequency"` + SmtpPass *string `json:"smtp_pass"` + SmtpPort *string `json:"smtp_port"` + SmtpSenderName *string `json:"smtp_sender_name"` + SmtpUser *string `json:"smtp_user"` + UriAllowList *string `json:"uri_allow_list"` } // AuthHealthResponse defines model for AuthHealthResponse. type AuthHealthResponse struct { - Description string `json:"description"` - Name string `json:"name"` - Version string `json:"version"` + Name AuthHealthResponseName `json:"name"` } +// AuthHealthResponseName defines model for AuthHealthResponse.Name. +type AuthHealthResponseName string + // BillingPlanId defines model for BillingPlanId. type BillingPlanId string @@ -664,11 +670,11 @@ type BranchResponse struct { GitBranch *string `json:"git_branch,omitempty"` Id string `json:"id"` IsDefault bool `json:"is_default"` - LatestCheckRunId *float32 `json:"latest_check_run_id,omitempty"` + LatestCheckRunId *int64 `json:"latest_check_run_id,omitempty"` Name string `json:"name"` ParentProjectRef string `json:"parent_project_ref"` Persistent bool `json:"persistent"` - PrNumber *float32 `json:"pr_number,omitempty"` + PrNumber *int32 `json:"pr_number,omitempty"` ProjectRef string `json:"project_ref"` ResetOnPush bool `json:"reset_on_push"` Status BranchResponseStatus `json:"status"` @@ -769,7 +775,7 @@ type DatabaseUpgradeStatus struct { LatestStatusAt string `json:"latest_status_at"` Progress *DatabaseUpgradeStatusProgress `json:"progress,omitempty"` Status DatabaseUpgradeStatusStatus `json:"status"` - TargetVersion float32 `json:"target_version"` + TargetVersion int `json:"target_version"` } // DatabaseUpgradeStatusError defines model for DatabaseUpgradeStatus.Error. @@ -779,7 +785,7 @@ type DatabaseUpgradeStatusError string type DatabaseUpgradeStatusProgress string // DatabaseUpgradeStatusStatus defines model for DatabaseUpgradeStatus.Status. -type DatabaseUpgradeStatusStatus float32 +type DatabaseUpgradeStatusStatus int // DatabaseUpgradeStatusResponse defines model for DatabaseUpgradeStatusResponse. type DatabaseUpgradeStatusResponse struct { @@ -808,7 +814,7 @@ type Domain struct { // FunctionResponse defines model for FunctionResponse. type FunctionResponse struct { - CreatedAt float32 `json:"created_at"` + CreatedAt int64 `json:"created_at"` EntrypointPath *string `json:"entrypoint_path,omitempty"` Id string `json:"id"` ImportMap *bool `json:"import_map,omitempty"` @@ -816,9 +822,9 @@ type FunctionResponse struct { Name string `json:"name"` Slug string `json:"slug"` Status FunctionResponseStatus `json:"status"` - UpdatedAt float32 `json:"updated_at"` + UpdatedAt int64 `json:"updated_at"` VerifyJwt *bool `json:"verify_jwt,omitempty"` - Version float32 `json:"version"` + Version int `json:"version"` } // FunctionResponseStatus defines model for FunctionResponse.Status. @@ -826,7 +832,7 @@ type FunctionResponseStatus string // FunctionSlugResponse defines model for FunctionSlugResponse. type FunctionSlugResponse struct { - CreatedAt float32 `json:"created_at"` + CreatedAt int64 `json:"created_at"` EntrypointPath *string `json:"entrypoint_path,omitempty"` Id string `json:"id"` ImportMap *bool `json:"import_map,omitempty"` @@ -834,9 +840,9 @@ type FunctionSlugResponse struct { Name string `json:"name"` Slug string `json:"slug"` Status FunctionSlugResponseStatus `json:"status"` - UpdatedAt float32 `json:"updated_at"` + UpdatedAt int64 `json:"updated_at"` VerifyJwt *bool `json:"verify_jwt,omitempty"` - Version float32 `json:"version"` + Version int `json:"version"` } // FunctionSlugResponseStatus defines model for FunctionSlugResponse.Status. @@ -898,7 +904,7 @@ type OAuthTokenBodyGrantType string // OAuthTokenResponse defines model for OAuthTokenResponse. type OAuthTokenResponse struct { AccessToken string `json:"access_token"` - ExpiresIn float32 `json:"expires_in"` + ExpiresIn int64 `json:"expires_in"` RefreshToken string `json:"refresh_token"` TokenType OAuthTokenResponseTokenType `json:"token_type"` } @@ -970,7 +976,7 @@ type PostgrestConfigWithJWTSecretResponse struct { type ProjectUpgradeEligibilityResponse struct { CurrentAppVersion string `json:"current_app_version"` CurrentAppVersionReleaseChannel ReleaseChannel `json:"current_app_version_release_channel"` - DurationEstimateHours float32 `json:"duration_estimate_hours"` + DurationEstimateHours int `json:"duration_estimate_hours"` Eligible bool `json:"eligible"` ExtensionDependentObjects []string `json:"extension_dependent_objects"` LatestAppVersion string `json:"latest_app_version"` @@ -1011,9 +1017,7 @@ type ReadOnlyStatusResponse struct { // RealtimeHealthResponse defines model for RealtimeHealthResponse. type RealtimeHealthResponse struct { - ConnectedCluster float32 `json:"connected_cluster"` - DbConnected bool `json:"db_connected"` - Healthy bool `json:"healthy"` + ConnectedCluster int `json:"connected_cluster"` } // ReleaseChannel defines model for ReleaseChannel. @@ -1087,8 +1091,8 @@ type SnippetMetaVisibility string // SnippetProject defines model for SnippetProject. type SnippetProject struct { - Id float32 `json:"id"` - Name string `json:"name"` + Id int64 `json:"id"` + Name string `json:"name"` } // SnippetResponse defines model for SnippetResponse. @@ -1114,8 +1118,8 @@ type SnippetResponseVisibility string // SnippetUser defines model for SnippetUser. type SnippetUser struct { - Id float32 `json:"id"` - Username string `json:"username"` + Id int64 `json:"id"` + Username string `json:"username"` } // SslEnforcementRequest defines model for SslEnforcementRequest. @@ -1144,7 +1148,7 @@ type SslValidation struct { // StorageConfigResponse defines model for StorageConfigResponse. type StorageConfigResponse struct { Features StorageFeatures `json:"features"` - FileSizeLimit float32 `json:"fileSizeLimit"` + FileSizeLimit int64 `json:"fileSizeLimit"` } // StorageFeatureImageTransformation defines model for StorageFeatureImageTransformation. @@ -1168,12 +1172,12 @@ type SupavisorConfigResponse struct { DatabaseType SupavisorConfigResponseDatabaseType `json:"database_type"` DbHost string `json:"db_host"` DbName string `json:"db_name"` - DbPort float32 `json:"db_port"` + DbPort int `json:"db_port"` DbUser string `json:"db_user"` - DefaultPoolSize *float32 `json:"default_pool_size"` + DefaultPoolSize *int `json:"default_pool_size"` Identifier string `json:"identifier"` IsUsingScramAuth bool `json:"is_using_scram_auth"` - MaxClientConn *float32 `json:"max_client_conn"` + MaxClientConn *int `json:"max_client_conn"` PoolMode SupavisorConfigResponsePoolMode `json:"pool_mode"` } @@ -1209,8 +1213,8 @@ type UpdateApiKeyBody struct { // UpdateAuthConfigBody defines model for UpdateAuthConfigBody. type UpdateAuthConfigBody struct { - ApiMaxRequestDuration *float32 `json:"api_max_request_duration,omitempty"` - DbMaxPoolSize *float32 `json:"db_max_pool_size,omitempty"` + ApiMaxRequestDuration *int `json:"api_max_request_duration,omitempty"` + DbMaxPoolSize *int `json:"db_max_pool_size,omitempty"` DisableSignup *bool `json:"disable_signup,omitempty"` ExternalAnonymousUsersEnabled *bool `json:"external_anonymous_users_enabled,omitempty"` ExternalAppleAdditionalClientIds *string `json:"external_apple_additional_client_ids,omitempty"` @@ -1297,11 +1301,11 @@ type UpdateAuthConfigBody struct { HookSendSmsEnabled *bool `json:"hook_send_sms_enabled,omitempty"` HookSendSmsSecrets *string `json:"hook_send_sms_secrets,omitempty"` HookSendSmsUri *string `json:"hook_send_sms_uri,omitempty"` - JwtExp *float32 `json:"jwt_exp,omitempty"` + JwtExp *int `json:"jwt_exp,omitempty"` MailerAllowUnverifiedEmailSignIns *bool `json:"mailer_allow_unverified_email_sign_ins,omitempty"` MailerAutoconfirm *bool `json:"mailer_autoconfirm,omitempty"` - MailerOtpExp *float32 `json:"mailer_otp_exp,omitempty"` - MailerOtpLength *float32 `json:"mailer_otp_length,omitempty"` + MailerOtpExp *int `json:"mailer_otp_exp,omitempty"` + MailerOtpLength *int `json:"mailer_otp_length,omitempty"` MailerSecureEmailChangeEnabled *bool `json:"mailer_secure_email_change_enabled,omitempty"` MailerSubjectsConfirmation *string `json:"mailer_subjects_confirmation,omitempty"` MailerSubjectsEmailChange *string `json:"mailer_subjects_email_change,omitempty"` @@ -1315,10 +1319,10 @@ type UpdateAuthConfigBody struct { MailerTemplatesMagicLinkContent *string `json:"mailer_templates_magic_link_content,omitempty"` MailerTemplatesReauthenticationContent *string `json:"mailer_templates_reauthentication_content,omitempty"` MailerTemplatesRecoveryContent *string `json:"mailer_templates_recovery_content,omitempty"` - MfaMaxEnrolledFactors *float32 `json:"mfa_max_enrolled_factors,omitempty"` + MfaMaxEnrolledFactors *int `json:"mfa_max_enrolled_factors,omitempty"` MfaPhoneEnrollEnabled *bool `json:"mfa_phone_enroll_enabled,omitempty"` - MfaPhoneMaxFrequency *float32 `json:"mfa_phone_max_frequency,omitempty"` - MfaPhoneOtpLength *float32 `json:"mfa_phone_otp_length,omitempty"` + MfaPhoneMaxFrequency *int `json:"mfa_phone_max_frequency,omitempty"` + MfaPhoneOtpLength *int `json:"mfa_phone_otp_length,omitempty"` MfaPhoneTemplate *string `json:"mfa_phone_template,omitempty"` MfaPhoneVerifyEnabled *bool `json:"mfa_phone_verify_enabled,omitempty"` MfaTotpEnrollEnabled *bool `json:"mfa_totp_enroll_enabled,omitempty"` @@ -1326,14 +1330,14 @@ type UpdateAuthConfigBody struct { MfaWebAuthnEnrollEnabled *bool `json:"mfa_web_authn_enroll_enabled,omitempty"` MfaWebAuthnVerifyEnabled *bool `json:"mfa_web_authn_verify_enabled,omitempty"` PasswordHibpEnabled *bool `json:"password_hibp_enabled,omitempty"` - PasswordMinLength *float32 `json:"password_min_length,omitempty"` + PasswordMinLength *int `json:"password_min_length,omitempty"` PasswordRequiredCharacters *UpdateAuthConfigBodyPasswordRequiredCharacters `json:"password_required_characters,omitempty"` - RateLimitAnonymousUsers *float32 `json:"rate_limit_anonymous_users,omitempty"` - RateLimitEmailSent *float32 `json:"rate_limit_email_sent,omitempty"` - RateLimitOtp *float32 `json:"rate_limit_otp,omitempty"` - RateLimitSmsSent *float32 `json:"rate_limit_sms_sent,omitempty"` - RateLimitTokenRefresh *float32 `json:"rate_limit_token_refresh,omitempty"` - RateLimitVerify *float32 `json:"rate_limit_verify,omitempty"` + RateLimitAnonymousUsers *int `json:"rate_limit_anonymous_users,omitempty"` + RateLimitEmailSent *int `json:"rate_limit_email_sent,omitempty"` + RateLimitOtp *int `json:"rate_limit_otp,omitempty"` + RateLimitSmsSent *int `json:"rate_limit_sms_sent,omitempty"` + RateLimitTokenRefresh *int `json:"rate_limit_token_refresh,omitempty"` + RateLimitVerify *int `json:"rate_limit_verify,omitempty"` RefreshTokenRotationEnabled *bool `json:"refresh_token_rotation_enabled,omitempty"` SamlEnabled *bool `json:"saml_enabled,omitempty"` SamlExternalUrl *string `json:"saml_external_url,omitempty"` @@ -1341,19 +1345,19 @@ type UpdateAuthConfigBody struct { SecurityCaptchaProvider *string `json:"security_captcha_provider,omitempty"` SecurityCaptchaSecret *string `json:"security_captcha_secret,omitempty"` SecurityManualLinkingEnabled *bool `json:"security_manual_linking_enabled,omitempty"` - SecurityRefreshTokenReuseInterval *float32 `json:"security_refresh_token_reuse_interval,omitempty"` + SecurityRefreshTokenReuseInterval *int `json:"security_refresh_token_reuse_interval,omitempty"` SecurityUpdatePasswordRequireReauthentication *bool `json:"security_update_password_require_reauthentication,omitempty"` - SessionsInactivityTimeout *float32 `json:"sessions_inactivity_timeout,omitempty"` + SessionsInactivityTimeout *int `json:"sessions_inactivity_timeout,omitempty"` SessionsSinglePerUser *bool `json:"sessions_single_per_user,omitempty"` SessionsTags *string `json:"sessions_tags,omitempty"` - SessionsTimebox *float32 `json:"sessions_timebox,omitempty"` + SessionsTimebox *int `json:"sessions_timebox,omitempty"` SiteUrl *string `json:"site_url,omitempty"` SmsAutoconfirm *bool `json:"sms_autoconfirm,omitempty"` - SmsMaxFrequency *float32 `json:"sms_max_frequency,omitempty"` + SmsMaxFrequency *int `json:"sms_max_frequency,omitempty"` SmsMessagebirdAccessKey *string `json:"sms_messagebird_access_key,omitempty"` SmsMessagebirdOriginator *string `json:"sms_messagebird_originator,omitempty"` - SmsOtpExp *float32 `json:"sms_otp_exp,omitempty"` - SmsOtpLength *float32 `json:"sms_otp_length,omitempty"` + SmsOtpExp *int `json:"sms_otp_exp,omitempty"` + SmsOtpLength *int `json:"sms_otp_length,omitempty"` SmsProvider *string `json:"sms_provider,omitempty"` SmsTemplate *string `json:"sms_template,omitempty"` SmsTestOtp *string `json:"sms_test_otp,omitempty"` @@ -1372,7 +1376,7 @@ type UpdateAuthConfigBody struct { SmsVonageFrom *string `json:"sms_vonage_from,omitempty"` SmtpAdminEmail *string `json:"smtp_admin_email,omitempty"` SmtpHost *string `json:"smtp_host,omitempty"` - SmtpMaxFrequency *float32 `json:"smtp_max_frequency,omitempty"` + SmtpMaxFrequency *int `json:"smtp_max_frequency,omitempty"` SmtpPass *string `json:"smtp_pass,omitempty"` SmtpPort *string `json:"smtp_port,omitempty"` SmtpSenderName *string `json:"smtp_sender_name,omitempty"` @@ -1489,7 +1493,7 @@ type UpdateSupavisorConfigBodyPoolMode string // UpdateSupavisorConfigResponse defines model for UpdateSupavisorConfigResponse. type UpdateSupavisorConfigResponse struct { - DefaultPoolSize *float32 `json:"default_pool_size"` + DefaultPoolSize *int `json:"default_pool_size"` PoolMode UpdateSupavisorConfigResponsePoolMode `json:"pool_mode"` } @@ -1616,8 +1620,8 @@ type V1PgbouncerConfigResponsePoolMode string // V1PhysicalBackup defines model for V1PhysicalBackup. type V1PhysicalBackup struct { - EarliestPhysicalBackupDateUnix *float32 `json:"earliest_physical_backup_date_unix,omitempty"` - LatestPhysicalBackupDateUnix *float32 `json:"latest_physical_backup_date_unix,omitempty"` + EarliestPhysicalBackupDateUnix *int64 `json:"earliest_physical_backup_date_unix,omitempty"` + LatestPhysicalBackupDateUnix *int64 `json:"latest_physical_backup_date_unix,omitempty"` } // V1PostgrestConfigResponse defines model for V1PostgrestConfigResponse. @@ -1632,9 +1636,9 @@ type V1PostgrestConfigResponse struct { // V1ProjectRefResponse defines model for V1ProjectRefResponse. type V1ProjectRefResponse struct { - Id float32 `json:"id"` - Name string `json:"name"` - Ref string `json:"ref"` + Id int64 `json:"id"` + Name string `json:"name"` + Ref string `json:"ref"` } // V1ProjectResponse defines model for V1ProjectResponse. @@ -1662,7 +1666,7 @@ type V1ProjectResponseStatus string // V1RestorePitrBody defines model for V1RestorePitrBody. type V1RestorePitrBody struct { - RecoveryTimeTargetUnix float32 `json:"recovery_time_target_unix"` + RecoveryTimeTargetUnix int64 `json:"recovery_time_target_unix"` } // V1RunQueryBody defines model for V1RunQueryBody. From fefeebdb4f9758049b9a820d2f7cbffe74bec76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Sat, 2 Nov 2024 13:12:22 +0900 Subject: [PATCH 119/305] fix: bump edge-runtime to 1.60.1 (#2820) Co-authored-by: Kalleby Santos --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index cd7befff5..c8aa224f4 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241029-46e1e40" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.59.1" + edgeRuntimeImage = "supabase/edge-runtime:v1.60.1" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.163.2" From 4cf189afa6dc8b9738b1de31e4c06fcb6d5e1aaf Mon Sep 17 00:00:00 2001 From: Julien Goux Date: Sun, 3 Nov 2024 03:43:40 +0100 Subject: [PATCH 120/305] feat(config): load local deno.json file as import map (#2824) * feat: load local deno.json file * move logic to config * use pattern logic and funcSlugPattern * fix new tests * chore: undo functions glob --------- Co-authored-by: Qiao Han --- internal/functions/deploy/deploy_test.go | 8 +++- pkg/config/config.go | 19 ++++++--- pkg/config/config_test.go | 51 ++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 8 deletions(-) diff --git a/internal/functions/deploy/deploy_test.go b/internal/functions/deploy/deploy_test.go index c92f210cc..558a33f32 100644 --- a/internal/functions/deploy/deploy_test.go +++ b/internal/functions/deploy/deploy_test.go @@ -322,12 +322,16 @@ func TestImportMapPath(t *testing.T) { } // Setup in-memory fs fsys := afero.NewMemMapFs() + // Custom global import map loaded via cli flag + customImportMapPath := filepath.Join(utils.FunctionsDir, "custom_import_map.json") + require.NoError(t, afero.WriteFile(fsys, customImportMapPath, []byte("{}"), 0644)) + // Create fallback import map to test precedence order require.NoError(t, afero.WriteFile(fsys, utils.FallbackImportMapPath, []byte("{}"), 0644)) // Run test - fc, err := GetFunctionConfig([]string{slug}, utils.FallbackImportMapPath, cast.Ptr(false), fsys) + fc, err := GetFunctionConfig([]string{slug}, customImportMapPath, cast.Ptr(false), fsys) // Check error assert.NoError(t, err) - assert.Equal(t, utils.FallbackImportMapPath, fc[slug].ImportMap) + assert.Equal(t, customImportMapPath, fc[slug].ImportMap) }) t.Run("returns empty string if no fallback", func(t *testing.T) { diff --git a/pkg/config/config.go b/pkg/config/config.go index 7fb78cd62..6589fb4e5 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -30,9 +30,8 @@ import ( "github.com/joho/godotenv" "github.com/mitchellh/mapstructure" "github.com/spf13/viper" - "golang.org/x/mod/semver" - "github.com/supabase/cli/pkg/fetcher" + "golang.org/x/mod/semver" ) // Type for turning human-friendly bytes string ("5MB", "32kB") into an int64 during toml decoding. @@ -654,21 +653,29 @@ func (c *config) Load(path string, fsys fs.FS) error { } c.Storage.Buckets[name] = bucket } + // Resolve functions config for slug, function := range c.Functions { - // TODO: support configuring alternative entrypoint path, such as index.js if len(function.Entrypoint) == 0 { function.Entrypoint = filepath.Join(builder.FunctionsDir, slug, "index.ts") } else if !filepath.IsAbs(function.Entrypoint) { // Append supabase/ because paths in configs are specified relative to config.toml function.Entrypoint = filepath.Join(builder.SupabaseDirPath, function.Entrypoint) } - // Functions may not use import map so we don't set a default value - if len(function.ImportMap) > 0 && !filepath.IsAbs(function.ImportMap) { + if len(function.ImportMap) == 0 { + functionDir := filepath.Dir(function.Entrypoint) + denoJsonPath := filepath.Join(functionDir, "deno.json") + denoJsoncPath := filepath.Join(functionDir, "deno.jsonc") + if _, err := fs.Stat(fsys, denoJsonPath); err == nil { + function.ImportMap = denoJsonPath + } else if _, err := fs.Stat(fsys, denoJsoncPath); err == nil { + function.ImportMap = denoJsoncPath + } + // Functions may not use import map so we don't set a default value + } else if !filepath.IsAbs(function.ImportMap) { function.ImportMap = filepath.Join(builder.SupabaseDirPath, function.ImportMap) } c.Functions[slug] = function } - if err := c.Db.Seed.loadSeedPaths(builder.SupabaseDirPath, fsys); err != nil { return err } diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 8e8f6a2e1..d80ea915b 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -356,3 +356,54 @@ func TestLoadEnv(t *testing.T) { assert.Equal(t, "test-secret", config.Auth.JwtSecret) assert.Equal(t, "test-root-key", config.Db.RootKey) } + +func TestLoadFunctionImportMap(t *testing.T) { + t.Run("uses deno.json as import map when present", func(t *testing.T) { + config := NewConfig() + fsys := fs.MapFS{ + "supabase/config.toml": &fs.MapFile{Data: []byte(` + project_id = "test" + [functions.hello] + `)}, + "supabase/functions/hello/deno.json": &fs.MapFile{}, + "supabase/functions/hello/index.ts": &fs.MapFile{}, + } + // Run test + assert.NoError(t, config.Load("", fsys)) + // Check that deno.json was set as import map + assert.Equal(t, "supabase/functions/hello/deno.json", config.Functions["hello"].ImportMap) + }) + + t.Run("uses deno.jsonc as import map when present", func(t *testing.T) { + config := NewConfig() + fsys := fs.MapFS{ + "supabase/config.toml": &fs.MapFile{Data: []byte(` + project_id = "test" + [functions.hello] + `)}, + "supabase/functions/hello/deno.jsonc": &fs.MapFile{}, + "supabase/functions/hello/index.ts": &fs.MapFile{}, + } + // Run test + assert.NoError(t, config.Load("", fsys)) + // Check that deno.json was set as import map + assert.Equal(t, "supabase/functions/hello/deno.jsonc", config.Functions["hello"].ImportMap) + }) + + t.Run("config.toml takes precedence over deno.json", func(t *testing.T) { + config := NewConfig() + fsys := fs.MapFS{ + "supabase/config.toml": &fs.MapFile{Data: []byte(` + project_id = "test" + [functions] + hello.import_map = "custom_import_map.json" + `)}, + "supabase/functions/hello/deno.json": &fs.MapFile{}, + "supabase/functions/hello/index.ts": &fs.MapFile{}, + } + // Run test + assert.NoError(t, config.Load("", fsys)) + // Check that config.toml takes precedence over deno.json + assert.Equal(t, "supabase/custom_import_map.json", config.Functions["hello"].ImportMap) + }) +} From bceba4cdb61e97d01022ce6150db7517a137408d Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Mon, 4 Nov 2024 22:35:21 -0500 Subject: [PATCH 121/305] chore: update NPM publishing blog link (#2832) --- scripts/postinstall.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/postinstall.js b/scripts/postinstall.js index 76b759046..517617ffb 100755 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -1,7 +1,7 @@ #!/usr/bin/env node // Ref 1: https://github.com/sanathkr/go-npm -// Ref 2: https://blog.xendit.engineer/how-we-repurposed-npm-to-publish-and-distribute-our-go-binaries-for-internal-cli-23981b80911b +// Ref 2: https://medium.com/xendit-engineering/how-we-repurposed-npm-to-publish-and-distribute-our-go-binaries-for-internal-cli-23981b80911b "use strict"; import binLinks from "bin-links"; From 1a3d443950d50af073054cfadf798876dbb48ccf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Tue, 5 Nov 2024 12:35:48 +0900 Subject: [PATCH 122/305] fix: bump edge-runtime to 1.61.0 (#2833) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index c8aa224f4..652f41870 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241029-46e1e40" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.60.1" + edgeRuntimeImage = "supabase/edge-runtime:v1.61.0" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.163.2" From 4dfab63ea0549f326a3ad32305ee9fb1c4611d0b Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Tue, 5 Nov 2024 04:40:53 +0100 Subject: [PATCH 123/305] fix: Bump studio to the latest image version 20241104 (#2829) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 652f41870..bfce77336 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -10,7 +10,7 @@ const ( inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" pgmetaImage = "supabase/postgres-meta:v0.84.2" - studioImage = "supabase/studio:20241029-46e1e40" + studioImage = "supabase/studio:20241104-531a96a" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.61.0" vectorImage = "timberio/vector:0.28.1-alpine" From 526da59cf43e5d337df726f5218328a4e13c7fd6 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Mon, 4 Nov 2024 20:30:32 +0800 Subject: [PATCH 124/305] chore: move auth config to its own file --- pkg/config/auth.go | 174 +++++++++++++++++++++++++++++++++++++++++++ pkg/config/config.go | 166 ----------------------------------------- 2 files changed, 174 insertions(+), 166 deletions(-) create mode 100644 pkg/config/auth.go diff --git a/pkg/config/auth.go b/pkg/config/auth.go new file mode 100644 index 000000000..aac6d0ed3 --- /dev/null +++ b/pkg/config/auth.go @@ -0,0 +1,174 @@ +package config + +import ( + "time" +) + +type ( + auth struct { + Enabled bool `toml:"enabled"` + Image string `toml:"-"` + SiteUrl string `toml:"site_url"` + AdditionalRedirectUrls []string `toml:"additional_redirect_urls"` + + JwtExpiry uint `toml:"jwt_expiry"` + EnableRefreshTokenRotation bool `toml:"enable_refresh_token_rotation"` + RefreshTokenReuseInterval uint `toml:"refresh_token_reuse_interval"` + EnableManualLinking bool `toml:"enable_manual_linking"` + + Hook hook `toml:"hook"` + MFA mfa `toml:"mfa"` + Sessions sessions `toml:"sessions"` + + EnableSignup bool `toml:"enable_signup"` + EnableAnonymousSignIns bool `toml:"enable_anonymous_sign_ins"` + Email email `toml:"email"` + Sms sms `toml:"sms"` + External map[string]provider `toml:"external"` + + // Custom secrets can be injected from .env file + JwtSecret string `toml:"-" mapstructure:"jwt_secret"` + AnonKey string `toml:"-" mapstructure:"anon_key"` + ServiceRoleKey string `toml:"-" mapstructure:"service_role_key"` + + ThirdParty thirdParty `toml:"third_party"` + } + + thirdParty struct { + Firebase tpaFirebase `toml:"firebase"` + Auth0 tpaAuth0 `toml:"auth0"` + Cognito tpaCognito `toml:"aws_cognito"` + } + + tpaFirebase struct { + Enabled bool `toml:"enabled"` + + ProjectID string `toml:"project_id"` + } + + tpaAuth0 struct { + Enabled bool `toml:"enabled"` + + Tenant string `toml:"tenant"` + TenantRegion string `toml:"tenant_region"` + } + + tpaCognito struct { + Enabled bool `toml:"enabled"` + + UserPoolID string `toml:"user_pool_id"` + UserPoolRegion string `toml:"user_pool_region"` + } + + email struct { + EnableSignup bool `toml:"enable_signup"` + DoubleConfirmChanges bool `toml:"double_confirm_changes"` + EnableConfirmations bool `toml:"enable_confirmations"` + SecurePasswordChange bool `toml:"secure_password_change"` + Template map[string]emailTemplate `toml:"template"` + Smtp smtp `toml:"smtp"` + MaxFrequency time.Duration `toml:"max_frequency"` + OtpLength uint `toml:"otp_length"` + OtpExpiry uint `toml:"otp_expiry"` + } + + smtp struct { + Host string `toml:"host"` + Port uint16 `toml:"port"` + User string `toml:"user"` + Pass string `toml:"pass"` + AdminEmail string `toml:"admin_email"` + SenderName string `toml:"sender_name"` + } + + emailTemplate struct { + Subject string `toml:"subject"` + ContentPath string `toml:"content_path"` + } + + sms struct { + EnableSignup bool `toml:"enable_signup"` + EnableConfirmations bool `toml:"enable_confirmations"` + Template string `toml:"template"` + Twilio twilioConfig `toml:"twilio" mapstructure:"twilio"` + TwilioVerify twilioConfig `toml:"twilio_verify" mapstructure:"twilio_verify"` + Messagebird messagebirdConfig `toml:"messagebird" mapstructure:"messagebird"` + Textlocal textlocalConfig `toml:"textlocal" mapstructure:"textlocal"` + Vonage vonageConfig `toml:"vonage" mapstructure:"vonage"` + TestOTP map[string]string `toml:"test_otp"` + MaxFrequency time.Duration `toml:"max_frequency"` + } + + hook struct { + MFAVerificationAttempt hookConfig `toml:"mfa_verification_attempt"` + PasswordVerificationAttempt hookConfig `toml:"password_verification_attempt"` + CustomAccessToken hookConfig `toml:"custom_access_token"` + SendSMS hookConfig `toml:"send_sms"` + SendEmail hookConfig `toml:"send_email"` + } + + factorTypeConfiguration struct { + EnrollEnabled bool `toml:"enroll_enabled"` + VerifyEnabled bool `toml:"verify_enabled"` + } + + phoneFactorTypeConfiguration struct { + factorTypeConfiguration + OtpLength uint `toml:"otp_length"` + Template string `toml:"template"` + MaxFrequency time.Duration `toml:"max_frequency"` + } + + mfa struct { + TOTP factorTypeConfiguration `toml:"totp"` + Phone phoneFactorTypeConfiguration `toml:"phone"` + WebAuthn factorTypeConfiguration `toml:"web_authn"` + MaxEnrolledFactors uint `toml:"max_enrolled_factors"` + } + + hookConfig struct { + Enabled bool `toml:"enabled"` + URI string `toml:"uri"` + Secrets string `toml:"secrets"` + } + + sessions struct { + Timebox time.Duration `toml:"timebox"` + InactivityTimeout time.Duration `toml:"inactivity_timeout"` + } + + twilioConfig struct { + Enabled bool `toml:"enabled"` + AccountSid string `toml:"account_sid"` + MessageServiceSid string `toml:"message_service_sid"` + AuthToken string `toml:"auth_token" mapstructure:"auth_token"` + } + + messagebirdConfig struct { + Enabled bool `toml:"enabled"` + Originator string `toml:"originator"` + AccessKey string `toml:"access_key" mapstructure:"access_key"` + } + + textlocalConfig struct { + Enabled bool `toml:"enabled"` + Sender string `toml:"sender"` + ApiKey string `toml:"api_key" mapstructure:"api_key"` + } + + vonageConfig struct { + Enabled bool `toml:"enabled"` + From string `toml:"from"` + ApiKey string `toml:"api_key" mapstructure:"api_key"` + ApiSecret string `toml:"api_secret" mapstructure:"api_secret"` + } + + provider struct { + Enabled bool `toml:"enabled"` + ClientId string `toml:"client_id"` + Secret string `toml:"secret"` + Url string `toml:"url"` + RedirectUri string `toml:"redirect_uri"` + SkipNonceCheck bool `toml:"skip_nonce_check"` + } +) diff --git a/pkg/config/config.go b/pkg/config/config.go index 6589fb4e5..b9056b095 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -165,172 +165,6 @@ type ( Pop3Port uint16 `toml:"pop3_port"` } - auth struct { - Enabled bool `toml:"enabled"` - Image string `toml:"-"` - SiteUrl string `toml:"site_url"` - AdditionalRedirectUrls []string `toml:"additional_redirect_urls"` - - JwtExpiry uint `toml:"jwt_expiry"` - EnableRefreshTokenRotation bool `toml:"enable_refresh_token_rotation"` - RefreshTokenReuseInterval uint `toml:"refresh_token_reuse_interval"` - EnableManualLinking bool `toml:"enable_manual_linking"` - - Hook hook `toml:"hook"` - MFA mfa `toml:"mfa"` - Sessions sessions `toml:"sessions"` - - EnableSignup bool `toml:"enable_signup"` - EnableAnonymousSignIns bool `toml:"enable_anonymous_sign_ins"` - Email email `toml:"email"` - Sms sms `toml:"sms"` - External map[string]provider - - // Custom secrets can be injected from .env file - JwtSecret string `toml:"-" mapstructure:"jwt_secret"` - AnonKey string `toml:"-" mapstructure:"anon_key"` - ServiceRoleKey string `toml:"-" mapstructure:"service_role_key"` - - ThirdParty thirdParty `toml:"third_party"` - } - - thirdParty struct { - Firebase tpaFirebase `toml:"firebase"` - Auth0 tpaAuth0 `toml:"auth0"` - Cognito tpaCognito `toml:"aws_cognito"` - } - - tpaFirebase struct { - Enabled bool `toml:"enabled"` - - ProjectID string `toml:"project_id"` - } - - tpaAuth0 struct { - Enabled bool `toml:"enabled"` - - Tenant string `toml:"tenant"` - TenantRegion string `toml:"tenant_region"` - } - - tpaCognito struct { - Enabled bool `toml:"enabled"` - - UserPoolID string `toml:"user_pool_id"` - UserPoolRegion string `toml:"user_pool_region"` - } - - email struct { - EnableSignup bool `toml:"enable_signup"` - DoubleConfirmChanges bool `toml:"double_confirm_changes"` - EnableConfirmations bool `toml:"enable_confirmations"` - SecurePasswordChange bool `toml:"secure_password_change"` - Template map[string]emailTemplate `toml:"template"` - Smtp smtp `toml:"smtp"` - MaxFrequency time.Duration `toml:"max_frequency"` - OtpLength uint `toml:"otp_length"` - OtpExpiry uint `toml:"otp_expiry"` - } - - smtp struct { - Host string `toml:"host"` - Port uint16 `toml:"port"` - User string `toml:"user"` - Pass string `toml:"pass"` - AdminEmail string `toml:"admin_email"` - SenderName string `toml:"sender_name"` - } - - emailTemplate struct { - Subject string `toml:"subject"` - ContentPath string `toml:"content_path"` - } - - sms struct { - EnableSignup bool `toml:"enable_signup"` - EnableConfirmations bool `toml:"enable_confirmations"` - Template string `toml:"template"` - Twilio twilioConfig `toml:"twilio" mapstructure:"twilio"` - TwilioVerify twilioConfig `toml:"twilio_verify" mapstructure:"twilio_verify"` - Messagebird messagebirdConfig `toml:"messagebird" mapstructure:"messagebird"` - Textlocal textlocalConfig `toml:"textlocal" mapstructure:"textlocal"` - Vonage vonageConfig `toml:"vonage" mapstructure:"vonage"` - TestOTP map[string]string `toml:"test_otp"` - MaxFrequency time.Duration `toml:"max_frequency"` - } - - hook struct { - MFAVerificationAttempt hookConfig `toml:"mfa_verification_attempt"` - PasswordVerificationAttempt hookConfig `toml:"password_verification_attempt"` - CustomAccessToken hookConfig `toml:"custom_access_token"` - SendSMS hookConfig `toml:"send_sms"` - SendEmail hookConfig `toml:"send_email"` - } - factorTypeConfiguration struct { - EnrollEnabled bool `toml:"enroll_enabled"` - VerifyEnabled bool `toml:"verify_enabled"` - } - - phoneFactorTypeConfiguration struct { - factorTypeConfiguration - OtpLength uint `toml:"otp_length"` - Template string `toml:"template"` - MaxFrequency time.Duration `toml:"max_frequency"` - } - - mfa struct { - TOTP factorTypeConfiguration `toml:"totp"` - Phone phoneFactorTypeConfiguration `toml:"phone"` - WebAuthn factorTypeConfiguration `toml:"web_authn"` - MaxEnrolledFactors uint `toml:"max_enrolled_factors"` - } - - hookConfig struct { - Enabled bool `toml:"enabled"` - URI string `toml:"uri"` - Secrets string `toml:"secrets"` - } - - sessions struct { - Timebox time.Duration `toml:"timebox"` - InactivityTimeout time.Duration `toml:"inactivity_timeout"` - } - - twilioConfig struct { - Enabled bool `toml:"enabled"` - AccountSid string `toml:"account_sid"` - MessageServiceSid string `toml:"message_service_sid"` - AuthToken string `toml:"auth_token" mapstructure:"auth_token"` - } - - messagebirdConfig struct { - Enabled bool `toml:"enabled"` - Originator string `toml:"originator"` - AccessKey string `toml:"access_key" mapstructure:"access_key"` - } - - textlocalConfig struct { - Enabled bool `toml:"enabled"` - Sender string `toml:"sender"` - ApiKey string `toml:"api_key" mapstructure:"api_key"` - } - - vonageConfig struct { - Enabled bool `toml:"enabled"` - From string `toml:"from"` - ApiKey string `toml:"api_key" mapstructure:"api_key"` - ApiSecret string `toml:"api_secret" mapstructure:"api_secret"` - } - - provider struct { - Enabled bool `toml:"enabled"` - ClientId string `toml:"client_id"` - Secret string `toml:"secret"` - Url string `toml:"url"` - RedirectUri string `toml:"redirect_uri"` - SkipNonceCheck bool `toml:"skip_nonce_check"` - } - edgeRuntime struct { Enabled bool `toml:"enabled"` Image string `toml:"-"` From 7752c114daa24d0c6a8cae5c4f949aa1132d065b Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Mon, 4 Nov 2024 22:36:47 +0800 Subject: [PATCH 125/305] feat(config): support global auth config update --- pkg/cast/cast.go | 20 ++++++++++- pkg/config/auth.go | 45 ++++++++++++++++++++++++ pkg/config/updater.go | 30 ++++++++++++++++ pkg/config/updater_test.go | 72 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 166 insertions(+), 1 deletion(-) diff --git a/pkg/cast/cast.go b/pkg/cast/cast.go index 3c7067163..1a276cda4 100644 --- a/pkg/cast/cast.go +++ b/pkg/cast/cast.go @@ -1,6 +1,9 @@ package cast -import "math" +import ( + "math" + "strings" +) // UintToInt converts a uint to an int, handling potential overflow func UintToInt(value uint) int { @@ -37,3 +40,18 @@ func IntToUintPtr(value *int) *uint { func Ptr[T any](v T) *T { return &v } + +func Val[T any](v *T, def T) T { + if v == nil { + return def + } + return *v +} + +func StrToArr(v string) []string { + // Avoid returning [""] if v is empty + if len(v) == 0 { + return nil + } + return strings.Split(v, ",") +} diff --git a/pkg/config/auth.go b/pkg/config/auth.go index aac6d0ed3..09df4f8ef 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -1,7 +1,12 @@ package config import ( + "strings" "time" + + v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/diff" ) type ( @@ -172,3 +177,43 @@ type ( SkipNonceCheck bool `toml:"skip_nonce_check"` } ) + +func (a *auth) ToUpdateAuthConfigBody() v1API.UpdateAuthConfigBody { + body := v1API.UpdateAuthConfigBody{ + SiteUrl: cast.Ptr(a.SiteUrl), + UriAllowList: cast.Ptr(strings.Join(a.AdditionalRedirectUrls, ",")), + JwtExp: cast.Ptr(cast.UintToInt(a.JwtExpiry)), + RefreshTokenRotationEnabled: cast.Ptr(a.EnableRefreshTokenRotation), + SecurityRefreshTokenReuseInterval: cast.Ptr(cast.UintToInt(a.RefreshTokenReuseInterval)), + SecurityManualLinkingEnabled: cast.Ptr(a.EnableManualLinking), + DisableSignup: cast.Ptr(!a.EnableSignup), + ExternalAnonymousUsersEnabled: cast.Ptr(a.EnableAnonymousSignIns), + } + return body +} + +func (a *auth) fromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) auth { + result := *a + result.SiteUrl = cast.Val(remoteConfig.SiteUrl, "") + result.AdditionalRedirectUrls = cast.StrToArr(cast.Val(remoteConfig.UriAllowList, "")) + result.JwtExpiry = cast.IntToUint(cast.Val(remoteConfig.JwtExp, 0)) + result.EnableRefreshTokenRotation = cast.Val(remoteConfig.RefreshTokenRotationEnabled, false) + result.RefreshTokenReuseInterval = cast.IntToUint(cast.Val(remoteConfig.SecurityRefreshTokenReuseInterval, 0)) + result.EnableManualLinking = cast.Val(remoteConfig.SecurityManualLinkingEnabled, false) + result.EnableSignup = !cast.Val(remoteConfig.DisableSignup, false) + result.EnableAnonymousSignIns = cast.Val(remoteConfig.ExternalAnonymousUsersEnabled, false) + return result +} + +func (a *auth) DiffWithRemote(remoteConfig v1API.AuthConfigResponse) ([]byte, error) { + // Convert the config values into easily comparable remoteConfig values + currentValue, err := ToTomlBytes(a) + if err != nil { + return nil, err + } + remoteCompare, err := ToTomlBytes(a.fromRemoteAuthConfig(remoteConfig)) + if err != nil { + return nil, err + } + return diff.Diff("remote[auth]", remoteCompare, "local[auth]", currentValue), nil +} diff --git a/pkg/config/updater.go b/pkg/config/updater.go index 04924124a..8dfcaa66e 100644 --- a/pkg/config/updater.go +++ b/pkg/config/updater.go @@ -24,6 +24,9 @@ func (u *ConfigUpdater) UpdateRemoteConfig(ctx context.Context, remote baseConfi if err := u.UpdateDbConfig(ctx, remote.ProjectId, remote.Db); err != nil { return err } + if err := u.UpdateAuthConfig(ctx, remote.ProjectId, remote.Auth); err != nil { + return err + } if err := u.UpdateStorageConfig(ctx, remote.ProjectId, remote.Storage); err != nil { return err } @@ -95,6 +98,33 @@ func (u *ConfigUpdater) UpdateDbConfig(ctx context.Context, projectRef string, c return nil } +func (u *ConfigUpdater) UpdateAuthConfig(ctx context.Context, projectRef string, c auth) error { + if !c.Enabled { + return nil + } + authConfig, err := u.client.V1GetAuthServiceConfigWithResponse(ctx, projectRef) + if err != nil { + return errors.Errorf("failed to read Auth config: %w", err) + } else if authConfig.JSON200 == nil { + return errors.Errorf("unexpected status %d: %s", authConfig.StatusCode(), string(authConfig.Body)) + } + authDiff, err := c.DiffWithRemote(*authConfig.JSON200) + if err != nil { + return err + } else if len(authDiff) == 0 { + fmt.Fprintln(os.Stderr, "Remote Auth config is up to date.") + return nil + } + fmt.Fprintln(os.Stderr, "Updating Auth service with config:", string(authDiff)) + + if resp, err := u.client.V1UpdateAuthServiceConfigWithResponse(ctx, projectRef, c.ToUpdateAuthConfigBody()); err != nil { + return errors.Errorf("failed to update Auth config: %w", err) + } else if status := resp.StatusCode(); status < 200 || status >= 300 { + return errors.Errorf("unexpected status %d: %s", status, string(resp.Body)) + } + return nil +} + func (u *ConfigUpdater) UpdateStorageConfig(ctx context.Context, projectRef string, c storage) error { if !c.Enabled { return nil diff --git a/pkg/config/updater_test.go b/pkg/config/updater_test.go index e0507dbde..1f2249d8c 100644 --- a/pkg/config/updater_test.go +++ b/pkg/config/updater_test.go @@ -155,6 +155,58 @@ func TestUpdateExperimentalConfig(t *testing.T) { }) } +func TestUpdateAuthConfig(t *testing.T) { + server := "http://localhost" + client, err := v1API.NewClientWithResponses(server) + require.NoError(t, err) + + t.Run("updates remote Auth config", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Setup mock server + defer gock.Off() + gock.New(server). + Get("/v1/projects/test-project/config/auth"). + Reply(http.StatusOK). + JSON(v1API.AuthConfigResponse{ + SiteUrl: cast.Ptr("http://localhost:3000"), + }) + gock.New(server). + Patch("/v1/projects/test-project/config/auth"). + Reply(http.StatusOK) + // Run test + err := updater.UpdateAuthConfig(context.Background(), "test-project", auth{Enabled: true}) + // Check result + assert.NoError(t, err) + assert.True(t, gock.IsDone()) + }) + + t.Run("skips update if no diff in Auth config", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Setup mock server + defer gock.Off() + gock.New(server). + Get("/v1/projects/test-project/config/auth"). + Reply(http.StatusOK). + JSON(v1API.AuthConfigResponse{}) + // Run test + err := updater.UpdateAuthConfig(context.Background(), "test-project", auth{ + Enabled: true, + EnableSignup: true, + }) + // Check result + assert.NoError(t, err) + assert.True(t, gock.IsDone()) + }) + + t.Run("skips update if disabled locally", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Run test + err := updater.UpdateAuthConfig(context.Background(), "test-project", auth{}) + // Check result + assert.NoError(t, err) + }) +} + func TestUpdateStorageConfig(t *testing.T) { server := "http://localhost" client, err := v1API.NewClientWithResponses(server) @@ -199,6 +251,14 @@ func TestUpdateStorageConfig(t *testing.T) { assert.NoError(t, err) assert.True(t, gock.IsDone()) }) + + t.Run("skips update if disabled locally", func(t *testing.T) { + updater := NewConfigUpdater(*client) + // Run test + err := updater.UpdateStorageConfig(context.Background(), "test-project", storage{}) + // Check result + assert.NoError(t, err) + }) } func TestUpdateRemoteConfig(t *testing.T) { @@ -233,6 +293,14 @@ func TestUpdateRemoteConfig(t *testing.T) { JSON(v1API.PostgresConfigResponse{ MaxConnections: cast.Ptr(cast.UintToInt(100)), }) + // Auth config + gock.New(server). + Get("/v1/projects/test-project/config/auth"). + Reply(http.StatusOK). + JSON(v1API.AuthConfigResponse{}) + gock.New(server). + Patch("/v1/projects/test-project/config/auth"). + Reply(http.StatusOK) // Storage config gock.New(server). Get("/v1/projects/test-project/config/storage"). @@ -259,6 +327,10 @@ func TestUpdateRemoteConfig(t *testing.T) { MaxConnections: cast.Ptr(cast.IntToUint(100)), }, }, + Auth: auth{ + Enabled: true, + SiteUrl: "http://localhost:3000", + }, Storage: storage{ Enabled: true, FileSizeLimit: 100, From 1c568bba6cb4311a54d232d48c2e144229cc8f2c Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Mon, 4 Nov 2024 22:37:24 +0800 Subject: [PATCH 126/305] fix(config): remove array of empty string --- pkg/cast/cast.go | 19 +++---------------- pkg/config/api.go | 10 ++++------ pkg/config/auth.go | 2 +- pkg/config/utils.go | 8 ++++++++ 4 files changed, 16 insertions(+), 23 deletions(-) diff --git a/pkg/cast/cast.go b/pkg/cast/cast.go index 1a276cda4..621ae9a61 100644 --- a/pkg/cast/cast.go +++ b/pkg/cast/cast.go @@ -1,18 +1,13 @@ package cast -import ( - "math" - "strings" -) +import "math" // UintToInt converts a uint to an int, handling potential overflow func UintToInt(value uint) int { if value <= math.MaxInt { - result := int(value) - return result + return int(value) } - maxInt := math.MaxInt - return maxInt + return math.MaxInt } // IntToUint converts an int to a uint, handling negative values @@ -47,11 +42,3 @@ func Val[T any](v *T, def T) T { } return *v } - -func StrToArr(v string) []string { - // Avoid returning [""] if v is empty - if len(v) == 0 { - return nil - } - return strings.Split(v, ",") -} diff --git a/pkg/config/api.go b/pkg/config/api.go index 51f516506..2bed7bc09 100644 --- a/pkg/config/api.go +++ b/pkg/config/api.go @@ -64,17 +64,15 @@ func (a *api) fromRemoteApiConfig(remoteConfig v1API.PostgrestConfigWithJWTSecre result.Enabled = true // Update Schemas if present in remoteConfig - schemas := strings.Split(remoteConfig.DbSchema, ",") - result.Schemas = make([]string, len(schemas)) + result.Schemas = strToArr(remoteConfig.DbSchema) // TODO: use slices.Map when upgrade go version - for i, schema := range schemas { + for i, schema := range result.Schemas { result.Schemas[i] = strings.TrimSpace(schema) } // Update ExtraSearchPath if present in remoteConfig - extraSearchPath := strings.Split(remoteConfig.DbExtraSearchPath, ",") - result.ExtraSearchPath = make([]string, len(extraSearchPath)) - for i, path := range extraSearchPath { + result.ExtraSearchPath = strToArr(remoteConfig.DbExtraSearchPath) + for i, path := range result.ExtraSearchPath { result.ExtraSearchPath[i] = strings.TrimSpace(path) } diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 09df4f8ef..d29c6f92c 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -195,7 +195,7 @@ func (a *auth) ToUpdateAuthConfigBody() v1API.UpdateAuthConfigBody { func (a *auth) fromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) auth { result := *a result.SiteUrl = cast.Val(remoteConfig.SiteUrl, "") - result.AdditionalRedirectUrls = cast.StrToArr(cast.Val(remoteConfig.UriAllowList, "")) + result.AdditionalRedirectUrls = strToArr(cast.Val(remoteConfig.UriAllowList, "")) result.JwtExpiry = cast.IntToUint(cast.Val(remoteConfig.JwtExp, 0)) result.EnableRefreshTokenRotation = cast.Val(remoteConfig.RefreshTokenRotationEnabled, false) result.RefreshTokenReuseInterval = cast.IntToUint(cast.Val(remoteConfig.SecurityRefreshTokenReuseInterval, 0)) diff --git a/pkg/config/utils.go b/pkg/config/utils.go index ac26a38d2..3101419eb 100644 --- a/pkg/config/utils.go +++ b/pkg/config/utils.go @@ -79,3 +79,11 @@ func replaceImageTag(image string, tag string) string { index := strings.IndexByte(image, ':') return image[:index+1] + strings.TrimSpace(tag) } + +func strToArr(v string) []string { + // Avoid returning [""] if v is empty + if len(v) == 0 { + return nil + } + return strings.Split(v, ",") +} From c697565c29be1828844ccbbc04507a693acf4f24 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Tue, 5 Nov 2024 00:02:04 +0800 Subject: [PATCH 127/305] chore: remove unnecessary cast --- pkg/config/auth.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/config/auth.go b/pkg/config/auth.go index d29c6f92c..9f428184c 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -180,14 +180,14 @@ type ( func (a *auth) ToUpdateAuthConfigBody() v1API.UpdateAuthConfigBody { body := v1API.UpdateAuthConfigBody{ - SiteUrl: cast.Ptr(a.SiteUrl), + SiteUrl: &a.SiteUrl, UriAllowList: cast.Ptr(strings.Join(a.AdditionalRedirectUrls, ",")), - JwtExp: cast.Ptr(cast.UintToInt(a.JwtExpiry)), - RefreshTokenRotationEnabled: cast.Ptr(a.EnableRefreshTokenRotation), - SecurityRefreshTokenReuseInterval: cast.Ptr(cast.UintToInt(a.RefreshTokenReuseInterval)), - SecurityManualLinkingEnabled: cast.Ptr(a.EnableManualLinking), + JwtExp: cast.UintToIntPtr(&a.JwtExpiry), + RefreshTokenRotationEnabled: &a.EnableRefreshTokenRotation, + SecurityRefreshTokenReuseInterval: cast.UintToIntPtr(&a.RefreshTokenReuseInterval), + SecurityManualLinkingEnabled: &a.EnableManualLinking, DisableSignup: cast.Ptr(!a.EnableSignup), - ExternalAnonymousUsersEnabled: cast.Ptr(a.EnableAnonymousSignIns), + ExternalAnonymousUsersEnabled: &a.EnableAnonymousSignIns, } return body } From b5c6ead610a95eb064b84f6b5729a7026ac7c8a8 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 6 Nov 2024 13:08:30 +0800 Subject: [PATCH 128/305] feat(config): sync sms config to remote (#2831) * feat(config): sync sms config to remote * chore: add unit tests for sms config --- pkg/config/auth.go | 141 +++++++++++++++++++- pkg/config/auth_test.go | 214 +++++++++++++++++++++++++++++++ pkg/config/config.go | 22 ++-- pkg/config/templates/config.toml | 2 +- pkg/config/updater.go | 2 +- pkg/config/utils.go | 33 +++++ 6 files changed, 398 insertions(+), 16 deletions(-) create mode 100644 pkg/config/auth_test.go diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 9f428184c..12c7ecc79 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -189,6 +189,7 @@ func (a *auth) ToUpdateAuthConfigBody() v1API.UpdateAuthConfigBody { DisableSignup: cast.Ptr(!a.EnableSignup), ExternalAnonymousUsersEnabled: &a.EnableAnonymousSignIns, } + a.Sms.toAuthConfigBody(&body) return body } @@ -202,18 +203,152 @@ func (a *auth) fromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) auth result.EnableManualLinking = cast.Val(remoteConfig.SecurityManualLinkingEnabled, false) result.EnableSignup = !cast.Val(remoteConfig.DisableSignup, false) result.EnableAnonymousSignIns = cast.Val(remoteConfig.ExternalAnonymousUsersEnabled, false) + result.Sms.fromAuthConfig(remoteConfig) return result } -func (a *auth) DiffWithRemote(remoteConfig v1API.AuthConfigResponse) ([]byte, error) { +func (s sms) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { + body.ExternalPhoneEnabled = &s.EnableSignup + body.SmsMaxFrequency = cast.Ptr(int(s.MaxFrequency.Seconds())) + body.SmsAutoconfirm = &s.EnableConfirmations + body.SmsTemplate = &s.Template + if otpString := mapToEnv(s.TestOTP); len(otpString) > 0 { + body.SmsTestOtp = &otpString + // Set a 10 year validity for test OTP + timestamp := time.Now().UTC().AddDate(10, 0, 0).Format(time.RFC3339) + body.SmsTestOtpValidUntil = ×tamp + } + // Api only overrides configs of enabled providers + switch { + case s.Twilio.Enabled: + body.SmsProvider = cast.Ptr("twilio") + body.SmsTwilioAuthToken = &s.Twilio.AuthToken + body.SmsTwilioAccountSid = &s.Twilio.AccountSid + body.SmsTwilioMessageServiceSid = &s.Twilio.MessageServiceSid + case s.TwilioVerify.Enabled: + body.SmsProvider = cast.Ptr("twilio_verify") + body.SmsTwilioVerifyAuthToken = &s.TwilioVerify.AuthToken + body.SmsTwilioVerifyAccountSid = &s.TwilioVerify.AccountSid + body.SmsTwilioVerifyMessageServiceSid = &s.TwilioVerify.MessageServiceSid + case s.Messagebird.Enabled: + body.SmsProvider = cast.Ptr("messagebird") + body.SmsMessagebirdAccessKey = &s.Messagebird.AccessKey + body.SmsMessagebirdOriginator = &s.Messagebird.Originator + case s.Textlocal.Enabled: + body.SmsProvider = cast.Ptr("textlocal") + body.SmsTextlocalApiKey = &s.Textlocal.ApiKey + body.SmsTextlocalSender = &s.Textlocal.Sender + case s.Vonage.Enabled: + body.SmsProvider = cast.Ptr("vonage") + body.SmsVonageApiSecret = &s.Vonage.ApiSecret + body.SmsVonageApiKey = &s.Vonage.ApiKey + body.SmsVonageFrom = &s.Vonage.From + } +} + +func (s *sms) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { + s.EnableSignup = cast.Val(remoteConfig.ExternalPhoneEnabled, false) + s.MaxFrequency = time.Duration(cast.Val(remoteConfig.SmsMaxFrequency, 0)) * time.Second + s.EnableConfirmations = cast.Val(remoteConfig.SmsAutoconfirm, false) + s.Template = cast.Val(remoteConfig.SmsTemplate, "") + s.TestOTP = envToMap(cast.Val(remoteConfig.SmsTestOtp, "")) + // We are only interested in the provider that's enabled locally + switch { + case s.Twilio.Enabled: + s.Twilio.AuthToken = hashPrefix + cast.Val(remoteConfig.SmsTwilioAuthToken, "") + s.Twilio.AccountSid = cast.Val(remoteConfig.SmsTwilioAccountSid, "") + s.Twilio.MessageServiceSid = cast.Val(remoteConfig.SmsTwilioMessageServiceSid, "") + case s.TwilioVerify.Enabled: + s.TwilioVerify.AuthToken = hashPrefix + cast.Val(remoteConfig.SmsTwilioVerifyAuthToken, "") + s.TwilioVerify.AccountSid = cast.Val(remoteConfig.SmsTwilioVerifyAccountSid, "") + s.TwilioVerify.MessageServiceSid = cast.Val(remoteConfig.SmsTwilioVerifyMessageServiceSid, "") + case s.Messagebird.Enabled: + s.Messagebird.AccessKey = hashPrefix + cast.Val(remoteConfig.SmsMessagebirdAccessKey, "") + s.Messagebird.Originator = cast.Val(remoteConfig.SmsMessagebirdOriginator, "") + case s.Textlocal.Enabled: + s.Textlocal.ApiKey = hashPrefix + cast.Val(remoteConfig.SmsTextlocalApiKey, "") + s.Textlocal.Sender = cast.Val(remoteConfig.SmsTextlocalSender, "") + case s.Vonage.Enabled: + s.Vonage.ApiSecret = hashPrefix + cast.Val(remoteConfig.SmsVonageApiSecret, "") + s.Vonage.ApiKey = cast.Val(remoteConfig.SmsVonageApiKey, "") + s.Vonage.From = cast.Val(remoteConfig.SmsVonageFrom, "") + case !s.EnableSignup: + // Nothing to do if both local and remote providers are disabled. + return + } + if provider := cast.Val(remoteConfig.SmsProvider, ""); len(provider) > 0 { + s.Twilio.Enabled = provider == "twilio" + s.TwilioVerify.Enabled = provider == "twilio_verify" + s.Messagebird.Enabled = provider == "messagebird" + s.Textlocal.Enabled = provider == "textlocal" + s.Vonage.Enabled = provider == "vonage" + } +} + +func (a *auth) DiffWithRemote(projectRef string, remoteConfig v1API.AuthConfigResponse) ([]byte, error) { + hashed := a.hashSecrets(projectRef) // Convert the config values into easily comparable remoteConfig values - currentValue, err := ToTomlBytes(a) + currentValue, err := ToTomlBytes(hashed) if err != nil { return nil, err } - remoteCompare, err := ToTomlBytes(a.fromRemoteAuthConfig(remoteConfig)) + remoteCompare, err := ToTomlBytes(hashed.fromRemoteAuthConfig(remoteConfig)) if err != nil { return nil, err } return diff.Diff("remote[auth]", remoteCompare, "local[auth]", currentValue), nil } + +const hashPrefix = "hash:" + +func (a *auth) hashSecrets(key string) auth { + hash := func(v string) string { + return hashPrefix + sha256Hmac(key, v) + } + result := *a + if len(result.Email.Smtp.Pass) > 0 { + result.Email.Smtp.Pass = hash(result.Email.Smtp.Pass) + } + // Only hash secrets for locally enabled providers because other envs won't be loaded + switch { + case result.Sms.Twilio.Enabled: + result.Sms.Twilio.AuthToken = hash(result.Sms.Twilio.AuthToken) + case result.Sms.TwilioVerify.Enabled: + result.Sms.TwilioVerify.AuthToken = hash(result.Sms.TwilioVerify.AuthToken) + case result.Sms.Messagebird.Enabled: + result.Sms.Messagebird.AccessKey = hash(result.Sms.Messagebird.AccessKey) + case result.Sms.Textlocal.Enabled: + result.Sms.Textlocal.ApiKey = hash(result.Sms.Textlocal.ApiKey) + case result.Sms.Vonage.Enabled: + result.Sms.Vonage.ApiSecret = hash(result.Sms.Vonage.ApiSecret) + } + if result.Hook.MFAVerificationAttempt.Enabled { + result.Hook.MFAVerificationAttempt.Secrets = hash(result.Hook.MFAVerificationAttempt.Secrets) + } + if result.Hook.PasswordVerificationAttempt.Enabled { + result.Hook.PasswordVerificationAttempt.Secrets = hash(result.Hook.PasswordVerificationAttempt.Secrets) + } + if result.Hook.CustomAccessToken.Enabled { + result.Hook.CustomAccessToken.Secrets = hash(result.Hook.CustomAccessToken.Secrets) + } + if result.Hook.SendSMS.Enabled { + result.Hook.SendSMS.Secrets = hash(result.Hook.SendSMS.Secrets) + } + if result.Hook.SendEmail.Enabled { + result.Hook.SendEmail.Secrets = hash(result.Hook.SendEmail.Secrets) + } + if size := len(a.External); size > 0 { + result.External = make(map[string]provider, size) + } + for name, provider := range a.External { + if provider.Enabled { + provider.Secret = hash(provider.Secret) + } + result.External[name] = provider + } + // Hide deprecated fields + delete(result.External, "slack") + delete(result.External, "linkedin") + // TODO: support SecurityCaptchaSecret in local config + return result +} diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go new file mode 100644 index 000000000..548253bda --- /dev/null +++ b/pkg/config/auth_test.go @@ -0,0 +1,214 @@ +package config + +import ( + "testing" + "time" + + "github.com/stretchr/testify/assert" + v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" +) + +func TestSmsDiff(t *testing.T) { + t.Run("local enabled remote enabled", func(t *testing.T) { + c := auth{EnableSignup: true, Sms: sms{ + EnableSignup: true, + EnableConfirmations: true, + Template: "Your code is {{ .Code }}", + TestOTP: map[string]string{"123": "456"}, + MaxFrequency: time.Minute, + Twilio: twilioConfig{ + Enabled: true, + AccountSid: "test-account", + MessageServiceSid: "test-service", + AuthToken: "test-token", + }, + }} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + ExternalPhoneEnabled: cast.Ptr(true), + SmsAutoconfirm: cast.Ptr(true), + SmsMaxFrequency: cast.Ptr(60), + SmsOtpExp: cast.Ptr(3600), + SmsOtpLength: 6, + SmsProvider: cast.Ptr("twilio"), + SmsTemplate: cast.Ptr("Your code is {{ .Code }}"), + SmsTestOtp: cast.Ptr("123=456"), + SmsTestOtpValidUntil: cast.Ptr("2050-01-01T01:00:00Z"), + SmsTwilioAccountSid: cast.Ptr("test-account"), + SmsTwilioAuthToken: cast.Ptr("c84443bc59b92caef8ec8500ff443584793756749523811eb333af2bbc74fc88"), + SmsTwilioContentSid: cast.Ptr("test-content"), + SmsTwilioMessageServiceSid: cast.Ptr("test-service"), + // Extra configs returned from api can be ignored + SmsMessagebirdAccessKey: cast.Ptr("test-messagebird-key"), + SmsMessagebirdOriginator: cast.Ptr("test-messagebird-originator"), + SmsTextlocalApiKey: cast.Ptr("test-textlocal-key"), + SmsTextlocalSender: cast.Ptr("test-textlocal-sencer"), + SmsTwilioVerifyAccountSid: cast.Ptr("test-verify-account"), + SmsTwilioVerifyAuthToken: cast.Ptr("test-verify-token"), + SmsTwilioVerifyMessageServiceSid: cast.Ptr("test-verify-service"), + SmsVonageApiKey: cast.Ptr("test-vonage-key"), + SmsVonageApiSecret: cast.Ptr("test-vonage-secret"), + SmsVonageFrom: cast.Ptr("test-vonage-from"), + }) + // Check error + assert.NoError(t, err) + assert.Empty(t, string(diff)) + }) + + t.Run("local disabled remote enabled", func(t *testing.T) { + c := auth{EnableSignup: true} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + ExternalPhoneEnabled: cast.Ptr(true), + SmsAutoconfirm: cast.Ptr(true), + SmsMaxFrequency: cast.Ptr(60), + SmsOtpExp: cast.Ptr(3600), + SmsOtpLength: 6, + SmsProvider: cast.Ptr("twilio"), + SmsTemplate: cast.Ptr("Your code is {{ .Code }}"), + SmsTestOtp: cast.Ptr("123=456,456=123"), + SmsTestOtpValidUntil: cast.Ptr("2050-01-01T01:00:00Z"), + SmsTwilioAccountSid: cast.Ptr("test-account"), + SmsTwilioAuthToken: cast.Ptr("c84443bc59b92caef8ec8500ff443584793756749523811eb333af2bbc74fc88"), + SmsTwilioContentSid: cast.Ptr("test-content"), + SmsTwilioMessageServiceSid: cast.Ptr("test-service"), + }) + // Check error + assert.NoError(t, err) + assert.Contains(t, string(diff), `-enable_signup = true`) + assert.Contains(t, string(diff), `-enable_confirmations = true`) + assert.Contains(t, string(diff), `-template = "Your code is {{ .Code }}"`) + assert.Contains(t, string(diff), `-max_frequency = "1m0s"`) + + assert.Contains(t, string(diff), `+enable_signup = false`) + assert.Contains(t, string(diff), `+enable_confirmations = false`) + assert.Contains(t, string(diff), `+template = ""`) + assert.Contains(t, string(diff), `+max_frequency = "0s"`) + + assert.Contains(t, string(diff), `[sms.twilio]`) + assert.Contains(t, string(diff), `-enabled = true`) + assert.Contains(t, string(diff), `+enabled = false`) + + assert.Contains(t, string(diff), `-[sms.test_otp]`) + assert.Contains(t, string(diff), `-123 = "456"`) + assert.Contains(t, string(diff), `-456 = "123"`) + }) + + t.Run("local enabled remote disabled", func(t *testing.T) { + c := auth{EnableSignup: true, Sms: sms{ + EnableSignup: true, + EnableConfirmations: true, + Template: "Your code is {{ .Code }}", + TestOTP: map[string]string{"123": "456"}, + MaxFrequency: time.Minute, + Messagebird: messagebirdConfig{ + Enabled: true, + Originator: "test-originator", + AccessKey: "test-access-key", + }, + }} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + ExternalPhoneEnabled: cast.Ptr(false), + SmsAutoconfirm: cast.Ptr(false), + SmsMaxFrequency: cast.Ptr(0), + SmsOtpExp: cast.Ptr(3600), + SmsOtpLength: 6, + SmsProvider: cast.Ptr("twilio"), + SmsTemplate: cast.Ptr(""), + SmsTwilioAccountSid: cast.Ptr("test-account"), + SmsTwilioAuthToken: cast.Ptr("c84443bc59b92caef8ec8500ff443584793756749523811eb333af2bbc74fc88"), + SmsTwilioContentSid: cast.Ptr("test-content"), + SmsTwilioMessageServiceSid: cast.Ptr("test-service"), + }) + // Check error + assert.NoError(t, err) + assert.Contains(t, string(diff), `-enable_signup = false`) + assert.Contains(t, string(diff), `-enable_confirmations = false`) + assert.Contains(t, string(diff), `-template = ""`) + assert.Contains(t, string(diff), `-max_frequency = "0s"`) + + assert.Contains(t, string(diff), `+enable_signup = true`) + assert.Contains(t, string(diff), `+enable_confirmations = true`) + assert.Contains(t, string(diff), `+template = "Your code is {{ .Code }}"`) + assert.Contains(t, string(diff), `+max_frequency = "1m0s"`) + + assert.Contains(t, string(diff), `[sms.twilio]`) + assert.Contains(t, string(diff), `-enabled = true`) + assert.Contains(t, string(diff), `+enabled = false`) + + assert.Contains(t, string(diff), `[sms.messagebird]`) + assert.Contains(t, string(diff), `-enabled = false`) + assert.Contains(t, string(diff), `-originator = ""`) + assert.Contains(t, string(diff), `-access_key = "hash:"`) + assert.Contains(t, string(diff), `+enabled = true`) + assert.Contains(t, string(diff), `+originator = "test-originator"`) + assert.Contains(t, string(diff), `+access_key = "hash:ab60d03fc809fb02dae838582f3ddc13d1d6cb32ffba77c4b969dd3caa496f13"`) + + assert.Contains(t, string(diff), `+[sms.test_otp]`) + assert.Contains(t, string(diff), `+123 = "456"`) + }) + + t.Run("local disabled remote disabled", func(t *testing.T) { + c := auth{EnableSignup: true, Sms: sms{ + EnableSignup: false, + EnableConfirmations: true, + Template: "Your code is {{ .Code }}", + TestOTP: map[string]string{"123": "456"}, + MaxFrequency: time.Minute, + }} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + ExternalPhoneEnabled: cast.Ptr(false), + SmsAutoconfirm: cast.Ptr(true), + SmsMaxFrequency: cast.Ptr(60), + SmsOtpExp: cast.Ptr(3600), + SmsOtpLength: 6, + SmsTemplate: cast.Ptr("Your code is {{ .Code }}"), + SmsTestOtp: cast.Ptr("123=456"), + SmsTestOtpValidUntil: cast.Ptr("2050-01-01T01:00:00Z"), + SmsProvider: cast.Ptr("messagebird"), + SmsMessagebirdAccessKey: cast.Ptr("test-messagebird-key"), + SmsMessagebirdOriginator: cast.Ptr("test-messagebird-originator"), + }) + // Check error + assert.NoError(t, err) + assert.Empty(t, string(diff)) + }) + + t.Run("enable sign up without provider", func(t *testing.T) { + // This is not a valid config because platform requires a SMS provider. + // For consistency, we handle this in config.Load and emit a warning. + c := auth{EnableSignup: true, Sms: sms{ + EnableSignup: true, + }} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + ExternalPhoneEnabled: cast.Ptr(false), + SmsProvider: cast.Ptr("twilio"), + }) + // Check error + assert.NoError(t, err) + assert.Contains(t, string(diff), `[sms]`) + assert.Contains(t, string(diff), `-enable_signup = false`) + assert.Contains(t, string(diff), `+enable_signup = true`) + }) + + t.Run("enable provider without sign up", func(t *testing.T) { + c := auth{EnableSignup: true, Sms: sms{ + Messagebird: messagebirdConfig{ + Enabled: true, + }, + }} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + ExternalPhoneEnabled: cast.Ptr(false), + SmsProvider: cast.Ptr("messagebird"), + SmsMessagebirdAccessKey: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + }) + // Check error + assert.NoError(t, err) + assert.Empty(t, string(diff)) + }) +} diff --git a/pkg/config/config.go b/pkg/config/config.go index b9056b095..5f167386b 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -553,7 +553,7 @@ func (c *baseConfig) Validate(fsys fs.FS) error { if c.ProjectId == "" { return errors.New("Missing required field in config: project_id") } else if sanitized := sanitizeProjectId(c.ProjectId); sanitized != c.ProjectId { - fmt.Fprintln(os.Stderr, "WARNING:", "project_id field in config is invalid. Auto-fixing to", sanitized) + fmt.Fprintln(os.Stderr, "WARN: project_id field in config is invalid. Auto-fixing to", sanitized) c.ProjectId = sanitized } // Validate api config @@ -665,7 +665,8 @@ func (c *baseConfig) Validate(fsys fs.FS) error { return err } // Validate sms config - if c.Auth.Sms.Twilio.Enabled { + switch { + case c.Auth.Sms.Twilio.Enabled: if len(c.Auth.Sms.Twilio.AccountSid) == 0 { return errors.New("Missing required field in config: auth.sms.twilio.account_sid") } @@ -678,8 +679,7 @@ func (c *baseConfig) Validate(fsys fs.FS) error { if c.Auth.Sms.Twilio.AuthToken, err = maybeLoadEnv(c.Auth.Sms.Twilio.AuthToken); err != nil { return err } - } - if c.Auth.Sms.TwilioVerify.Enabled { + case c.Auth.Sms.TwilioVerify.Enabled: if len(c.Auth.Sms.TwilioVerify.AccountSid) == 0 { return errors.New("Missing required field in config: auth.sms.twilio_verify.account_sid") } @@ -692,8 +692,7 @@ func (c *baseConfig) Validate(fsys fs.FS) error { if c.Auth.Sms.TwilioVerify.AuthToken, err = maybeLoadEnv(c.Auth.Sms.TwilioVerify.AuthToken); err != nil { return err } - } - if c.Auth.Sms.Messagebird.Enabled { + case c.Auth.Sms.Messagebird.Enabled: if len(c.Auth.Sms.Messagebird.Originator) == 0 { return errors.New("Missing required field in config: auth.sms.messagebird.originator") } @@ -703,8 +702,7 @@ func (c *baseConfig) Validate(fsys fs.FS) error { if c.Auth.Sms.Messagebird.AccessKey, err = maybeLoadEnv(c.Auth.Sms.Messagebird.AccessKey); err != nil { return err } - } - if c.Auth.Sms.Textlocal.Enabled { + case c.Auth.Sms.Textlocal.Enabled: if len(c.Auth.Sms.Textlocal.Sender) == 0 { return errors.New("Missing required field in config: auth.sms.textlocal.sender") } @@ -714,8 +712,7 @@ func (c *baseConfig) Validate(fsys fs.FS) error { if c.Auth.Sms.Textlocal.ApiKey, err = maybeLoadEnv(c.Auth.Sms.Textlocal.ApiKey); err != nil { return err } - } - if c.Auth.Sms.Vonage.Enabled { + case c.Auth.Sms.Vonage.Enabled: if len(c.Auth.Sms.Vonage.From) == 0 { return errors.New("Missing required field in config: auth.sms.vonage.from") } @@ -731,6 +728,9 @@ func (c *baseConfig) Validate(fsys fs.FS) error { if c.Auth.Sms.Vonage.ApiSecret, err = maybeLoadEnv(c.Auth.Sms.Vonage.ApiSecret); err != nil { return err } + case c.Auth.Sms.EnableSignup: + c.Auth.Sms.EnableSignup = false + fmt.Fprintln(os.Stderr, "WARN: no SMS provider is enabled. Disabling phone login") } if err := c.Auth.Hook.MFAVerificationAttempt.HandleHook("mfa_verification_attempt"); err != nil { return err @@ -895,7 +895,7 @@ func (c *seed) loadSeedPaths(basePath string, fsys fs.FS) error { return errors.Errorf("failed to apply glob pattern: %w", err) } if len(matches) == 0 { - fmt.Fprintln(os.Stderr, "No seed files matched pattern:", pattern) + fmt.Fprintln(os.Stderr, "WARN: no seed files matched pattern:", pattern) } sort.Strings(matches) // Remove duplicates diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index e47487c21..8df89bea3 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -142,7 +142,7 @@ otp_expiry = 3600 [auth.sms] # Allow/disallow new user signups via SMS to your project. -enable_signup = true +enable_signup = false # If enabled, users need to confirm their phone number before signing in. enable_confirmations = false # Template for sending OTP to users diff --git a/pkg/config/updater.go b/pkg/config/updater.go index 8dfcaa66e..466b37c1b 100644 --- a/pkg/config/updater.go +++ b/pkg/config/updater.go @@ -108,7 +108,7 @@ func (u *ConfigUpdater) UpdateAuthConfig(ctx context.Context, projectRef string, } else if authConfig.JSON200 == nil { return errors.Errorf("unexpected status %d: %s", authConfig.StatusCode(), string(authConfig.Body)) } - authDiff, err := c.DiffWithRemote(*authConfig.JSON200) + authDiff, err := c.DiffWithRemote(projectRef, *authConfig.JSON200) if err != nil { return err } else if len(authDiff) == 0 { diff --git a/pkg/config/utils.go b/pkg/config/utils.go index 3101419eb..2dd9c1aae 100644 --- a/pkg/config/utils.go +++ b/pkg/config/utils.go @@ -1,6 +1,10 @@ package config import ( + "crypto/hmac" + "crypto/sha256" + "encoding/hex" + "fmt" "path/filepath" "strings" ) @@ -87,3 +91,32 @@ func strToArr(v string) []string { } return strings.Split(v, ",") } + +func mapToEnv(input map[string]string) string { + var result []string + for k, v := range input { + kv := fmt.Sprintf("%s=%s", k, v) + result = append(result, kv) + } + return strings.Join(result, ",") +} + +func envToMap(input string) map[string]string { + env := strToArr(input) + if len(env) == 0 { + return nil + } + result := make(map[string]string, len(env)) + for _, kv := range env { + if parts := strings.Split(kv, "="); len(parts) > 1 { + result[parts[0]] = parts[1] + } + } + return result +} + +func sha256Hmac(key, value string) string { + h := hmac.New(sha256.New, []byte(key)) + h.Write([]byte(value)) + return hex.EncodeToString(h.Sum(nil)) +} From cc62b3c09d68a4faea540198c5271abe6f12b6fd Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Wed, 6 Nov 2024 09:46:35 +0100 Subject: [PATCH 129/305] chore: refactor let api decide for restart (#2835) --- go.mod | 2 +- pkg/config/db.go | 11 ----------- pkg/config/updater.go | 7 ------- 3 files changed, 1 insertion(+), 19 deletions(-) diff --git a/go.mod b/go.mod index b1f94ae6b..9545fde60 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,6 @@ require ( github.com/go-xmlfmt/xmlfmt v1.1.2 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/golangci/golangci-lint v1.61.0 - github.com/google/go-cmp v0.6.0 github.com/google/go-github/v62 v62.0.0 github.com/google/go-querystring v1.1.0 github.com/google/uuid v1.6.0 @@ -170,6 +169,7 @@ require ( github.com/golangci/plugin-module-register v0.1.1 // indirect github.com/golangci/revgrep v0.5.3 // indirect github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect + github.com/google/go-cmp v0.6.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/gordonklaus/ineffassign v0.1.0 // indirect github.com/gorilla/css v1.0.0 // indirect diff --git a/pkg/config/db.go b/pkg/config/db.go index e7c5f820b..7ce21fad0 100644 --- a/pkg/config/db.go +++ b/pkg/config/db.go @@ -3,7 +3,6 @@ package config import ( "bytes" - "github.com/google/go-cmp/cmp" v1API "github.com/supabase/cli/pkg/api" "github.com/supabase/cli/pkg/cast" "github.com/supabase/cli/pkg/diff" @@ -81,16 +80,6 @@ type ( } ) -// Compare two db config, if changes requires restart return true, return false otherwise -func (a settings) requireDbRestart(b settings) bool { - return !cmp.Equal(a.MaxConnections, b.MaxConnections) || - !cmp.Equal(a.MaxWorkerProcesses, b.MaxWorkerProcesses) || - !cmp.Equal(a.MaxParallelWorkers, b.MaxParallelWorkers) || - !cmp.Equal(a.MaxWalSenders, b.MaxWalSenders) || - !cmp.Equal(a.MaxReplicationSlots, b.MaxReplicationSlots) || - !cmp.Equal(a.SharedBuffers, b.SharedBuffers) -} - func (a *settings) ToUpdatePostgresConfigBody() v1API.UpdatePostgresConfigBody { body := v1API.UpdatePostgresConfigBody{} diff --git a/pkg/config/updater.go b/pkg/config/updater.go index 466b37c1b..832eb639b 100644 --- a/pkg/config/updater.go +++ b/pkg/config/updater.go @@ -75,14 +75,7 @@ func (u *ConfigUpdater) UpdateDbSettingsConfig(ctx context.Context, projectRef s return nil } fmt.Fprintln(os.Stderr, "Updating DB service with config:", string(dbDiff)) - - remoteConfig := s.fromRemoteConfig(*dbConfig.JSON200) - restartRequired := s.requireDbRestart(remoteConfig) - if restartRequired { - fmt.Fprintln(os.Stderr, "Database will be restarted to apply config updates...") - } updateBody := s.ToUpdatePostgresConfigBody() - updateBody.RestartDatabase = &restartRequired if resp, err := u.client.V1UpdatePostgresConfigWithResponse(ctx, projectRef, updateBody); err != nil { return errors.Errorf("failed to update DB config: %w", err) } else if resp.JSON200 == nil { From 9320b5406cdd9fa586c1ffd9fa48b093763583e5 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 6 Nov 2024 16:49:04 +0800 Subject: [PATCH 130/305] fix(studio): bump studio image to 20241106-fe0e32d (#2838) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index bfce77336..4e6ec76b3 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -10,7 +10,7 @@ const ( inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" pgmetaImage = "supabase/postgres-meta:v0.84.2" - studioImage = "supabase/studio:20241104-531a96a" + studioImage = "supabase/studio:20241106-fe0e32d" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.61.0" vectorImage = "timberio/vector:0.28.1-alpine" From 5bd2b619f4160d7be3c33c7e0cff16041a8be330 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 6 Nov 2024 16:58:53 +0800 Subject: [PATCH 131/305] fix(functions): create new reader for retrying deploy (#2840) --- pkg/function/batch.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/function/batch.go b/pkg/function/batch.go index 1d52bace4..43f837fc4 100644 --- a/pkg/function/batch.go +++ b/pkg/function/batch.go @@ -55,7 +55,7 @@ func (s *EdgeRuntimeAPI) UpsertFunctions(ctx context.Context, functionConfig con VerifyJwt: function.VerifyJWT, ImportMapPath: toFileURL(function.ImportMap), EntrypointPath: toFileURL(function.Entrypoint), - }, eszipContentType, &body); err != nil { + }, eszipContentType, bytes.NewReader(body.Bytes())); err != nil { return errors.Errorf("failed to update function: %w", err) } else if resp.JSON200 == nil { return errors.Errorf("unexpected status %d: %s", resp.StatusCode(), string(resp.Body)) @@ -67,7 +67,7 @@ func (s *EdgeRuntimeAPI) UpsertFunctions(ctx context.Context, functionConfig con VerifyJwt: function.VerifyJWT, ImportMapPath: toFileURL(function.ImportMap), EntrypointPath: toFileURL(function.Entrypoint), - }, eszipContentType, &body); err != nil { + }, eszipContentType, bytes.NewReader(body.Bytes())); err != nil { return errors.Errorf("failed to create function: %w", err) } else if resp.JSON201 == nil { return errors.Errorf("unexpected status %d: %s", resp.StatusCode(), string(resp.Body)) From 2564fc61a2d070201e114e4879bfa1a4fe570a2c Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 6 Nov 2024 22:30:06 +0800 Subject: [PATCH 132/305] feat(config): sync external provider config to remote (#2839) --- pkg/config/auth.go | 278 ++++++++++++++++++++++++++++++++++++++-- pkg/config/auth_test.go | 203 +++++++++++++++++++++++++++++ pkg/config/config.go | 8 ++ 3 files changed, 481 insertions(+), 8 deletions(-) diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 12c7ecc79..0de7315a6 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -1,6 +1,7 @@ package config import ( + "maps" "strings" "time" @@ -25,11 +26,11 @@ type ( MFA mfa `toml:"mfa"` Sessions sessions `toml:"sessions"` - EnableSignup bool `toml:"enable_signup"` - EnableAnonymousSignIns bool `toml:"enable_anonymous_sign_ins"` - Email email `toml:"email"` - Sms sms `toml:"sms"` - External map[string]provider `toml:"external"` + EnableSignup bool `toml:"enable_signup"` + EnableAnonymousSignIns bool `toml:"enable_anonymous_sign_ins"` + Email email `toml:"email"` + Sms sms `toml:"sms"` + External external `toml:"external"` // Custom secrets can be injected from .env file JwtSecret string `toml:"-" mapstructure:"jwt_secret"` @@ -39,6 +40,8 @@ type ( ThirdParty thirdParty `toml:"third_party"` } + external map[string]provider + thirdParty struct { Firebase tpaFirebase `toml:"firebase"` Auth0 tpaAuth0 `toml:"auth0"` @@ -190,6 +193,7 @@ func (a *auth) ToUpdateAuthConfigBody() v1API.UpdateAuthConfigBody { ExternalAnonymousUsersEnabled: &a.EnableAnonymousSignIns, } a.Sms.toAuthConfigBody(&body) + a.External.toAuthConfigBody(&body) return body } @@ -204,6 +208,8 @@ func (a *auth) fromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) auth result.EnableSignup = !cast.Val(remoteConfig.DisableSignup, false) result.EnableAnonymousSignIns = cast.Val(remoteConfig.ExternalAnonymousUsersEnabled, false) result.Sms.fromAuthConfig(remoteConfig) + result.External = maps.Clone(result.External) + result.External.fromAuthConfig(remoteConfig) return result } @@ -285,6 +291,265 @@ func (s *sms) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { } } +func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { + if len(e) == 0 { + return + } + var p *provider + // Ignore configs of disabled providers because their envs are not loaded + p = cast.Ptr(e["apple"]) + if body.ExternalAppleEnabled = &p.Enabled; *body.ExternalAppleEnabled { + body.ExternalAppleClientId = &p.ClientId + body.ExternalAppleSecret = &p.Secret + } + p = cast.Ptr(e["azure"]) + if body.ExternalAzureEnabled = &p.Enabled; *body.ExternalAzureEnabled { + body.ExternalAzureClientId = &p.ClientId + body.ExternalAzureSecret = &p.Secret + body.ExternalAzureUrl = &p.Url + } + p = cast.Ptr(e["bitbucket"]) + if body.ExternalBitbucketEnabled = &p.Enabled; *body.ExternalBitbucketEnabled { + body.ExternalBitbucketClientId = &p.ClientId + body.ExternalBitbucketSecret = &p.Secret + } + p = cast.Ptr(e["discord"]) + if body.ExternalDiscordEnabled = &p.Enabled; *body.ExternalDiscordEnabled { + body.ExternalDiscordClientId = &p.ClientId + body.ExternalDiscordSecret = &p.Secret + } + p = cast.Ptr(e["facebook"]) + if body.ExternalFacebookEnabled = &p.Enabled; *body.ExternalFacebookEnabled { + body.ExternalFacebookClientId = &p.ClientId + body.ExternalFacebookSecret = &p.Secret + } + p = cast.Ptr(e["figma"]) + if body.ExternalFigmaEnabled = &p.Enabled; *body.ExternalFigmaEnabled { + body.ExternalFigmaClientId = &p.ClientId + body.ExternalFigmaSecret = &p.Secret + } + p = cast.Ptr(e["github"]) + if body.ExternalGithubEnabled = &p.Enabled; *body.ExternalGithubEnabled { + body.ExternalGithubClientId = &p.ClientId + body.ExternalGithubSecret = &p.Secret + } + p = cast.Ptr(e["gitlab"]) + if body.ExternalGitlabEnabled = &p.Enabled; *body.ExternalGitlabEnabled { + body.ExternalGitlabClientId = &p.ClientId + body.ExternalGitlabSecret = &p.Secret + body.ExternalGitlabUrl = &p.Url + } + p = cast.Ptr(e["google"]) + if body.ExternalGoogleEnabled = &p.Enabled; *body.ExternalGoogleEnabled { + body.ExternalGoogleClientId = &p.ClientId + body.ExternalGoogleSecret = &p.Secret + body.ExternalGoogleSkipNonceCheck = &p.SkipNonceCheck + } + p = cast.Ptr(e["kakao"]) + if body.ExternalKakaoEnabled = &p.Enabled; *body.ExternalKakaoEnabled { + body.ExternalKakaoClientId = &p.ClientId + body.ExternalKakaoSecret = &p.Secret + } + p = cast.Ptr(e["keycloak"]) + if body.ExternalKeycloakEnabled = &p.Enabled; *body.ExternalKeycloakEnabled { + body.ExternalKeycloakClientId = &p.ClientId + body.ExternalKeycloakSecret = &p.Secret + body.ExternalKeycloakUrl = &p.Url + } + p = cast.Ptr(e["linkedin_oidc"]) + if body.ExternalLinkedinOidcEnabled = &p.Enabled; *body.ExternalLinkedinOidcEnabled { + body.ExternalLinkedinOidcClientId = &p.ClientId + body.ExternalLinkedinOidcSecret = &p.Secret + } + p = cast.Ptr(e["notion"]) + if body.ExternalNotionEnabled = &p.Enabled; *body.ExternalNotionEnabled { + body.ExternalNotionClientId = &p.ClientId + body.ExternalNotionSecret = &p.Secret + } + p = cast.Ptr(e["slack_oidc"]) + if body.ExternalSlackOidcEnabled = &p.Enabled; *body.ExternalSlackOidcEnabled { + body.ExternalSlackOidcClientId = &p.ClientId + body.ExternalSlackOidcSecret = &p.Secret + } + p = cast.Ptr(e["spotify"]) + if body.ExternalSpotifyEnabled = &p.Enabled; *body.ExternalSpotifyEnabled { + body.ExternalSpotifyClientId = &p.ClientId + body.ExternalSpotifySecret = &p.Secret + } + p = cast.Ptr(e["twitch"]) + if body.ExternalTwitchEnabled = &p.Enabled; *body.ExternalTwitchEnabled { + body.ExternalTwitchClientId = &p.ClientId + body.ExternalTwitchSecret = &p.Secret + } + p = cast.Ptr(e["twitter"]) + if body.ExternalTwitterEnabled = &p.Enabled; *body.ExternalTwitterEnabled { + body.ExternalTwitterClientId = &p.ClientId + body.ExternalTwitterSecret = &p.Secret + } + p = cast.Ptr(e["workos"]) + if body.ExternalWorkosEnabled = &p.Enabled; *body.ExternalWorkosEnabled { + body.ExternalWorkosClientId = &p.ClientId + body.ExternalWorkosSecret = &p.Secret + body.ExternalWorkosUrl = &p.Url + } + p = cast.Ptr(e["zoom"]) + if body.ExternalZoomEnabled = &p.Enabled; *body.ExternalZoomEnabled { + body.ExternalZoomClientId = &p.ClientId + body.ExternalZoomSecret = &p.Secret + } +} + +func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { + if len(e) == 0 { + return + } + var p provider + // Ignore configs of disabled providers because their envs are not loaded + if p = e["apple"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalAppleClientId, "") + if ids := cast.Val(remoteConfig.ExternalAppleAdditionalClientIds, ""); len(ids) > 0 { + p.ClientId += "," + ids + } + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalAppleSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalAppleEnabled, false) + e["apple"] = p + + if p = e["azure"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalAzureClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalAzureSecret, "") + p.Url = cast.Val(remoteConfig.ExternalAzureUrl, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalAzureEnabled, false) + e["azure"] = p + + if p = e["bitbucket"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalBitbucketClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalBitbucketSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalBitbucketEnabled, false) + e["bitbucket"] = p + + if p = e["discord"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalDiscordClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalDiscordSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalDiscordEnabled, false) + e["discord"] = p + + if p = e["facebook"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalFacebookClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalFacebookSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalFacebookEnabled, false) + e["facebook"] = p + + if p = e["figma"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalFigmaClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalFigmaSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalFigmaEnabled, false) + e["figma"] = p + + if p = e["github"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalGithubClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalGithubSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalGithubEnabled, false) + e["github"] = p + + if p = e["gitlab"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalGitlabClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalGitlabSecret, "") + p.Url = cast.Val(remoteConfig.ExternalGitlabUrl, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalGitlabEnabled, false) + e["gitlab"] = p + + if p = e["google"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalGoogleClientId, "") + if ids := cast.Val(remoteConfig.ExternalGoogleAdditionalClientIds, ""); len(ids) > 0 { + p.ClientId += "," + ids + } + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalGoogleSecret, "") + p.SkipNonceCheck = cast.Val(remoteConfig.ExternalGoogleSkipNonceCheck, false) + } + p.Enabled = cast.Val(remoteConfig.ExternalGoogleEnabled, false) + e["google"] = p + + if p = e["kakao"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalKakaoClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalKakaoSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalKakaoEnabled, false) + e["kakao"] = p + + if p = e["keycloak"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalKeycloakClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalKeycloakSecret, "") + p.Url = cast.Val(remoteConfig.ExternalKeycloakUrl, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalKeycloakEnabled, false) + e["keycloak"] = p + + if p = e["linkedin_oidc"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalLinkedinOidcClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalLinkedinOidcSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalLinkedinOidcEnabled, false) + e["linkedin_oidc"] = p + + if p = e["notion"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalNotionClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalNotionSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalNotionEnabled, false) + e["notion"] = p + + if p = e["slack_oidc"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalSlackOidcClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalSlackOidcSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalSlackOidcEnabled, false) + e["slack_oidc"] = p + + if p = e["spotify"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalSpotifyClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalSpotifySecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalSpotifyEnabled, false) + e["spotify"] = p + + if p = e["twitch"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalTwitchClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalTwitchSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalTwitchEnabled, false) + e["twitch"] = p + + if p = e["twitter"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalTwitterClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalTwitterSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalTwitterEnabled, false) + e["twitter"] = p + + if p = e["workos"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalWorkosClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalWorkosSecret, "") + p.Url = cast.Val(remoteConfig.ExternalWorkosUrl, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalWorkosEnabled, false) + e["workos"] = p + + if p = e["zoom"]; p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalZoomClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalZoomSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalZoomEnabled, false) + e["zoom"] = p +} + func (a *auth) DiffWithRemote(projectRef string, remoteConfig v1API.AuthConfigResponse) ([]byte, error) { hashed := a.hashSecrets(projectRef) // Convert the config values into easily comparable remoteConfig values @@ -346,9 +611,6 @@ func (a *auth) hashSecrets(key string) auth { } result.External[name] = provider } - // Hide deprecated fields - delete(result.External, "slack") - delete(result.External, "linkedin") // TODO: support SecurityCaptchaSecret in local config return result } diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index 548253bda..4de37b8d1 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -212,3 +212,206 @@ func TestSmsDiff(t *testing.T) { assert.Empty(t, string(diff)) }) } + +func TestExternalDiff(t *testing.T) { + t.Run("local and remote enabled", func(t *testing.T) { + c := auth{EnableSignup: true, External: map[string]provider{ + "apple": {Enabled: true}, + "azure": {Enabled: true}, + "bitbucket": {Enabled: true}, + "discord": {Enabled: true}, + "facebook": {Enabled: true}, + "figma": {Enabled: true}, + "github": {Enabled: true}, + "gitlab": {Enabled: true}, + "google": {Enabled: true}, + "kakao": {Enabled: true}, + "keycloak": {Enabled: true}, + "linkedin_oidc": {Enabled: true}, + "notion": {Enabled: true}, + "slack_oidc": {Enabled: true}, + "spotify": {Enabled: true}, + "twitch": {Enabled: true}, + "twitter": {Enabled: true}, + "workos": {Enabled: true}, + "zoom": {Enabled: true}, + }} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + ExternalAppleAdditionalClientIds: cast.Ptr(""), + ExternalAppleClientId: cast.Ptr(""), + ExternalAppleEnabled: cast.Ptr(true), + ExternalAppleSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalAzureClientId: cast.Ptr(""), + ExternalAzureEnabled: cast.Ptr(true), + ExternalAzureSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalAzureUrl: cast.Ptr(""), + ExternalBitbucketClientId: cast.Ptr(""), + ExternalBitbucketEnabled: cast.Ptr(true), + ExternalBitbucketSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalDiscordClientId: cast.Ptr(""), + ExternalDiscordEnabled: cast.Ptr(true), + ExternalDiscordSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalFacebookClientId: cast.Ptr(""), + ExternalFacebookEnabled: cast.Ptr(true), + ExternalFacebookSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalFigmaClientId: cast.Ptr(""), + ExternalFigmaEnabled: cast.Ptr(true), + ExternalFigmaSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalGithubClientId: cast.Ptr(""), + ExternalGithubEnabled: cast.Ptr(true), + ExternalGithubSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalGitlabClientId: cast.Ptr(""), + ExternalGitlabEnabled: cast.Ptr(true), + ExternalGitlabSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalGitlabUrl: cast.Ptr(""), + ExternalGoogleAdditionalClientIds: cast.Ptr(""), + ExternalGoogleClientId: cast.Ptr(""), + ExternalGoogleEnabled: cast.Ptr(true), + ExternalGoogleSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalGoogleSkipNonceCheck: cast.Ptr(false), + ExternalKakaoClientId: cast.Ptr(""), + ExternalKakaoEnabled: cast.Ptr(true), + ExternalKakaoSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalKeycloakClientId: cast.Ptr(""), + ExternalKeycloakEnabled: cast.Ptr(true), + ExternalKeycloakSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalKeycloakUrl: cast.Ptr(""), + ExternalLinkedinOidcClientId: cast.Ptr(""), + ExternalLinkedinOidcEnabled: cast.Ptr(true), + ExternalLinkedinOidcSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalNotionClientId: cast.Ptr(""), + ExternalNotionEnabled: cast.Ptr(true), + ExternalNotionSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalSlackOidcClientId: cast.Ptr(""), + ExternalSlackOidcEnabled: cast.Ptr(true), + ExternalSlackOidcSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalSpotifyClientId: cast.Ptr(""), + ExternalSpotifyEnabled: cast.Ptr(true), + ExternalSpotifySecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalTwitchClientId: cast.Ptr(""), + ExternalTwitchEnabled: cast.Ptr(true), + ExternalTwitchSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalTwitterClientId: cast.Ptr(""), + ExternalTwitterEnabled: cast.Ptr(true), + ExternalTwitterSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalWorkosClientId: cast.Ptr(""), + ExternalWorkosEnabled: cast.Ptr(true), + ExternalWorkosSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalWorkosUrl: cast.Ptr(""), + ExternalZoomClientId: cast.Ptr(""), + ExternalZoomEnabled: cast.Ptr(true), + ExternalZoomSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + // Deprecated fields should be ignored + ExternalSlackClientId: cast.Ptr(""), + ExternalSlackEnabled: cast.Ptr(true), + ExternalSlackSecret: cast.Ptr(""), + }) + // Check error + assert.NoError(t, err) + assert.Empty(t, string(diff)) + }) + + t.Run("local enabled and disabled", func(t *testing.T) { + c := auth{EnableSignup: true, External: map[string]provider{ + "apple": { + Enabled: true, + ClientId: "test-client-1,test-client-2", + Secret: "test-secret", + }, + "azure": {}, + "bitbucket": {}, + "discord": {}, + "facebook": {}, + "figma": {}, + "github": {}, + "gitlab": {}, + "google": {}, + "kakao": {}, + "keycloak": {}, + "linkedin_oidc": {}, + "notion": {}, + "slack_oidc": {}, + "spotify": {}, + "twitch": {}, + "twitter": {}, + "workos": {}, + "zoom": {}, + }} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + ExternalAppleAdditionalClientIds: cast.Ptr("test-client-2"), + ExternalAppleClientId: cast.Ptr("test-client-1"), + ExternalAppleEnabled: cast.Ptr(false), + ExternalAppleSecret: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), + ExternalGoogleAdditionalClientIds: cast.Ptr("test-client-2"), + ExternalGoogleClientId: cast.Ptr("test-client-1"), + ExternalGoogleEnabled: cast.Ptr(true), + ExternalGoogleSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalGoogleSkipNonceCheck: cast.Ptr(true), + }) + // Check error + assert.NoError(t, err) + assert.Contains(t, string(diff), `[external.apple]`) + assert.Contains(t, string(diff), `-enabled = false`) + assert.Contains(t, string(diff), `+enabled = true`) + assert.Contains(t, string(diff), `client_id = "test-client-1,test-client-2"`) + assert.Contains(t, string(diff), `secret = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"`) + + assert.Contains(t, string(diff), `[external.google]`) + assert.Contains(t, string(diff), `-enabled = true`) + assert.Contains(t, string(diff), `+enabled = false`) + }) + + t.Run("local and remote disabled", func(t *testing.T) { + c := auth{EnableSignup: true, External: map[string]provider{ + "apple": {}, + "azure": {}, + "bitbucket": {}, + "discord": {}, + "facebook": {}, + "figma": {}, + "github": {}, + "gitlab": {}, + "google": {}, + "kakao": {}, + "keycloak": {}, + "linkedin_oidc": {}, + "notion": {}, + "slack_oidc": {}, + "spotify": {}, + "twitch": {}, + "twitter": {}, + "workos": {}, + "zoom": {}, + }} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + ExternalAppleEnabled: cast.Ptr(false), + ExternalAzureEnabled: cast.Ptr(false), + ExternalBitbucketEnabled: cast.Ptr(false), + ExternalDiscordEnabled: cast.Ptr(false), + ExternalFacebookEnabled: cast.Ptr(false), + ExternalFigmaEnabled: cast.Ptr(false), + ExternalGithubEnabled: cast.Ptr(false), + ExternalGitlabEnabled: cast.Ptr(false), + ExternalGoogleEnabled: cast.Ptr(false), + ExternalGoogleSkipNonceCheck: cast.Ptr(false), + ExternalKakaoEnabled: cast.Ptr(false), + ExternalKeycloakEnabled: cast.Ptr(false), + ExternalLinkedinOidcEnabled: cast.Ptr(false), + ExternalNotionEnabled: cast.Ptr(false), + ExternalSlackOidcEnabled: cast.Ptr(false), + ExternalSpotifyEnabled: cast.Ptr(false), + ExternalTwitchEnabled: cast.Ptr(false), + ExternalTwitterEnabled: cast.Ptr(false), + ExternalWorkosEnabled: cast.Ptr(false), + ExternalZoomEnabled: cast.Ptr(false), + // Deprecated fields should be ignored + ExternalSlackEnabled: cast.Ptr(false), + }) + // Check error + assert.NoError(t, err) + assert.Empty(t, string(diff)) + }) +} diff --git a/pkg/config/config.go b/pkg/config/config.go index 5f167386b..c1860fe4a 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -296,9 +296,11 @@ func NewConfig(editors ...ConfigEditor) config { "bitbucket": {}, "discord": {}, "facebook": {}, + "figma": {}, "github": {}, "gitlab": {}, "google": {}, + "kakao": {}, "keycloak": {}, "linkedin": {}, // TODO: remove this field in v2 "linkedin_oidc": {}, @@ -748,6 +750,12 @@ func (c *baseConfig) Validate(fsys fs.FS) error { return err } // Validate oauth config + for _, ext := range []string{"linkedin", "slack"} { + if c.Auth.External[ext].Enabled { + fmt.Fprintf(os.Stderr, `WARN: disabling deprecated "%[1]s" provider. Please use [auth.external.%[1]s_oidc] instead\n`, ext) + } + delete(c.Auth.External, ext) + } for ext, provider := range c.Auth.External { if !provider.Enabled { continue From 834959d5f9ab321ef24e13c982d6dc8ac955adcf Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Thu, 7 Nov 2024 01:26:09 +0100 Subject: [PATCH 133/305] fix(studio): bump studio image to 20241106-f29003e (#2845) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 4e6ec76b3..ce980a4ed 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -10,7 +10,7 @@ const ( inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" pgmetaImage = "supabase/postgres-meta:v0.84.2" - studioImage = "supabase/studio:20241106-fe0e32d" + studioImage = "supabase/studio:20241106-f29003e" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.61.0" vectorImage = "timberio/vector:0.28.1-alpine" From 9a896d681324e29d784bc4bf0921a94b469f690d Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Thu, 7 Nov 2024 12:14:59 +0800 Subject: [PATCH 134/305] feat: login via browser with device code (#2843) --- internal/login/login.go | 64 ++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/internal/login/login.go b/internal/login/login.go index 1cb74afdc..6239b500a 100644 --- a/internal/login/login.go +++ b/internal/login/login.go @@ -13,7 +13,6 @@ import ( "net/http" "os" "os/user" - "strconv" "strings" "time" @@ -43,8 +42,6 @@ type AccessTokenResponse struct { Nonce string `json:"nonce"` } -const defaultRetryAfterSeconds = 2 -const defaultMaxRetries = 90 const decryptionErrorMsg = "cannot decrypt access token" var loggedInMsg = "You are now logged in. " + utils.Aqua("Happy coding!") @@ -128,6 +125,8 @@ func (enc LoginEncryption) decryptAccessToken(accessToken string, publicKey stri return string(decryptedAccessToken), nil } +const maxRetries = 2 + func pollForAccessToken(ctx context.Context, url string) (AccessTokenResponse, error) { // TODO: Move to OpenAPI-generated http client once we reach v1 on API schema. client := fetcher.NewFetcher( @@ -137,20 +136,31 @@ func pollForAccessToken(ctx context.Context, url string) (AccessTokenResponse, e }), fetcher.WithExpectedStatus(http.StatusOK), ) - timeout := backoff.NewConstantBackOff(defaultRetryAfterSeconds) + console := utils.NewConsole() probe := func() (AccessTokenResponse, error) { - resp, err := client.Send(ctx, http.MethodGet, url, nil) - if err == nil { - return fetcher.ParseJSON[AccessTokenResponse](resp.Body) - } else if resp != nil { - if retryAfterSeconds, err := strconv.Atoi(resp.Header.Get("Retry-After")); err == nil { - timeout.Interval = time.Duration(retryAfterSeconds) * time.Second - } + // TODO: support automatic login flow + deviceCode, err := console.PromptText(ctx, "Enter your verification code: ") + if err != nil { + return AccessTokenResponse{}, err + } + urlWithQuery := fmt.Sprintf("%s?device_code=%s", url, deviceCode) + resp, err := client.Send(ctx, http.MethodGet, urlWithQuery, nil) + if err != nil { + return AccessTokenResponse{}, err } - return AccessTokenResponse{}, err + return fetcher.ParseJSON[AccessTokenResponse](resp.Body) + } + policy := backoff.WithContext(backoff.WithMaxRetries(&backoff.ZeroBackOff{}, maxRetries), ctx) + return backoff.RetryNotifyWithData(probe, policy, newErrorCallback()) +} + +func newErrorCallback() backoff.Notify { + failureCount := 0 + return func(err error, d time.Duration) { + failureCount += 1 + fmt.Fprintln(os.Stderr, err) + fmt.Fprintf(os.Stderr, "Retry (%d/%d): ", failureCount, maxRetries) } - policy := backoff.WithContext(backoff.WithMaxRetries(timeout, defaultMaxRetries), ctx) - return backoff.RetryWithData(probe, policy) } func Run(ctx context.Context, stdout io.Writer, params RunParams) error { @@ -194,22 +204,16 @@ func Run(ctx context.Context, stdout io.Writer, params RunParams) error { fmt.Fprintf(stdout, "Here is your login link, open it in the browser %s\n\n", utils.Bold(createLoginSessionUrl)) } - if err := utils.RunProgram(ctx, func(p utils.Program, ctx context.Context) error { - p.Send(utils.StatusMsg("Your token is now being generated and securely encrypted. Waiting for it to arrive...")) - - sessionPollingUrl := "/platform/cli/login/" + params.SessionId - accessTokenResponse, err := pollForAccessToken(ctx, sessionPollingUrl) - if err != nil { - return err - } - - decryptedAccessToken, err := params.Encryption.decryptAccessToken(accessTokenResponse.AccessToken, accessTokenResponse.PublicKey, accessTokenResponse.Nonce) - if err != nil { - return err - } - - return utils.SaveAccessToken(decryptedAccessToken, params.Fsys) - }); err != nil { + sessionPollingUrl := "/platform/cli/login/" + params.SessionId + accessTokenResponse, err := pollForAccessToken(ctx, sessionPollingUrl) + if err != nil { + return err + } + decryptedAccessToken, err := params.Encryption.decryptAccessToken(accessTokenResponse.AccessToken, accessTokenResponse.PublicKey, accessTokenResponse.Nonce) + if err != nil { + return err + } + if err := utils.SaveAccessToken(decryptedAccessToken, params.Fsys); err != nil { return err } From 10e102bced53b1a811fb729869474d64d56cba45 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Thu, 7 Nov 2024 17:58:18 +0800 Subject: [PATCH 135/305] fix: link fails due to wrong api key type (#2850) --- api/beta.yaml | 16 +++++++++++++--- pkg/api/types.gen.go | 18 +++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/api/beta.yaml b/api/beta.yaml index ff547903e..257a46e84 100644 --- a/api/beta.yaml +++ b/api/beta.yaml @@ -1519,6 +1519,8 @@ paths: type: array items: $ref: '#/components/schemas/V1ServiceHealthResponse' + '403': + description: '' '500': description: Failed to retrieve project's service health status tags: @@ -3063,6 +3065,13 @@ components: ApiKeyResponse: type: object properties: + type: + nullable: true + type: string + enum: + - publishable + - secret + - legacy name: type: string api_key: @@ -3070,9 +3079,6 @@ components: id: type: string nullable: true - type: - nullable: true - type: object prefix: type: string nullable: true @@ -3786,6 +3792,8 @@ components: type: string statement_timeout: type: string + track_commit_timestamp: + type: boolean wal_keep_size: type: string wal_sender_timeout: @@ -3847,6 +3855,8 @@ components: type: string statement_timeout: type: string + track_commit_timestamp: + type: boolean wal_keep_size: type: string wal_sender_timeout: diff --git a/pkg/api/types.gen.go b/pkg/api/types.gen.go index 66d467611..9334b80b8 100644 --- a/pkg/api/types.gen.go +++ b/pkg/api/types.gen.go @@ -14,6 +14,13 @@ const ( Oauth2Scopes = "oauth2.Scopes" ) +// Defines values for ApiKeyResponseType. +const ( + ApiKeyResponseTypeLegacy ApiKeyResponseType = "legacy" + ApiKeyResponseTypePublishable ApiKeyResponseType = "publishable" + ApiKeyResponseTypeSecret ApiKeyResponseType = "secret" +) + // Defines values for AuthHealthResponseName. const ( GoTrue AuthHealthResponseName = "GoTrue" @@ -58,8 +65,8 @@ const ( // Defines values for CreateApiKeyBodyType. const ( - Publishable CreateApiKeyBodyType = "publishable" - Secret CreateApiKeyBodyType = "secret" + CreateApiKeyBodyTypePublishable CreateApiKeyBodyType = "publishable" + CreateApiKeyBodyTypeSecret CreateApiKeyBodyType = "secret" ) // Defines values for CreateProviderBodyType. @@ -412,10 +419,13 @@ type ApiKeyResponse struct { Name string `json:"name"` Prefix *string `json:"prefix"` SecretJwtTemplate *ApiKeySecretJWTTemplate `json:"secret_jwt_template"` - Type *map[string]interface{} `json:"type"` + Type *ApiKeyResponseType `json:"type"` UpdatedAt *string `json:"updated_at"` } +// ApiKeyResponseType defines model for ApiKeyResponse.Type. +type ApiKeyResponseType string + // ApiKeySecretJWTTemplate defines model for ApiKeySecretJWTTemplate. type ApiKeySecretJWTTemplate struct { Role string `json:"role"` @@ -950,6 +960,7 @@ type PostgresConfigResponse struct { SessionReplicationRole *PostgresConfigResponseSessionReplicationRole `json:"session_replication_role,omitempty"` SharedBuffers *string `json:"shared_buffers,omitempty"` StatementTimeout *string `json:"statement_timeout,omitempty"` + TrackCommitTimestamp *bool `json:"track_commit_timestamp,omitempty"` WalKeepSize *string `json:"wal_keep_size,omitempty"` WalSenderTimeout *string `json:"wal_sender_timeout,omitempty"` WorkMem *string `json:"work_mem,omitempty"` @@ -1440,6 +1451,7 @@ type UpdatePostgresConfigBody struct { SessionReplicationRole *UpdatePostgresConfigBodySessionReplicationRole `json:"session_replication_role,omitempty"` SharedBuffers *string `json:"shared_buffers,omitempty"` StatementTimeout *string `json:"statement_timeout,omitempty"` + TrackCommitTimestamp *bool `json:"track_commit_timestamp,omitempty"` WalKeepSize *string `json:"wal_keep_size,omitempty"` WalSenderTimeout *string `json:"wal_sender_timeout,omitempty"` WorkMem *string `json:"work_mem,omitempty"` From 1becd0fa4a064d9ac38b0d0bc20eac0c8d8ae3dc Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Thu, 7 Nov 2024 18:42:35 +0800 Subject: [PATCH 136/305] fix: auto detect deno.json for globbed slugs (#2852) --- internal/functions/deploy/deploy.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index 855d44537..6713d47d3 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -82,13 +82,22 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, for _, name := range slugs { function := utils.Config.Functions[name] // Precedence order: flag > config > fallback + functionDir := filepath.Join(utils.FunctionsDir, name) if len(function.Entrypoint) == 0 { - function.Entrypoint = filepath.Join(utils.FunctionsDir, name, "index.ts") + function.Entrypoint = filepath.Join(functionDir, "index.ts") } if len(importMapPath) > 0 { function.ImportMap = importMapPath - } else if len(function.ImportMap) == 0 && fallbackExists { - function.ImportMap = utils.FallbackImportMapPath + } else if len(function.ImportMap) == 0 { + denoJsonPath := filepath.Join(functionDir, "deno.json") + denoJsoncPath := filepath.Join(functionDir, "deno.jsonc") + if _, err := fsys.Stat(denoJsonPath); err == nil { + function.ImportMap = denoJsonPath + } else if _, err := fsys.Stat(denoJsoncPath); err == nil { + function.ImportMap = denoJsoncPath + } else if fallbackExists { + function.ImportMap = utils.FallbackImportMapPath + } } if noVerifyJWT != nil { function.VerifyJWT = cast.Ptr(!*noVerifyJWT) From da7f3040c4d63298ac8cb32bef1ad0a499946935 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Fri, 8 Nov 2024 11:33:07 +0800 Subject: [PATCH 137/305] feat: support tracking commit timestamp (#2848) --- internal/postgresConfig/update/update.go | 9 +++++---- pkg/config/db.go | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/postgresConfig/update/update.go b/internal/postgresConfig/update/update.go index 09db6504a..94632d486 100644 --- a/internal/postgresConfig/update/update.go +++ b/internal/postgresConfig/update/update.go @@ -39,11 +39,12 @@ func Run(ctx context.Context, projectRef string, values []string, replaceOverrid for k, v := range newConfigOverrides { // this is hacky - if we're able to convert the value to an integer, we do so // if we start supporting config fields with e.g. floating pt overrides this'll need to be updated - attemptedConvert, err := strconv.Atoi(v) - if err != nil { - finalOverrides[k] = v + if vInt, err := strconv.Atoi(v); err == nil { + finalOverrides[k] = vInt + } else if vBool, err := strconv.ParseBool(v); err == nil { + finalOverrides[k] = vBool } else { - finalOverrides[k] = attemptedConvert + finalOverrides[k] = v } } } diff --git a/pkg/config/db.go b/pkg/config/db.go index 7ce21fad0..71ee29f7a 100644 --- a/pkg/config/db.go +++ b/pkg/config/db.go @@ -43,6 +43,7 @@ type ( SessionReplicationRole *SessionReplicationRole `toml:"session_replication_role"` SharedBuffers *string `toml:"shared_buffers"` StatementTimeout *string `toml:"statement_timeout"` + TrackCommitTimestamp *bool `toml:"track_commit_timestamp"` WalKeepSize *string `toml:"wal_keep_size"` WalSenderTimeout *string `toml:"wal_sender_timeout"` WorkMem *string `toml:"work_mem"` @@ -104,6 +105,7 @@ func (a *settings) ToUpdatePostgresConfigBody() v1API.UpdatePostgresConfigBody { body.MaxWalSize = a.MaxWalSize body.SessionReplicationRole = (*v1API.UpdatePostgresConfigBodySessionReplicationRole)(a.SessionReplicationRole) body.StatementTimeout = a.StatementTimeout + body.TrackCommitTimestamp = a.TrackCommitTimestamp body.WalKeepSize = a.WalKeepSize body.WalSenderTimeout = a.WalSenderTimeout body.WorkMem = a.WorkMem @@ -131,6 +133,7 @@ func (a *settings) fromRemoteConfig(remoteConfig v1API.PostgresConfigResponse) s result.SessionReplicationRole = (*SessionReplicationRole)(remoteConfig.SessionReplicationRole) result.SharedBuffers = remoteConfig.SharedBuffers result.StatementTimeout = remoteConfig.StatementTimeout + result.TrackCommitTimestamp = remoteConfig.TrackCommitTimestamp result.WalKeepSize = remoteConfig.WalKeepSize result.WalSenderTimeout = remoteConfig.WalSenderTimeout result.WorkMem = remoteConfig.WorkMem From 5afa9222844562a1d30675d2c696507094ecb023 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 04:46:51 +0000 Subject: [PATCH 138/305] chore(deps): bump google.golang.org/grpc from 1.67.1 to 1.68.0 (#2858) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.67.1 to 1.68.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.67.1...v1.68.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 9545fde60..c83e12d5d 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( golang.org/x/mod v0.21.0 golang.org/x/oauth2 v0.23.0 golang.org/x/term v0.25.0 - google.golang.org/grpc v1.67.1 + google.golang.org/grpc v1.68.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.12.0 ) @@ -334,12 +334,12 @@ require ( golang.org/x/crypto v0.27.0 // indirect golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect - golang.org/x/net v0.28.0 // indirect + golang.org/x/net v0.29.0 // indirect golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.26.0 // indirect golang.org/x/text v0.18.0 // indirect golang.org/x/tools v0.24.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index 224110f05..ee438683b 100644 --- a/go.sum +++ b/go.sum @@ -1197,8 +1197,8 @@ golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= +golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1462,8 +1462,8 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= -google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= +google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 h1:hjSy6tcFQZ171igDaN5QHOw2n6vx40juYbC/x67CEhc= +google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:qpvKtACPCQhAdu3PyQgV4l3LMXZEtft7y8QcarRsp9I= google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ= google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.0.5/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= @@ -1479,8 +1479,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= -google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0= +google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From 8b176c98215389e336152a770d046cea74bd1ab5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 13:52:53 +0800 Subject: [PATCH 139/305] chore(deps): bump golang.org/x/oauth2 from 0.23.0 to 0.24.0 (#2857) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index c83e12d5d..d547520fc 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( github.com/zalando/go-keyring v0.2.6 go.opentelemetry.io/otel v1.31.0 golang.org/x/mod v0.21.0 - golang.org/x/oauth2 v0.23.0 + golang.org/x/oauth2 v0.24.0 golang.org/x/term v0.25.0 google.golang.org/grpc v1.68.0 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index ee438683b..f87ec56c8 100644 --- a/go.sum +++ b/go.sum @@ -1205,8 +1205,8 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= -golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= +golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= From 91ca58e52020737dac7ac063364d25888bf4ed25 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 05:57:28 +0000 Subject: [PATCH 140/305] chore(deps): bump golang.org/x/mod from 0.21.0 to 0.22.0 (#2859) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d547520fc..cbc8b0df0 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 github.com/zalando/go-keyring v0.2.6 go.opentelemetry.io/otel v1.31.0 - golang.org/x/mod v0.21.0 + golang.org/x/mod v0.22.0 golang.org/x/oauth2 v0.24.0 golang.org/x/term v0.25.0 google.golang.org/grpc v1.68.0 diff --git a/go.sum b/go.sum index f87ec56c8..c7745ef71 100644 --- a/go.sum +++ b/go.sum @@ -1148,8 +1148,8 @@ golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0= -golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= +golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= +golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= From 372c7579a1dbe510f9de504a4973394f83cb2607 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 8 Nov 2024 06:01:45 +0000 Subject: [PATCH 141/305] chore(deps): bump golang.org/x/term from 0.25.0 to 0.26.0 (#2860) --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index cbc8b0df0..42af714c8 100644 --- a/go.mod +++ b/go.mod @@ -51,7 +51,7 @@ require ( go.opentelemetry.io/otel v1.31.0 golang.org/x/mod v0.22.0 golang.org/x/oauth2 v0.24.0 - golang.org/x/term v0.25.0 + golang.org/x/term v0.26.0 google.golang.org/grpc v1.68.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.12.0 @@ -336,7 +336,7 @@ require ( golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect golang.org/x/net v0.29.0 // indirect golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.26.0 // indirect + golang.org/x/sys v0.27.0 // indirect golang.org/x/text v0.18.0 // indirect golang.org/x/tools v0.24.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect diff --git a/go.sum b/go.sum index c7745ef71..6f8be10c9 100644 --- a/go.sum +++ b/go.sum @@ -1292,8 +1292,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= +golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1308,8 +1308,8 @@ golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= -golang.org/x/term v0.25.0 h1:WtHI/ltw4NvSUig5KARz9h521QvRC8RmF/cuYqifU24= -golang.org/x/term v0.25.0/go.mod h1:RPyXicDX+6vLxogjjRxjgD2TKtmAO6NZBsBRfrOLu7M= +golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= +golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 8f2cdde50e05d5858ea8830c867a1b14d46daff5 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Fri, 8 Nov 2024 14:04:43 +0800 Subject: [PATCH 142/305] fix: skip seeding for disabled remote (#2856) * fix: skip seeding for disabled remote * chore: rename config variable * Update push.go --- internal/db/push/push.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/db/push/push.go b/internal/db/push/push.go index f52d78974..2141255ae 100644 --- a/internal/db/push/push.go +++ b/internal/db/push/push.go @@ -12,6 +12,7 @@ import ( "github.com/spf13/afero" "github.com/supabase/cli/internal/migration/up" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/migration" ) @@ -30,8 +31,9 @@ func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, } var seeds []migration.SeedFile if includeSeed { - seeds, err = migration.GetPendingSeeds(ctx, utils.Config.Db.Seed.SqlPaths, conn, afero.NewIOFS(fsys)) - if err != nil { + if remote, _ := utils.Config.GetRemoteByProjectRef(flags.ProjectRef); !remote.Db.Seed.Enabled { + fmt.Fprintln(os.Stderr, "Skipping seed because it is disabled in config.toml for project:", remote.ProjectId) + } else if seeds, err = migration.GetPendingSeeds(ctx, remote.Db.Seed.SqlPaths, conn, afero.NewIOFS(fsys)); err != nil { return err } } From e26aee5c5218d5966d414dc696a5d1ea440e2980 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Fri, 8 Nov 2024 15:08:03 +0900 Subject: [PATCH 143/305] fix: bump edge-runtime to 1.61.1 (#2855) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index ce980a4ed..cedf72b22 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241106-f29003e" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.61.0" + edgeRuntimeImage = "supabase/edge-runtime:v1.61.1" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.163.2" From 14fa86b7590170f7297d4fba2948af9aa489d33c Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Fri, 8 Nov 2024 17:32:59 +0800 Subject: [PATCH 144/305] fix: allows env var to override linked project id (#2480) * fix: allows env var to override linked project id * chore: only unlink the temp project --- internal/unlink/unlink.go | 11 +++++------ internal/utils/flags/project_ref.go | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/internal/unlink/unlink.go b/internal/unlink/unlink.go index c6297581e..b59f4d1f0 100644 --- a/internal/unlink/unlink.go +++ b/internal/unlink/unlink.go @@ -9,16 +9,15 @@ import ( "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/internal/utils/credentials" - "github.com/supabase/cli/internal/utils/flags" "github.com/zalando/go-keyring" ) func Run(ctx context.Context, fsys afero.Fs) error { - projectRef, err := flags.LoadProjectRef(fsys) - if err != nil { - return err - } - if err := Unlink(projectRef, fsys); err != nil { + if projectRef, err := afero.ReadFile(fsys, utils.ProjectRefPath); errors.Is(err, os.ErrNotExist) { + return errors.New(utils.ErrNotLinked) + } else if err != nil { + return errors.Errorf("failed to load project ref: %w", err) + } else if err := Unlink(string(projectRef), fsys); err != nil { return err } fmt.Fprintln(os.Stdout, "Finished "+utils.Aqua("supabase unlink")+".") diff --git a/internal/utils/flags/project_ref.go b/internal/utils/flags/project_ref.go index c2d5012bc..437bbb668 100644 --- a/internal/utils/flags/project_ref.go +++ b/internal/utils/flags/project_ref.go @@ -17,9 +17,6 @@ var ProjectRef string func ParseProjectRef(ctx context.Context, fsys afero.Fs) error { // Flag takes highest precedence - if len(ProjectRef) == 0 { - ProjectRef = viper.GetString("PROJECT_ID") - } if len(ProjectRef) > 0 { return utils.AssertProjectRefIsValid(ProjectRef) } @@ -59,13 +56,17 @@ func PromptProjectRef(ctx context.Context, title string) error { } func LoadProjectRef(fsys afero.Fs) (string, error) { - projectRefBytes, err := afero.ReadFile(fsys, utils.ProjectRefPath) - if errors.Is(err, os.ErrNotExist) { - return "", errors.New(utils.ErrNotLinked) - } else if err != nil { - return "", errors.Errorf("failed to load project ref: %w", err) + // Env var takes precedence over ref file + ProjectRef = viper.GetString("PROJECT_ID") + if len(ProjectRef) == 0 { + projectRefBytes, err := afero.ReadFile(fsys, utils.ProjectRefPath) + if errors.Is(err, os.ErrNotExist) { + return "", errors.New(utils.ErrNotLinked) + } else if err != nil { + return "", errors.Errorf("failed to load project ref: %w", err) + } + ProjectRef = string(bytes.TrimSpace(projectRefBytes)) } - ProjectRef = string(bytes.TrimSpace(projectRefBytes)) if err := utils.AssertProjectRefIsValid(ProjectRef); err != nil { return "", err } From cc8af2b4a66b7c20cbc64d4a518f787f9e54a52a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 04:30:38 +0000 Subject: [PATCH 145/305] chore(deps): bump github.com/golangci/golangci-lint from 1.61.0 to 1.62.0 (#2865) chore(deps): bump github.com/golangci/golangci-lint Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.61.0 to 1.62.0. - [Release notes](https://github.com/golangci/golangci-lint/releases) - [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md) - [Commits](https://github.com/golangci/golangci-lint/compare/v1.61.0...v1.62.0) --- updated-dependencies: - dependency-name: github.com/golangci/golangci-lint dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 73 ++++++++++++++-------------- go.sum | 147 +++++++++++++++++++++++++++++---------------------------- 2 files changed, 111 insertions(+), 109 deletions(-) diff --git a/go.mod b/go.mod index 42af714c8..bd1f98f3c 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/go-git/go-git/v5 v5.12.0 github.com/go-xmlfmt/xmlfmt v1.1.2 github.com/golang-jwt/jwt/v5 v5.2.1 - github.com/golangci/golangci-lint v1.61.0 + github.com/golangci/golangci-lint v1.62.0 github.com/google/go-github/v62 v62.0.0 github.com/google/go-querystring v1.1.0 github.com/google/uuid v1.6.0 @@ -63,10 +63,10 @@ require ( al.essio.dev/pkg/shellescape v1.5.1 // indirect dario.cat/mergo v1.0.0 // indirect github.com/4meepo/tagalign v1.3.4 // indirect - github.com/Abirdcfly/dupword v0.1.1 // indirect - github.com/Antonboom/errname v0.1.13 // indirect - github.com/Antonboom/nilnil v0.1.9 // indirect - github.com/Antonboom/testifylint v1.4.3 // indirect + github.com/Abirdcfly/dupword v0.1.3 // indirect + github.com/Antonboom/errname v1.0.0 // indirect + github.com/Antonboom/nilnil v1.0.0 // indirect + github.com/Antonboom/testifylint v1.5.0 // indirect github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/Crocmagnon/fatcontext v0.5.2 // indirect github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect @@ -76,8 +76,8 @@ require ( github.com/OpenPeeDeeP/depguard/v2 v2.2.0 // indirect github.com/ProtonMail/go-crypto v1.0.0 // indirect github.com/alecthomas/chroma/v2 v2.8.0 // indirect - github.com/alecthomas/go-check-sumtype v0.1.4 // indirect - github.com/alexkohler/nakedret/v2 v2.0.4 // indirect + github.com/alecthomas/go-check-sumtype v0.2.0 // indirect + github.com/alexkohler/nakedret/v2 v2.0.5 // indirect github.com/alexkohler/prealloc v1.0.0 // indirect github.com/alingse/asasalint v0.0.11 // indirect github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect @@ -88,11 +88,11 @@ require ( github.com/aymerick/douceur v0.2.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bitfield/gotestdox v0.2.2 // indirect - github.com/bkielbasa/cyclop v1.2.1 // indirect + github.com/bkielbasa/cyclop v1.2.3 // indirect github.com/blizzy78/varnamelen v0.8.0 // indirect github.com/bombsimon/wsl/v4 v4.4.1 // indirect - github.com/breml/bidichk v0.2.7 // indirect - github.com/breml/errchkjson v0.3.6 // indirect + github.com/breml/bidichk v0.3.2 // indirect + github.com/breml/errchkjson v0.4.0 // indirect github.com/butuzov/ireturn v0.3.0 // indirect github.com/butuzov/mirror v1.2.0 // indirect github.com/bytedance/sonic v1.11.6 // indirect @@ -104,7 +104,7 @@ require ( github.com/charmbracelet/harmonica v0.2.0 // indirect github.com/charmbracelet/x/ansi v0.1.4 // indirect github.com/chavacava/garif v0.1.0 // indirect - github.com/ckaznocha/intrange v0.2.0 // indirect + github.com/ckaznocha/intrange v0.2.1 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/iasm v0.2.0 // indirect @@ -126,7 +126,7 @@ require ( github.com/docker/go-metrics v0.0.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/ettle/strcase v0.2.0 // indirect - github.com/fatih/color v1.17.0 // indirect + github.com/fatih/color v1.18.0 // indirect github.com/fatih/structtag v1.2.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/firefart/nonamedreturns v1.0.5 // indirect @@ -135,9 +135,9 @@ require ( github.com/fzipp/gocyclo v0.6.0 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/getkin/kin-openapi v0.124.0 // indirect - github.com/ghostiam/protogetter v0.3.6 // indirect + github.com/ghostiam/protogetter v0.3.8 // indirect github.com/gin-contrib/sse v0.1.0 // indirect - github.com/go-critic/go-critic v0.11.4 // indirect + github.com/go-critic/go-critic v0.11.5 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect github.com/go-logr/logr v1.4.2 // indirect @@ -154,7 +154,7 @@ require ( github.com/go-toolsmith/astp v1.1.0 // indirect github.com/go-toolsmith/strparse v1.1.0 // indirect github.com/go-toolsmith/typep v1.1.0 // indirect - github.com/go-viper/mapstructure/v2 v2.1.0 // indirect + github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/gobwas/glob v0.2.3 // indirect github.com/goccy/go-json v0.10.2 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect @@ -163,6 +163,7 @@ require ( github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect + github.com/golangci/go-printf-func-name v0.1.0 // indirect github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9 // indirect github.com/golangci/misspell v0.6.0 // indirect github.com/golangci/modinfo v0.3.4 // indirect @@ -193,14 +194,13 @@ require ( github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jgautheron/goconst v1.7.1 // indirect github.com/jingyugao/rowserrcheck v1.1.1 // indirect - github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af // indirect github.com/jjti/go-spancheck v0.6.2 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/julz/importas v0.1.0 // indirect github.com/karamaru-alpha/copyloopvar v1.1.0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/kisielk/errcheck v1.7.0 // indirect + github.com/kisielk/errcheck v1.8.0 // indirect github.com/kkHAIKE/contextcheck v1.1.5 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/kr/pretty v0.3.1 // indirect @@ -208,14 +208,13 @@ require ( github.com/kulti/thelper v0.6.3 // indirect github.com/kunwardeep/paralleltest v1.0.10 // indirect github.com/kyoh86/exportloopref v0.1.11 // indirect - github.com/lasiar/canonicalheader v1.1.1 // indirect + github.com/lasiar/canonicalheader v1.1.2 // indirect github.com/ldez/gomoddirectives v0.2.4 // indirect github.com/ldez/tagliatelle v0.5.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect github.com/leonklingele/grouper v1.1.2 // indirect github.com/lib/pq v1.10.9 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect - github.com/lufeee/execinquery v1.2.1 // indirect github.com/macabu/inamedparam v0.1.3 // indirect github.com/magiconair/properties v1.8.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect @@ -227,7 +226,7 @@ require ( github.com/mattn/go-localereader v0.0.1 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/mgechev/revive v1.3.9 // indirect + github.com/mgechev/revive v1.5.0 // indirect github.com/microcosm-cc/bluemonday v1.0.25 // indirect github.com/miekg/pkcs11 v1.1.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect @@ -246,7 +245,7 @@ require ( github.com/nakabonne/nestif v0.3.1 // indirect github.com/nishanths/exhaustive v0.12.0 // indirect github.com/nishanths/predeclared v0.2.2 // indirect - github.com/nunnatsa/ginkgolinter v0.16.2 // indirect + github.com/nunnatsa/ginkgolinter v0.18.0 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect @@ -265,8 +264,9 @@ require ( github.com/quasilyte/gogrep v0.5.0 // indirect github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect + github.com/raeperd/recvcheck v0.1.2 // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/rogpeppe/go-internal v1.12.0 // indirect + github.com/rogpeppe/go-internal v1.13.1 // indirect github.com/ryancurrah/gomodguard v1.3.5 // indirect github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect @@ -276,14 +276,14 @@ require ( github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect github.com/sashamelentyev/interfacebloat v1.1.0 // indirect github.com/sashamelentyev/usestdlibvars v1.27.0 // indirect - github.com/securego/gosec/v2 v2.21.2 // indirect + github.com/securego/gosec/v2 v2.21.4 // indirect github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/sivchari/containedctx v1.0.3 // indirect - github.com/sivchari/tenv v1.10.0 // indirect + github.com/sivchari/tenv v1.12.1 // indirect github.com/skeema/knownhosts v1.2.2 // indirect - github.com/sonatard/noctx v0.0.2 // indirect + github.com/sonatard/noctx v0.1.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/sourcegraph/go-diff v0.7.0 // indirect github.com/spf13/cast v1.6.0 // indirect @@ -292,10 +292,10 @@ require ( github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect github.com/tdakkota/asciicheck v0.2.0 // indirect - github.com/tetafro/godot v1.4.17 // indirect + github.com/tetafro/godot v1.4.18 // indirect github.com/theupdateframework/notary v0.7.0 // indirect github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 // indirect - github.com/timonwong/loggercheck v0.9.4 // indirect + github.com/timonwong/loggercheck v0.10.1 // indirect github.com/tomarrell/wrapcheck/v2 v2.9.0 // indirect github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect @@ -303,6 +303,7 @@ require ( github.com/ultraware/funlen v0.1.0 // indirect github.com/ultraware/whitespace v0.1.1 // indirect github.com/uudashr/gocognit v1.1.3 // indirect + github.com/uudashr/iface v1.2.0 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect @@ -314,7 +315,7 @@ require ( github.com/yuin/goldmark v1.5.4 // indirect github.com/yuin/goldmark-emoji v1.0.2 // indirect gitlab.com/bosi/decorder v0.4.2 // indirect - go-simpler.org/musttag v0.12.2 // indirect + go-simpler.org/musttag v0.13.0 // indirect go-simpler.org/sloglint v0.7.2 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 // indirect @@ -327,18 +328,18 @@ require ( go.opentelemetry.io/otel/trace v1.31.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/atomic v1.9.0 // indirect - go.uber.org/automaxprocs v1.5.3 // indirect + go.uber.org/automaxprocs v1.6.0 // indirect go.uber.org/multierr v1.9.0 // indirect go.uber.org/zap v1.24.0 // indirect golang.org/x/arch v0.8.0 // indirect - golang.org/x/crypto v0.27.0 // indirect - golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect - golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f // indirect - golang.org/x/net v0.29.0 // indirect - golang.org/x/sync v0.8.0 // indirect + golang.org/x/crypto v0.29.0 // indirect + golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect + golang.org/x/exp/typeparams v0.0.0-20240909161429-701f63a606c0 // indirect + golang.org/x/net v0.31.0 // indirect + golang.org/x/sync v0.9.0 // indirect golang.org/x/sys v0.27.0 // indirect - golang.org/x/text v0.18.0 // indirect - golang.org/x/tools v0.24.0 // indirect + golang.org/x/text v0.20.0 // indirect + golang.org/x/tools v0.27.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect google.golang.org/protobuf v1.34.2 // indirect diff --git a/go.sum b/go.sum index 6f8be10c9..477747194 100644 --- a/go.sum +++ b/go.sum @@ -41,14 +41,14 @@ dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/4meepo/tagalign v1.3.4 h1:P51VcvBnf04YkHzjfclN6BbsopfJR5rxs1n+5zHt+w8= github.com/4meepo/tagalign v1.3.4/go.mod h1:M+pnkHH2vG8+qhE5bVc/zeP7HS/j910Fwa9TUSyZVI0= -github.com/Abirdcfly/dupword v0.1.1 h1:Bsxe0fIw6OwBtXMIncaTxCLHYO5BB+3mcsR5E8VXloY= -github.com/Abirdcfly/dupword v0.1.1/go.mod h1:B49AcJdTYYkpd4HjgAcutNGG9HZ2JWwKunH9Y2BA6sM= -github.com/Antonboom/errname v0.1.13 h1:JHICqsewj/fNckzrfVSe+T33svwQxmjC+1ntDsHOVvM= -github.com/Antonboom/errname v0.1.13/go.mod h1:uWyefRYRN54lBg6HseYCFhs6Qjcy41Y3Jl/dVhA87Ns= -github.com/Antonboom/nilnil v0.1.9 h1:eKFMejSxPSA9eLSensFmjW2XTgTwJMjZ8hUHtV4s/SQ= -github.com/Antonboom/nilnil v0.1.9/go.mod h1:iGe2rYwCq5/Me1khrysB4nwI7swQvjclR8/YRPl5ihQ= -github.com/Antonboom/testifylint v1.4.3 h1:ohMt6AHuHgttaQ1xb6SSnxCeK4/rnK7KKzbvs7DmEck= -github.com/Antonboom/testifylint v1.4.3/go.mod h1:+8Q9+AOLsz5ZiQiiYujJKs9mNz398+M6UgslP4qgJLA= +github.com/Abirdcfly/dupword v0.1.3 h1:9Pa1NuAsZvpFPi9Pqkd93I7LIYRURj+A//dFd5tgBeE= +github.com/Abirdcfly/dupword v0.1.3/go.mod h1:8VbB2t7e10KRNdwTVoxdBaxla6avbhGzb8sCTygUMhw= +github.com/Antonboom/errname v1.0.0 h1:oJOOWR07vS1kRusl6YRSlat7HFnb3mSfMl6sDMRoTBA= +github.com/Antonboom/errname v1.0.0/go.mod h1:gMOBFzK/vrTiXN9Oh+HFs+e6Ndl0eTFbtsRTSRdXyGI= +github.com/Antonboom/nilnil v1.0.0 h1:n+v+B12dsE5tbAqRODXmEKfZv9j2KcTBrp+LkoM4HZk= +github.com/Antonboom/nilnil v1.0.0/go.mod h1:fDJ1FSFoLN6yoG65ANb1WihItf6qt9PJVTn/s2IrcII= +github.com/Antonboom/testifylint v1.5.0 h1:dlUIsDMtCrZWUnvkaCz3quJCoIjaGi41GzjPBGkkJ8A= +github.com/Antonboom/testifylint v1.5.0/go.mod h1:wqaJbu0Blb5Wag2wv7Z5xt+CIV+eVLxtGZrlK13z3AE= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -80,8 +80,8 @@ github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WV github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= github.com/alecthomas/chroma/v2 v2.8.0 h1:w9WJUjFFmHHB2e8mRpL9jjy3alYDlU0QLDezj1xE264= github.com/alecthomas/chroma/v2 v2.8.0/go.mod h1:yrkMI9807G1ROx13fhe1v6PN2DDeaR73L3d+1nmYQtw= -github.com/alecthomas/go-check-sumtype v0.1.4 h1:WCvlB3l5Vq5dZQTFmodqL2g68uHiSwwlWcT5a2FGK0c= -github.com/alecthomas/go-check-sumtype v0.1.4/go.mod h1:WyYPfhfkdhyrdaligV6svFopZV8Lqdzn5pyVBaV6jhQ= +github.com/alecthomas/go-check-sumtype v0.2.0 h1:Bo+e4DFf3rs7ME9w/0SU/g6nmzJaphduP8Cjiz0gbwY= +github.com/alecthomas/go-check-sumtype v0.2.0/go.mod h1:WyYPfhfkdhyrdaligV6svFopZV8Lqdzn5pyVBaV6jhQ= github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk= github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -89,8 +89,8 @@ github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuy github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/alexkohler/nakedret/v2 v2.0.4 h1:yZuKmjqGi0pSmjGpOC016LtPJysIL0WEUiaXW5SUnNg= -github.com/alexkohler/nakedret/v2 v2.0.4/go.mod h1:bF5i0zF2Wo2o4X4USt9ntUWve6JbFv02Ff4vlkmS/VU= +github.com/alexkohler/nakedret/v2 v2.0.5 h1:fP5qLgtwbx9EJE8dGEERT02YwS8En4r9nnZ71RK+EVU= +github.com/alexkohler/nakedret/v2 v2.0.5/go.mod h1:bF5i0zF2Wo2o4X4USt9ntUWve6JbFv02Ff4vlkmS/VU= github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pOcUuw= github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQRnw= @@ -124,18 +124,18 @@ github.com/bitfield/gotestdox v0.2.2 h1:x6RcPAbBbErKLnapz1QeAlf3ospg8efBsedU93CD github.com/bitfield/gotestdox v0.2.2/go.mod h1:D+gwtS0urjBrzguAkTM2wodsTQYFHdpx8eqRJ3N+9pY= github.com/bitly/go-hostpool v0.1.0/go.mod h1:4gOCgp6+NZnVqlKyZ/iBZFTAJKembaVENUpMkpg42fw= github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= -github.com/bkielbasa/cyclop v1.2.1 h1:AeF71HZDob1P2/pRm1so9cd1alZnrpyc4q2uP2l0gJY= -github.com/bkielbasa/cyclop v1.2.1/go.mod h1:K/dT/M0FPAiYjBgQGau7tz+3TMh4FWAEqlMhzFWCrgM= +github.com/bkielbasa/cyclop v1.2.3 h1:faIVMIGDIANuGPWH031CZJTi2ymOQBULs9H21HSMa5w= +github.com/bkielbasa/cyclop v1.2.3/go.mod h1:kHTwA9Q0uZqOADdupvcFJQtp/ksSnytRMe8ztxG8Fuo= github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ089M= github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/bombsimon/wsl/v4 v4.4.1 h1:jfUaCkN+aUpobrMO24zwyAMwMAV5eSziCkOKEauOLdw= github.com/bombsimon/wsl/v4 v4.4.1/go.mod h1:Xu/kDxGZTofQcDGCtQe9KCzhHphIe0fDuyWTxER9Feo= -github.com/breml/bidichk v0.2.7 h1:dAkKQPLl/Qrk7hnP6P+E0xOodrq8Us7+U0o4UBOAlQY= -github.com/breml/bidichk v0.2.7/go.mod h1:YodjipAGI9fGcYM7II6wFvGhdMYsC5pHDlGzqvEW3tQ= -github.com/breml/errchkjson v0.3.6 h1:VLhVkqSBH96AvXEyclMR37rZslRrY2kcyq+31HCsVrA= -github.com/breml/errchkjson v0.3.6/go.mod h1:jhSDoFheAF2RSDOlCfhHO9KqhZgAYLyvHe7bRCX8f/U= +github.com/breml/bidichk v0.3.2 h1:xV4flJ9V5xWTqxL+/PMFF6dtJPvZLPsyixAoPe8BGJs= +github.com/breml/bidichk v0.3.2/go.mod h1:VzFLBxuYtT23z5+iVkamXO386OB+/sVwZOpIj6zXGos= +github.com/breml/errchkjson v0.4.0 h1:gftf6uWZMtIa/Is3XJgibewBm2ksAQSY/kABDNFTAdk= +github.com/breml/errchkjson v0.4.0/go.mod h1:AuBOSTHyLSaaAFlWsRSuRBIroCh3eh7ZHh5YeelDIk8= github.com/bugsnag/bugsnag-go v1.0.5-0.20150529004307-13fd6b8acda0 h1:s7+5BfS4WFJoVF9pnB8kBk03S7pZXRdKamnV0FOl5Sc= github.com/bugsnag/bugsnag-go v1.0.5-0.20150529004307-13fd6b8acda0/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b h1:otBG+dV+YK+Soembjv71DPz3uX/V/6MMlSyD9JBQ6kQ= @@ -181,8 +181,8 @@ github.com/chavacava/garif v0.1.0/go.mod h1:XMyYCkEL58DF0oyW4qDjjnPWONs2HBqYKI+U github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/ckaznocha/intrange v0.2.0 h1:FykcZuJ8BD7oX93YbO1UY9oZtkRbp+1/kJcDjkefYLs= -github.com/ckaznocha/intrange v0.2.0/go.mod h1:r5I7nUlAAG56xmkOpw4XVr16BXhwYTUdcuRFeevn1oE= +github.com/ckaznocha/intrange v0.2.1 h1:M07spnNEQoALOJhwrImSrJLaxwuiQK+hA2DeajBlwYk= +github.com/ckaznocha/intrange v0.2.1/go.mod h1:7NEhVyf8fzZO5Ds7CRaqPEm52Ut83hsTiL5zbER/HYk= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004 h1:lkAMpLVBDaj17e85keuznYcH5rqI438v41pKcBl4ZxQ= github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON2oQp+43nFtAV/uvKQIFpSPerB57DCt9t8sSA= @@ -269,8 +269,8 @@ github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q= github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= -github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= -github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= @@ -292,16 +292,16 @@ github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj github.com/getkin/kin-openapi v0.124.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM= github.com/getsentry/sentry-go v0.29.1 h1:DyZuChN8Hz3ARxGVV8ePaNXh1dQ7d76AiB117xcREwA= github.com/getsentry/sentry-go v0.29.1/go.mod h1:x3AtIzN01d6SiWkderzaH28Tm0lgkafpJ5Bm3li39O0= -github.com/ghostiam/protogetter v0.3.6 h1:R7qEWaSgFCsy20yYHNIJsU9ZOb8TziSRRxuAOTVKeOk= -github.com/ghostiam/protogetter v0.3.6/go.mod h1:7lpeDnEJ1ZjL/YtyoN99ljO4z0pd3H0d18/t2dPBxHw= +github.com/ghostiam/protogetter v0.3.8 h1:LYcXbYvybUyTIxN2Mj9h6rHrDZBDwZloPoKctWrFyJY= +github.com/ghostiam/protogetter v0.3.8/go.mod h1:WZ0nw9pfzsgxuRsPOFQomgDVSWtDLJRfQJEhsGbmQMA= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= -github.com/go-critic/go-critic v0.11.4 h1:O7kGOCx0NDIni4czrkRIXTnit0mkyKOCePh3My6OyEU= -github.com/go-critic/go-critic v0.11.4/go.mod h1:2QAdo4iuLik5S9YG0rT4wcZ8QxwHYkrr6/2MWAiv/vc= +github.com/go-critic/go-critic v0.11.5 h1:TkDTOn5v7EEngMxu8KbuFqFR43USaaH8XRJLz1jhVYA= +github.com/go-critic/go-critic v0.11.5/go.mod h1:wu6U7ny9PiaHaZHcvMDmdysMqvDem162Rh3zWTrqk8M= github.com/go-errors/errors v1.5.1 h1:ZwEMSLRCapFLflTpT7NKaAc7ukJ8ZPEjzlxt8rPN8bk= github.com/go-errors/errors v1.5.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= @@ -368,8 +368,8 @@ github.com/go-toolsmith/strparse v1.1.0 h1:GAioeZUK9TGxnLS+qfdqNbA4z0SSm5zVNtCQi github.com/go-toolsmith/strparse v1.1.0/go.mod h1:7ksGy58fsaQkGQlY8WVoBFNyEPMGuJin1rfoPS4lBSQ= github.com/go-toolsmith/typep v1.1.0 h1:fIRYDyF+JywLfqzyhdiHzRop/GQDxxNhLGQ6gFUNHus= github.com/go-toolsmith/typep v1.1.0/go.mod h1:fVIw+7zjdsMxDA3ITWnH1yOiw1rnTQKCsF/sk2H/qig= -github.com/go-viper/mapstructure/v2 v2.1.0 h1:gHnMa2Y/pIxElCH2GlZZ1lZSsn6XMtufpGyP1XxdC/w= -github.com/go-viper/mapstructure/v2 v2.1.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss= +github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/go-xmlfmt/xmlfmt v1.1.2 h1:Nea7b4icn8s57fTx1M5AI4qQT5HEM3rVUO8MuE6g80U= github.com/go-xmlfmt/xmlfmt v1.1.2/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= @@ -422,10 +422,12 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a h1:w8hkcTqaFpzKqonE9uMCefW1WDie15eSP/4MssdenaM= github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk= +github.com/golangci/go-printf-func-name v0.1.0 h1:dVokQP+NMTO7jwO4bwsRwLWeudOVUPPyAKJuzv8pEJU= +github.com/golangci/go-printf-func-name v0.1.0/go.mod h1:wqhWFH5mUdJQhweRnldEywnR5021wTdZSNgwYceV14s= github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9 h1:/1322Qns6BtQxUZDTAT4SdcoxknUki7IAoK4SAXr8ME= github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9/go.mod h1:Oesb/0uFAyWoaw1U1qS5zyjCg5NP9C9iwjnI4tIsXEE= -github.com/golangci/golangci-lint v1.61.0 h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8= -github.com/golangci/golangci-lint v1.61.0/go.mod h1:e4lztIrJJgLPhWvFPDkhiMwEFRrWlmFbrZea3FsJyN8= +github.com/golangci/golangci-lint v1.62.0 h1:/G0g+bi1BhmGJqLdNQkKBWjcim8HjOPc4tsKuHDOhcI= +github.com/golangci/golangci-lint v1.62.0/go.mod h1:jtoOhQcKTz8B6dGNFyfQV3WZkQk+YvBDewDtNpiAJts= github.com/golangci/misspell v0.6.0 h1:JCle2HUTNWirNlDIAUO44hUsKhOFqGPoC4LZxlaSXDs= github.com/golangci/misspell v0.6.0/go.mod h1:keMNyY6R9isGaSAu+4Q8NMBwMPkh15Gtc8UCVoDtAWo= github.com/golangci/modinfo v0.3.4 h1:oU5huX3fbxqQXdfspamej74DFX0kyGLkw1ppvXoJ8GA= @@ -588,8 +590,6 @@ github.com/jinzhu/gorm v0.0.0-20170222002820-5409931a1bb8/go.mod h1:Vla75njaFJ8c github.com/jinzhu/inflection v0.0.0-20170102125226-1c35d901db3d h1:jRQLvyVGL+iVtDElaEIDdKwpPqUIZJfzkNLV34htpEc= github.com/jinzhu/inflection v0.0.0-20170102125226-1c35d901db3d/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af h1:KA9BjwUk7KlCh6S9EAGWBt1oExIUv9WyNCiRz5amv48= -github.com/jirfag/go-printf-func-name v0.0.0-20200119135958-7558a9eaa5af/go.mod h1:HEWGJkRDzjJY2sqdDwxccsGicWEf9BQOZsq2tV+xzM0= github.com/jjti/go-spancheck v0.6.2 h1:iYtoxqPMzHUPp7St+5yA8+cONdyXD3ug6KK15n7Pklk= github.com/jjti/go-spancheck v0.6.2/go.mod h1:+X7lvIrR5ZdUTkxFYqzJ0abr8Sb5LOo80uOhWNqIrYA= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= @@ -616,8 +616,8 @@ github.com/karamaru-alpha/copyloopvar v1.1.0/go.mod h1:u7CIfztblY0jZLOQZgH3oYsJz github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/errcheck v1.7.0 h1:+SbscKmWJ5mOK/bO1zS60F5I9WwZDWOfRsC4RwfwRV0= -github.com/kisielk/errcheck v1.7.0/go.mod h1:1kLL+jV4e+CFfueBmI1dSK2ADDyQnlrnrY/FqKluHJQ= +github.com/kisielk/errcheck v1.8.0 h1:ZX/URYa7ilESY19ik/vBmCn6zdGQLxACwjAcWbHlYlg= +github.com/kisielk/errcheck v1.8.0/go.mod h1:1kLL+jV4e+CFfueBmI1dSK2ADDyQnlrnrY/FqKluHJQ= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkHAIKE/contextcheck v1.1.5 h1:CdnJh63tcDe53vG+RebdpdXJTc9atMgGqdx8LXxiilg= github.com/kkHAIKE/contextcheck v1.1.5/go.mod h1:O930cpht4xb1YQpK+1+AgoM3mFsvxr7uyFptcnWTYUA= @@ -645,8 +645,8 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/kyoh86/exportloopref v0.1.11 h1:1Z0bcmTypkL3Q4k+IDHMWTcnCliEZcaPiIe0/ymEyhQ= github.com/kyoh86/exportloopref v0.1.11/go.mod h1:qkV4UF1zGl6EkF1ox8L5t9SwyeBAZ3qLMd6up458uqA= -github.com/lasiar/canonicalheader v1.1.1 h1:wC+dY9ZfiqiPwAexUApFush/csSPXeIi4QqyxXmng8I= -github.com/lasiar/canonicalheader v1.1.1/go.mod h1:cXkb3Dlk6XXy+8MVQnF23CYKWlyA7kfQhSw2CcZtZb0= +github.com/lasiar/canonicalheader v1.1.2 h1:vZ5uqwvDbyJCnMhmFYimgMZnJMjwljN5VGY0VKbMXb4= +github.com/lasiar/canonicalheader v1.1.2/go.mod h1:qJCeLFS0G/QlLQ506T+Fk/fWMa2VmBUiEI2cuMK4djI= github.com/ldez/gomoddirectives v0.2.4 h1:j3YjBIjEBbqZ0NKtBNzr8rtMHTOrLPeiwTkfUJZ3alg= github.com/ldez/gomoddirectives v0.2.4/go.mod h1:oWu9i62VcQDYp9EQ0ONTfqLNh+mDLWWDO+SO0qSQw5g= github.com/ldez/tagliatelle v0.5.0 h1:epgfuYt9v0CG3fms0pEgIMNPuFf/LpPIfjk4kyqSioo= @@ -664,8 +664,6 @@ github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= -github.com/lufeee/execinquery v1.2.1 h1:hf0Ems4SHcUGBxpGN7Jz78z1ppVkP/837ZlETPCEtOM= -github.com/lufeee/execinquery v1.2.1/go.mod h1:EC7DrEKView09ocscGHC+apXMIaorh4xqSxS/dy8SbM= github.com/macabu/inamedparam v0.1.3 h1:2tk/phHkMlEL/1GNe/Yf6kkR/hkcUdAEY3L0hjYV1Mk= github.com/macabu/inamedparam v0.1.3/go.mod h1:93FLICAIk/quk7eaPPQvbzihUdn/QkGDwIZEoLtpH6I= github.com/magiconair/properties v1.5.3/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= @@ -704,8 +702,8 @@ github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh github.com/mattn/go-sqlite3 v1.6.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mgechev/revive v1.3.9 h1:18Y3R4a2USSBF+QZKFQwVkBROUda7uoBlkEuBD+YD1A= -github.com/mgechev/revive v1.3.9/go.mod h1:+uxEIr5UH0TjXWHTno3xh4u7eg6jDpXKzQccA9UGhHU= +github.com/mgechev/revive v1.5.0 h1:oaSmjA7rP8+HyoRuCgC531VHwnLH1AlJdjj+1AnQceQ= +github.com/mgechev/revive v1.5.0/go.mod h1:L6T3H8EoerRO86c7WuGpvohIUmiploGiyoYbtIWFmV8= github.com/microcosm-cc/bluemonday v1.0.25 h1:4NEwSfiJ+Wva0VxN5B8OwMicaJvD8r9tlJWm9rtloEg= github.com/microcosm-cc/bluemonday v1.0.25/go.mod h1:ZIOjCQp1OrzBBPIJmfX4qDYFuhU02nx4bn030ixfHLE= github.com/miekg/pkcs11 v1.0.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= @@ -756,8 +754,8 @@ github.com/nishanths/exhaustive v0.12.0 h1:vIY9sALmw6T/yxiASewa4TQcFsVYZQQRUQJhK github.com/nishanths/exhaustive v0.12.0/go.mod h1:mEZ95wPIZW+x8kC4TgC+9YCUgiST7ecevsVDTgc2obs= github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk= github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c= -github.com/nunnatsa/ginkgolinter v0.16.2 h1:8iLqHIZvN4fTLDC0Ke9tbSZVcyVHoBs0HIbnVSxfHJk= -github.com/nunnatsa/ginkgolinter v0.16.2/go.mod h1:4tWRinDN1FeJgU+iJANW/kz7xKN5nYRAOfJDQUS9dOQ= +github.com/nunnatsa/ginkgolinter v0.18.0 h1:ZXO1wKhPg3A6LpbN5dMuqwhfOjN5c3ous8YdKOuqk9k= +github.com/nunnatsa/ginkgolinter v0.18.0/go.mod h1:vPrWafSULmjMGCMsfGA908if95VnHQNAahvSBOjTuWs= github.com/oapi-codegen/runtime v1.1.1 h1:EXLHh0DXIJnWhdRPN2w4MXAzFyE4CskzhNLUmtpMYro= github.com/oapi-codegen/runtime v1.1.1/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= @@ -845,6 +843,8 @@ github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 h1:TCg2WBOl github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0= github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 h1:M8mH9eK4OUR4lu7Gd+PU1fV2/qnDNfzT635KRSObncs= github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ= +github.com/raeperd/recvcheck v0.1.2 h1:SjdquRsRXJc26eSonWIo8b7IMtKD3OAT2Lb5G3ZX1+4= +github.com/raeperd/recvcheck v0.1.2/go.mod h1:n04eYkwIR0JbgD73wT8wL4JjPC3wm0nFtzBnWNocnYU= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= @@ -852,8 +852,8 @@ github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= @@ -877,8 +877,8 @@ github.com/sashamelentyev/interfacebloat v1.1.0/go.mod h1:+Y9yU5YdTkrNvoX0xHc84d github.com/sashamelentyev/usestdlibvars v1.27.0 h1:t/3jZpSXtRPRf2xr0m63i32ZrusyurIGT9E5wAvXQnI= github.com/sashamelentyev/usestdlibvars v1.27.0/go.mod h1:9nl0jgOfHKWNFS43Ojw0i7aRoS4j6EBye3YBhmAIRF8= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/securego/gosec/v2 v2.21.2 h1:deZp5zmYf3TWwU7A7cR2+SolbTpZ3HQiwFqnzQyEl3M= -github.com/securego/gosec/v2 v2.21.2/go.mod h1:au33kg78rNseF5PwPnTWhuYBFf534bvJRvOrgZ/bFzU= +github.com/securego/gosec/v2 v2.21.4 h1:Le8MSj0PDmOnHJgUATjD96PaXRvCpKC+DGJvwyy0Mlk= +github.com/securego/gosec/v2 v2.21.4/go.mod h1:Jtb/MwRQfRxCXyCm1rfM1BEiiiTfUOdyzzAhlr6lUTA= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8= github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4= github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c h1:W65qqJCIOVP4jpqPQ0YvHYKwcMEMVWIzWC5iNQQfBTU= @@ -898,14 +898,14 @@ github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sivchari/containedctx v1.0.3 h1:x+etemjbsh2fB5ewm5FeLNi5bUjK0V8n0RB+Wwfd0XE= github.com/sivchari/containedctx v1.0.3/go.mod h1:c1RDvCbnJLtH4lLcYD/GqwiBSSf4F5Qk0xld2rBqzJ4= -github.com/sivchari/tenv v1.10.0 h1:g/hzMA+dBCKqGXgW8AV/1xIWhAvDrx0zFKNR48NFMg0= -github.com/sivchari/tenv v1.10.0/go.mod h1:tdY24masnVoZFxYrHv/nD6Tc8FbkEtAQEEziXpyMgqY= +github.com/sivchari/tenv v1.12.1 h1:+E0QzjktdnExv/wwsnnyk4oqZBUfuh89YMQT1cyuvSY= +github.com/sivchari/tenv v1.12.1/go.mod h1:1LjSOUCc25snIr5n3DtGGrENhX3LuWefcplwVGC24mw= github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= github.com/slack-go/slack v0.15.0 h1:LE2lj2y9vqqiOf+qIIy0GvEoxgF1N5yLGZffmEZykt0= github.com/slack-go/slack v0.15.0/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= -github.com/sonatard/noctx v0.0.2 h1:L7Dz4De2zDQhW8S0t+KUjY0MAQJd6SgVwhzNIc4ok00= -github.com/sonatard/noctx v0.0.2/go.mod h1:kzFz+CzWSjQ2OzIm46uJZoXuBpa2+0y3T36U18dWqIo= +github.com/sonatard/noctx v0.1.0 h1:JjqOc2WN16ISWAjAk8M5ej0RfExEXtkEyExl2hLW+OM= +github.com/sonatard/noctx v0.1.0/go.mod h1:0RvBxqY8D4j9cTTTWE8ylt2vqj2EPI8fHmrxHdsaZ2c= github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/sourcegraph/go-diff v0.7.0 h1:9uLlrd5T46OXs5qpp8L/MTltk0zikUGi0sNNyCpA8G0= @@ -958,14 +958,14 @@ github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= -github.com/tetafro/godot v1.4.17 h1:pGzu+Ye7ZUEFx7LHU0dAKmCOXWsPjl7qA6iMGndsjPs= -github.com/tetafro/godot v1.4.17/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= +github.com/tetafro/godot v1.4.18 h1:ouX3XGiziKDypbpXqShBfnNLTSjR8r3/HVzrtJ+bHlI= +github.com/tetafro/godot v1.4.18/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= github.com/theupdateframework/notary v0.7.0 h1:QyagRZ7wlSpjT5N2qQAh/pN+DVqgekv4DzbAiAiEL3c= github.com/theupdateframework/notary v0.7.0/go.mod h1:c9DRxcmhHmVLDay4/2fUYdISnHqbFDGRSlXPO0AhYWw= github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 h1:quvGphlmUVU+nhpFa4gg4yJyTRJ13reZMDHrKwYw53M= github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966/go.mod h1:27bSVNWSBOHm+qRp1T9qzaIpsWEP6TbUnei/43HK+PQ= -github.com/timonwong/loggercheck v0.9.4 h1:HKKhqrjcVj8sxL7K77beXh0adEm6DLjV/QOGeMXEVi4= -github.com/timonwong/loggercheck v0.9.4/go.mod h1:caz4zlPcgvpEkXgVnAJGowHAMW2NwHaNlpS8xDbVhTg= +github.com/timonwong/loggercheck v0.10.1 h1:uVZYClxQFpw55eh+PIoqM7uAOHMrhVcDoWDery9R8Lg= +github.com/timonwong/loggercheck v0.10.1/go.mod h1:HEAWU8djynujaAVX7QI65Myb8qgfcZ1uKbdpg3ZzKl8= github.com/tomarrell/wrapcheck/v2 v2.9.0 h1:801U2YCAjLhdN8zhZ/7tdjB3EnAoRlJHt/s+9hijLQ4= github.com/tomarrell/wrapcheck/v2 v2.9.0/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo= github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= @@ -980,6 +980,8 @@ github.com/ultraware/whitespace v0.1.1 h1:bTPOGejYFulW3PkcrqkeQwOd6NKOOXvmGD9bo/ github.com/ultraware/whitespace v0.1.1/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= github.com/uudashr/gocognit v1.1.3 h1:l+a111VcDbKfynh+airAy/DJQKaXh2m9vkoysMPSZyM= github.com/uudashr/gocognit v1.1.3/go.mod h1:aKH8/e8xbTRBwjbCkwZ8qt4l2EpKXl31KMHgSS+lZ2U= +github.com/uudashr/iface v1.2.0 h1:ECJjh5q/1Zmnv/2yFpWV6H3oMg5+Mo+vL0aqw9Gjazo= +github.com/uudashr/iface v1.2.0/go.mod h1:Ux/7d/rAF3owK4m53cTVXL4YoVHKNqnoOeQHn2xrlp0= github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 h1:MzD3XeOOSO3mAjOPpF07jFteSKZxsRHvlIcAR9RQzKM= github.com/withfig/autocomplete-tools/packages/cobra v1.2.0/go.mod h1:RoXh7+7qknOXL65uTzdzE1mPxqcPwS7FLCE9K5GfmKo= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= @@ -1019,8 +1021,8 @@ gitlab.com/bosi/decorder v0.4.2 h1:qbQaV3zgwnBZ4zPMhGLW4KZe7A7NwxEhJx39R3shffo= gitlab.com/bosi/decorder v0.4.2/go.mod h1:muuhHoaJkA9QLcYHq4Mj8FJUwDZ+EirSHRiaTcTf6T8= go-simpler.org/assert v0.9.0 h1:PfpmcSvL7yAnWyChSjOz6Sp6m9j5lyK8Ok9pEL31YkQ= go-simpler.org/assert v0.9.0/go.mod h1:74Eqh5eI6vCK6Y5l3PI8ZYFXG4Sa+tkr70OIPJAUr28= -go-simpler.org/musttag v0.12.2 h1:J7lRc2ysXOq7eM8rwaTYnNrHd5JwjppzB6mScysB2Cs= -go-simpler.org/musttag v0.12.2/go.mod h1:uN1DVIasMTQKk6XSik7yrJoEysGtR2GRqvWnI9S7TYM= +go-simpler.org/musttag v0.13.0 h1:Q/YAW0AHvaoaIbsPj3bvEI5/QFP7w696IMUpnKXQfCE= +go-simpler.org/musttag v0.13.0/go.mod h1:FTzIGeK6OkKlUDVpj0iQUXZLUO1Js9+mvykDQy9C5yM= go-simpler.org/sloglint v0.7.2 h1:Wc9Em/Zeuu7JYpl+oKoYOsQSy2X560aVueCW/m6IijY= go-simpler.org/sloglint v0.7.2/go.mod h1:US+9C80ppl7VsThQclkM7BkCHQAzuz8kHLsW3ppuluo= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -1056,8 +1058,8 @@ go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8= -go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0= +go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= +go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= @@ -1098,8 +1100,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= +golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1110,12 +1112,12 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e h1:I88y4caeGeuDQxgdoFPUq097j7kNfw6uvuiNxUBfcBk= -golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e/go.mod h1:akd2r19cwCdwSwWeIdzYQGa/EZZyqcOdwWiwj5L5eKQ= +golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk= +golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= -golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f h1:phY1HzDcf18Aq9A8KkmRtY9WvOFIxN8wgfvy6Zm1DV8= -golang.org/x/exp/typeparams v0.0.0-20240314144324-c7f7c6466f7f/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= +golang.org/x/exp/typeparams v0.0.0-20240909161429-701f63a606c0 h1:bVwtbF629Xlyxk6xLQq2TDYmqP0uiWaet5LwRebuY0k= +golang.org/x/exp/typeparams v0.0.0-20240909161429-701f63a606c0/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -1197,8 +1199,8 @@ golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= -golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= +golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1222,8 +1224,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= +golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1326,8 +1328,8 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= -golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= +golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1354,7 +1356,6 @@ golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1403,8 +1404,8 @@ golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= -golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24= -golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ= +golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o= +golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 98ca5cf57f0b8a702f93d500bb85f60ae3da0344 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 04:35:18 +0000 Subject: [PATCH 146/305] chore(deps): bump go.opentelemetry.io/otel from 1.31.0 to 1.32.0 (#2868) Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.31.0 to 1.32.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.31.0...v1.32.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/otel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index bd1f98f3c..2ab6798a2 100644 --- a/go.mod +++ b/go.mod @@ -48,7 +48,7 @@ require ( github.com/stripe/pg-schema-diff v0.7.0 github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 github.com/zalando/go-keyring v0.2.6 - go.opentelemetry.io/otel v1.31.0 + go.opentelemetry.io/otel v1.32.0 golang.org/x/mod v0.22.0 golang.org/x/oauth2 v0.24.0 golang.org/x/term v0.26.0 @@ -322,10 +322,10 @@ require ( go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect - go.opentelemetry.io/otel/metric v1.31.0 // indirect + go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.28.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect - go.opentelemetry.io/otel/trace v1.31.0 // indirect + go.opentelemetry.io/otel/trace v1.32.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/automaxprocs v1.6.0 // indirect diff --git a/go.sum b/go.sum index 477747194..dcf975492 100644 --- a/go.sum +++ b/go.sum @@ -1032,8 +1032,8 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8= -go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= -go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= +go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= +go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 h1:U2guen0GhqH8o/G2un8f/aG/y++OuW6MyCo6hT9prXk= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0/go.mod h1:yeGZANgEcpdx/WK0IvvRFC+2oLiMS2u4L/0Rj2M2Qr0= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY= @@ -1042,14 +1042,14 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 h1:R3X6Z go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0/go.mod h1:QWFXnDavXWwMx2EEcZsf3yxgEKAqsxQ+Syjp+seyInw= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 h1:j9+03ymgYhPKmeXGk5Zu+cIZOlVzd9Zv7QIiyItjFBU= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0/go.mod h1:Y5+XiUG4Emn1hTfciPzGPJaSI+RpDts6BnCIir0SLqk= -go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE= -go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY= +go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= +go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= -go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= -go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= +go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= +go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= From 732f381efdbfdc32833bd487c3ac0ac064a9d35a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Mon, 11 Nov 2024 13:37:48 +0900 Subject: [PATCH 147/305] fix: bump edge-runtime to 1.61.2 (#2864) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index cedf72b22..49f691706 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241106-f29003e" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.61.1" + edgeRuntimeImage = "supabase/edge-runtime:v1.61.2" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.163.2" From 31c632192db1c15edea11e052f5003b40b920f8c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Nov 2024 12:40:08 +0800 Subject: [PATCH 148/305] chore(deps): bump github.com/containers/common from 0.60.4 to 0.61.0 (#2867) Bumps [github.com/containers/common](https://github.com/containers/common) from 0.60.4 to 0.61.0. - [Release notes](https://github.com/containers/common/releases) - [Commits](https://github.com/containers/common/compare/v0.60.4...v0.61.0) --- updated-dependencies: - dependency-name: github.com/containers/common dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 16 ++++++++-------- go.sum | 43 ++++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/go.mod b/go.mod index 2ab6798a2..4e58e4562 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/charmbracelet/bubbletea v0.25.0 github.com/charmbracelet/glamour v0.7.0 github.com/charmbracelet/lipgloss v0.12.1 - github.com/containers/common v0.60.4 + github.com/containers/common v0.61.0 github.com/deepmap/oapi-codegen/v2 v2.2.0 github.com/docker/cli v27.3.1+incompatible github.com/docker/docker v27.3.1+incompatible @@ -61,7 +61,7 @@ require ( 4d63.com/gocheckcompilerdirectives v1.2.1 // indirect 4d63.com/gochecknoglobals v0.2.1 // indirect al.essio.dev/pkg/shellescape v1.5.1 // indirect - dario.cat/mergo v1.0.0 // indirect + dario.cat/mergo v1.0.1 // indirect github.com/4meepo/tagalign v1.3.4 // indirect github.com/Abirdcfly/dupword v0.1.3 // indirect github.com/Antonboom/errname v1.0.0 // indirect @@ -110,9 +110,9 @@ require ( github.com/cloudwego/iasm v0.2.0 // indirect github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect github.com/containerd/log v0.1.0 // indirect - github.com/containers/storage v1.55.0 // indirect + github.com/containers/storage v1.56.0 // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect - github.com/cyphar/filepath-securejoin v0.3.1 // indirect + github.com/cyphar/filepath-securejoin v0.3.4 // indirect github.com/daixiang0/gci v0.13.5 // indirect github.com/danieljoos/wincred v1.2.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect @@ -130,7 +130,7 @@ require ( github.com/fatih/structtag v1.2.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/firefart/nonamedreturns v1.0.5 // indirect - github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/fsnotify/fsnotify v1.8.0 // indirect github.com/fvbommel/sortorder v1.1.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect @@ -282,7 +282,7 @@ require ( github.com/sirupsen/logrus v1.9.3 // indirect github.com/sivchari/containedctx v1.0.3 // indirect github.com/sivchari/tenv v1.12.1 // indirect - github.com/skeema/knownhosts v1.2.2 // indirect + github.com/skeema/knownhosts v1.3.0 // indirect github.com/sonatard/noctx v0.1.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect github.com/sourcegraph/go-diff v0.7.0 // indirect @@ -333,7 +333,7 @@ require ( go.uber.org/zap v1.24.0 // indirect golang.org/x/arch v0.8.0 // indirect golang.org/x/crypto v0.29.0 // indirect - golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect + golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect golang.org/x/exp/typeparams v0.0.0-20240909161429-701f63a606c0 // indirect golang.org/x/net v0.31.0 // indirect golang.org/x/sync v0.9.0 // indirect @@ -342,7 +342,7 @@ require ( golang.org/x/tools v0.27.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect - google.golang.org/protobuf v1.34.2 // indirect + google.golang.org/protobuf v1.35.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index dcf975492..e224d065e 100644 --- a/go.sum +++ b/go.sum @@ -36,8 +36,8 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= -dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= +dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/4meepo/tagalign v1.3.4 h1:P51VcvBnf04YkHzjfclN6BbsopfJR5rxs1n+5zHt+w8= github.com/4meepo/tagalign v1.3.4/go.mod h1:M+pnkHH2vG8+qhE5bVc/zeP7HS/j910Fwa9TUSyZVI0= @@ -200,10 +200,10 @@ github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2 github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= -github.com/containers/common v0.60.4 h1:H5+LAMHPZEqX6vVNOQ+IguVsaFl8kbO/SZ/VPXjxhy0= -github.com/containers/common v0.60.4/go.mod h1:I0upBi1qJX3QmzGbUOBN1LVP6RvkKhd3qQpZbQT+Q54= -github.com/containers/storage v1.55.0 h1:wTWZ3YpcQf1F+dSP4KxG9iqDfpQY1otaUXjPpffuhgg= -github.com/containers/storage v1.55.0/go.mod h1:28cB81IDk+y7ok60Of6u52RbCeBRucbFOeLunhER1RQ= +github.com/containers/common v0.61.0 h1:j/84PTqZIKKYy42OEJsZmjZ4g4Kq2ERuC3tqp2yWdh4= +github.com/containers/common v0.61.0/go.mod h1:NGRISq2vTFPSbhNqj6MLwyes4tWSlCnqbJg7R77B8xc= +github.com/containers/storage v1.56.0 h1:DZ9KSkj6M2tvj/4bBoaJu3QDHRl35BwsZ4kmLJS97ZI= +github.com/containers/storage v1.56.0/go.mod h1:c6WKowcAlED/DkWGNuL9bvGYqIWCVy7isRMdCSKWNjk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= @@ -213,8 +213,8 @@ github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/curioswitch/go-reassign v0.2.0 h1:G9UZyOcpk/d7Gd6mqYgd8XYWFMw/znxwGDUstnC9DIo= github.com/curioswitch/go-reassign v0.2.0/go.mod h1:x6OpXuWvgfQaMGks2BZybTngWjT84hqJfKoO8Tt/Roc= -github.com/cyphar/filepath-securejoin v0.3.1 h1:1V7cHiaW+C+39wEfpH6XlLBQo3j/PciWFrgfCLS8XrE= -github.com/cyphar/filepath-securejoin v0.3.1/go.mod h1:F7i41x/9cBF7lzCrVsYs9fuzwRZm4NQsGTBdpp6mETc= +github.com/cyphar/filepath-securejoin v0.3.4 h1:VBWugsJh2ZxJmLFSM06/0qzQyiQX2Qs0ViKrUAcqdZ8= +github.com/cyphar/filepath-securejoin v0.3.4/go.mod h1:8s/MCNJREmFK0H02MF6Ihv1nakJe4L/w3WZLHNkvlYM= github.com/daixiang0/gci v0.13.5 h1:kThgmH1yBmZSBCh1EJVxQ7JsHpm5Oms0AMed/0LaH4c= github.com/daixiang0/gci v0.13.5/go.mod h1:12etP2OniiIdP4q+kjUGrC/rUagga7ODbqsom5Eo5Yk= github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0= @@ -280,8 +280,9 @@ github.com/firefart/nonamedreturns v1.0.5/go.mod h1:gHJjDqhGM4WyPt639SOZs+G89Ko7 github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= +github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/fvbommel/sortorder v1.1.0 h1:fUmoe+HLsBTctBDoaBwpQo5N+nrCp8g/BjKb/6ZQmYw= github.com/fvbommel/sortorder v1.1.0/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0= github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= @@ -472,8 +473,8 @@ github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5 h1:5iH8iuqE5apketRbSFBy+X1V0o+l+8NF1avt4HWl7cA= -github.com/google/pprof v0.0.0-20240827171923-fa2c70bbbfe5/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgYQBbFN4U4JNXUNYpxael3UzMyo= +github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= @@ -763,12 +764,12 @@ github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.0 h1:Iw5WCbBcaAAd0fpRb1c9r5YCylv4XDoCSigm1zLevwU= github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= -github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= -github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag= +github.com/onsi/ginkgo/v2 v2.21.0 h1:7rg/4f3rB88pb5obDgNZrNHrQ4e6WpjonchcpuBRnZM= +github.com/onsi/ginkgo/v2 v2.21.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.9.0/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA= -github.com/onsi/gomega v1.34.2 h1:pNCwDkzrsv7MS9kpaQvVb1aVLahQXyJ/Tv5oAZMI3i8= -github.com/onsi/gomega v1.34.2/go.mod h1:v1xfxRgk0KIsG+QOdm7p8UosrOzPYRo60fd3B/1Dukc= +github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4= +github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= github.com/opencontainers/go-digest v0.0.0-20170106003457-a6d0ee40d420/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= @@ -900,8 +901,8 @@ github.com/sivchari/containedctx v1.0.3 h1:x+etemjbsh2fB5ewm5FeLNi5bUjK0V8n0RB+W github.com/sivchari/containedctx v1.0.3/go.mod h1:c1RDvCbnJLtH4lLcYD/GqwiBSSf4F5Qk0xld2rBqzJ4= github.com/sivchari/tenv v1.12.1 h1:+E0QzjktdnExv/wwsnnyk4oqZBUfuh89YMQT1cyuvSY= github.com/sivchari/tenv v1.12.1/go.mod h1:1LjSOUCc25snIr5n3DtGGrENhX3LuWefcplwVGC24mw= -github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= -github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= +github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY= +github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M= github.com/slack-go/slack v0.15.0 h1:LE2lj2y9vqqiOf+qIIy0GvEoxgF1N5yLGZffmEZykt0= github.com/slack-go/slack v0.15.0/go.mod h1:hlGi5oXA+Gt+yWTPP0plCdRKmjsDxecdHxYQdlMQKOw= github.com/sonatard/noctx v0.1.0 h1:JjqOc2WN16ISWAjAk8M5ej0RfExEXtkEyExl2hLW+OM= @@ -1112,8 +1113,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 h1:e66Fs6Z+fZTbFBAxKfP3PALWBtpfqks2bwGcexMxgtk= -golang.org/x/exp v0.0.0-20240909161429-701f63a606c0/go.mod h1:2TbTHSBQa924w8M6Xs1QcRcFwyucIwBGpK1p2f1YFFY= +golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBnqWrJc+rq0DPKyvvdbY= +golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20240909161429-701f63a606c0 h1:bVwtbF629Xlyxk6xLQq2TDYmqP0uiWaet5LwRebuY0k= @@ -1494,8 +1495,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/cenkalti/backoff.v2 v2.2.1 h1:eJ9UAg01/HIHG987TwxvnzK2MgxXq97YY6rYDpY9aII= From 935c74777a9857e61844ead0d230916b5b0c8e63 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Fri, 8 Nov 2024 16:38:10 +0800 Subject: [PATCH 149/305] feat(config): sync hook config to remote --- pkg/config/auth.go | 57 ++++++++++++++++++++++++++++++ pkg/config/auth_test.go | 78 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 0de7315a6..ad88e93c4 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -192,6 +192,8 @@ func (a *auth) ToUpdateAuthConfigBody() v1API.UpdateAuthConfigBody { DisableSignup: cast.Ptr(!a.EnableSignup), ExternalAnonymousUsersEnabled: &a.EnableAnonymousSignIns, } + a.Hook.toAuthConfigBody(&body) + // TODO: mfa, sessions, email a.Sms.toAuthConfigBody(&body) a.External.toAuthConfigBody(&body) return body @@ -207,12 +209,67 @@ func (a *auth) fromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) auth result.EnableManualLinking = cast.Val(remoteConfig.SecurityManualLinkingEnabled, false) result.EnableSignup = !cast.Val(remoteConfig.DisableSignup, false) result.EnableAnonymousSignIns = cast.Val(remoteConfig.ExternalAnonymousUsersEnabled, false) + result.Hook.fromAuthConfig(remoteConfig) result.Sms.fromAuthConfig(remoteConfig) result.External = maps.Clone(result.External) result.External.fromAuthConfig(remoteConfig) return result } +func (h hook) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { + if body.HookCustomAccessTokenEnabled = &h.CustomAccessToken.Enabled; *body.HookCustomAccessTokenEnabled { + body.HookCustomAccessTokenUri = &h.CustomAccessToken.URI + body.HookCustomAccessTokenSecrets = &h.CustomAccessToken.Secrets + } + if body.HookSendEmailEnabled = &h.SendEmail.Enabled; *body.HookSendEmailEnabled { + body.HookSendEmailUri = &h.SendEmail.URI + body.HookSendEmailSecrets = &h.SendEmail.Secrets + } + if body.HookSendSmsEnabled = &h.SendSMS.Enabled; *body.HookSendSmsEnabled { + body.HookSendSmsUri = &h.SendSMS.URI + body.HookSendSmsSecrets = &h.SendSMS.Secrets + } + // Enterprise and team only features + if body.HookMfaVerificationAttemptEnabled = &h.MFAVerificationAttempt.Enabled; *body.HookMfaVerificationAttemptEnabled { + body.HookMfaVerificationAttemptUri = &h.MFAVerificationAttempt.URI + body.HookMfaVerificationAttemptSecrets = &h.MFAVerificationAttempt.Secrets + } + if body.HookPasswordVerificationAttemptEnabled = &h.PasswordVerificationAttempt.Enabled; *body.HookPasswordVerificationAttemptEnabled { + body.HookPasswordVerificationAttemptUri = &h.PasswordVerificationAttempt.URI + body.HookPasswordVerificationAttemptSecrets = &h.PasswordVerificationAttempt.Secrets + } +} + +func (h *hook) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { + // Ignore disabled hooks because their envs are not loaded + if h.CustomAccessToken.Enabled { + h.CustomAccessToken.URI = cast.Val(remoteConfig.HookCustomAccessTokenUri, "") + h.CustomAccessToken.Secrets = hashPrefix + cast.Val(remoteConfig.HookCustomAccessTokenSecrets, "") + } + h.CustomAccessToken.Enabled = cast.Val(remoteConfig.HookCustomAccessTokenEnabled, false) + if h.SendEmail.Enabled { + h.SendEmail.URI = cast.Val(remoteConfig.HookSendEmailUri, "") + h.SendEmail.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendEmailSecrets, "") + } + h.SendEmail.Enabled = cast.Val(remoteConfig.HookSendEmailEnabled, false) + if h.SendSMS.Enabled { + h.SendSMS.URI = cast.Val(remoteConfig.HookSendSmsUri, "") + h.SendSMS.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendSmsSecrets, "") + } + h.SendSMS.Enabled = cast.Val(remoteConfig.HookSendSmsEnabled, false) + // Enterprise and team only features + if h.MFAVerificationAttempt.Enabled { + h.MFAVerificationAttempt.URI = cast.Val(remoteConfig.HookMfaVerificationAttemptUri, "") + h.MFAVerificationAttempt.Secrets = hashPrefix + cast.Val(remoteConfig.HookMfaVerificationAttemptSecrets, "") + } + h.MFAVerificationAttempt.Enabled = cast.Val(remoteConfig.HookMfaVerificationAttemptEnabled, false) + if h.PasswordVerificationAttempt.Enabled { + h.PasswordVerificationAttempt.URI = cast.Val(remoteConfig.HookPasswordVerificationAttemptUri, "") + h.PasswordVerificationAttempt.Secrets = hashPrefix + cast.Val(remoteConfig.HookPasswordVerificationAttemptSecrets, "") + } + h.PasswordVerificationAttempt.Enabled = cast.Val(remoteConfig.HookPasswordVerificationAttemptEnabled, false) +} + func (s sms) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { body.ExternalPhoneEnabled = &s.EnableSignup body.SmsMaxFrequency = cast.Ptr(int(s.MaxFrequency.Seconds())) diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index 4de37b8d1..1db789691 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -9,6 +9,84 @@ import ( "github.com/supabase/cli/pkg/cast" ) +func TestHookDiff(t *testing.T) { + t.Run("local and remote enabled", func(t *testing.T) { + c := auth{EnableSignup: true, Hook: hook{ + CustomAccessToken: hookConfig{Enabled: true}, + SendSMS: hookConfig{Enabled: true}, + SendEmail: hookConfig{Enabled: true}, + MFAVerificationAttempt: hookConfig{Enabled: true}, + PasswordVerificationAttempt: hookConfig{Enabled: true}, + }} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + HookCustomAccessTokenEnabled: cast.Ptr(true), + HookCustomAccessTokenUri: cast.Ptr(""), + HookCustomAccessTokenSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + HookSendEmailEnabled: cast.Ptr(true), + HookSendEmailUri: cast.Ptr(""), + HookSendEmailSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + HookSendSmsEnabled: cast.Ptr(true), + HookSendSmsUri: cast.Ptr(""), + HookSendSmsSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + HookMfaVerificationAttemptEnabled: cast.Ptr(true), + HookMfaVerificationAttemptUri: cast.Ptr(""), + HookMfaVerificationAttemptSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + HookPasswordVerificationAttemptEnabled: cast.Ptr(true), + HookPasswordVerificationAttemptUri: cast.Ptr(""), + HookPasswordVerificationAttemptSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + }) + // Check error + assert.NoError(t, err) + assert.Empty(t, string(diff)) + }) + + t.Run("local enabled and disabled", func(t *testing.T) { + c := auth{EnableSignup: true, Hook: hook{ + CustomAccessToken: hookConfig{Enabled: true}, + MFAVerificationAttempt: hookConfig{Enabled: false}, + }} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + HookCustomAccessTokenEnabled: cast.Ptr(false), + HookCustomAccessTokenUri: cast.Ptr(""), + HookCustomAccessTokenSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + HookMfaVerificationAttemptEnabled: cast.Ptr(true), + HookMfaVerificationAttemptUri: cast.Ptr(""), + HookMfaVerificationAttemptSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + }) + // Check error + assert.NoError(t, err) + + assert.Contains(t, string(diff), `[hook.mfa_verification_attempt]`) + assert.Contains(t, string(diff), `-enabled = true`) + assert.Contains(t, string(diff), `+enabled = false`) + assert.Contains(t, string(diff), `uri = ""`) + assert.Contains(t, string(diff), `secrets = ""`) + + assert.Contains(t, string(diff), `[hook.custom_access_token]`) + assert.Contains(t, string(diff), `-enabled = false`) + assert.Contains(t, string(diff), `+enabled = true`) + assert.Contains(t, string(diff), `uri = ""`) + assert.Contains(t, string(diff), `secrets = "hash:b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"`) + }) + + t.Run("local and remote disabled", func(t *testing.T) { + c := auth{EnableSignup: true} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + HookCustomAccessTokenEnabled: cast.Ptr(false), + HookSendEmailEnabled: cast.Ptr(false), + HookSendSmsEnabled: cast.Ptr(false), + HookMfaVerificationAttemptEnabled: cast.Ptr(false), + HookPasswordVerificationAttemptEnabled: cast.Ptr(false), + }) + // Check error + assert.NoError(t, err) + assert.Empty(t, string(diff)) + }) +} + func TestSmsDiff(t *testing.T) { t.Run("local enabled remote enabled", func(t *testing.T) { c := auth{EnableSignup: true, Sms: sms{ From f7962f2cb1bce3ffd84278708b51d273d778d865 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Fri, 8 Nov 2024 16:56:38 +0800 Subject: [PATCH 150/305] feat(config): sync mfa and sessions config to remote --- pkg/config/auth.go | 42 ++++++++++- pkg/config/auth_test.go | 118 +++++++++++++++++++++++++++++++ pkg/config/templates/config.toml | 12 ++-- pkg/config/testdata/config.toml | 4 +- 4 files changed, 167 insertions(+), 9 deletions(-) diff --git a/pkg/config/auth.go b/pkg/config/auth.go index ad88e93c4..c40b6e289 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -193,7 +193,9 @@ func (a *auth) ToUpdateAuthConfigBody() v1API.UpdateAuthConfigBody { ExternalAnonymousUsersEnabled: &a.EnableAnonymousSignIns, } a.Hook.toAuthConfigBody(&body) - // TODO: mfa, sessions, email + a.MFA.toAuthConfigBody(&body) + a.Sessions.toAuthConfigBody(&body) + // TODO: email a.Sms.toAuthConfigBody(&body) a.External.toAuthConfigBody(&body) return body @@ -210,6 +212,8 @@ func (a *auth) fromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) auth result.EnableSignup = !cast.Val(remoteConfig.DisableSignup, false) result.EnableAnonymousSignIns = cast.Val(remoteConfig.ExternalAnonymousUsersEnabled, false) result.Hook.fromAuthConfig(remoteConfig) + result.MFA.fromAuthConfig(remoteConfig) + result.Sessions.fromAuthConfig(remoteConfig) result.Sms.fromAuthConfig(remoteConfig) result.External = maps.Clone(result.External) result.External.fromAuthConfig(remoteConfig) @@ -270,6 +274,42 @@ func (h *hook) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { h.PasswordVerificationAttempt.Enabled = cast.Val(remoteConfig.HookPasswordVerificationAttemptEnabled, false) } +func (m mfa) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { + body.MfaMaxEnrolledFactors = cast.UintToIntPtr(&m.MaxEnrolledFactors) + body.MfaTotpEnrollEnabled = &m.TOTP.EnrollEnabled + body.MfaTotpVerifyEnabled = &m.TOTP.VerifyEnabled + body.MfaPhoneEnrollEnabled = &m.Phone.EnrollEnabled + body.MfaPhoneVerifyEnabled = &m.Phone.VerifyEnabled + body.MfaPhoneOtpLength = cast.UintToIntPtr(&m.Phone.OtpLength) + body.MfaPhoneTemplate = &m.Phone.Template + body.MfaPhoneMaxFrequency = cast.Ptr(int(m.Phone.MaxFrequency.Seconds())) + body.MfaWebAuthnEnrollEnabled = &m.WebAuthn.EnrollEnabled + body.MfaWebAuthnVerifyEnabled = &m.WebAuthn.VerifyEnabled +} + +func (m *mfa) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { + m.MaxEnrolledFactors = cast.IntToUint(cast.Val(remoteConfig.MfaMaxEnrolledFactors, 0)) + m.TOTP.EnrollEnabled = cast.Val(remoteConfig.MfaTotpEnrollEnabled, false) + m.TOTP.VerifyEnabled = cast.Val(remoteConfig.MfaTotpVerifyEnabled, false) + m.Phone.EnrollEnabled = cast.Val(remoteConfig.MfaPhoneEnrollEnabled, false) + m.Phone.VerifyEnabled = cast.Val(remoteConfig.MfaPhoneVerifyEnabled, false) + m.Phone.OtpLength = cast.IntToUint(remoteConfig.MfaPhoneOtpLength) + m.Phone.Template = cast.Val(remoteConfig.MfaPhoneTemplate, "") + m.Phone.MaxFrequency = time.Duration(cast.Val(remoteConfig.MfaPhoneMaxFrequency, 0)) * time.Second + m.WebAuthn.EnrollEnabled = cast.Val(remoteConfig.MfaWebAuthnEnrollEnabled, false) + m.WebAuthn.VerifyEnabled = cast.Val(remoteConfig.MfaWebAuthnVerifyEnabled, false) +} + +func (s sessions) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { + body.SessionsTimebox = cast.Ptr(int(s.Timebox.Seconds())) + body.SessionsInactivityTimeout = cast.Ptr(int(s.InactivityTimeout.Seconds())) +} + +func (s *sessions) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { + s.Timebox = time.Duration(cast.Val(remoteConfig.SessionsTimebox, 0)) * time.Second + s.InactivityTimeout = time.Duration(cast.Val(remoteConfig.SessionsInactivityTimeout, 0)) * time.Second +} + func (s sms) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { body.ExternalPhoneEnabled = &s.EnableSignup body.SmsMaxFrequency = cast.Ptr(int(s.MaxFrequency.Seconds())) diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index 1db789691..aa10693ee 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -87,6 +87,124 @@ func TestHookDiff(t *testing.T) { }) } +func TestMfaDiff(t *testing.T) { + t.Run("local and remote enabled", func(t *testing.T) { + c := auth{EnableSignup: true, MFA: mfa{ + TOTP: factorTypeConfiguration{ + EnrollEnabled: true, + VerifyEnabled: true, + }, + Phone: phoneFactorTypeConfiguration{ + factorTypeConfiguration: factorTypeConfiguration{ + EnrollEnabled: true, + VerifyEnabled: true, + }, + OtpLength: 6, + Template: "Your code is {{ .Code }}", + MaxFrequency: 5 * time.Second, + }, + WebAuthn: factorTypeConfiguration{ + EnrollEnabled: true, + VerifyEnabled: true, + }, + MaxEnrolledFactors: 10, + }} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + MfaMaxEnrolledFactors: cast.Ptr(10), + MfaTotpEnrollEnabled: cast.Ptr(true), + MfaTotpVerifyEnabled: cast.Ptr(true), + MfaPhoneEnrollEnabled: cast.Ptr(true), + MfaPhoneVerifyEnabled: cast.Ptr(true), + MfaPhoneOtpLength: 6, + MfaPhoneTemplate: cast.Ptr("Your code is {{ .Code }}"), + MfaPhoneMaxFrequency: cast.Ptr(5), + MfaWebAuthnEnrollEnabled: cast.Ptr(true), + MfaWebAuthnVerifyEnabled: cast.Ptr(true), + }) + // Check error + assert.NoError(t, err) + assert.Empty(t, string(diff)) + }) + + t.Run("local enabled and disabled", func(t *testing.T) { + c := auth{EnableSignup: true, MFA: mfa{ + TOTP: factorTypeConfiguration{ + EnrollEnabled: false, + VerifyEnabled: false, + }, + Phone: phoneFactorTypeConfiguration{ + factorTypeConfiguration: factorTypeConfiguration{ + EnrollEnabled: true, + VerifyEnabled: true, + }, + }, + }} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + MfaMaxEnrolledFactors: cast.Ptr(10), + MfaTotpEnrollEnabled: cast.Ptr(false), + MfaTotpVerifyEnabled: cast.Ptr(false), + MfaPhoneEnrollEnabled: cast.Ptr(false), + MfaPhoneVerifyEnabled: cast.Ptr(false), + MfaPhoneOtpLength: 6, + MfaPhoneTemplate: cast.Ptr("Your code is {{ .Code }}"), + MfaPhoneMaxFrequency: cast.Ptr(5), + MfaWebAuthnEnrollEnabled: cast.Ptr(false), + MfaWebAuthnVerifyEnabled: cast.Ptr(false), + }) + // Check error + assert.NoError(t, err) + assert.Contains(t, string(diff), ` [mfa]`) + assert.Contains(t, string(diff), `-max_enrolled_factors = 10`) + assert.Contains(t, string(diff), `+max_enrolled_factors = 0`) + assert.Contains(t, string(diff), ` [mfa.totp]`) + assert.Contains(t, string(diff), ` enroll_enabled = false`) + assert.Contains(t, string(diff), ` verify_enabled = false`) + assert.Contains(t, string(diff), ` [mfa.phone]`) + assert.Contains(t, string(diff), `-enroll_enabled = false`) + assert.Contains(t, string(diff), `-verify_enabled = false`) + assert.Contains(t, string(diff), `-otp_length = 6`) + assert.Contains(t, string(diff), `-template = "Your code is {{ .Code }}"`) + assert.Contains(t, string(diff), `-max_frequency = "5s"`) + assert.Contains(t, string(diff), `+enroll_enabled = true`) + assert.Contains(t, string(diff), `+verify_enabled = true`) + assert.Contains(t, string(diff), `+otp_length = 0`) + assert.Contains(t, string(diff), `+template = ""`) + assert.Contains(t, string(diff), `+max_frequency = "0s"`) + assert.Contains(t, string(diff), ` [mfa.web_authn]`) + assert.Contains(t, string(diff), ` enroll_enabled = false`) + assert.Contains(t, string(diff), ` verify_enabled = false`) + }) + + t.Run("local and remote disabled", func(t *testing.T) { + c := auth{EnableSignup: true, MFA: mfa{ + MaxEnrolledFactors: 10, + Phone: phoneFactorTypeConfiguration{ + OtpLength: 6, + Template: "Your code is {{ .Code }}", + MaxFrequency: 5 * time.Second, + }, + }} + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + MfaMaxEnrolledFactors: cast.Ptr(10), + MfaTotpEnrollEnabled: cast.Ptr(false), + MfaTotpVerifyEnabled: cast.Ptr(false), + MfaPhoneEnrollEnabled: cast.Ptr(false), + MfaPhoneVerifyEnabled: cast.Ptr(false), + MfaPhoneOtpLength: 6, + MfaPhoneTemplate: cast.Ptr("Your code is {{ .Code }}"), + MfaPhoneMaxFrequency: cast.Ptr(5), + MfaWebAuthnEnrollEnabled: cast.Ptr(false), + MfaWebAuthnVerifyEnabled: cast.Ptr(false), + }) + // Check error + assert.NoError(t, err) + assert.Empty(t, string(diff)) + }) +} + func TestSmsDiff(t *testing.T) { t.Run("local enabled remote enabled", func(t *testing.T) { c := auth{EnableSignup: true, Sms: sms{ diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index 8df89bea3..43854f7d6 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -184,12 +184,12 @@ enroll_enabled = true verify_enabled = true # Configure Multi-factor-authentication via Phone Messaging -# [auth.mfa.phone] -# enroll_enabled = true -# verify_enabled = true -# otp_length = 6 -# template = "Your code is {{ `{{ .Code }}` }} ." -# max_frequency = "10s" +[auth.mfa.phone] +enroll_enabled = false +verify_enabled = false +otp_length = 6 +template = "Your code is {{ `{{ .Code }}` }}" +max_frequency = "5s" # Configure Multi-factor-authentication via WebAuthn # [auth.mfa.web_authn] diff --git a/pkg/config/testdata/config.toml b/pkg/config/testdata/config.toml index b8314644d..9aba86c3d 100644 --- a/pkg/config/testdata/config.toml +++ b/pkg/config/testdata/config.toml @@ -188,8 +188,8 @@ verify_enabled = true enroll_enabled = true verify_enabled = true otp_length = 6 -template = "Your code is {{ `{{ .Code }}` }} ." -max_frequency = "10s" +template = "Your code is {{ `{{ .Code }}` }}" +max_frequency = "5s" # Configure Multi-factor-authentication via Phone Messaging [auth.mfa.web_authn] From fe2d741fb3143b5b536da0607e5835f21ef96c4d Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Fri, 8 Nov 2024 17:01:15 +0800 Subject: [PATCH 151/305] chore: regroup auth config --- pkg/config/auth.go | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/pkg/config/auth.go b/pkg/config/auth.go index c40b6e289..1c7b7d1b9 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -12,25 +12,24 @@ import ( type ( auth struct { - Enabled bool `toml:"enabled"` - Image string `toml:"-"` - SiteUrl string `toml:"site_url"` - AdditionalRedirectUrls []string `toml:"additional_redirect_urls"` + Enabled bool `toml:"enabled"` + Image string `toml:"-"` - JwtExpiry uint `toml:"jwt_expiry"` - EnableRefreshTokenRotation bool `toml:"enable_refresh_token_rotation"` - RefreshTokenReuseInterval uint `toml:"refresh_token_reuse_interval"` - EnableManualLinking bool `toml:"enable_manual_linking"` + SiteUrl string `toml:"site_url"` + AdditionalRedirectUrls []string `toml:"additional_redirect_urls"` + JwtExpiry uint `toml:"jwt_expiry"` + EnableRefreshTokenRotation bool `toml:"enable_refresh_token_rotation"` + RefreshTokenReuseInterval uint `toml:"refresh_token_reuse_interval"` + EnableManualLinking bool `toml:"enable_manual_linking"` + EnableSignup bool `toml:"enable_signup"` + EnableAnonymousSignIns bool `toml:"enable_anonymous_sign_ins"` Hook hook `toml:"hook"` MFA mfa `toml:"mfa"` Sessions sessions `toml:"sessions"` - - EnableSignup bool `toml:"enable_signup"` - EnableAnonymousSignIns bool `toml:"enable_anonymous_sign_ins"` - Email email `toml:"email"` - Sms sms `toml:"sms"` - External external `toml:"external"` + Email email `toml:"email"` + Sms sms `toml:"sms"` + External external `toml:"external"` // Custom secrets can be injected from .env file JwtSecret string `toml:"-" mapstructure:"jwt_secret"` From f583b325f9b0ca1fe7d683faff6a220a67ba4fa6 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Fri, 8 Nov 2024 18:30:30 +0800 Subject: [PATCH 152/305] fix: validate mfa enroll and verify config --- pkg/config/config.go | 52 +++++++++++++++++++++++---------------- pkg/config/config_test.go | 7 +++++- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index c1860fe4a..6dce74af9 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -734,19 +734,10 @@ func (c *baseConfig) Validate(fsys fs.FS) error { c.Auth.Sms.EnableSignup = false fmt.Fprintln(os.Stderr, "WARN: no SMS provider is enabled. Disabling phone login") } - if err := c.Auth.Hook.MFAVerificationAttempt.HandleHook("mfa_verification_attempt"); err != nil { + if err := c.Auth.Hook.validate(); err != nil { return err } - if err := c.Auth.Hook.PasswordVerificationAttempt.HandleHook("password_verification_attempt"); err != nil { - return err - } - if err := c.Auth.Hook.CustomAccessToken.HandleHook("custom_access_token"); err != nil { - return err - } - if err := c.Auth.Hook.SendSMS.HandleHook("send_sms"); err != nil { - return err - } - if err := c.Auth.Hook.SendEmail.HandleHook("send_email"); err != nil { + if err := c.Auth.MFA.validate(); err != nil { return err } // Validate oauth config @@ -917,16 +908,33 @@ func (c *seed) loadSeedPaths(basePath string, fsys fs.FS) error { return nil } -func (h *hookConfig) HandleHook(hookType string) error { +func (h *hook) validate() error { + if err := h.MFAVerificationAttempt.validate("mfa_verification_attempt"); err != nil { + return err + } + if err := h.PasswordVerificationAttempt.validate("password_verification_attempt"); err != nil { + return err + } + if err := h.CustomAccessToken.validate("custom_access_token"); err != nil { + return err + } + if err := h.SendSMS.validate("send_sms"); err != nil { + return err + } + return h.SendEmail.validate("send_email") +} + +func (h *hookConfig) validate(hookType string) error { // If not enabled do nothing if !h.Enabled { return nil } if h.URI == "" { return errors.Errorf("missing required field in config: auth.hook.%s.uri", hookType) - } - if err := validateHookURI(h.URI, hookType); err != nil { - return err + } else if parsed, err := url.Parse(h.URI); err != nil { + return errors.Errorf("failed to parse template url: %w", err) + } else if !(parsed.Scheme == "http" || parsed.Scheme == "https" || parsed.Scheme == "pg-functions") { + return errors.Errorf("Invalid HTTP hook config: auth.hook.%v should be a Postgres function URI, or a HTTP or HTTPS URL", hookType) } var err error if h.Secrets, err = maybeLoadEnv(h.Secrets); err != nil { @@ -935,13 +943,15 @@ func (h *hookConfig) HandleHook(hookType string) error { return nil } -func validateHookURI(uri, hookName string) error { - parsed, err := url.Parse(uri) - if err != nil { - return errors.Errorf("failed to parse template url: %w", err) +func (m *mfa) validate() error { + if m.TOTP.EnrollEnabled && !m.TOTP.VerifyEnabled { + return errors.Errorf("Invalid MFA config: auth.mfa.totp.enroll_enabled requires verify_enabled") + } + if m.Phone.EnrollEnabled && !m.Phone.VerifyEnabled { + return errors.Errorf("Invalid MFA config: auth.mfa.phone.enroll_enabled requires verify_enabled") } - if !(parsed.Scheme == "http" || parsed.Scheme == "https" || parsed.Scheme == "pg-functions") { - return errors.Errorf("Invalid HTTP hook config: auth.hook.%v should be a Postgres function URI, or a HTTP or HTTPS URL", hookName) + if m.WebAuthn.EnrollEnabled && !m.WebAuthn.VerifyEnabled { + return errors.Errorf("Invalid MFA config: auth.mfa.web_authn.enroll_enabled requires verify_enabled") } return nil } diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index d80ea915b..8f1169d5e 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -247,7 +247,12 @@ func TestValidateHookURI(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - err := validateHookURI(tt.uri, tt.hookName) + h := hookConfig{ + Enabled: true, + URI: tt.uri, + Secrets: "test-secret", + } + err := h.validate(tt.hookName) if tt.shouldErr { assert.Error(t, err, "Expected an error for %v", tt.name) assert.EqualError(t, err, tt.errorMsg, "Expected error message does not match for %v", tt.name) From 499875b1f2e36dd159f82611cc142dfc31f8ef5e Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Mon, 11 Nov 2024 12:33:54 +0800 Subject: [PATCH 153/305] chore: refactor sms and oauth validation test --- pkg/config/config.go | 226 ++++++++++++++++++++++--------------------- 1 file changed, 117 insertions(+), 109 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 6dce74af9..2ae693b05 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -666,115 +666,21 @@ func (c *baseConfig) Validate(fsys fs.FS) error { if c.Auth.Email.Smtp.Pass, err = maybeLoadEnv(c.Auth.Email.Smtp.Pass); err != nil { return err } - // Validate sms config - switch { - case c.Auth.Sms.Twilio.Enabled: - if len(c.Auth.Sms.Twilio.AccountSid) == 0 { - return errors.New("Missing required field in config: auth.sms.twilio.account_sid") - } - if len(c.Auth.Sms.Twilio.MessageServiceSid) == 0 { - return errors.New("Missing required field in config: auth.sms.twilio.message_service_sid") - } - if len(c.Auth.Sms.Twilio.AuthToken) == 0 { - return errors.New("Missing required field in config: auth.sms.twilio.auth_token") - } - if c.Auth.Sms.Twilio.AuthToken, err = maybeLoadEnv(c.Auth.Sms.Twilio.AuthToken); err != nil { - return err - } - case c.Auth.Sms.TwilioVerify.Enabled: - if len(c.Auth.Sms.TwilioVerify.AccountSid) == 0 { - return errors.New("Missing required field in config: auth.sms.twilio_verify.account_sid") - } - if len(c.Auth.Sms.TwilioVerify.MessageServiceSid) == 0 { - return errors.New("Missing required field in config: auth.sms.twilio_verify.message_service_sid") - } - if len(c.Auth.Sms.TwilioVerify.AuthToken) == 0 { - return errors.New("Missing required field in config: auth.sms.twilio_verify.auth_token") - } - if c.Auth.Sms.TwilioVerify.AuthToken, err = maybeLoadEnv(c.Auth.Sms.TwilioVerify.AuthToken); err != nil { - return err - } - case c.Auth.Sms.Messagebird.Enabled: - if len(c.Auth.Sms.Messagebird.Originator) == 0 { - return errors.New("Missing required field in config: auth.sms.messagebird.originator") - } - if len(c.Auth.Sms.Messagebird.AccessKey) == 0 { - return errors.New("Missing required field in config: auth.sms.messagebird.access_key") - } - if c.Auth.Sms.Messagebird.AccessKey, err = maybeLoadEnv(c.Auth.Sms.Messagebird.AccessKey); err != nil { - return err - } - case c.Auth.Sms.Textlocal.Enabled: - if len(c.Auth.Sms.Textlocal.Sender) == 0 { - return errors.New("Missing required field in config: auth.sms.textlocal.sender") - } - if len(c.Auth.Sms.Textlocal.ApiKey) == 0 { - return errors.New("Missing required field in config: auth.sms.textlocal.api_key") - } - if c.Auth.Sms.Textlocal.ApiKey, err = maybeLoadEnv(c.Auth.Sms.Textlocal.ApiKey); err != nil { - return err - } - case c.Auth.Sms.Vonage.Enabled: - if len(c.Auth.Sms.Vonage.From) == 0 { - return errors.New("Missing required field in config: auth.sms.vonage.from") - } - if len(c.Auth.Sms.Vonage.ApiKey) == 0 { - return errors.New("Missing required field in config: auth.sms.vonage.api_key") - } - if len(c.Auth.Sms.Vonage.ApiSecret) == 0 { - return errors.New("Missing required field in config: auth.sms.vonage.api_secret") - } - if c.Auth.Sms.Vonage.ApiKey, err = maybeLoadEnv(c.Auth.Sms.Vonage.ApiKey); err != nil { - return err - } - if c.Auth.Sms.Vonage.ApiSecret, err = maybeLoadEnv(c.Auth.Sms.Vonage.ApiSecret); err != nil { - return err - } - case c.Auth.Sms.EnableSignup: - c.Auth.Sms.EnableSignup = false - fmt.Fprintln(os.Stderr, "WARN: no SMS provider is enabled. Disabling phone login") - } if err := c.Auth.Hook.validate(); err != nil { return err } if err := c.Auth.MFA.validate(); err != nil { return err } - // Validate oauth config - for _, ext := range []string{"linkedin", "slack"} { - if c.Auth.External[ext].Enabled { - fmt.Fprintf(os.Stderr, `WARN: disabling deprecated "%[1]s" provider. Please use [auth.external.%[1]s_oidc] instead\n`, ext) - } - delete(c.Auth.External, ext) + if err := c.Auth.Sms.validate(); err != nil { + return err } - for ext, provider := range c.Auth.External { - if !provider.Enabled { - continue - } - if provider.ClientId == "" { - return errors.Errorf("Missing required field in config: auth.external.%s.client_id", ext) - } - if !sliceContains([]string{"apple", "google"}, ext) && provider.Secret == "" { - return errors.Errorf("Missing required field in config: auth.external.%s.secret", ext) - } - if provider.ClientId, err = maybeLoadEnv(provider.ClientId); err != nil { - return err - } - if provider.Secret, err = maybeLoadEnv(provider.Secret); err != nil { - return err - } - if provider.RedirectUri, err = maybeLoadEnv(provider.RedirectUri); err != nil { - return err - } - if provider.Url, err = maybeLoadEnv(provider.Url); err != nil { - return err - } - c.Auth.External[ext] = provider + if err := c.Auth.External.validate(); err != nil { + return err + } + if err := c.Auth.ThirdParty.validate(); err != nil { + return err } - } - // Validate Third-Party Auth config - if err := c.Auth.ThirdParty.validate(); err != nil { - return err } // Validate functions config if c.EdgeRuntime.Enabled { @@ -808,7 +714,7 @@ func (c *baseConfig) Validate(fsys fs.FS) error { return errors.Errorf("Invalid config for analytics.backend. Must be one of: %v", allowed) } } - if err := c.Experimental.validateWebhooks(); err != nil { + if err := c.Experimental.validate(); err != nil { return err } return nil @@ -908,6 +814,111 @@ func (c *seed) loadSeedPaths(basePath string, fsys fs.FS) error { return nil } +func (s *sms) validate() (err error) { + switch { + case s.Twilio.Enabled: + if len(s.Twilio.AccountSid) == 0 { + return errors.New("Missing required field in config: auth.sms.twilio.account_sid") + } + if len(s.Twilio.MessageServiceSid) == 0 { + return errors.New("Missing required field in config: auth.sms.twilio.message_service_sid") + } + if len(s.Twilio.AuthToken) == 0 { + return errors.New("Missing required field in config: auth.sms.twilio.auth_token") + } + if s.Twilio.AuthToken, err = maybeLoadEnv(s.Twilio.AuthToken); err != nil { + return err + } + case s.TwilioVerify.Enabled: + if len(s.TwilioVerify.AccountSid) == 0 { + return errors.New("Missing required field in config: auth.sms.twilio_verify.account_sid") + } + if len(s.TwilioVerify.MessageServiceSid) == 0 { + return errors.New("Missing required field in config: auth.sms.twilio_verify.message_service_sid") + } + if len(s.TwilioVerify.AuthToken) == 0 { + return errors.New("Missing required field in config: auth.sms.twilio_verify.auth_token") + } + if s.TwilioVerify.AuthToken, err = maybeLoadEnv(s.TwilioVerify.AuthToken); err != nil { + return err + } + case s.Messagebird.Enabled: + if len(s.Messagebird.Originator) == 0 { + return errors.New("Missing required field in config: auth.sms.messagebird.originator") + } + if len(s.Messagebird.AccessKey) == 0 { + return errors.New("Missing required field in config: auth.sms.messagebird.access_key") + } + if s.Messagebird.AccessKey, err = maybeLoadEnv(s.Messagebird.AccessKey); err != nil { + return err + } + case s.Textlocal.Enabled: + if len(s.Textlocal.Sender) == 0 { + return errors.New("Missing required field in config: auth.sms.textlocal.sender") + } + if len(s.Textlocal.ApiKey) == 0 { + return errors.New("Missing required field in config: auth.sms.textlocal.api_key") + } + if s.Textlocal.ApiKey, err = maybeLoadEnv(s.Textlocal.ApiKey); err != nil { + return err + } + case s.Vonage.Enabled: + if len(s.Vonage.From) == 0 { + return errors.New("Missing required field in config: auth.sms.vonage.from") + } + if len(s.Vonage.ApiKey) == 0 { + return errors.New("Missing required field in config: auth.sms.vonage.api_key") + } + if len(s.Vonage.ApiSecret) == 0 { + return errors.New("Missing required field in config: auth.sms.vonage.api_secret") + } + if s.Vonage.ApiKey, err = maybeLoadEnv(s.Vonage.ApiKey); err != nil { + return err + } + if s.Vonage.ApiSecret, err = maybeLoadEnv(s.Vonage.ApiSecret); err != nil { + return err + } + case s.EnableSignup: + s.EnableSignup = false + fmt.Fprintln(os.Stderr, "WARN: no SMS provider is enabled. Disabling phone login") + } + return nil +} + +func (e external) validate() (err error) { + for _, ext := range []string{"linkedin", "slack"} { + if e[ext].Enabled { + fmt.Fprintf(os.Stderr, `WARN: disabling deprecated "%[1]s" provider. Please use [auth.external.%[1]s_oidc] instead\n`, ext) + } + delete(e, ext) + } + for ext, provider := range e { + if !provider.Enabled { + continue + } + if provider.ClientId == "" { + return errors.Errorf("Missing required field in config: auth.external.%s.client_id", ext) + } + if !sliceContains([]string{"apple", "google"}, ext) && provider.Secret == "" { + return errors.Errorf("Missing required field in config: auth.external.%s.secret", ext) + } + if provider.ClientId, err = maybeLoadEnv(provider.ClientId); err != nil { + return err + } + if provider.Secret, err = maybeLoadEnv(provider.Secret); err != nil { + return err + } + if provider.RedirectUri, err = maybeLoadEnv(provider.RedirectUri); err != nil { + return err + } + if provider.Url, err = maybeLoadEnv(provider.Url); err != nil { + return err + } + e[ext] = provider + } + return nil +} + func (h *hook) validate() error { if err := h.MFAVerificationAttempt.validate("mfa_verification_attempt"); err != nil { return err @@ -924,7 +935,7 @@ func (h *hook) validate() error { return h.SendEmail.validate("send_email") } -func (h *hookConfig) validate(hookType string) error { +func (h *hookConfig) validate(hookType string) (err error) { // If not enabled do nothing if !h.Enabled { return nil @@ -936,7 +947,6 @@ func (h *hookConfig) validate(hookType string) error { } else if !(parsed.Scheme == "http" || parsed.Scheme == "https" || parsed.Scheme == "pg-functions") { return errors.Errorf("Invalid HTTP hook config: auth.hook.%v should be a Postgres function URI, or a HTTP or HTTPS URL", hookType) } - var err error if h.Secrets, err = maybeLoadEnv(h.Secrets); err != nil { return errors.Errorf("missing required field in config: auth.hook.%s.secrets", hookType) } @@ -1196,11 +1206,9 @@ func ToTomlBytes(config any) ([]byte, error) { return buf.Bytes(), nil } -func (e *experimental) validateWebhooks() error { - if e.Webhooks != nil { - if !e.Webhooks.Enabled { - return errors.Errorf("Webhooks cannot be deactivated. [experimental.webhooks] enabled can either be true or left undefined") - } +func (e *experimental) validate() error { + if e.Webhooks != nil && !e.Webhooks.Enabled { + return errors.Errorf("Webhooks cannot be deactivated. [experimental.webhooks] enabled can either be true or left undefined") } return nil } From 96136cf0f33c2564ce8159e41e982a23de286c1d Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Mon, 11 Nov 2024 12:35:02 +0800 Subject: [PATCH 154/305] chore: stricter unit tests for unchanged fields --- pkg/config/auth_test.go | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index aa10693ee..df63f898f 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -58,17 +58,17 @@ func TestHookDiff(t *testing.T) { // Check error assert.NoError(t, err) - assert.Contains(t, string(diff), `[hook.mfa_verification_attempt]`) + assert.Contains(t, string(diff), ` [hook.mfa_verification_attempt]`) assert.Contains(t, string(diff), `-enabled = true`) assert.Contains(t, string(diff), `+enabled = false`) - assert.Contains(t, string(diff), `uri = ""`) - assert.Contains(t, string(diff), `secrets = ""`) + assert.Contains(t, string(diff), ` uri = ""`) + assert.Contains(t, string(diff), ` secrets = ""`) - assert.Contains(t, string(diff), `[hook.custom_access_token]`) + assert.Contains(t, string(diff), ` [hook.custom_access_token]`) assert.Contains(t, string(diff), `-enabled = false`) assert.Contains(t, string(diff), `+enabled = true`) - assert.Contains(t, string(diff), `uri = ""`) - assert.Contains(t, string(diff), `secrets = "hash:b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"`) + assert.Contains(t, string(diff), ` uri = ""`) + assert.Contains(t, string(diff), ` secrets = "hash:b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"`) }) t.Run("local and remote disabled", func(t *testing.T) { @@ -282,7 +282,7 @@ func TestSmsDiff(t *testing.T) { assert.Contains(t, string(diff), `+template = ""`) assert.Contains(t, string(diff), `+max_frequency = "0s"`) - assert.Contains(t, string(diff), `[sms.twilio]`) + assert.Contains(t, string(diff), ` [sms.twilio]`) assert.Contains(t, string(diff), `-enabled = true`) assert.Contains(t, string(diff), `+enabled = false`) @@ -330,11 +330,11 @@ func TestSmsDiff(t *testing.T) { assert.Contains(t, string(diff), `+template = "Your code is {{ .Code }}"`) assert.Contains(t, string(diff), `+max_frequency = "1m0s"`) - assert.Contains(t, string(diff), `[sms.twilio]`) + assert.Contains(t, string(diff), ` [sms.twilio]`) assert.Contains(t, string(diff), `-enabled = true`) assert.Contains(t, string(diff), `+enabled = false`) - assert.Contains(t, string(diff), `[sms.messagebird]`) + assert.Contains(t, string(diff), ` [sms.messagebird]`) assert.Contains(t, string(diff), `-enabled = false`) assert.Contains(t, string(diff), `-originator = ""`) assert.Contains(t, string(diff), `-access_key = "hash:"`) @@ -386,7 +386,7 @@ func TestSmsDiff(t *testing.T) { }) // Check error assert.NoError(t, err) - assert.Contains(t, string(diff), `[sms]`) + assert.Contains(t, string(diff), ` [sms]`) assert.Contains(t, string(diff), `-enable_signup = false`) assert.Contains(t, string(diff), `+enable_signup = true`) }) @@ -548,13 +548,13 @@ func TestExternalDiff(t *testing.T) { }) // Check error assert.NoError(t, err) - assert.Contains(t, string(diff), `[external.apple]`) + assert.Contains(t, string(diff), ` [external.apple]`) assert.Contains(t, string(diff), `-enabled = false`) assert.Contains(t, string(diff), `+enabled = true`) - assert.Contains(t, string(diff), `client_id = "test-client-1,test-client-2"`) - assert.Contains(t, string(diff), `secret = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"`) + assert.Contains(t, string(diff), ` client_id = "test-client-1,test-client-2"`) + assert.Contains(t, string(diff), ` secret = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"`) - assert.Contains(t, string(diff), `[external.google]`) + assert.Contains(t, string(diff), ` [external.google]`) assert.Contains(t, string(diff), `-enabled = true`) assert.Contains(t, string(diff), `+enabled = false`) }) From 9f962a566e31c213b2d9afb445c9fcc0869aa1b4 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Mon, 11 Nov 2024 22:24:15 +0800 Subject: [PATCH 155/305] feat(config): sync smtp and email config to remote --- internal/start/start.go | 23 +++- pkg/config/auth.go | 59 +++++++- pkg/config/auth_test.go | 271 +++++++++++++++++++++++++++++++++---- pkg/config/config.go | 58 +++++--- pkg/config/updater_test.go | 1 + 5 files changed, 358 insertions(+), 54 deletions(-) diff --git a/internal/start/start.go b/internal/start/start.go index ebddb6d40..ba098b734 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -490,12 +490,6 @@ EOF fmt.Sprintf("GOTRUE_EXTERNAL_ANONYMOUS_USERS_ENABLED=%v", utils.Config.Auth.EnableAnonymousSignIns), - fmt.Sprintf("GOTRUE_SMTP_HOST=%s", utils.Config.Auth.Email.Smtp.Host), - fmt.Sprintf("GOTRUE_SMTP_PORT=%d", utils.Config.Auth.Email.Smtp.Port), - fmt.Sprintf("GOTRUE_SMTP_USER=%s", utils.Config.Auth.Email.Smtp.User), - fmt.Sprintf("GOTRUE_SMTP_PASS=%s", utils.Config.Auth.Email.Smtp.Pass), - fmt.Sprintf("GOTRUE_SMTP_ADMIN_EMAIL=%s", utils.Config.Auth.Email.Smtp.AdminEmail), - fmt.Sprintf("GOTRUE_SMTP_SENDER_NAME=%s", utils.Config.Auth.Email.Smtp.SenderName), fmt.Sprintf("GOTRUE_SMTP_MAX_FREQUENCY=%v", utils.Config.Auth.Email.MaxFrequency), "GOTRUE_MAILER_URLPATHS_INVITE=" + utils.GetApiUrl("/auth/v1/verify"), @@ -525,6 +519,23 @@ EOF fmt.Sprintf("GOTRUE_MFA_MAX_ENROLLED_FACTORS=%v", utils.Config.Auth.MFA.MaxEnrolledFactors), } + if utils.Config.Auth.Email.Smtp != nil { + env = append(env, + fmt.Sprintf("GOTRUE_SMTP_HOST=%s", utils.Config.Auth.Email.Smtp.Host), + fmt.Sprintf("GOTRUE_SMTP_PORT=%d", utils.Config.Auth.Email.Smtp.Port), + fmt.Sprintf("GOTRUE_SMTP_USER=%s", utils.Config.Auth.Email.Smtp.User), + fmt.Sprintf("GOTRUE_SMTP_PASS=%s", utils.Config.Auth.Email.Smtp.Pass), + fmt.Sprintf("GOTRUE_SMTP_ADMIN_EMAIL=%s", utils.Config.Auth.Email.Smtp.AdminEmail), + fmt.Sprintf("GOTRUE_SMTP_SENDER_NAME=%s", utils.Config.Auth.Email.Smtp.SenderName), + ) + } else if utils.Config.Inbucket.Enabled { + env = append(env, + "GOTRUE_SMTP_HOST="+utils.InbucketId, + "GOTRUE_SMTP_PORT=2500", + "GOTRUE_SMTP_ADMIN_EMAIL=admin@email.com", + ) + } + if utils.Config.Auth.Sessions.Timebox > 0 { env = append(env, fmt.Sprintf("GOTRUE_SESSIONS_TIMEBOX=%v", utils.Config.Auth.Sessions.Timebox)) } diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 1c7b7d1b9..fb44ef04e 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -2,6 +2,7 @@ package config import ( "maps" + "strconv" "strings" "time" @@ -73,7 +74,7 @@ type ( EnableConfirmations bool `toml:"enable_confirmations"` SecurePasswordChange bool `toml:"secure_password_change"` Template map[string]emailTemplate `toml:"template"` - Smtp smtp `toml:"smtp"` + Smtp *smtp `toml:"smtp"` MaxFrequency time.Duration `toml:"max_frequency"` OtpLength uint `toml:"otp_length"` OtpExpiry uint `toml:"otp_expiry"` @@ -194,7 +195,7 @@ func (a *auth) ToUpdateAuthConfigBody() v1API.UpdateAuthConfigBody { a.Hook.toAuthConfigBody(&body) a.MFA.toAuthConfigBody(&body) a.Sessions.toAuthConfigBody(&body) - // TODO: email + a.Email.toAuthConfigBody(&body) a.Sms.toAuthConfigBody(&body) a.External.toAuthConfigBody(&body) return body @@ -213,6 +214,7 @@ func (a *auth) fromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) auth result.Hook.fromAuthConfig(remoteConfig) result.MFA.fromAuthConfig(remoteConfig) result.Sessions.fromAuthConfig(remoteConfig) + result.Email.fromAuthConfig(remoteConfig) result.Sms.fromAuthConfig(remoteConfig) result.External = maps.Clone(result.External) result.External.fromAuthConfig(remoteConfig) @@ -309,6 +311,53 @@ func (s *sessions) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { s.InactivityTimeout = time.Duration(cast.Val(remoteConfig.SessionsInactivityTimeout, 0)) * time.Second } +func (e email) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { + body.ExternalEmailEnabled = &e.EnableSignup + body.MailerSecureEmailChangeEnabled = &e.DoubleConfirmChanges + body.MailerAutoconfirm = cast.Ptr(!e.EnableConfirmations) + body.MailerOtpLength = cast.UintToIntPtr(&e.OtpLength) + body.MailerOtpExp = cast.UintToIntPtr(&e.OtpExpiry) + body.SecurityUpdatePasswordRequireReauthentication = &e.SecurePasswordChange + body.SmtpMaxFrequency = cast.Ptr(int(e.MaxFrequency.Seconds())) + if e.Smtp != nil { + body.SmtpHost = &e.Smtp.Host + body.SmtpPort = cast.Ptr(strconv.Itoa(int(e.Smtp.Port))) + body.SmtpUser = &e.Smtp.User + body.SmtpPass = &e.Smtp.Pass + body.SmtpAdminEmail = &e.Smtp.AdminEmail + body.SmtpSenderName = &e.Smtp.SenderName + } else { + // Setting a single empty string disables SMTP + body.SmtpHost = cast.Ptr("") + } +} + +func (e *email) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { + e.EnableSignup = cast.Val(remoteConfig.ExternalEmailEnabled, false) + e.DoubleConfirmChanges = cast.Val(remoteConfig.MailerSecureEmailChangeEnabled, false) + e.EnableConfirmations = !cast.Val(remoteConfig.MailerAutoconfirm, false) + e.OtpLength = cast.IntToUint(cast.Val(remoteConfig.MailerOtpLength, 0)) + e.OtpExpiry = cast.IntToUint(remoteConfig.MailerOtpExp) + e.SecurePasswordChange = cast.Val(remoteConfig.SecurityUpdatePasswordRequireReauthentication, false) + e.MaxFrequency = time.Duration(cast.Val(remoteConfig.SmtpMaxFrequency, 0)) * time.Second + // Api resets all values when SMTP is disabled + if remoteConfig.SmtpHost != nil { + e.Smtp = &smtp{ + Host: *remoteConfig.SmtpHost, + User: cast.Val(remoteConfig.SmtpUser, ""), + Pass: hashPrefix + cast.Val(remoteConfig.SmtpPass, ""), + AdminEmail: cast.Val(remoteConfig.SmtpAdminEmail, ""), + SenderName: cast.Val(remoteConfig.SmtpSenderName, ""), + } + portStr := cast.Val(remoteConfig.SmtpPort, "") + if port, err := strconv.ParseUint(portStr, 10, 16); err == nil { + e.Smtp.Port = uint16(port) + } + } else { + e.Smtp = nil + } +} + func (s sms) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { body.ExternalPhoneEnabled = &s.EnableSignup body.SmsMaxFrequency = cast.Ptr(int(s.MaxFrequency.Seconds())) @@ -667,8 +716,10 @@ func (a *auth) hashSecrets(key string) auth { return hashPrefix + sha256Hmac(key, v) } result := *a - if len(result.Email.Smtp.Pass) > 0 { - result.Email.Smtp.Pass = hash(result.Email.Smtp.Pass) + if result.Email.Smtp != nil && len(result.Email.Smtp.Pass) > 0 { + copy := *result.Email.Smtp + copy.Pass = hash(result.Email.Smtp.Pass) + result.Email.Smtp = © } // Only hash secrets for locally enabled providers because other envs won't be loaded switch { diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index df63f898f..7f5c4d20f 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -9,15 +9,25 @@ import ( "github.com/supabase/cli/pkg/cast" ) +func newWithDefaults() auth { + return auth{ + EnableSignup: true, + Email: email{ + EnableConfirmations: true, + }, + } +} + func TestHookDiff(t *testing.T) { t.Run("local and remote enabled", func(t *testing.T) { - c := auth{EnableSignup: true, Hook: hook{ + c := newWithDefaults() + c.Hook = hook{ CustomAccessToken: hookConfig{Enabled: true}, SendSMS: hookConfig{Enabled: true}, SendEmail: hookConfig{Enabled: true}, MFAVerificationAttempt: hookConfig{Enabled: true}, PasswordVerificationAttempt: hookConfig{Enabled: true}, - }} + } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ HookCustomAccessTokenEnabled: cast.Ptr(true), @@ -42,10 +52,11 @@ func TestHookDiff(t *testing.T) { }) t.Run("local enabled and disabled", func(t *testing.T) { - c := auth{EnableSignup: true, Hook: hook{ + c := newWithDefaults() + c.Hook = hook{ CustomAccessToken: hookConfig{Enabled: true}, MFAVerificationAttempt: hookConfig{Enabled: false}, - }} + } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ HookCustomAccessTokenEnabled: cast.Ptr(false), @@ -72,7 +83,7 @@ func TestHookDiff(t *testing.T) { }) t.Run("local and remote disabled", func(t *testing.T) { - c := auth{EnableSignup: true} + c := newWithDefaults() // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ HookCustomAccessTokenEnabled: cast.Ptr(false), @@ -89,7 +100,8 @@ func TestHookDiff(t *testing.T) { func TestMfaDiff(t *testing.T) { t.Run("local and remote enabled", func(t *testing.T) { - c := auth{EnableSignup: true, MFA: mfa{ + c := newWithDefaults() + c.MFA = mfa{ TOTP: factorTypeConfiguration{ EnrollEnabled: true, VerifyEnabled: true, @@ -108,7 +120,7 @@ func TestMfaDiff(t *testing.T) { VerifyEnabled: true, }, MaxEnrolledFactors: 10, - }} + } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ MfaMaxEnrolledFactors: cast.Ptr(10), @@ -128,7 +140,8 @@ func TestMfaDiff(t *testing.T) { }) t.Run("local enabled and disabled", func(t *testing.T) { - c := auth{EnableSignup: true, MFA: mfa{ + c := newWithDefaults() + c.MFA = mfa{ TOTP: factorTypeConfiguration{ EnrollEnabled: false, VerifyEnabled: false, @@ -139,7 +152,7 @@ func TestMfaDiff(t *testing.T) { VerifyEnabled: true, }, }, - }} + } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ MfaMaxEnrolledFactors: cast.Ptr(10), @@ -178,14 +191,15 @@ func TestMfaDiff(t *testing.T) { }) t.Run("local and remote disabled", func(t *testing.T) { - c := auth{EnableSignup: true, MFA: mfa{ + c := newWithDefaults() + c.MFA = mfa{ MaxEnrolledFactors: 10, Phone: phoneFactorTypeConfiguration{ OtpLength: 6, Template: "Your code is {{ .Code }}", MaxFrequency: 5 * time.Second, }, - }} + } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ MfaMaxEnrolledFactors: cast.Ptr(10), @@ -205,9 +219,203 @@ func TestMfaDiff(t *testing.T) { }) } +func TestEmailDiff(t *testing.T) { + t.Run("local enabled remote enabled", func(t *testing.T) { + c := newWithDefaults() + c.Email = email{ + EnableSignup: true, + DoubleConfirmChanges: true, + EnableConfirmations: true, + SecurePasswordChange: true, + Template: map[string]emailTemplate{ + "invite": {}, + "confirmation": {}, + "recovery": {}, + "magic_link": {}, + "email_change": {}, + }, + Smtp: &smtp{ + Host: "smtp.sendgrid.net", + Port: 587, + User: "apikey", + Pass: "test-key", + AdminEmail: "admin@email.com", + SenderName: "Admin", + }, + MaxFrequency: time.Second, + OtpLength: 6, + OtpExpiry: 3600, + } + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + ExternalEmailEnabled: cast.Ptr(true), + MailerSecureEmailChangeEnabled: cast.Ptr(true), + MailerAutoconfirm: cast.Ptr(false), + MailerOtpLength: cast.Ptr(6), + MailerOtpExp: 3600, + SecurityUpdatePasswordRequireReauthentication: cast.Ptr(true), + SmtpHost: cast.Ptr("smtp.sendgrid.net"), + SmtpPort: cast.Ptr("587"), + SmtpUser: cast.Ptr("apikey"), + SmtpPass: cast.Ptr("ed64b7695a606bc6ab4fcb41fe815b5ddf1063ccbc87afe1fa89756635db520e"), + SmtpAdminEmail: cast.Ptr("admin@email.com"), + SmtpSenderName: cast.Ptr("Admin"), + SmtpMaxFrequency: cast.Ptr(1), + }) + // Check error + assert.NoError(t, err) + assert.Empty(t, string(diff)) + }) + + t.Run("local enabled remote disabled", func(t *testing.T) { + c := newWithDefaults() + c.Email = email{ + EnableSignup: true, + DoubleConfirmChanges: true, + EnableConfirmations: true, + SecurePasswordChange: true, + Template: map[string]emailTemplate{ + "invite": {}, + "confirmation": {}, + "recovery": {}, + "magic_link": {}, + "email_change": {}, + }, + Smtp: &smtp{ + Host: "smtp.sendgrid.net", + Port: 587, + User: "apikey", + Pass: "test-key", + AdminEmail: "admin@email.com", + SenderName: "Admin", + }, + MaxFrequency: time.Second, + OtpLength: 8, + OtpExpiry: 86400, + } + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + ExternalEmailEnabled: cast.Ptr(false), + MailerSecureEmailChangeEnabled: cast.Ptr(false), + MailerAutoconfirm: cast.Ptr(true), + MailerOtpLength: cast.Ptr(6), + MailerOtpExp: 3600, + SecurityUpdatePasswordRequireReauthentication: cast.Ptr(false), + SmtpMaxFrequency: cast.Ptr(60), + }) + // Check error + assert.NoError(t, err) + assert.Contains(t, string(diff), ` [email]`) + assert.Contains(t, string(diff), `-enable_signup = false`) + assert.Contains(t, string(diff), `-double_confirm_changes = false`) + assert.Contains(t, string(diff), `-enable_confirmations = false`) + assert.Contains(t, string(diff), `-secure_password_change = false`) + assert.Contains(t, string(diff), `-max_frequency = "1m0s"`) + assert.Contains(t, string(diff), `-otp_length = 6`) + assert.Contains(t, string(diff), `-otp_expiry = 3600`) + assert.Contains(t, string(diff), `+enable_signup = true`) + assert.Contains(t, string(diff), `+double_confirm_changes = true`) + assert.Contains(t, string(diff), `+enable_confirmations = true`) + assert.Contains(t, string(diff), `+secure_password_change = true`) + assert.Contains(t, string(diff), `+max_frequency = "1s"`) + assert.Contains(t, string(diff), `+otp_length = 8`) + assert.Contains(t, string(diff), `+otp_expiry = 86400`) + }) + + t.Run("local disabled remote enabled", func(t *testing.T) { + c := newWithDefaults() + c.Email = email{ + EnableConfirmations: false, + Template: map[string]emailTemplate{ + "invite": {}, + "confirmation": {}, + "recovery": {}, + "magic_link": {}, + "email_change": {}, + }, + MaxFrequency: time.Minute, + OtpLength: 8, + OtpExpiry: 86400, + } + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + ExternalEmailEnabled: cast.Ptr(true), + MailerSecureEmailChangeEnabled: cast.Ptr(true), + MailerAutoconfirm: cast.Ptr(false), + MailerOtpLength: cast.Ptr(6), + MailerOtpExp: 3600, + SecurityUpdatePasswordRequireReauthentication: cast.Ptr(true), + SmtpHost: cast.Ptr("smtp.sendgrid.net"), + SmtpPort: cast.Ptr("587"), + SmtpUser: cast.Ptr("apikey"), + SmtpPass: cast.Ptr("ed64b7695a606bc6ab4fcb41fe815b5ddf1063ccbc87afe1fa89756635db520e"), + SmtpAdminEmail: cast.Ptr("admin@email.com"), + SmtpSenderName: cast.Ptr("Admin"), + SmtpMaxFrequency: cast.Ptr(1), + }) + // Check error + assert.NoError(t, err) + + assert.Contains(t, string(diff), ` [email]`) + assert.Contains(t, string(diff), `-enable_signup = true`) + assert.Contains(t, string(diff), `-double_confirm_changes = true`) + assert.Contains(t, string(diff), `-enable_confirmations = true`) + assert.Contains(t, string(diff), `-secure_password_change = true`) + assert.Contains(t, string(diff), `-max_frequency = "1s"`) + assert.Contains(t, string(diff), `-otp_length = 6`) + assert.Contains(t, string(diff), `-otp_expiry = 3600`) + assert.Contains(t, string(diff), `+enable_signup = false`) + assert.Contains(t, string(diff), `+double_confirm_changes = false`) + assert.Contains(t, string(diff), `+enable_confirmations = false`) + assert.Contains(t, string(diff), `+secure_password_change = false`) + assert.Contains(t, string(diff), `+max_frequency = "1m0s"`) + assert.Contains(t, string(diff), `+otp_length = 8`) + assert.Contains(t, string(diff), `+otp_expiry = 86400`) + + assert.Contains(t, string(diff), `-[email.smtp]`) + assert.Contains(t, string(diff), `-host = "smtp.sendgrid.net"`) + assert.Contains(t, string(diff), `-port = 587`) + assert.Contains(t, string(diff), `-user = "apikey"`) + assert.Contains(t, string(diff), `-pass = "hash:ed64b7695a606bc6ab4fcb41fe815b5ddf1063ccbc87afe1fa89756635db520e"`) + assert.Contains(t, string(diff), `-admin_email = "admin@email.com"`) + assert.Contains(t, string(diff), `-sender_name = "Admin"`) + }) + + t.Run("local disabled remote disabled", func(t *testing.T) { + c := newWithDefaults() + c.Email = email{ + EnableConfirmations: false, + Template: map[string]emailTemplate{ + "invite": {}, + "confirmation": {}, + "recovery": {}, + "magic_link": {}, + "email_change": {}, + }, + MaxFrequency: time.Minute, + OtpLength: 6, + OtpExpiry: 3600, + } + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + ExternalEmailEnabled: cast.Ptr(false), + MailerSecureEmailChangeEnabled: cast.Ptr(false), + MailerAutoconfirm: cast.Ptr(true), + MailerOtpLength: cast.Ptr(6), + MailerOtpExp: 3600, + SecurityUpdatePasswordRequireReauthentication: cast.Ptr(false), + SmtpMaxFrequency: cast.Ptr(60), + }) + // Check error + assert.NoError(t, err) + assert.Empty(t, string(diff)) + }) +} + func TestSmsDiff(t *testing.T) { t.Run("local enabled remote enabled", func(t *testing.T) { - c := auth{EnableSignup: true, Sms: sms{ + c := newWithDefaults() + c.Sms = sms{ EnableSignup: true, EnableConfirmations: true, Template: "Your code is {{ .Code }}", @@ -219,7 +427,7 @@ func TestSmsDiff(t *testing.T) { MessageServiceSid: "test-service", AuthToken: "test-token", }, - }} + } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(true), @@ -253,7 +461,7 @@ func TestSmsDiff(t *testing.T) { }) t.Run("local disabled remote enabled", func(t *testing.T) { - c := auth{EnableSignup: true} + c := newWithDefaults() // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(true), @@ -292,7 +500,8 @@ func TestSmsDiff(t *testing.T) { }) t.Run("local enabled remote disabled", func(t *testing.T) { - c := auth{EnableSignup: true, Sms: sms{ + c := newWithDefaults() + c.Sms = sms{ EnableSignup: true, EnableConfirmations: true, Template: "Your code is {{ .Code }}", @@ -303,7 +512,7 @@ func TestSmsDiff(t *testing.T) { Originator: "test-originator", AccessKey: "test-access-key", }, - }} + } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(false), @@ -347,13 +556,14 @@ func TestSmsDiff(t *testing.T) { }) t.Run("local disabled remote disabled", func(t *testing.T) { - c := auth{EnableSignup: true, Sms: sms{ + c := newWithDefaults() + c.Sms = sms{ EnableSignup: false, EnableConfirmations: true, Template: "Your code is {{ .Code }}", TestOTP: map[string]string{"123": "456"}, MaxFrequency: time.Minute, - }} + } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(false), @@ -376,9 +586,10 @@ func TestSmsDiff(t *testing.T) { t.Run("enable sign up without provider", func(t *testing.T) { // This is not a valid config because platform requires a SMS provider. // For consistency, we handle this in config.Load and emit a warning. - c := auth{EnableSignup: true, Sms: sms{ + c := newWithDefaults() + c.Sms = sms{ EnableSignup: true, - }} + } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(false), @@ -392,11 +603,12 @@ func TestSmsDiff(t *testing.T) { }) t.Run("enable provider without sign up", func(t *testing.T) { - c := auth{EnableSignup: true, Sms: sms{ + c := newWithDefaults() + c.Sms = sms{ Messagebird: messagebirdConfig{ Enabled: true, }, - }} + } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(false), @@ -411,7 +623,8 @@ func TestSmsDiff(t *testing.T) { func TestExternalDiff(t *testing.T) { t.Run("local and remote enabled", func(t *testing.T) { - c := auth{EnableSignup: true, External: map[string]provider{ + c := newWithDefaults() + c.External = map[string]provider{ "apple": {Enabled: true}, "azure": {Enabled: true}, "bitbucket": {Enabled: true}, @@ -431,7 +644,7 @@ func TestExternalDiff(t *testing.T) { "twitter": {Enabled: true}, "workos": {Enabled: true}, "zoom": {Enabled: true}, - }} + } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ ExternalAppleAdditionalClientIds: cast.Ptr(""), @@ -509,7 +722,8 @@ func TestExternalDiff(t *testing.T) { }) t.Run("local enabled and disabled", func(t *testing.T) { - c := auth{EnableSignup: true, External: map[string]provider{ + c := newWithDefaults() + c.External = map[string]provider{ "apple": { Enabled: true, ClientId: "test-client-1,test-client-2", @@ -533,7 +747,7 @@ func TestExternalDiff(t *testing.T) { "twitter": {}, "workos": {}, "zoom": {}, - }} + } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ ExternalAppleAdditionalClientIds: cast.Ptr("test-client-2"), @@ -560,7 +774,8 @@ func TestExternalDiff(t *testing.T) { }) t.Run("local and remote disabled", func(t *testing.T) { - c := auth{EnableSignup: true, External: map[string]provider{ + c := newWithDefaults() + c.External = map[string]provider{ "apple": {}, "azure": {}, "bitbucket": {}, @@ -580,7 +795,7 @@ func TestExternalDiff(t *testing.T) { "twitter": {}, "workos": {}, "zoom": {}, - }} + } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ ExternalAppleEnabled: cast.Ptr(false), diff --git a/pkg/config/config.go b/pkg/config/config.go index 2ae693b05..271d07b49 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -219,8 +219,16 @@ func (c *baseConfig) Clone() baseConfig { copy.Storage.Buckets = maps.Clone(c.Storage.Buckets) copy.Functions = maps.Clone(c.Functions) copy.Auth.External = maps.Clone(c.Auth.External) + if c.Auth.Email.Smtp != nil { + mailer := *c.Auth.Email.Smtp + copy.Auth.Email.Smtp = &mailer + } copy.Auth.Email.Template = maps.Clone(c.Auth.Email.Template) copy.Auth.Sms.TestOTP = maps.Clone(c.Auth.Sms.TestOTP) + if c.Experimental.Webhooks != nil { + webhooks := *c.Experimental.Webhooks + copy.Experimental.Webhooks = &webhooks + } return copy } @@ -284,11 +292,6 @@ func NewConfig(editors ...ConfigEditor) config { "magic_link": {}, "email_change": {}, }, - Smtp: smtp{ - Host: "inbucket", - Port: 2500, - AdminEmail: "admin@email.com", - }, }, External: map[string]provider{ "apple": {}, @@ -655,23 +658,15 @@ func (c *baseConfig) Validate(fsys fs.FS) error { return errors.Errorf("Invalid config for auth.additional_redirect_urls[%d]: %v", i, err) } } - // Validate email config - for name, tmpl := range c.Auth.Email.Template { - if len(tmpl.ContentPath) > 0 { - if _, err = fs.Stat(fsys, filepath.Clean(tmpl.ContentPath)); err != nil { - return errors.Errorf("Invalid config for auth.email.%s.content_path: %s", name, tmpl.ContentPath) - } - } - } - if c.Auth.Email.Smtp.Pass, err = maybeLoadEnv(c.Auth.Email.Smtp.Pass); err != nil { - return err - } if err := c.Auth.Hook.validate(); err != nil { return err } if err := c.Auth.MFA.validate(); err != nil { return err } + if err := c.Auth.Email.validate(fsys); err != nil { + return err + } if err := c.Auth.Sms.validate(); err != nil { return err } @@ -814,6 +809,37 @@ func (c *seed) loadSeedPaths(basePath string, fsys fs.FS) error { return nil } +func (e *email) validate(fsys fs.FS) (err error) { + for name, tmpl := range e.Template { + if len(tmpl.ContentPath) > 0 { + if _, err = fs.Stat(fsys, filepath.Clean(tmpl.ContentPath)); err != nil { + return errors.Errorf("Invalid config for auth.email.%s.content_path: %s", name, tmpl.ContentPath) + } + } + } + if e.Smtp != nil { + if len(e.Smtp.Host) == 0 { + return errors.New("Missing required field in config: auth.email.smtp.host") + } + if e.Smtp.Port == 0 { + return errors.New("Missing required field in config: auth.email.smtp.port") + } + if len(e.Smtp.User) == 0 { + return errors.New("Missing required field in config: auth.email.smtp.user") + } + if len(e.Smtp.Pass) == 0 { + return errors.New("Missing required field in config: auth.email.smtp.pass") + } + if len(e.Smtp.AdminEmail) == 0 { + return errors.New("Missing required field in config: auth.email.smtp.admin_email") + } + if e.Smtp.Pass, err = maybeLoadEnv(e.Smtp.Pass); err != nil { + return err + } + } + return nil +} + func (s *sms) validate() (err error) { switch { case s.Twilio.Enabled: diff --git a/pkg/config/updater_test.go b/pkg/config/updater_test.go index 1f2249d8c..3e549e055 100644 --- a/pkg/config/updater_test.go +++ b/pkg/config/updater_test.go @@ -192,6 +192,7 @@ func TestUpdateAuthConfig(t *testing.T) { err := updater.UpdateAuthConfig(context.Background(), "test-project", auth{ Enabled: true, EnableSignup: true, + Email: email{EnableConfirmations: true}, }) // Check result assert.NoError(t, err) From 8e30fd7049004d9c376720ec48550147f60d0e09 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Tue, 12 Nov 2024 16:26:29 +0800 Subject: [PATCH 156/305] chore: reformat local auth env vars --- internal/start/start.go | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/internal/start/start.go b/internal/start/start.go index ba098b734..b19a54168 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -539,7 +539,6 @@ EOF if utils.Config.Auth.Sessions.Timebox > 0 { env = append(env, fmt.Sprintf("GOTRUE_SESSIONS_TIMEBOX=%v", utils.Config.Auth.Sessions.Timebox)) } - if utils.Config.Auth.Sessions.InactivityTimeout > 0 { env = append(env, fmt.Sprintf("GOTRUE_SESSIONS_INACTIVITY_TIMEOUT=%v", utils.Config.Auth.Sessions.InactivityTimeout)) } @@ -561,7 +560,8 @@ EOF } } - if utils.Config.Auth.Sms.Twilio.Enabled { + switch { + case utils.Config.Auth.Sms.Twilio.Enabled: env = append( env, "GOTRUE_SMS_PROVIDER=twilio", @@ -569,8 +569,7 @@ EOF "GOTRUE_SMS_TWILIO_AUTH_TOKEN="+utils.Config.Auth.Sms.Twilio.AuthToken, "GOTRUE_SMS_TWILIO_MESSAGE_SERVICE_SID="+utils.Config.Auth.Sms.Twilio.MessageServiceSid, ) - } - if utils.Config.Auth.Sms.TwilioVerify.Enabled { + case utils.Config.Auth.Sms.TwilioVerify.Enabled: env = append( env, "GOTRUE_SMS_PROVIDER=twilio_verify", @@ -578,24 +577,21 @@ EOF "GOTRUE_SMS_TWILIO_VERIFY_AUTH_TOKEN="+utils.Config.Auth.Sms.TwilioVerify.AuthToken, "GOTRUE_SMS_TWILIO_VERIFY_MESSAGE_SERVICE_SID="+utils.Config.Auth.Sms.TwilioVerify.MessageServiceSid, ) - } - if utils.Config.Auth.Sms.Messagebird.Enabled { + case utils.Config.Auth.Sms.Messagebird.Enabled: env = append( env, "GOTRUE_SMS_PROVIDER=messagebird", "GOTRUE_SMS_MESSAGEBIRD_ACCESS_KEY="+utils.Config.Auth.Sms.Messagebird.AccessKey, "GOTRUE_SMS_MESSAGEBIRD_ORIGINATOR="+utils.Config.Auth.Sms.Messagebird.Originator, ) - } - if utils.Config.Auth.Sms.Textlocal.Enabled { + case utils.Config.Auth.Sms.Textlocal.Enabled: env = append( env, "GOTRUE_SMS_PROVIDER=textlocal", "GOTRUE_SMS_TEXTLOCAL_API_KEY="+utils.Config.Auth.Sms.Textlocal.ApiKey, "GOTRUE_SMS_TEXTLOCAL_SENDER="+utils.Config.Auth.Sms.Textlocal.Sender, ) - } - if utils.Config.Auth.Sms.Vonage.Enabled { + case utils.Config.Auth.Sms.Vonage.Enabled: env = append( env, "GOTRUE_SMS_PROVIDER=vonage", @@ -604,6 +600,7 @@ EOF "GOTRUE_SMS_VONAGE_FROM="+utils.Config.Auth.Sms.Vonage.From, ) } + if utils.Config.Auth.Hook.MFAVerificationAttempt.Enabled { env = append( env, @@ -612,7 +609,6 @@ EOF "GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_SECRETS="+utils.Config.Auth.Hook.MFAVerificationAttempt.Secrets, ) } - if utils.Config.Auth.Hook.PasswordVerificationAttempt.Enabled { env = append( env, @@ -621,7 +617,6 @@ EOF "GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_SECRETS="+utils.Config.Auth.Hook.PasswordVerificationAttempt.Secrets, ) } - if utils.Config.Auth.Hook.CustomAccessToken.Enabled { env = append( env, @@ -630,7 +625,6 @@ EOF "GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_SECRETS="+utils.Config.Auth.Hook.CustomAccessToken.Secrets, ) } - if utils.Config.Auth.Hook.SendSMS.Enabled { env = append( env, @@ -639,7 +633,6 @@ EOF "GOTRUE_HOOK_SEND_SMS_SECRETS="+utils.Config.Auth.Hook.SendSMS.Secrets, ) } - if utils.Config.Auth.Hook.SendEmail.Enabled { env = append( env, @@ -648,6 +641,7 @@ EOF "GOTRUE_HOOK_SEND_EMAIL_SECRETS="+utils.Config.Auth.Hook.SendEmail.Secrets, ) } + if utils.Config.Auth.MFA.Phone.EnrollEnabled || utils.Config.Auth.MFA.Phone.VerifyEnabled { env = append( env, @@ -666,20 +660,14 @@ EOF fmt.Sprintf("GOTRUE_EXTERNAL_%s_SKIP_NONCE_CHECK=%t", strings.ToUpper(name), config.SkipNonceCheck), ) - if config.RedirectUri != "" { - env = append(env, - fmt.Sprintf("GOTRUE_EXTERNAL_%s_REDIRECT_URI=%s", strings.ToUpper(name), config.RedirectUri), - ) - } else { - env = append(env, - fmt.Sprintf("GOTRUE_EXTERNAL_%s_REDIRECT_URI=%s", strings.ToUpper(name), utils.GetApiUrl("/auth/v1/callback")), - ) + redirectUri := config.RedirectUri + if redirectUri == "" { + redirectUri = utils.GetApiUrl("/auth/v1/callback") } + env = append(env, fmt.Sprintf("GOTRUE_EXTERNAL_%s_REDIRECT_URI=%s", strings.ToUpper(name), redirectUri)) if config.Url != "" { - env = append(env, - fmt.Sprintf("GOTRUE_EXTERNAL_%s_URL=%s", strings.ToUpper(name), config.Url), - ) + env = append(env, fmt.Sprintf("GOTRUE_EXTERNAL_%s_URL=%s", strings.ToUpper(name), config.Url)) } } From 1e5e47bafb1b77b2981e2f0d62ab9d098cc05247 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Tue, 12 Nov 2024 16:59:10 +0800 Subject: [PATCH 157/305] chore: move config copy to diff method --- pkg/config/api.go | 31 +++++++------- pkg/config/auth.go | 97 ++++++++++++++++++++----------------------- pkg/config/config.go | 20 +++++---- pkg/config/db.go | 55 ++++++++++++------------ pkg/config/storage.go | 14 +++---- 5 files changed, 105 insertions(+), 112 deletions(-) diff --git a/pkg/config/api.go b/pkg/config/api.go index 2bed7bc09..405bcb7bd 100644 --- a/pkg/config/api.go +++ b/pkg/config/api.go @@ -55,40 +55,37 @@ func (a *api) ToUpdatePostgrestConfigBody() v1API.UpdatePostgrestConfigBody { return body } -func (a *api) fromRemoteApiConfig(remoteConfig v1API.PostgrestConfigWithJWTSecretResponse) api { - result := *a - if remoteConfig.DbSchema == "" { - result.Enabled = false - return result +func (a *api) fromRemoteApiConfig(remoteConfig v1API.PostgrestConfigWithJWTSecretResponse) { + if a.Enabled = len(remoteConfig.DbSchema) > 0; !a.Enabled { + return } - result.Enabled = true // Update Schemas if present in remoteConfig - result.Schemas = strToArr(remoteConfig.DbSchema) + a.Schemas = strToArr(remoteConfig.DbSchema) // TODO: use slices.Map when upgrade go version - for i, schema := range result.Schemas { - result.Schemas[i] = strings.TrimSpace(schema) + for i, schema := range a.Schemas { + a.Schemas[i] = strings.TrimSpace(schema) } // Update ExtraSearchPath if present in remoteConfig - result.ExtraSearchPath = strToArr(remoteConfig.DbExtraSearchPath) - for i, path := range result.ExtraSearchPath { - result.ExtraSearchPath[i] = strings.TrimSpace(path) + a.ExtraSearchPath = strToArr(remoteConfig.DbExtraSearchPath) + for i, path := range a.ExtraSearchPath { + a.ExtraSearchPath[i] = strings.TrimSpace(path) } // Update MaxRows if present in remoteConfig - result.MaxRows = cast.IntToUint(remoteConfig.MaxRows) - - return result + a.MaxRows = cast.IntToUint(remoteConfig.MaxRows) } func (a *api) DiffWithRemote(remoteConfig v1API.PostgrestConfigWithJWTSecretResponse) ([]byte, error) { + copy := *a // Convert the config values into easily comparable remoteConfig values - currentValue, err := ToTomlBytes(a) + currentValue, err := ToTomlBytes(copy) if err != nil { return nil, err } - remoteCompare, err := ToTomlBytes(a.fromRemoteApiConfig(remoteConfig)) + copy.fromRemoteApiConfig(remoteConfig) + remoteCompare, err := ToTomlBytes(copy) if err != nil { return nil, err } diff --git a/pkg/config/auth.go b/pkg/config/auth.go index fb44ef04e..4ac13d84b 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -1,7 +1,6 @@ package config import ( - "maps" "strconv" "strings" "time" @@ -201,24 +200,21 @@ func (a *auth) ToUpdateAuthConfigBody() v1API.UpdateAuthConfigBody { return body } -func (a *auth) fromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) auth { - result := *a - result.SiteUrl = cast.Val(remoteConfig.SiteUrl, "") - result.AdditionalRedirectUrls = strToArr(cast.Val(remoteConfig.UriAllowList, "")) - result.JwtExpiry = cast.IntToUint(cast.Val(remoteConfig.JwtExp, 0)) - result.EnableRefreshTokenRotation = cast.Val(remoteConfig.RefreshTokenRotationEnabled, false) - result.RefreshTokenReuseInterval = cast.IntToUint(cast.Val(remoteConfig.SecurityRefreshTokenReuseInterval, 0)) - result.EnableManualLinking = cast.Val(remoteConfig.SecurityManualLinkingEnabled, false) - result.EnableSignup = !cast.Val(remoteConfig.DisableSignup, false) - result.EnableAnonymousSignIns = cast.Val(remoteConfig.ExternalAnonymousUsersEnabled, false) - result.Hook.fromAuthConfig(remoteConfig) - result.MFA.fromAuthConfig(remoteConfig) - result.Sessions.fromAuthConfig(remoteConfig) - result.Email.fromAuthConfig(remoteConfig) - result.Sms.fromAuthConfig(remoteConfig) - result.External = maps.Clone(result.External) - result.External.fromAuthConfig(remoteConfig) - return result +func (a *auth) fromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) { + a.SiteUrl = cast.Val(remoteConfig.SiteUrl, "") + a.AdditionalRedirectUrls = strToArr(cast.Val(remoteConfig.UriAllowList, "")) + a.JwtExpiry = cast.IntToUint(cast.Val(remoteConfig.JwtExp, 0)) + a.EnableRefreshTokenRotation = cast.Val(remoteConfig.RefreshTokenRotationEnabled, false) + a.RefreshTokenReuseInterval = cast.IntToUint(cast.Val(remoteConfig.SecurityRefreshTokenReuseInterval, 0)) + a.EnableManualLinking = cast.Val(remoteConfig.SecurityManualLinkingEnabled, false) + a.EnableSignup = !cast.Val(remoteConfig.DisableSignup, false) + a.EnableAnonymousSignIns = cast.Val(remoteConfig.ExternalAnonymousUsersEnabled, false) + a.Hook.fromAuthConfig(remoteConfig) + a.MFA.fromAuthConfig(remoteConfig) + a.Sessions.fromAuthConfig(remoteConfig) + a.Email.fromAuthConfig(remoteConfig) + a.Sms.fromAuthConfig(remoteConfig) + a.External.fromAuthConfig(remoteConfig) } func (h hook) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { @@ -696,13 +692,15 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { } func (a *auth) DiffWithRemote(projectRef string, remoteConfig v1API.AuthConfigResponse) ([]byte, error) { - hashed := a.hashSecrets(projectRef) + copy := a.Clone() + copy.hashSecrets(projectRef) // Convert the config values into easily comparable remoteConfig values - currentValue, err := ToTomlBytes(hashed) + currentValue, err := ToTomlBytes(copy) if err != nil { return nil, err } - remoteCompare, err := ToTomlBytes(hashed.fromRemoteAuthConfig(remoteConfig)) + copy.fromRemoteAuthConfig(remoteConfig) + remoteCompare, err := ToTomlBytes(copy) if err != nil { return nil, err } @@ -711,53 +709,46 @@ func (a *auth) DiffWithRemote(projectRef string, remoteConfig v1API.AuthConfigRe const hashPrefix = "hash:" -func (a *auth) hashSecrets(key string) auth { +func (a *auth) hashSecrets(key string) { hash := func(v string) string { return hashPrefix + sha256Hmac(key, v) } - result := *a - if result.Email.Smtp != nil && len(result.Email.Smtp.Pass) > 0 { - copy := *result.Email.Smtp - copy.Pass = hash(result.Email.Smtp.Pass) - result.Email.Smtp = © + if a.Email.Smtp != nil && len(a.Email.Smtp.Pass) > 0 { + a.Email.Smtp.Pass = hash(a.Email.Smtp.Pass) } // Only hash secrets for locally enabled providers because other envs won't be loaded switch { - case result.Sms.Twilio.Enabled: - result.Sms.Twilio.AuthToken = hash(result.Sms.Twilio.AuthToken) - case result.Sms.TwilioVerify.Enabled: - result.Sms.TwilioVerify.AuthToken = hash(result.Sms.TwilioVerify.AuthToken) - case result.Sms.Messagebird.Enabled: - result.Sms.Messagebird.AccessKey = hash(result.Sms.Messagebird.AccessKey) - case result.Sms.Textlocal.Enabled: - result.Sms.Textlocal.ApiKey = hash(result.Sms.Textlocal.ApiKey) - case result.Sms.Vonage.Enabled: - result.Sms.Vonage.ApiSecret = hash(result.Sms.Vonage.ApiSecret) + case a.Sms.Twilio.Enabled: + a.Sms.Twilio.AuthToken = hash(a.Sms.Twilio.AuthToken) + case a.Sms.TwilioVerify.Enabled: + a.Sms.TwilioVerify.AuthToken = hash(a.Sms.TwilioVerify.AuthToken) + case a.Sms.Messagebird.Enabled: + a.Sms.Messagebird.AccessKey = hash(a.Sms.Messagebird.AccessKey) + case a.Sms.Textlocal.Enabled: + a.Sms.Textlocal.ApiKey = hash(a.Sms.Textlocal.ApiKey) + case a.Sms.Vonage.Enabled: + a.Sms.Vonage.ApiSecret = hash(a.Sms.Vonage.ApiSecret) } - if result.Hook.MFAVerificationAttempt.Enabled { - result.Hook.MFAVerificationAttempt.Secrets = hash(result.Hook.MFAVerificationAttempt.Secrets) + if a.Hook.MFAVerificationAttempt.Enabled { + a.Hook.MFAVerificationAttempt.Secrets = hash(a.Hook.MFAVerificationAttempt.Secrets) } - if result.Hook.PasswordVerificationAttempt.Enabled { - result.Hook.PasswordVerificationAttempt.Secrets = hash(result.Hook.PasswordVerificationAttempt.Secrets) + if a.Hook.PasswordVerificationAttempt.Enabled { + a.Hook.PasswordVerificationAttempt.Secrets = hash(a.Hook.PasswordVerificationAttempt.Secrets) } - if result.Hook.CustomAccessToken.Enabled { - result.Hook.CustomAccessToken.Secrets = hash(result.Hook.CustomAccessToken.Secrets) + if a.Hook.CustomAccessToken.Enabled { + a.Hook.CustomAccessToken.Secrets = hash(a.Hook.CustomAccessToken.Secrets) } - if result.Hook.SendSMS.Enabled { - result.Hook.SendSMS.Secrets = hash(result.Hook.SendSMS.Secrets) + if a.Hook.SendSMS.Enabled { + a.Hook.SendSMS.Secrets = hash(a.Hook.SendSMS.Secrets) } - if result.Hook.SendEmail.Enabled { - result.Hook.SendEmail.Secrets = hash(result.Hook.SendEmail.Secrets) - } - if size := len(a.External); size > 0 { - result.External = make(map[string]provider, size) + if a.Hook.SendEmail.Enabled { + a.Hook.SendEmail.Secrets = hash(a.Hook.SendEmail.Secrets) } for name, provider := range a.External { if provider.Enabled { provider.Secret = hash(provider.Secret) } - result.External[name] = provider + a.External[name] = provider } // TODO: support SecurityCaptchaSecret in local config - return result } diff --git a/pkg/config/config.go b/pkg/config/config.go index 271d07b49..34e336475 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -214,17 +214,23 @@ func (f function) IsEnabled() bool { return f.Enabled == nil || *f.Enabled } +func (a *auth) Clone() auth { + copy := *a + copy.External = maps.Clone(a.External) + if a.Email.Smtp != nil { + mailer := *a.Email.Smtp + copy.Email.Smtp = &mailer + } + copy.Email.Template = maps.Clone(a.Email.Template) + copy.Sms.TestOTP = maps.Clone(a.Sms.TestOTP) + return copy +} + func (c *baseConfig) Clone() baseConfig { copy := *c copy.Storage.Buckets = maps.Clone(c.Storage.Buckets) copy.Functions = maps.Clone(c.Functions) - copy.Auth.External = maps.Clone(c.Auth.External) - if c.Auth.Email.Smtp != nil { - mailer := *c.Auth.Email.Smtp - copy.Auth.Email.Smtp = &mailer - } - copy.Auth.Email.Template = maps.Clone(c.Auth.Email.Template) - copy.Auth.Sms.TestOTP = maps.Clone(c.Auth.Sms.TestOTP) + copy.Auth = c.Auth.Clone() if c.Experimental.Webhooks != nil { webhooks := *c.Experimental.Webhooks copy.Experimental.Webhooks = &webhooks diff --git a/pkg/config/db.go b/pkg/config/db.go index 71ee29f7a..4e22dd53f 100644 --- a/pkg/config/db.go +++ b/pkg/config/db.go @@ -112,32 +112,29 @@ func (a *settings) ToUpdatePostgresConfigBody() v1API.UpdatePostgresConfigBody { return body } -func (a *settings) fromRemoteConfig(remoteConfig v1API.PostgresConfigResponse) settings { - result := *a - - result.EffectiveCacheSize = remoteConfig.EffectiveCacheSize - result.LogicalDecodingWorkMem = remoteConfig.LogicalDecodingWorkMem - result.MaintenanceWorkMem = remoteConfig.MaintenanceWorkMem - result.MaxConnections = cast.IntToUintPtr(remoteConfig.MaxConnections) - result.MaxLocksPerTransaction = cast.IntToUintPtr(remoteConfig.MaxLocksPerTransaction) - result.MaxParallelMaintenanceWorkers = cast.IntToUintPtr(remoteConfig.MaxParallelMaintenanceWorkers) - result.MaxParallelWorkers = cast.IntToUintPtr(remoteConfig.MaxParallelWorkers) - result.MaxParallelWorkersPerGather = cast.IntToUintPtr(remoteConfig.MaxParallelWorkersPerGather) - result.MaxReplicationSlots = cast.IntToUintPtr(remoteConfig.MaxReplicationSlots) - result.MaxSlotWalKeepSize = remoteConfig.MaxSlotWalKeepSize - result.MaxStandbyArchiveDelay = remoteConfig.MaxStandbyArchiveDelay - result.MaxStandbyStreamingDelay = remoteConfig.MaxStandbyStreamingDelay - result.MaxWalSenders = cast.IntToUintPtr(remoteConfig.MaxWalSenders) - result.MaxWalSize = remoteConfig.MaxWalSize - result.MaxWorkerProcesses = cast.IntToUintPtr(remoteConfig.MaxWorkerProcesses) - result.SessionReplicationRole = (*SessionReplicationRole)(remoteConfig.SessionReplicationRole) - result.SharedBuffers = remoteConfig.SharedBuffers - result.StatementTimeout = remoteConfig.StatementTimeout - result.TrackCommitTimestamp = remoteConfig.TrackCommitTimestamp - result.WalKeepSize = remoteConfig.WalKeepSize - result.WalSenderTimeout = remoteConfig.WalSenderTimeout - result.WorkMem = remoteConfig.WorkMem - return result +func (a *settings) fromRemoteConfig(remoteConfig v1API.PostgresConfigResponse) { + a.EffectiveCacheSize = remoteConfig.EffectiveCacheSize + a.LogicalDecodingWorkMem = remoteConfig.LogicalDecodingWorkMem + a.MaintenanceWorkMem = remoteConfig.MaintenanceWorkMem + a.MaxConnections = cast.IntToUintPtr(remoteConfig.MaxConnections) + a.MaxLocksPerTransaction = cast.IntToUintPtr(remoteConfig.MaxLocksPerTransaction) + a.MaxParallelMaintenanceWorkers = cast.IntToUintPtr(remoteConfig.MaxParallelMaintenanceWorkers) + a.MaxParallelWorkers = cast.IntToUintPtr(remoteConfig.MaxParallelWorkers) + a.MaxParallelWorkersPerGather = cast.IntToUintPtr(remoteConfig.MaxParallelWorkersPerGather) + a.MaxReplicationSlots = cast.IntToUintPtr(remoteConfig.MaxReplicationSlots) + a.MaxSlotWalKeepSize = remoteConfig.MaxSlotWalKeepSize + a.MaxStandbyArchiveDelay = remoteConfig.MaxStandbyArchiveDelay + a.MaxStandbyStreamingDelay = remoteConfig.MaxStandbyStreamingDelay + a.MaxWalSenders = cast.IntToUintPtr(remoteConfig.MaxWalSenders) + a.MaxWalSize = remoteConfig.MaxWalSize + a.MaxWorkerProcesses = cast.IntToUintPtr(remoteConfig.MaxWorkerProcesses) + a.SessionReplicationRole = (*SessionReplicationRole)(remoteConfig.SessionReplicationRole) + a.SharedBuffers = remoteConfig.SharedBuffers + a.StatementTimeout = remoteConfig.StatementTimeout + a.TrackCommitTimestamp = remoteConfig.TrackCommitTimestamp + a.WalKeepSize = remoteConfig.WalKeepSize + a.WalSenderTimeout = remoteConfig.WalSenderTimeout + a.WorkMem = remoteConfig.WorkMem } const pgConfHeader = "\n# supabase [db.settings] configuration\n" @@ -152,12 +149,14 @@ func (a *settings) ToPostgresConfig() string { } func (a *settings) DiffWithRemote(remoteConfig v1API.PostgresConfigResponse) ([]byte, error) { + copy := *a // Convert the config values into easily comparable remoteConfig values - currentValue, err := ToTomlBytes(a) + currentValue, err := ToTomlBytes(copy) if err != nil { return nil, err } - remoteCompare, err := ToTomlBytes(a.fromRemoteConfig(remoteConfig)) + copy.fromRemoteConfig(remoteConfig) + remoteCompare, err := ToTomlBytes(copy) if err != nil { return nil, err } diff --git a/pkg/config/storage.go b/pkg/config/storage.go index d2799ce04..3398dee42 100644 --- a/pkg/config/storage.go +++ b/pkg/config/storage.go @@ -44,20 +44,20 @@ func (s *storage) ToUpdateStorageConfigBody() v1API.UpdateStorageConfigBody { return body } -func (s *storage) fromRemoteStorageConfig(remoteConfig v1API.StorageConfigResponse) storage { - result := *s - result.FileSizeLimit = sizeInBytes(remoteConfig.FileSizeLimit) - result.ImageTransformation.Enabled = remoteConfig.Features.ImageTransformation.Enabled - return result +func (s *storage) fromRemoteStorageConfig(remoteConfig v1API.StorageConfigResponse) { + s.FileSizeLimit = sizeInBytes(remoteConfig.FileSizeLimit) + s.ImageTransformation.Enabled = remoteConfig.Features.ImageTransformation.Enabled } func (s *storage) DiffWithRemote(remoteConfig v1API.StorageConfigResponse) ([]byte, error) { + copy := *s // Convert the config values into easily comparable remoteConfig values - currentValue, err := ToTomlBytes(s) + currentValue, err := ToTomlBytes(copy) if err != nil { return nil, err } - remoteCompare, err := ToTomlBytes(s.fromRemoteStorageConfig(remoteConfig)) + copy.fromRemoteStorageConfig(remoteConfig) + remoteCompare, err := ToTomlBytes(copy) if err != nil { return nil, err } From 4a573957f3a9462b1b4c29fec2e1052d24cb5a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Tue, 12 Nov 2024 18:11:35 +0900 Subject: [PATCH 158/305] fix: bump edge-runtime to 1.62.1 (#2872) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 49f691706..3369399d3 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241106-f29003e" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.61.2" + edgeRuntimeImage = "supabase/edge-runtime:v1.62.1" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.163.2" From 3257ea30554cc8e90b13c5ac0b92f21976f50692 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 13 Nov 2024 12:09:09 +0800 Subject: [PATCH 159/305] chore: replace case conversion with equal fold (#2870) --- cmd/bootstrap.go | 8 ++++---- internal/sso/internal/saml/files.go | 2 +- internal/storage/client/scheme.go | 2 +- internal/storage/cp/cp.go | 6 +++--- pkg/parser/state.go | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/bootstrap.go b/cmd/bootstrap.go index 1d8faa263..fd9f74912 100644 --- a/cmd/bootstrap.go +++ b/cmd/bootstrap.go @@ -43,15 +43,15 @@ var ( return err } if len(args) > 0 { - name := strings.ToLower(args[0]) + name := args[0] for _, t := range templates { - if t.Name == name { + if strings.EqualFold(t.Name, name) { starter = t break } } - if name != starter.Name { - return errors.New("Invalid template: " + args[0]) + if !strings.EqualFold(starter.Name, name) { + return errors.New("Invalid template: " + name) } } else { if err := promptStarterTemplate(ctx, templates); err != nil { diff --git a/internal/sso/internal/saml/files.go b/internal/sso/internal/saml/files.go index 3c327e6c0..62e0846e3 100644 --- a/internal/sso/internal/saml/files.go +++ b/internal/sso/internal/saml/files.go @@ -65,7 +65,7 @@ func ValidateMetadataURL(ctx context.Context, metadataURL string) error { return errors.Errorf("failed to parse metadata uri: %w", err) } - if strings.ToLower(parsed.Scheme) != "https" { + if !strings.EqualFold(parsed.Scheme, "https") { return errors.New("only HTTPS Metadata URLs are supported") } diff --git a/internal/storage/client/scheme.go b/internal/storage/client/scheme.go index 768c29036..bb3254f5b 100644 --- a/internal/storage/client/scheme.go +++ b/internal/storage/client/scheme.go @@ -16,7 +16,7 @@ func ParseStorageURL(objectURL string) (string, error) { if err != nil { return "", errors.Errorf("failed to parse storage url: %w", err) } - if strings.ToLower(parsed.Scheme) != STORAGE_SCHEME || len(parsed.Path) == 0 || len(parsed.Host) > 0 { + if !strings.EqualFold(parsed.Scheme, STORAGE_SCHEME) || len(parsed.Path) == 0 || len(parsed.Host) > 0 { return "", errors.New(ErrInvalidURL) } return parsed.Path, nil diff --git a/internal/storage/cp/cp.go b/internal/storage/cp/cp.go index 3676e0348..8aed7a6fa 100644 --- a/internal/storage/cp/cp.go +++ b/internal/storage/cp/cp.go @@ -35,7 +35,7 @@ func Run(ctx context.Context, src, dst string, recursive bool, maxJobs uint, fsy if err != nil { return err } - if strings.ToLower(srcParsed.Scheme) == client.STORAGE_SCHEME && dstParsed.Scheme == "" { + if strings.EqualFold(srcParsed.Scheme, client.STORAGE_SCHEME) && dstParsed.Scheme == "" { localPath := dst if !filepath.IsAbs(dst) { localPath = filepath.Join(utils.CurrentDirAbs, dst) @@ -44,7 +44,7 @@ func Run(ctx context.Context, src, dst string, recursive bool, maxJobs uint, fsy return DownloadStorageObjectAll(ctx, api, srcParsed.Path, localPath, maxJobs, fsys) } return api.DownloadObject(ctx, srcParsed.Path, localPath, fsys) - } else if srcParsed.Scheme == "" && strings.ToLower(dstParsed.Scheme) == client.STORAGE_SCHEME { + } else if srcParsed.Scheme == "" && strings.EqualFold(dstParsed.Scheme, client.STORAGE_SCHEME) { localPath := src if !filepath.IsAbs(localPath) { localPath = filepath.Join(utils.CurrentDirAbs, localPath) @@ -53,7 +53,7 @@ func Run(ctx context.Context, src, dst string, recursive bool, maxJobs uint, fsy return UploadStorageObjectAll(ctx, api, dstParsed.Path, localPath, maxJobs, fsys, opts...) } return api.UploadObject(ctx, dstParsed.Path, src, fsys, opts...) - } else if strings.ToLower(srcParsed.Scheme) == client.STORAGE_SCHEME && strings.ToLower(dstParsed.Scheme) == client.STORAGE_SCHEME { + } else if strings.EqualFold(srcParsed.Scheme, client.STORAGE_SCHEME) && strings.EqualFold(dstParsed.Scheme, client.STORAGE_SCHEME) { return errors.New("Copying between buckets is not supported") } utils.CmdSuggestion = fmt.Sprintf("Run %s to copy between local directories.", utils.Aqua("cp -r ")) diff --git a/pkg/parser/state.go b/pkg/parser/state.go index 38556f376..f32a67131 100644 --- a/pkg/parser/state.go +++ b/pkg/parser/state.go @@ -47,7 +47,7 @@ func (s *ReadyState) Next(r rune, data []byte) State { fallthrough case 'C': offset := len(data) - len(BEGIN_ATOMIC) - if offset >= 0 && strings.ToUpper(string(data[offset:])) == BEGIN_ATOMIC { + if offset >= 0 && strings.EqualFold(string(data[offset:]), BEGIN_ATOMIC) { return &AtomicState{prev: s, delimiter: []byte(END_ATOMIC)} } } @@ -176,7 +176,7 @@ func (s *AtomicState) Next(r rune, data []byte) State { if _, ok := s.prev.(*ReadyState); ok { window := data[len(data)-len(s.delimiter):] // Treat delimiter as case insensitive - if strings.ToUpper(string(window)) == string(s.delimiter) { + if strings.EqualFold(string(window), string(s.delimiter)) { return &ReadyState{} } } From 3550893b0a2caa93fbe2c12358814d0f3d9835ba Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 13 Nov 2024 12:10:31 +0800 Subject: [PATCH 160/305] feat: support config push command (#2875) --- cmd/config.go | 38 +++++++++++++++++++++++++ internal/config/push/push.go | 30 ++++++++++++++++++++ pkg/config/updater.go | 55 +++++++++++++++++++++++++----------- 3 files changed, 106 insertions(+), 17 deletions(-) create mode 100644 cmd/config.go create mode 100644 internal/config/push/push.go diff --git a/cmd/config.go b/cmd/config.go new file mode 100644 index 000000000..d73daa546 --- /dev/null +++ b/cmd/config.go @@ -0,0 +1,38 @@ +package cmd + +import ( + "os" + "os/signal" + + "github.com/spf13/afero" + "github.com/spf13/cobra" + "github.com/supabase/cli/internal/config/push" + "github.com/supabase/cli/internal/utils/flags" +) + +var ( + configCmd = &cobra.Command{ + GroupID: groupManagementAPI, + Use: "config", + Short: "Manage Supabase project configurations", + PersistentPreRunE: func(cmd *cobra.Command, args []string) error { + ctx, _ := signal.NotifyContext(cmd.Context(), os.Interrupt) + cmd.SetContext(ctx) + return cmd.Root().PersistentPreRunE(cmd, args) + }, + } + + configPushCmd = &cobra.Command{ + Use: "push", + Short: "Pushes local config.toml to the linked project", + RunE: func(cmd *cobra.Command, args []string) error { + return push.Run(cmd.Context(), flags.ProjectRef, afero.NewOsFs()) + }, + } +) + +func init() { + configCmd.PersistentFlags().StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.") + configCmd.AddCommand(configPushCmd) + rootCmd.AddCommand(configCmd) +} diff --git a/internal/config/push/push.go b/internal/config/push/push.go new file mode 100644 index 000000000..0a8c88c4e --- /dev/null +++ b/internal/config/push/push.go @@ -0,0 +1,30 @@ +package push + +import ( + "context" + "fmt" + "os" + + "github.com/spf13/afero" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/config" +) + +func Run(ctx context.Context, ref string, fsys afero.Fs) error { + if err := utils.LoadConfigFS(fsys); err != nil { + return err + } + client := config.NewConfigUpdater(*utils.GetSupabase()) + fmt.Fprintln(os.Stderr, "Pushing config to project:", ref) + remote, _ := utils.Config.GetRemoteByProjectRef(ref) + console := utils.NewConsole() + keep := func(name string) bool { + title := fmt.Sprintf("Do you want to push %s config to remote?", name) + shouldPush, err := console.PromptYesNo(ctx, title, true) + if err != nil { + fmt.Fprintln(os.Stderr, err) + } + return shouldPush + } + return client.UpdateRemoteConfig(ctx, remote, keep) +} diff --git a/pkg/config/updater.go b/pkg/config/updater.go index 832eb639b..445000d0b 100644 --- a/pkg/config/updater.go +++ b/pkg/config/updater.go @@ -17,26 +17,26 @@ func NewConfigUpdater(client v1API.ClientWithResponses) ConfigUpdater { return ConfigUpdater{client: client} } -func (u *ConfigUpdater) UpdateRemoteConfig(ctx context.Context, remote baseConfig) error { - if err := u.UpdateApiConfig(ctx, remote.ProjectId, remote.Api); err != nil { +func (u *ConfigUpdater) UpdateRemoteConfig(ctx context.Context, remote baseConfig, filter ...func(string) bool) error { + if err := u.UpdateApiConfig(ctx, remote.ProjectId, remote.Api, filter...); err != nil { return err } - if err := u.UpdateDbConfig(ctx, remote.ProjectId, remote.Db); err != nil { + if err := u.UpdateDbConfig(ctx, remote.ProjectId, remote.Db, filter...); err != nil { return err } - if err := u.UpdateAuthConfig(ctx, remote.ProjectId, remote.Auth); err != nil { + if err := u.UpdateAuthConfig(ctx, remote.ProjectId, remote.Auth, filter...); err != nil { return err } - if err := u.UpdateStorageConfig(ctx, remote.ProjectId, remote.Storage); err != nil { + if err := u.UpdateStorageConfig(ctx, remote.ProjectId, remote.Storage, filter...); err != nil { return err } - if err := u.UpdateExperimentalConfig(ctx, remote.ProjectId, remote.Experimental); err != nil { + if err := u.UpdateExperimentalConfig(ctx, remote.ProjectId, remote.Experimental, filter...); err != nil { return err } return nil } -func (u *ConfigUpdater) UpdateApiConfig(ctx context.Context, projectRef string, c api) error { +func (u *ConfigUpdater) UpdateApiConfig(ctx context.Context, projectRef string, c api, filter ...func(string) bool) error { apiConfig, err := u.client.V1GetPostgrestServiceConfigWithResponse(ctx, projectRef) if err != nil { return errors.Errorf("failed to read API config: %w", err) @@ -51,7 +51,11 @@ func (u *ConfigUpdater) UpdateApiConfig(ctx context.Context, projectRef string, return nil } fmt.Fprintln(os.Stderr, "Updating API service with config:", string(apiDiff)) - + for _, keep := range filter { + if !keep("api") { + return nil + } + } if resp, err := u.client.V1UpdatePostgrestServiceConfigWithResponse(ctx, projectRef, c.ToUpdatePostgrestConfigBody()); err != nil { return errors.Errorf("failed to update API config: %w", err) } else if resp.JSON200 == nil { @@ -60,7 +64,7 @@ func (u *ConfigUpdater) UpdateApiConfig(ctx context.Context, projectRef string, return nil } -func (u *ConfigUpdater) UpdateDbSettingsConfig(ctx context.Context, projectRef string, s settings) error { +func (u *ConfigUpdater) UpdateDbSettingsConfig(ctx context.Context, projectRef string, s settings, filter ...func(string) bool) error { dbConfig, err := u.client.V1GetPostgresConfigWithResponse(ctx, projectRef) if err != nil { return errors.Errorf("failed to read DB config: %w", err) @@ -75,6 +79,11 @@ func (u *ConfigUpdater) UpdateDbSettingsConfig(ctx context.Context, projectRef s return nil } fmt.Fprintln(os.Stderr, "Updating DB service with config:", string(dbDiff)) + for _, keep := range filter { + if !keep("db") { + return nil + } + } updateBody := s.ToUpdatePostgresConfigBody() if resp, err := u.client.V1UpdatePostgresConfigWithResponse(ctx, projectRef, updateBody); err != nil { return errors.Errorf("failed to update DB config: %w", err) @@ -84,14 +93,14 @@ func (u *ConfigUpdater) UpdateDbSettingsConfig(ctx context.Context, projectRef s return nil } -func (u *ConfigUpdater) UpdateDbConfig(ctx context.Context, projectRef string, c db) error { - if err := u.UpdateDbSettingsConfig(ctx, projectRef, c.Settings); err != nil { +func (u *ConfigUpdater) UpdateDbConfig(ctx context.Context, projectRef string, c db, filter ...func(string) bool) error { + if err := u.UpdateDbSettingsConfig(ctx, projectRef, c.Settings, filter...); err != nil { return err } return nil } -func (u *ConfigUpdater) UpdateAuthConfig(ctx context.Context, projectRef string, c auth) error { +func (u *ConfigUpdater) UpdateAuthConfig(ctx context.Context, projectRef string, c auth, filter ...func(string) bool) error { if !c.Enabled { return nil } @@ -109,7 +118,11 @@ func (u *ConfigUpdater) UpdateAuthConfig(ctx context.Context, projectRef string, return nil } fmt.Fprintln(os.Stderr, "Updating Auth service with config:", string(authDiff)) - + for _, keep := range filter { + if !keep("auth") { + return nil + } + } if resp, err := u.client.V1UpdateAuthServiceConfigWithResponse(ctx, projectRef, c.ToUpdateAuthConfigBody()); err != nil { return errors.Errorf("failed to update Auth config: %w", err) } else if status := resp.StatusCode(); status < 200 || status >= 300 { @@ -118,7 +131,7 @@ func (u *ConfigUpdater) UpdateAuthConfig(ctx context.Context, projectRef string, return nil } -func (u *ConfigUpdater) UpdateStorageConfig(ctx context.Context, projectRef string, c storage) error { +func (u *ConfigUpdater) UpdateStorageConfig(ctx context.Context, projectRef string, c storage, filter ...func(string) bool) error { if !c.Enabled { return nil } @@ -136,7 +149,11 @@ func (u *ConfigUpdater) UpdateStorageConfig(ctx context.Context, projectRef stri return nil } fmt.Fprintln(os.Stderr, "Updating Storage service with config:", string(storageDiff)) - + for _, keep := range filter { + if !keep("storage") { + return nil + } + } if resp, err := u.client.V1UpdateStorageConfigWithResponse(ctx, projectRef, c.ToUpdateStorageConfigBody()); err != nil { return errors.Errorf("failed to update Storage config: %w", err) } else if status := resp.StatusCode(); status < 200 || status >= 300 { @@ -145,10 +162,14 @@ func (u *ConfigUpdater) UpdateStorageConfig(ctx context.Context, projectRef stri return nil } -func (u *ConfigUpdater) UpdateExperimentalConfig(ctx context.Context, projectRef string, exp experimental) error { +func (u *ConfigUpdater) UpdateExperimentalConfig(ctx context.Context, projectRef string, exp experimental, filter ...func(string) bool) error { if exp.Webhooks != nil && exp.Webhooks.Enabled { fmt.Fprintln(os.Stderr, "Enabling webhooks for project:", projectRef) - + for _, keep := range filter { + if !keep("webhooks") { + return nil + } + } if resp, err := u.client.V1EnableDatabaseWebhookWithResponse(ctx, projectRef); err != nil { return errors.Errorf("failed to enable webhooks: %w", err) } else if status := resp.StatusCode(); status < 200 || status >= 300 { From 4cf6fd2ce97f9c48f363db84d9f131d12582cb9b Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 13 Nov 2024 12:30:17 +0800 Subject: [PATCH 161/305] fix: bump default postgres version to 15.6 (#2557) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 3369399d3..a66a4a90a 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -3,7 +3,7 @@ package config const ( pg13Image = "supabase/postgres:13.3.0" pg14Image = "supabase/postgres:14.1.0.89" - Pg15Image = "supabase/postgres:15.1.1.78" + Pg15Image = "supabase/postgres:15.6.1.139" // Append to ServiceImages when adding new dependencies below // TODO: try https://github.com/axllent/mailpit kongImage = "library/kong:2.8.1" From 859f9d1a27e3ca7de7e3edd4296ff1b344ed3ae4 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Tue, 12 Nov 2024 00:30:36 +0800 Subject: [PATCH 162/305] fix(config): support defining template content in toml --- pkg/config/auth.go | 106 +++++++++++++++++++++++++++++ pkg/config/auth_test.go | 147 ++++++++++++++++++++++++++++++++++------ pkg/config/config.go | 25 ++++--- 3 files changed, 250 insertions(+), 28 deletions(-) diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 4ac13d84b..2a71f2177 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -91,6 +91,8 @@ type ( emailTemplate struct { Subject string `toml:"subject"` ContentPath string `toml:"content_path"` + // Exposed for remote diff only, not valid in config.toml + Content string `toml:"content"` } sms struct { @@ -326,6 +328,53 @@ func (e email) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { // Setting a single empty string disables SMTP body.SmtpHost = cast.Ptr("") } + if len(e.Template) == 0 { + return + } + var tmpl *emailTemplate + // When local config is not set, we assume platform defaults should not change + tmpl = cast.Ptr(e.Template["invite"]) + if len(tmpl.Subject) > 0 { + body.MailerSubjectsInvite = &tmpl.Subject + } + if len(tmpl.Content) > 0 { + body.MailerTemplatesInviteContent = &tmpl.Content + } + tmpl = cast.Ptr(e.Template["confirmation"]) + if len(tmpl.Subject) > 0 { + body.MailerSubjectsConfirmation = &tmpl.Subject + } + if len(tmpl.Content) > 0 { + body.MailerTemplatesConfirmationContent = &tmpl.Content + } + tmpl = cast.Ptr(e.Template["recovery"]) + if len(tmpl.Subject) > 0 { + body.MailerSubjectsRecovery = &tmpl.Subject + } + if len(tmpl.Content) > 0 { + body.MailerTemplatesRecoveryContent = &tmpl.Content + } + tmpl = cast.Ptr(e.Template["magic_link"]) + if len(tmpl.Subject) > 0 { + body.MailerSubjectsMagicLink = &tmpl.Subject + } + if len(tmpl.Content) > 0 { + body.MailerTemplatesMagicLinkContent = &tmpl.Content + } + tmpl = cast.Ptr(e.Template["email_change"]) + if len(tmpl.Subject) > 0 { + body.MailerSubjectsEmailChange = &tmpl.Subject + } + if len(tmpl.Content) > 0 { + body.MailerTemplatesEmailChangeContent = &tmpl.Content + } + tmpl = cast.Ptr(e.Template["reauthentication"]) + if len(tmpl.Subject) > 0 { + body.MailerSubjectsReauthentication = &tmpl.Subject + } + if len(tmpl.Content) > 0 { + body.MailerTemplatesReauthenticationContent = &tmpl.Content + } } func (e *email) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { @@ -352,6 +401,63 @@ func (e *email) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { } else { e.Smtp = nil } + if len(e.Template) == 0 { + return + } + var tmpl emailTemplate + tmpl = e.Template["invite"] + if len(tmpl.Subject) > 0 { + tmpl.Subject = cast.Val(remoteConfig.MailerSubjectsInvite, "") + } + if len(tmpl.Content) > 0 { + tmpl.Content = cast.Val(remoteConfig.MailerTemplatesInviteContent, "") + } + e.Template["invite"] = tmpl + + tmpl = e.Template["confirmation"] + if len(tmpl.Subject) > 0 { + tmpl.Subject = cast.Val(remoteConfig.MailerSubjectsConfirmation, "") + } + if len(tmpl.Content) > 0 { + tmpl.Content = cast.Val(remoteConfig.MailerTemplatesConfirmationContent, "") + } + e.Template["confirmation"] = tmpl + + tmpl = e.Template["recovery"] + if len(tmpl.Subject) > 0 { + tmpl.Subject = cast.Val(remoteConfig.MailerSubjectsRecovery, "") + } + if len(tmpl.Content) > 0 { + tmpl.Content = cast.Val(remoteConfig.MailerTemplatesRecoveryContent, "") + } + e.Template["recovery"] = tmpl + + tmpl = e.Template["magic_link"] + if len(tmpl.Subject) > 0 { + tmpl.Subject = cast.Val(remoteConfig.MailerSubjectsMagicLink, "") + } + if len(tmpl.Content) > 0 { + tmpl.Content = cast.Val(remoteConfig.MailerTemplatesMagicLinkContent, "") + } + e.Template["magic_link"] = tmpl + + tmpl = e.Template["email_change"] + if len(tmpl.Subject) > 0 { + tmpl.Subject = cast.Val(remoteConfig.MailerSubjectsEmailChange, "") + } + if len(tmpl.Content) > 0 { + tmpl.Content = cast.Val(remoteConfig.MailerTemplatesEmailChangeContent, "") + } + e.Template["email_change"] = tmpl + + tmpl = e.Template["reauthentication"] + if len(tmpl.Subject) > 0 { + tmpl.Subject = cast.Val(remoteConfig.MailerSubjectsReauthentication, "") + } + if len(tmpl.Content) > 0 { + tmpl.Content = cast.Val(remoteConfig.MailerTemplatesReauthenticationContent, "") + } + e.Template["reauthentication"] = tmpl } func (s sms) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index 7f5c4d20f..086c9107b 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -228,11 +228,30 @@ func TestEmailDiff(t *testing.T) { EnableConfirmations: true, SecurePasswordChange: true, Template: map[string]emailTemplate{ - "invite": {}, - "confirmation": {}, - "recovery": {}, - "magic_link": {}, - "email_change": {}, + "invite": { + Subject: "invite-subject", + Content: "invite-content", + }, + "confirmation": { + Subject: "confirmation-subject", + Content: "confirmation-content", + }, + "recovery": { + Subject: "recovery-subject", + Content: "recovery-content", + }, + "magic_link": { + Subject: "magic-link-subject", + Content: "magic-link-content", + }, + "email_change": { + Subject: "email-change-subject", + Content: "email-change-content", + }, + "reauthentication": { + Subject: "reauthentication-subject", + Content: "reauthentication-content", + }, }, Smtp: &smtp{ Host: "smtp.sendgrid.net", @@ -261,6 +280,19 @@ func TestEmailDiff(t *testing.T) { SmtpAdminEmail: cast.Ptr("admin@email.com"), SmtpSenderName: cast.Ptr("Admin"), SmtpMaxFrequency: cast.Ptr(1), + // Custom templates + MailerSubjectsInvite: cast.Ptr("invite-subject"), + MailerTemplatesInviteContent: cast.Ptr("invite-content"), + MailerSubjectsConfirmation: cast.Ptr("confirmation-subject"), + MailerTemplatesConfirmationContent: cast.Ptr("confirmation-content"), + MailerSubjectsRecovery: cast.Ptr("recovery-subject"), + MailerTemplatesRecoveryContent: cast.Ptr("recovery-content"), + MailerSubjectsMagicLink: cast.Ptr("magic-link-subject"), + MailerTemplatesMagicLinkContent: cast.Ptr("magic-link-content"), + MailerSubjectsEmailChange: cast.Ptr("email-change-subject"), + MailerTemplatesEmailChangeContent: cast.Ptr("email-change-content"), + MailerSubjectsReauthentication: cast.Ptr("reauthentication-subject"), + MailerTemplatesReauthenticationContent: cast.Ptr("reauthentication-content"), }) // Check error assert.NoError(t, err) @@ -275,11 +307,28 @@ func TestEmailDiff(t *testing.T) { EnableConfirmations: true, SecurePasswordChange: true, Template: map[string]emailTemplate{ - "invite": {}, - "confirmation": {}, - "recovery": {}, - "magic_link": {}, - "email_change": {}, + "invite": { + Subject: "invite-subject", + Content: "invite-content", + }, + "confirmation": { + Subject: "confirmation-subject", + }, + "recovery": { + Content: "recovery-content", + }, + "magic_link": { + Subject: "magic-link-subject", + Content: "magic-link-content", + }, + "email_change": { + Subject: "email-change-subject", + Content: "email-change-content", + }, + "reauthentication": { + Subject: "reauthentication-subject", + Content: "reauthentication-content", + }, }, Smtp: &smtp{ Host: "smtp.sendgrid.net", @@ -302,9 +351,15 @@ func TestEmailDiff(t *testing.T) { MailerOtpExp: 3600, SecurityUpdatePasswordRequireReauthentication: cast.Ptr(false), SmtpMaxFrequency: cast.Ptr(60), + // Custom templates + MailerTemplatesConfirmationContent: cast.Ptr("confirmation-content"), + MailerSubjectsRecovery: cast.Ptr("recovery-subject"), + MailerSubjectsMagicLink: cast.Ptr("magic-link-subject"), + MailerTemplatesEmailChangeContent: cast.Ptr("email-change-content"), }) // Check error assert.NoError(t, err) + assert.Contains(t, string(diff), ` [email]`) assert.Contains(t, string(diff), `-enable_signup = false`) assert.Contains(t, string(diff), `-double_confirm_changes = false`) @@ -320,6 +375,43 @@ func TestEmailDiff(t *testing.T) { assert.Contains(t, string(diff), `+max_frequency = "1s"`) assert.Contains(t, string(diff), `+otp_length = 8`) assert.Contains(t, string(diff), `+otp_expiry = 86400`) + + assert.Contains(t, string(diff), `+[email.smtp]`) + assert.Contains(t, string(diff), `+host = "smtp.sendgrid.net"`) + assert.Contains(t, string(diff), `+port = 587`) + assert.Contains(t, string(diff), `+user = "apikey"`) + assert.Contains(t, string(diff), `+pass = "hash:ed64b7695a606bc6ab4fcb41fe815b5ddf1063ccbc87afe1fa89756635db520e"`) + assert.Contains(t, string(diff), `+admin_email = "admin@email.com"`) + assert.Contains(t, string(diff), `+sender_name = "Admin"`) + + assert.Contains(t, string(diff), ` [email.template]`) + assert.Contains(t, string(diff), ` [email.template.confirmation]`) + assert.Contains(t, string(diff), `-subject = ""`) + assert.Contains(t, string(diff), `+subject = "confirmation-subject"`) + assert.Contains(t, string(diff), ` content_path = ""`) + assert.Contains(t, string(diff), ` content = ""`) + assert.Contains(t, string(diff), ` [email.template.email_change]`) + assert.Contains(t, string(diff), `-subject = ""`) + assert.Contains(t, string(diff), `+subject = "email-change-subject"`) + assert.Contains(t, string(diff), ` content_path = ""`) + assert.Contains(t, string(diff), ` content = "email-change-content"`) + assert.Contains(t, string(diff), ` [email.template.invite]`) + assert.Contains(t, string(diff), `-subject = ""`) + assert.Contains(t, string(diff), `-content_path = ""`) + assert.Contains(t, string(diff), `-content = ""`) + assert.Contains(t, string(diff), `+subject = "invite-subject"`) + assert.Contains(t, string(diff), `+content_path = ""`) + assert.Contains(t, string(diff), `+content = "invite-content"`) + assert.Contains(t, string(diff), ` [email.template.magic_link]`) + assert.Contains(t, string(diff), ` subject = "magic-link-subject"`) + assert.Contains(t, string(diff), ` content_path = ""`) + assert.Contains(t, string(diff), `-content = ""`) + assert.Contains(t, string(diff), `+content = "magic-link-content"`) + assert.Contains(t, string(diff), ` [email.template.recovery]`) + assert.Contains(t, string(diff), ` subject = ""`) + assert.Contains(t, string(diff), ` content_path = ""`) + assert.Contains(t, string(diff), `-content = ""`) + assert.Contains(t, string(diff), `+content = "recovery-content"`) }) t.Run("local disabled remote enabled", func(t *testing.T) { @@ -327,11 +419,12 @@ func TestEmailDiff(t *testing.T) { c.Email = email{ EnableConfirmations: false, Template: map[string]emailTemplate{ - "invite": {}, - "confirmation": {}, - "recovery": {}, - "magic_link": {}, - "email_change": {}, + "invite": {}, + "confirmation": {}, + "recovery": {}, + "magic_link": {}, + "email_change": {}, + "reauthentication": {}, }, MaxFrequency: time.Minute, OtpLength: 8, @@ -352,6 +445,19 @@ func TestEmailDiff(t *testing.T) { SmtpAdminEmail: cast.Ptr("admin@email.com"), SmtpSenderName: cast.Ptr("Admin"), SmtpMaxFrequency: cast.Ptr(1), + // Custom templates + MailerSubjectsInvite: cast.Ptr("invite-subject"), + MailerTemplatesInviteContent: cast.Ptr("invite-content"), + MailerSubjectsConfirmation: cast.Ptr("confirmation-subject"), + MailerTemplatesConfirmationContent: cast.Ptr("confirmation-content"), + MailerSubjectsRecovery: cast.Ptr("recovery-subject"), + MailerTemplatesRecoveryContent: cast.Ptr("recovery-content"), + MailerSubjectsMagicLink: cast.Ptr("magic-link-subject"), + MailerTemplatesMagicLinkContent: cast.Ptr("magic-link-content"), + MailerSubjectsEmailChange: cast.Ptr("email-change-subject"), + MailerTemplatesEmailChangeContent: cast.Ptr("email-change-content"), + MailerSubjectsReauthentication: cast.Ptr("reauthentication-subject"), + MailerTemplatesReauthenticationContent: cast.Ptr("reauthentication-content"), }) // Check error assert.NoError(t, err) @@ -386,11 +492,12 @@ func TestEmailDiff(t *testing.T) { c.Email = email{ EnableConfirmations: false, Template: map[string]emailTemplate{ - "invite": {}, - "confirmation": {}, - "recovery": {}, - "magic_link": {}, - "email_change": {}, + "invite": {}, + "confirmation": {}, + "recovery": {}, + "magic_link": {}, + "email_change": {}, + "reauthentication": {}, }, MaxFrequency: time.Minute, OtpLength: 6, diff --git a/pkg/config/config.go b/pkg/config/config.go index 34e336475..3895ddb4c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -292,11 +292,12 @@ func NewConfig(editors ...ConfigEditor) config { Image: gotrueImage, Email: email{ Template: map[string]emailTemplate{ - "invite": {}, - "confirmation": {}, - "recovery": {}, - "magic_link": {}, - "email_change": {}, + "invite": {}, + "confirmation": {}, + "recovery": {}, + "magic_link": {}, + "email_change": {}, + "reauthentication": {}, }, }, External: map[string]provider{ @@ -817,11 +818,19 @@ func (c *seed) loadSeedPaths(basePath string, fsys fs.FS) error { func (e *email) validate(fsys fs.FS) (err error) { for name, tmpl := range e.Template { - if len(tmpl.ContentPath) > 0 { - if _, err = fs.Stat(fsys, filepath.Clean(tmpl.ContentPath)); err != nil { - return errors.Errorf("Invalid config for auth.email.%s.content_path: %s", name, tmpl.ContentPath) + if len(tmpl.ContentPath) == 0 { + if len(tmpl.Content) > 0 { + return errors.Errorf("Invalid config for auth.email.%s.content: please use content_path instead", name) } + continue + } + // Load the file content of the template within the config + if content, err := fs.ReadFile(fsys, filepath.Clean(tmpl.ContentPath)); err != nil { + return errors.Errorf("Invalid config for auth.email.%s.content_path: %w", name, err) + } else { + tmpl.Content = string(content) } + e.Template[name] = tmpl } if e.Smtp != nil { if len(e.Smtp.Host) == 0 { From 0b378f04e3adda81586523f4a1357090a5146f2c Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Wed, 13 Nov 2024 14:26:44 +0800 Subject: [PATCH 163/305] chore: make content and subject pointers --- internal/start/start.go | 4 +- pkg/config/auth.go | 104 ++++++++++++++++------------------------ pkg/config/auth_test.go | 73 ++++++++++++++-------------- pkg/config/config.go | 6 +-- 4 files changed, 80 insertions(+), 107 deletions(-) diff --git a/internal/start/start.go b/internal/start/start.go index b19a54168..bdb0989aa 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -552,10 +552,10 @@ EOF id+filepath.Ext(tmpl.ContentPath), )) } - if len(tmpl.Subject) > 0 { + if tmpl.Subject != nil { env = append(env, fmt.Sprintf("GOTRUE_MAILER_SUBJECTS_%s=%s", strings.ToUpper(id), - tmpl.Subject, + *tmpl.Subject, )) } } diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 2a71f2177..a2ea016f2 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -89,10 +89,10 @@ type ( } emailTemplate struct { - Subject string `toml:"subject"` + Subject *string `toml:"subject"` + Content *string `toml:"content"` + // Only content path is accepted in config.toml ContentPath string `toml:"content_path"` - // Exposed for remote diff only, not valid in config.toml - Content string `toml:"content"` } sms struct { @@ -332,49 +332,24 @@ func (e email) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { return } var tmpl *emailTemplate - // When local config is not set, we assume platform defaults should not change tmpl = cast.Ptr(e.Template["invite"]) - if len(tmpl.Subject) > 0 { - body.MailerSubjectsInvite = &tmpl.Subject - } - if len(tmpl.Content) > 0 { - body.MailerTemplatesInviteContent = &tmpl.Content - } + body.MailerSubjectsInvite = tmpl.Subject + body.MailerTemplatesInviteContent = tmpl.Content tmpl = cast.Ptr(e.Template["confirmation"]) - if len(tmpl.Subject) > 0 { - body.MailerSubjectsConfirmation = &tmpl.Subject - } - if len(tmpl.Content) > 0 { - body.MailerTemplatesConfirmationContent = &tmpl.Content - } + body.MailerSubjectsConfirmation = tmpl.Subject + body.MailerTemplatesConfirmationContent = tmpl.Content tmpl = cast.Ptr(e.Template["recovery"]) - if len(tmpl.Subject) > 0 { - body.MailerSubjectsRecovery = &tmpl.Subject - } - if len(tmpl.Content) > 0 { - body.MailerTemplatesRecoveryContent = &tmpl.Content - } + body.MailerSubjectsRecovery = tmpl.Subject + body.MailerTemplatesRecoveryContent = tmpl.Content tmpl = cast.Ptr(e.Template["magic_link"]) - if len(tmpl.Subject) > 0 { - body.MailerSubjectsMagicLink = &tmpl.Subject - } - if len(tmpl.Content) > 0 { - body.MailerTemplatesMagicLinkContent = &tmpl.Content - } + body.MailerSubjectsMagicLink = tmpl.Subject + body.MailerTemplatesMagicLinkContent = tmpl.Content tmpl = cast.Ptr(e.Template["email_change"]) - if len(tmpl.Subject) > 0 { - body.MailerSubjectsEmailChange = &tmpl.Subject - } - if len(tmpl.Content) > 0 { - body.MailerTemplatesEmailChangeContent = &tmpl.Content - } + body.MailerSubjectsEmailChange = tmpl.Subject + body.MailerTemplatesEmailChangeContent = tmpl.Content tmpl = cast.Ptr(e.Template["reauthentication"]) - if len(tmpl.Subject) > 0 { - body.MailerSubjectsReauthentication = &tmpl.Subject - } - if len(tmpl.Content) > 0 { - body.MailerTemplatesReauthenticationContent = &tmpl.Content - } + body.MailerSubjectsReauthentication = tmpl.Subject + body.MailerTemplatesReauthenticationContent = tmpl.Content } func (e *email) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { @@ -405,57 +380,58 @@ func (e *email) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { return } var tmpl emailTemplate + // When local config is not set, we assume platform defaults should not change tmpl = e.Template["invite"] - if len(tmpl.Subject) > 0 { - tmpl.Subject = cast.Val(remoteConfig.MailerSubjectsInvite, "") + if tmpl.Subject != nil { + tmpl.Subject = remoteConfig.MailerSubjectsInvite } - if len(tmpl.Content) > 0 { - tmpl.Content = cast.Val(remoteConfig.MailerTemplatesInviteContent, "") + if tmpl.Content != nil { + tmpl.Content = remoteConfig.MailerTemplatesInviteContent } e.Template["invite"] = tmpl tmpl = e.Template["confirmation"] - if len(tmpl.Subject) > 0 { - tmpl.Subject = cast.Val(remoteConfig.MailerSubjectsConfirmation, "") + if tmpl.Subject != nil { + tmpl.Subject = remoteConfig.MailerSubjectsConfirmation } - if len(tmpl.Content) > 0 { - tmpl.Content = cast.Val(remoteConfig.MailerTemplatesConfirmationContent, "") + if tmpl.Content != nil { + tmpl.Content = remoteConfig.MailerTemplatesConfirmationContent } e.Template["confirmation"] = tmpl tmpl = e.Template["recovery"] - if len(tmpl.Subject) > 0 { - tmpl.Subject = cast.Val(remoteConfig.MailerSubjectsRecovery, "") + if tmpl.Subject != nil { + tmpl.Subject = remoteConfig.MailerSubjectsRecovery } - if len(tmpl.Content) > 0 { - tmpl.Content = cast.Val(remoteConfig.MailerTemplatesRecoveryContent, "") + if tmpl.Content != nil { + tmpl.Content = remoteConfig.MailerTemplatesRecoveryContent } e.Template["recovery"] = tmpl tmpl = e.Template["magic_link"] - if len(tmpl.Subject) > 0 { - tmpl.Subject = cast.Val(remoteConfig.MailerSubjectsMagicLink, "") + if tmpl.Subject != nil { + tmpl.Subject = remoteConfig.MailerSubjectsMagicLink } - if len(tmpl.Content) > 0 { - tmpl.Content = cast.Val(remoteConfig.MailerTemplatesMagicLinkContent, "") + if tmpl.Content != nil { + tmpl.Content = remoteConfig.MailerTemplatesMagicLinkContent } e.Template["magic_link"] = tmpl tmpl = e.Template["email_change"] - if len(tmpl.Subject) > 0 { - tmpl.Subject = cast.Val(remoteConfig.MailerSubjectsEmailChange, "") + if tmpl.Subject != nil { + tmpl.Subject = remoteConfig.MailerSubjectsEmailChange } - if len(tmpl.Content) > 0 { - tmpl.Content = cast.Val(remoteConfig.MailerTemplatesEmailChangeContent, "") + if tmpl.Content != nil { + tmpl.Content = remoteConfig.MailerTemplatesEmailChangeContent } e.Template["email_change"] = tmpl tmpl = e.Template["reauthentication"] - if len(tmpl.Subject) > 0 { - tmpl.Subject = cast.Val(remoteConfig.MailerSubjectsReauthentication, "") + if tmpl.Subject != nil { + tmpl.Subject = remoteConfig.MailerSubjectsReauthentication } - if len(tmpl.Content) > 0 { - tmpl.Content = cast.Val(remoteConfig.MailerTemplatesReauthenticationContent, "") + if tmpl.Content != nil { + tmpl.Content = remoteConfig.MailerTemplatesReauthenticationContent } e.Template["reauthentication"] = tmpl } diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index 086c9107b..97b4e507f 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -229,28 +229,28 @@ func TestEmailDiff(t *testing.T) { SecurePasswordChange: true, Template: map[string]emailTemplate{ "invite": { - Subject: "invite-subject", - Content: "invite-content", + Subject: cast.Ptr("invite-subject"), + Content: cast.Ptr("invite-content"), }, "confirmation": { - Subject: "confirmation-subject", - Content: "confirmation-content", + Subject: cast.Ptr("confirmation-subject"), + Content: cast.Ptr("confirmation-content"), }, "recovery": { - Subject: "recovery-subject", - Content: "recovery-content", + Subject: cast.Ptr("recovery-subject"), + Content: cast.Ptr("recovery-content"), }, "magic_link": { - Subject: "magic-link-subject", - Content: "magic-link-content", + Subject: cast.Ptr("magic-link-subject"), + Content: cast.Ptr("magic-link-content"), }, "email_change": { - Subject: "email-change-subject", - Content: "email-change-content", + Subject: cast.Ptr("email-change-subject"), + Content: cast.Ptr("email-change-content"), }, "reauthentication": { - Subject: "reauthentication-subject", - Content: "reauthentication-content", + Subject: cast.Ptr("reauthentication-subject"), + Content: cast.Ptr("reauthentication-content"), }, }, Smtp: &smtp{ @@ -308,26 +308,26 @@ func TestEmailDiff(t *testing.T) { SecurePasswordChange: true, Template: map[string]emailTemplate{ "invite": { - Subject: "invite-subject", - Content: "invite-content", + Subject: cast.Ptr("invite-subject"), + Content: cast.Ptr("invite-content"), }, "confirmation": { - Subject: "confirmation-subject", + Subject: cast.Ptr("confirmation-subject"), }, "recovery": { - Content: "recovery-content", + Content: cast.Ptr("recovery-content"), }, "magic_link": { - Subject: "magic-link-subject", - Content: "magic-link-content", + Subject: cast.Ptr("magic-link-subject"), + Content: cast.Ptr("magic-link-content"), }, "email_change": { - Subject: "email-change-subject", - Content: "email-change-content", + Subject: cast.Ptr("email-change-subject"), + Content: cast.Ptr("email-change-content"), }, "reauthentication": { - Subject: "reauthentication-subject", - Content: "reauthentication-content", + Subject: cast.Ptr(""), + Content: cast.Ptr(""), }, }, Smtp: &smtp{ @@ -376,42 +376,39 @@ func TestEmailDiff(t *testing.T) { assert.Contains(t, string(diff), `+otp_length = 8`) assert.Contains(t, string(diff), `+otp_expiry = 86400`) - assert.Contains(t, string(diff), `+[email.smtp]`) - assert.Contains(t, string(diff), `+host = "smtp.sendgrid.net"`) - assert.Contains(t, string(diff), `+port = 587`) - assert.Contains(t, string(diff), `+user = "apikey"`) - assert.Contains(t, string(diff), `+pass = "hash:ed64b7695a606bc6ab4fcb41fe815b5ddf1063ccbc87afe1fa89756635db520e"`) - assert.Contains(t, string(diff), `+admin_email = "admin@email.com"`) - assert.Contains(t, string(diff), `+sender_name = "Admin"`) - assert.Contains(t, string(diff), ` [email.template]`) assert.Contains(t, string(diff), ` [email.template.confirmation]`) - assert.Contains(t, string(diff), `-subject = ""`) assert.Contains(t, string(diff), `+subject = "confirmation-subject"`) assert.Contains(t, string(diff), ` content_path = ""`) - assert.Contains(t, string(diff), ` content = ""`) assert.Contains(t, string(diff), ` [email.template.email_change]`) - assert.Contains(t, string(diff), `-subject = ""`) assert.Contains(t, string(diff), `+subject = "email-change-subject"`) assert.Contains(t, string(diff), ` content_path = ""`) assert.Contains(t, string(diff), ` content = "email-change-content"`) assert.Contains(t, string(diff), ` [email.template.invite]`) - assert.Contains(t, string(diff), `-subject = ""`) assert.Contains(t, string(diff), `-content_path = ""`) - assert.Contains(t, string(diff), `-content = ""`) assert.Contains(t, string(diff), `+subject = "invite-subject"`) assert.Contains(t, string(diff), `+content_path = ""`) assert.Contains(t, string(diff), `+content = "invite-content"`) assert.Contains(t, string(diff), ` [email.template.magic_link]`) assert.Contains(t, string(diff), ` subject = "magic-link-subject"`) assert.Contains(t, string(diff), ` content_path = ""`) - assert.Contains(t, string(diff), `-content = ""`) assert.Contains(t, string(diff), `+content = "magic-link-content"`) + assert.Contains(t, string(diff), ` [email.template.reauthentication]`) + assert.Contains(t, string(diff), `-content_path = ""`) + assert.Contains(t, string(diff), `+subject = ""`) + assert.Contains(t, string(diff), `+content_path = ""`) + assert.Contains(t, string(diff), `+content = ""`) assert.Contains(t, string(diff), ` [email.template.recovery]`) - assert.Contains(t, string(diff), ` subject = ""`) assert.Contains(t, string(diff), ` content_path = ""`) - assert.Contains(t, string(diff), `-content = ""`) assert.Contains(t, string(diff), `+content = "recovery-content"`) + + assert.Contains(t, string(diff), `+[email.smtp]`) + assert.Contains(t, string(diff), `+host = "smtp.sendgrid.net"`) + assert.Contains(t, string(diff), `+port = 587`) + assert.Contains(t, string(diff), `+user = "apikey"`) + assert.Contains(t, string(diff), `+pass = "hash:ed64b7695a606bc6ab4fcb41fe815b5ddf1063ccbc87afe1fa89756635db520e"`) + assert.Contains(t, string(diff), `+admin_email = "admin@email.com"`) + assert.Contains(t, string(diff), `+sender_name = "Admin"`) }) t.Run("local disabled remote enabled", func(t *testing.T) { diff --git a/pkg/config/config.go b/pkg/config/config.go index 3895ddb4c..b1e7ed570 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -30,6 +30,7 @@ import ( "github.com/joho/godotenv" "github.com/mitchellh/mapstructure" "github.com/spf13/viper" + "github.com/supabase/cli/pkg/cast" "github.com/supabase/cli/pkg/fetcher" "golang.org/x/mod/semver" ) @@ -819,16 +820,15 @@ func (c *seed) loadSeedPaths(basePath string, fsys fs.FS) error { func (e *email) validate(fsys fs.FS) (err error) { for name, tmpl := range e.Template { if len(tmpl.ContentPath) == 0 { - if len(tmpl.Content) > 0 { + if tmpl.Content != nil { return errors.Errorf("Invalid config for auth.email.%s.content: please use content_path instead", name) } continue } - // Load the file content of the template within the config if content, err := fs.ReadFile(fsys, filepath.Clean(tmpl.ContentPath)); err != nil { return errors.Errorf("Invalid config for auth.email.%s.content_path: %w", name, err) } else { - tmpl.Content = string(content) + tmpl.Content = cast.Ptr(string(content)) } e.Template[name] = tmpl } From b497d18da75a3ef27387cfe7fa5d8172353ae5b7 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Wed, 13 Nov 2024 14:58:22 +0800 Subject: [PATCH 164/305] chore: externalise test snapshots for config diff --- pkg/config/api_test.go | 23 +-- pkg/config/auth_test.go | 180 ++---------------- pkg/config/db_test.go | 17 +- .../TestApiDiff/detects_differences.diff | 14 ++ .../handles_api_disabled_on_local_side.diff | 9 + .../handles_api_disabled_on_remote_side.diff | 9 + .../detects_differences.diff | 10 + .../handles_api_disabled_on_local_side.diff | 7 + .../handles_api_disabled_on_remote_side.diff | 7 + .../local_disabled_remote_enabled.diff | 38 ++++ .../local_enabled_remote_disabled.diff | 55 ++++++ .../local_enabled_and_disabled.diff | 21 ++ .../local_enabled_and_disabled.diff | 21 ++ .../local_enabled_and_disabled.diff | 26 +++ .../enable_sign_up_without_provider.diff | 12 ++ .../local_disabled_remote_enabled.diff | 31 +++ .../local_enabled_remote_disabled.diff | 43 +++++ 17 files changed, 336 insertions(+), 187 deletions(-) create mode 100644 pkg/config/testdata/TestApiDiff/detects_differences.diff create mode 100644 pkg/config/testdata/TestApiDiff/handles_api_disabled_on_local_side.diff create mode 100644 pkg/config/testdata/TestApiDiff/handles_api_disabled_on_remote_side.diff create mode 100644 pkg/config/testdata/TestDbSettingsDiff/detects_differences.diff create mode 100644 pkg/config/testdata/TestDbSettingsDiff/handles_api_disabled_on_local_side.diff create mode 100644 pkg/config/testdata/TestDbSettingsDiff/handles_api_disabled_on_remote_side.diff create mode 100644 pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff create mode 100644 pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff create mode 100644 pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff create mode 100644 pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff create mode 100644 pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff create mode 100644 pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff create mode 100644 pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff create mode 100644 pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff diff --git a/pkg/config/api_test.go b/pkg/config/api_test.go index d48001244..92859c671 100644 --- a/pkg/config/api_test.go +++ b/pkg/config/api_test.go @@ -33,7 +33,7 @@ func TestApiToUpdatePostgrestConfigBody(t *testing.T) { }) } -func TestApiDiffWithRemote(t *testing.T) { +func TestApiDiff(t *testing.T) { t.Run("detects differences", func(t *testing.T) { api := &api{ Enabled: true, @@ -49,14 +49,9 @@ func TestApiDiffWithRemote(t *testing.T) { } diff, err := api.DiffWithRemote(remoteConfig) - assert.NoError(t, err, string(diff)) - - assert.Contains(t, string(diff), "-schemas = [\"public\"]") - assert.Contains(t, string(diff), "+schemas = [\"public\", \"private\"]") - assert.Contains(t, string(diff), "-extra_search_path = [\"public\"]") - assert.Contains(t, string(diff), "+extra_search_path = [\"extensions\", \"public\"]") - assert.Contains(t, string(diff), "-max_rows = 500") - assert.Contains(t, string(diff), "+max_rows = 1000") + assert.NoError(t, err) + + assertSnapshotEqual(t, diff) }) t.Run("handles no differences", func(t *testing.T) { @@ -114,10 +109,9 @@ func TestApiDiffWithRemote(t *testing.T) { } diff, err := api.DiffWithRemote(remoteConfig) - assert.NoError(t, err, string(diff)) + assert.NoError(t, err) - assert.Contains(t, string(diff), "-enabled = false") - assert.Contains(t, string(diff), "+enabled = true") + assertSnapshotEqual(t, diff) }) t.Run("handles api disabled on local side", func(t *testing.T) { @@ -135,9 +129,8 @@ func TestApiDiffWithRemote(t *testing.T) { } diff, err := api.DiffWithRemote(remoteConfig) - assert.NoError(t, err, string(diff)) + assert.NoError(t, err) - assert.Contains(t, string(diff), "-enabled = true") - assert.Contains(t, string(diff), "+enabled = false") + assertSnapshotEqual(t, diff) }) } diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index 97b4e507f..e8d373b9f 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -1,9 +1,12 @@ package config import ( + "os" + "path/filepath" "testing" "time" + "github.com/go-errors/errors" "github.com/stretchr/testify/assert" v1API "github.com/supabase/cli/pkg/api" "github.com/supabase/cli/pkg/cast" @@ -18,6 +21,16 @@ func newWithDefaults() auth { } } +func assertSnapshotEqual(t *testing.T, actual []byte) { + snapshot := filepath.Join("testdata", filepath.FromSlash(t.Name())) + ".diff" + expected, err := os.ReadFile(snapshot) + if errors.Is(err, os.ErrNotExist) { + assert.NoError(t, os.MkdirAll(filepath.Dir(snapshot), 0755)) + assert.NoError(t, os.WriteFile(snapshot, actual, 0600)) + } + assert.Equal(t, string(expected), string(actual)) +} + func TestHookDiff(t *testing.T) { t.Run("local and remote enabled", func(t *testing.T) { c := newWithDefaults() @@ -68,18 +81,7 @@ func TestHookDiff(t *testing.T) { }) // Check error assert.NoError(t, err) - - assert.Contains(t, string(diff), ` [hook.mfa_verification_attempt]`) - assert.Contains(t, string(diff), `-enabled = true`) - assert.Contains(t, string(diff), `+enabled = false`) - assert.Contains(t, string(diff), ` uri = ""`) - assert.Contains(t, string(diff), ` secrets = ""`) - - assert.Contains(t, string(diff), ` [hook.custom_access_token]`) - assert.Contains(t, string(diff), `-enabled = false`) - assert.Contains(t, string(diff), `+enabled = true`) - assert.Contains(t, string(diff), ` uri = ""`) - assert.Contains(t, string(diff), ` secrets = "hash:b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"`) + assertSnapshotEqual(t, diff) }) t.Run("local and remote disabled", func(t *testing.T) { @@ -168,26 +170,7 @@ func TestMfaDiff(t *testing.T) { }) // Check error assert.NoError(t, err) - assert.Contains(t, string(diff), ` [mfa]`) - assert.Contains(t, string(diff), `-max_enrolled_factors = 10`) - assert.Contains(t, string(diff), `+max_enrolled_factors = 0`) - assert.Contains(t, string(diff), ` [mfa.totp]`) - assert.Contains(t, string(diff), ` enroll_enabled = false`) - assert.Contains(t, string(diff), ` verify_enabled = false`) - assert.Contains(t, string(diff), ` [mfa.phone]`) - assert.Contains(t, string(diff), `-enroll_enabled = false`) - assert.Contains(t, string(diff), `-verify_enabled = false`) - assert.Contains(t, string(diff), `-otp_length = 6`) - assert.Contains(t, string(diff), `-template = "Your code is {{ .Code }}"`) - assert.Contains(t, string(diff), `-max_frequency = "5s"`) - assert.Contains(t, string(diff), `+enroll_enabled = true`) - assert.Contains(t, string(diff), `+verify_enabled = true`) - assert.Contains(t, string(diff), `+otp_length = 0`) - assert.Contains(t, string(diff), `+template = ""`) - assert.Contains(t, string(diff), `+max_frequency = "0s"`) - assert.Contains(t, string(diff), ` [mfa.web_authn]`) - assert.Contains(t, string(diff), ` enroll_enabled = false`) - assert.Contains(t, string(diff), ` verify_enabled = false`) + assertSnapshotEqual(t, diff) }) t.Run("local and remote disabled", func(t *testing.T) { @@ -359,56 +342,7 @@ func TestEmailDiff(t *testing.T) { }) // Check error assert.NoError(t, err) - - assert.Contains(t, string(diff), ` [email]`) - assert.Contains(t, string(diff), `-enable_signup = false`) - assert.Contains(t, string(diff), `-double_confirm_changes = false`) - assert.Contains(t, string(diff), `-enable_confirmations = false`) - assert.Contains(t, string(diff), `-secure_password_change = false`) - assert.Contains(t, string(diff), `-max_frequency = "1m0s"`) - assert.Contains(t, string(diff), `-otp_length = 6`) - assert.Contains(t, string(diff), `-otp_expiry = 3600`) - assert.Contains(t, string(diff), `+enable_signup = true`) - assert.Contains(t, string(diff), `+double_confirm_changes = true`) - assert.Contains(t, string(diff), `+enable_confirmations = true`) - assert.Contains(t, string(diff), `+secure_password_change = true`) - assert.Contains(t, string(diff), `+max_frequency = "1s"`) - assert.Contains(t, string(diff), `+otp_length = 8`) - assert.Contains(t, string(diff), `+otp_expiry = 86400`) - - assert.Contains(t, string(diff), ` [email.template]`) - assert.Contains(t, string(diff), ` [email.template.confirmation]`) - assert.Contains(t, string(diff), `+subject = "confirmation-subject"`) - assert.Contains(t, string(diff), ` content_path = ""`) - assert.Contains(t, string(diff), ` [email.template.email_change]`) - assert.Contains(t, string(diff), `+subject = "email-change-subject"`) - assert.Contains(t, string(diff), ` content_path = ""`) - assert.Contains(t, string(diff), ` content = "email-change-content"`) - assert.Contains(t, string(diff), ` [email.template.invite]`) - assert.Contains(t, string(diff), `-content_path = ""`) - assert.Contains(t, string(diff), `+subject = "invite-subject"`) - assert.Contains(t, string(diff), `+content_path = ""`) - assert.Contains(t, string(diff), `+content = "invite-content"`) - assert.Contains(t, string(diff), ` [email.template.magic_link]`) - assert.Contains(t, string(diff), ` subject = "magic-link-subject"`) - assert.Contains(t, string(diff), ` content_path = ""`) - assert.Contains(t, string(diff), `+content = "magic-link-content"`) - assert.Contains(t, string(diff), ` [email.template.reauthentication]`) - assert.Contains(t, string(diff), `-content_path = ""`) - assert.Contains(t, string(diff), `+subject = ""`) - assert.Contains(t, string(diff), `+content_path = ""`) - assert.Contains(t, string(diff), `+content = ""`) - assert.Contains(t, string(diff), ` [email.template.recovery]`) - assert.Contains(t, string(diff), ` content_path = ""`) - assert.Contains(t, string(diff), `+content = "recovery-content"`) - - assert.Contains(t, string(diff), `+[email.smtp]`) - assert.Contains(t, string(diff), `+host = "smtp.sendgrid.net"`) - assert.Contains(t, string(diff), `+port = 587`) - assert.Contains(t, string(diff), `+user = "apikey"`) - assert.Contains(t, string(diff), `+pass = "hash:ed64b7695a606bc6ab4fcb41fe815b5ddf1063ccbc87afe1fa89756635db520e"`) - assert.Contains(t, string(diff), `+admin_email = "admin@email.com"`) - assert.Contains(t, string(diff), `+sender_name = "Admin"`) + assertSnapshotEqual(t, diff) }) t.Run("local disabled remote enabled", func(t *testing.T) { @@ -458,30 +392,7 @@ func TestEmailDiff(t *testing.T) { }) // Check error assert.NoError(t, err) - - assert.Contains(t, string(diff), ` [email]`) - assert.Contains(t, string(diff), `-enable_signup = true`) - assert.Contains(t, string(diff), `-double_confirm_changes = true`) - assert.Contains(t, string(diff), `-enable_confirmations = true`) - assert.Contains(t, string(diff), `-secure_password_change = true`) - assert.Contains(t, string(diff), `-max_frequency = "1s"`) - assert.Contains(t, string(diff), `-otp_length = 6`) - assert.Contains(t, string(diff), `-otp_expiry = 3600`) - assert.Contains(t, string(diff), `+enable_signup = false`) - assert.Contains(t, string(diff), `+double_confirm_changes = false`) - assert.Contains(t, string(diff), `+enable_confirmations = false`) - assert.Contains(t, string(diff), `+secure_password_change = false`) - assert.Contains(t, string(diff), `+max_frequency = "1m0s"`) - assert.Contains(t, string(diff), `+otp_length = 8`) - assert.Contains(t, string(diff), `+otp_expiry = 86400`) - - assert.Contains(t, string(diff), `-[email.smtp]`) - assert.Contains(t, string(diff), `-host = "smtp.sendgrid.net"`) - assert.Contains(t, string(diff), `-port = 587`) - assert.Contains(t, string(diff), `-user = "apikey"`) - assert.Contains(t, string(diff), `-pass = "hash:ed64b7695a606bc6ab4fcb41fe815b5ddf1063ccbc87afe1fa89756635db520e"`) - assert.Contains(t, string(diff), `-admin_email = "admin@email.com"`) - assert.Contains(t, string(diff), `-sender_name = "Admin"`) + assertSnapshotEqual(t, diff) }) t.Run("local disabled remote disabled", func(t *testing.T) { @@ -584,23 +495,7 @@ func TestSmsDiff(t *testing.T) { }) // Check error assert.NoError(t, err) - assert.Contains(t, string(diff), `-enable_signup = true`) - assert.Contains(t, string(diff), `-enable_confirmations = true`) - assert.Contains(t, string(diff), `-template = "Your code is {{ .Code }}"`) - assert.Contains(t, string(diff), `-max_frequency = "1m0s"`) - - assert.Contains(t, string(diff), `+enable_signup = false`) - assert.Contains(t, string(diff), `+enable_confirmations = false`) - assert.Contains(t, string(diff), `+template = ""`) - assert.Contains(t, string(diff), `+max_frequency = "0s"`) - - assert.Contains(t, string(diff), ` [sms.twilio]`) - assert.Contains(t, string(diff), `-enabled = true`) - assert.Contains(t, string(diff), `+enabled = false`) - - assert.Contains(t, string(diff), `-[sms.test_otp]`) - assert.Contains(t, string(diff), `-123 = "456"`) - assert.Contains(t, string(diff), `-456 = "123"`) + assertSnapshotEqual(t, diff) }) t.Run("local enabled remote disabled", func(t *testing.T) { @@ -633,30 +528,7 @@ func TestSmsDiff(t *testing.T) { }) // Check error assert.NoError(t, err) - assert.Contains(t, string(diff), `-enable_signup = false`) - assert.Contains(t, string(diff), `-enable_confirmations = false`) - assert.Contains(t, string(diff), `-template = ""`) - assert.Contains(t, string(diff), `-max_frequency = "0s"`) - - assert.Contains(t, string(diff), `+enable_signup = true`) - assert.Contains(t, string(diff), `+enable_confirmations = true`) - assert.Contains(t, string(diff), `+template = "Your code is {{ .Code }}"`) - assert.Contains(t, string(diff), `+max_frequency = "1m0s"`) - - assert.Contains(t, string(diff), ` [sms.twilio]`) - assert.Contains(t, string(diff), `-enabled = true`) - assert.Contains(t, string(diff), `+enabled = false`) - - assert.Contains(t, string(diff), ` [sms.messagebird]`) - assert.Contains(t, string(diff), `-enabled = false`) - assert.Contains(t, string(diff), `-originator = ""`) - assert.Contains(t, string(diff), `-access_key = "hash:"`) - assert.Contains(t, string(diff), `+enabled = true`) - assert.Contains(t, string(diff), `+originator = "test-originator"`) - assert.Contains(t, string(diff), `+access_key = "hash:ab60d03fc809fb02dae838582f3ddc13d1d6cb32ffba77c4b969dd3caa496f13"`) - - assert.Contains(t, string(diff), `+[sms.test_otp]`) - assert.Contains(t, string(diff), `+123 = "456"`) + assertSnapshotEqual(t, diff) }) t.Run("local disabled remote disabled", func(t *testing.T) { @@ -701,9 +573,7 @@ func TestSmsDiff(t *testing.T) { }) // Check error assert.NoError(t, err) - assert.Contains(t, string(diff), ` [sms]`) - assert.Contains(t, string(diff), `-enable_signup = false`) - assert.Contains(t, string(diff), `+enable_signup = true`) + assertSnapshotEqual(t, diff) }) t.Run("enable provider without sign up", func(t *testing.T) { @@ -866,15 +736,7 @@ func TestExternalDiff(t *testing.T) { }) // Check error assert.NoError(t, err) - assert.Contains(t, string(diff), ` [external.apple]`) - assert.Contains(t, string(diff), `-enabled = false`) - assert.Contains(t, string(diff), `+enabled = true`) - assert.Contains(t, string(diff), ` client_id = "test-client-1,test-client-2"`) - assert.Contains(t, string(diff), ` secret = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"`) - - assert.Contains(t, string(diff), ` [external.google]`) - assert.Contains(t, string(diff), `-enabled = true`) - assert.Contains(t, string(diff), `+enabled = false`) + assertSnapshotEqual(t, diff) }) t.Run("local and remote disabled", func(t *testing.T) { diff --git a/pkg/config/db_test.go b/pkg/config/db_test.go index 8d70ec21b..575fd202d 100644 --- a/pkg/config/db_test.go +++ b/pkg/config/db_test.go @@ -42,7 +42,7 @@ func TestDbSettingsToUpdatePostgresConfigBody(t *testing.T) { }) } -func TestDbSettingsDiffWithRemote(t *testing.T) { +func TestDbSettingsDiff(t *testing.T) { t.Run("detects differences", func(t *testing.T) { db := &db{ Settings: settings{ @@ -61,12 +61,7 @@ func TestDbSettingsDiffWithRemote(t *testing.T) { diff, err := db.Settings.DiffWithRemote(remoteConfig) assert.NoError(t, err) - assert.Contains(t, string(diff), "-effective_cache_size = \"8GB\"") - assert.Contains(t, string(diff), "+effective_cache_size = \"4GB\"") - assert.Contains(t, string(diff), "-max_connections = 200") - assert.Contains(t, string(diff), "+max_connections = 100") - assert.Contains(t, string(diff), "-shared_buffers = \"2GB\"") - assert.Contains(t, string(diff), "+shared_buffers = \"1GB\"") + assertSnapshotEqual(t, diff) }) t.Run("handles no differences", func(t *testing.T) { @@ -127,9 +122,7 @@ func TestDbSettingsDiffWithRemote(t *testing.T) { diff, err := db.Settings.DiffWithRemote(remoteConfig) assert.NoError(t, err) - assert.Contains(t, string(diff), "+effective_cache_size = \"4GB\"") - assert.Contains(t, string(diff), "+max_connections = 100") - assert.Contains(t, string(diff), "+shared_buffers = \"1GB\"") + assertSnapshotEqual(t, diff) }) t.Run("handles api disabled on local side", func(t *testing.T) { @@ -148,9 +141,7 @@ func TestDbSettingsDiffWithRemote(t *testing.T) { diff, err := db.Settings.DiffWithRemote(remoteConfig) assert.NoError(t, err) - assert.Contains(t, string(diff), "-effective_cache_size = \"4GB\"") - assert.Contains(t, string(diff), "-max_connections = 100") - assert.Contains(t, string(diff), "-shared_buffers = \"1GB\"") + assertSnapshotEqual(t, diff) }) } diff --git a/pkg/config/testdata/TestApiDiff/detects_differences.diff b/pkg/config/testdata/TestApiDiff/detects_differences.diff new file mode 100644 index 000000000..5d0e9603e --- /dev/null +++ b/pkg/config/testdata/TestApiDiff/detects_differences.diff @@ -0,0 +1,14 @@ +diff remote[api] local[api] +--- remote[api] ++++ local[api] +@@ -1,7 +1,7 @@ + enabled = true +-schemas = ["public"] +-extra_search_path = ["public"] +-max_rows = 500 ++schemas = ["public", "private"] ++extra_search_path = ["extensions", "public"] ++max_rows = 1000 + port = 0 + external_url = "" + diff --git a/pkg/config/testdata/TestApiDiff/handles_api_disabled_on_local_side.diff b/pkg/config/testdata/TestApiDiff/handles_api_disabled_on_local_side.diff new file mode 100644 index 000000000..67a5ccd5c --- /dev/null +++ b/pkg/config/testdata/TestApiDiff/handles_api_disabled_on_local_side.diff @@ -0,0 +1,9 @@ +diff remote[api] local[api] +--- remote[api] ++++ local[api] +@@ -1,4 +1,4 @@ +-enabled = true ++enabled = false + schemas = ["public"] + extra_search_path = ["public"] + max_rows = 500 diff --git a/pkg/config/testdata/TestApiDiff/handles_api_disabled_on_remote_side.diff b/pkg/config/testdata/TestApiDiff/handles_api_disabled_on_remote_side.diff new file mode 100644 index 000000000..200d36c40 --- /dev/null +++ b/pkg/config/testdata/TestApiDiff/handles_api_disabled_on_remote_side.diff @@ -0,0 +1,9 @@ +diff remote[api] local[api] +--- remote[api] ++++ local[api] +@@ -1,4 +1,4 @@ +-enabled = false ++enabled = true + schemas = ["public", "private"] + extra_search_path = ["extensions", "public"] + max_rows = 500 diff --git a/pkg/config/testdata/TestDbSettingsDiff/detects_differences.diff b/pkg/config/testdata/TestDbSettingsDiff/detects_differences.diff new file mode 100644 index 000000000..12aeb50ae --- /dev/null +++ b/pkg/config/testdata/TestDbSettingsDiff/detects_differences.diff @@ -0,0 +1,10 @@ +diff remote[db.settings] local[db.settings] +--- remote[db.settings] ++++ local[db.settings] +@@ -1,3 +1,3 @@ +-effective_cache_size = "8GB" +-max_connections = 200 +-shared_buffers = "2GB" ++effective_cache_size = "4GB" ++max_connections = 100 ++shared_buffers = "1GB" diff --git a/pkg/config/testdata/TestDbSettingsDiff/handles_api_disabled_on_local_side.diff b/pkg/config/testdata/TestDbSettingsDiff/handles_api_disabled_on_local_side.diff new file mode 100644 index 000000000..392143fd1 --- /dev/null +++ b/pkg/config/testdata/TestDbSettingsDiff/handles_api_disabled_on_local_side.diff @@ -0,0 +1,7 @@ +diff remote[db.settings] local[db.settings] +--- remote[db.settings] ++++ local[db.settings] +@@ -1,3 +0,0 @@ +-effective_cache_size = "4GB" +-max_connections = 100 +-shared_buffers = "1GB" diff --git a/pkg/config/testdata/TestDbSettingsDiff/handles_api_disabled_on_remote_side.diff b/pkg/config/testdata/TestDbSettingsDiff/handles_api_disabled_on_remote_side.diff new file mode 100644 index 000000000..938242538 --- /dev/null +++ b/pkg/config/testdata/TestDbSettingsDiff/handles_api_disabled_on_remote_side.diff @@ -0,0 +1,7 @@ +diff remote[db.settings] local[db.settings] +--- remote[db.settings] ++++ local[db.settings] +@@ -0,0 +1,3 @@ ++effective_cache_size = "4GB" ++max_connections = 100 ++shared_buffers = "1GB" diff --git a/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff b/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff new file mode 100644 index 000000000..d6c7f6dca --- /dev/null +++ b/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff @@ -0,0 +1,38 @@ +diff remote[auth] local[auth] +--- remote[auth] ++++ local[auth] +@@ -49,13 +49,13 @@ + inactivity_timeout = "0s" + + [email] +-enable_signup = true +-double_confirm_changes = true +-enable_confirmations = true +-secure_password_change = true +-max_frequency = "1s" +-otp_length = 6 +-otp_expiry = 3600 ++enable_signup = false ++double_confirm_changes = false ++enable_confirmations = false ++secure_password_change = false ++max_frequency = "1m0s" ++otp_length = 8 ++otp_expiry = 86400 + [email.template] + [email.template.confirmation] + content_path = "" +@@ -69,13 +69,6 @@ + content_path = "" + [email.template.recovery] + content_path = "" +-[email.smtp] +-host = "smtp.sendgrid.net" +-port = 587 +-user = "apikey" +-pass = "hash:ed64b7695a606bc6ab4fcb41fe815b5ddf1063ccbc87afe1fa89756635db520e" +-admin_email = "admin@email.com" +-sender_name = "Admin" + + [sms] + enable_signup = false diff --git a/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff new file mode 100644 index 000000000..9bcf8ccba --- /dev/null +++ b/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff @@ -0,0 +1,55 @@ +diff remote[auth] local[auth] +--- remote[auth] ++++ local[auth] +@@ -49,28 +49,43 @@ + inactivity_timeout = "0s" + + [email] +-enable_signup = false +-double_confirm_changes = false +-enable_confirmations = false +-secure_password_change = false +-max_frequency = "1m0s" +-otp_length = 6 +-otp_expiry = 3600 ++enable_signup = true ++double_confirm_changes = true ++enable_confirmations = true ++secure_password_change = true ++max_frequency = "1s" ++otp_length = 8 ++otp_expiry = 86400 + [email.template] + [email.template.confirmation] ++subject = "confirmation-subject" + content_path = "" + [email.template.email_change] ++subject = "email-change-subject" + content = "email-change-content" + content_path = "" + [email.template.invite] ++subject = "invite-subject" ++content = "invite-content" + content_path = "" + [email.template.magic_link] + subject = "magic-link-subject" ++content = "magic-link-content" + content_path = "" + [email.template.reauthentication] ++subject = "" ++content = "" + content_path = "" + [email.template.recovery] +-content_path = "" ++content = "recovery-content" ++content_path = "" ++[email.smtp] ++host = "smtp.sendgrid.net" ++port = 587 ++user = "apikey" ++pass = "hash:ed64b7695a606bc6ab4fcb41fe815b5ddf1063ccbc87afe1fa89756635db520e" ++admin_email = "admin@email.com" ++sender_name = "Admin" + + [sms] + enable_signup = false diff --git a/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff new file mode 100644 index 000000000..fcfb3d1d0 --- /dev/null +++ b/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff @@ -0,0 +1,21 @@ +diff remote[auth] local[auth] +--- remote[auth] ++++ local[auth] +@@ -88,7 +88,7 @@ + + [external] + [external.apple] +-enabled = false ++enabled = true + client_id = "test-client-1,test-client-2" + secret = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" + url = "" +@@ -144,7 +144,7 @@ + redirect_uri = "" + skip_nonce_check = false + [external.google] +-enabled = true ++enabled = false + client_id = "" + secret = "" + url = "" diff --git a/pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff new file mode 100644 index 000000000..b45808d4c --- /dev/null +++ b/pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff @@ -0,0 +1,21 @@ +diff remote[auth] local[auth] +--- remote[auth] ++++ local[auth] +@@ -9,7 +9,7 @@ + + [hook] + [hook.mfa_verification_attempt] +-enabled = true ++enabled = false + uri = "" + secrets = "" + [hook.password_verification_attempt] +@@ -17,7 +17,7 @@ + uri = "" + secrets = "" + [hook.custom_access_token] +-enabled = false ++enabled = true + uri = "" + secrets = "hash:b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad" + [hook.send_sms] diff --git a/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff new file mode 100644 index 000000000..f7935bfa4 --- /dev/null +++ b/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff @@ -0,0 +1,26 @@ +diff remote[auth] local[auth] +--- remote[auth] ++++ local[auth] +@@ -30,16 +30,16 @@ + secrets = "" + + [mfa] +-max_enrolled_factors = 10 ++max_enrolled_factors = 0 + [mfa.totp] + enroll_enabled = false + verify_enabled = false + [mfa.phone] +-enroll_enabled = false +-verify_enabled = false +-otp_length = 6 +-template = "Your code is {{ .Code }}" +-max_frequency = "5s" ++enroll_enabled = true ++verify_enabled = true ++otp_length = 0 ++template = "" ++max_frequency = "0s" + [mfa.web_authn] + enroll_enabled = false + verify_enabled = false diff --git a/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff b/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff new file mode 100644 index 000000000..2e44496fd --- /dev/null +++ b/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff @@ -0,0 +1,12 @@ +diff remote[auth] local[auth] +--- remote[auth] ++++ local[auth] +@@ -58,7 +58,7 @@ + otp_expiry = 0 + + [sms] +-enable_signup = false ++enable_signup = true + enable_confirmations = false + template = "" + max_frequency = "0s" diff --git a/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff b/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff new file mode 100644 index 000000000..a173a8adf --- /dev/null +++ b/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff @@ -0,0 +1,31 @@ +diff remote[auth] local[auth] +--- remote[auth] ++++ local[auth] +@@ -58,12 +58,12 @@ + otp_expiry = 0 + + [sms] +-enable_signup = true +-enable_confirmations = true +-template = "Your code is {{ .Code }}" +-max_frequency = "1m0s" ++enable_signup = false ++enable_confirmations = false ++template = "" ++max_frequency = "0s" + [sms.twilio] +-enabled = true ++enabled = false + account_sid = "" + message_service_sid = "" + auth_token = "" +@@ -85,9 +85,6 @@ + from = "" + api_key = "" + api_secret = "" +-[sms.test_otp] +-123 = "456" +-456 = "123" + + [third_party] + [third_party.firebase] diff --git a/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff new file mode 100644 index 000000000..f9ee1d7f0 --- /dev/null +++ b/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff @@ -0,0 +1,43 @@ +diff remote[auth] local[auth] +--- remote[auth] ++++ local[auth] +@@ -58,12 +58,12 @@ + otp_expiry = 0 + + [sms] +-enable_signup = false +-enable_confirmations = false +-template = "" +-max_frequency = "0s" ++enable_signup = true ++enable_confirmations = true ++template = "Your code is {{ .Code }}" ++max_frequency = "1m0s" + [sms.twilio] +-enabled = true ++enabled = false + account_sid = "" + message_service_sid = "" + auth_token = "" +@@ -73,9 +73,9 @@ + message_service_sid = "" + auth_token = "" + [sms.messagebird] +-enabled = false +-originator = "" +-access_key = "hash:" ++enabled = true ++originator = "test-originator" ++access_key = "hash:ab60d03fc809fb02dae838582f3ddc13d1d6cb32ffba77c4b969dd3caa496f13" + [sms.textlocal] + enabled = false + sender = "" +@@ -85,6 +85,8 @@ + from = "" + api_key = "" + api_secret = "" ++[sms.test_otp] ++123 = "456" + + [third_party] + [third_party.firebase] From b8e94ed4f1d99d98f9d6719250745a1b4d9890ab Mon Sep 17 00:00:00 2001 From: Lakshan Perera Date: Wed, 13 Nov 2024 19:26:07 +1100 Subject: [PATCH 165/305] fix: do not abort function reqs after 200s --- internal/functions/serve/templates/main.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/internal/functions/serve/templates/main.ts b/internal/functions/serve/templates/main.ts index e94b183ac..154cd1a11 100644 --- a/internal/functions/serve/templates/main.ts +++ b/internal/functions/serve/templates/main.ts @@ -187,14 +187,7 @@ Deno.serve({ maybeEntrypoint }); - const controller = new AbortController(); - const { signal } = controller; - - // Note: Requests are aborted after 200s (same config as in production) - // TODO: make this configuarable - setTimeout(() => controller.abort(), 200 * 1000); - - return await worker.fetch(req, { signal }); + return await worker.fetch(req); } catch (e) { console.error(e); From bc420764e895ad6b9078445c6cfb2e80583f965b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Thu, 14 Nov 2024 15:18:41 +0900 Subject: [PATCH 166/305] fix: bump edge-runtime to 1.62.2 (#2880) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index a66a4a90a..452ba6c53 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241106-f29003e" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.62.1" + edgeRuntimeImage = "supabase/edge-runtime:v1.62.2" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.163.2" From 65d8be4ca1b10c3f89cfd67cd836836f965b3729 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Thu, 14 Nov 2024 14:22:06 +0800 Subject: [PATCH 167/305] fix: use base config when no remote is declared (#2882) --- internal/config/push/push.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/config/push/push.go b/internal/config/push/push.go index 0a8c88c4e..a4c901473 100644 --- a/internal/config/push/push.go +++ b/internal/config/push/push.go @@ -15,8 +15,12 @@ func Run(ctx context.Context, ref string, fsys afero.Fs) error { return err } client := config.NewConfigUpdater(*utils.GetSupabase()) - fmt.Fprintln(os.Stderr, "Pushing config to project:", ref) - remote, _ := utils.Config.GetRemoteByProjectRef(ref) + remote, err := utils.Config.GetRemoteByProjectRef(ref) + if err != nil { + // Use base config when no remote is declared + remote.ProjectId = ref + } + fmt.Fprintln(os.Stderr, "Pushing config to project:", remote.ProjectId) console := utils.NewConsole() keep := func(name string) bool { title := fmt.Sprintf("Do you want to push %s config to remote?", name) From ccf52ad7ebf8750431dbd5b0c07adc14904942db Mon Sep 17 00:00:00 2001 From: Lakshan Perera Date: Thu, 14 Nov 2024 19:46:10 +1100 Subject: [PATCH 168/305] fix: enable readFileSyncAPI in user workers --- internal/functions/serve/templates/main.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/functions/serve/templates/main.ts b/internal/functions/serve/templates/main.ts index 154cd1a11..87a0c5498 100644 --- a/internal/functions/serve/templates/main.ts +++ b/internal/functions/serve/templates/main.ts @@ -184,7 +184,10 @@ Deno.serve({ cpuTimeSoftLimitMs, cpuTimeHardLimitMs, decoratorType, - maybeEntrypoint + maybeEntrypoint, + context: { + useReadSyncFileAPI: true, + }, }); return await worker.fetch(req); From 1ab41c079db8592bafed03b629024a9c7b82a8c3 Mon Sep 17 00:00:00 2001 From: Lakshan Perera Date: Fri, 15 Nov 2024 13:29:54 +1100 Subject: [PATCH 169/305] fix: match edge function error codes to hosted platform --- internal/functions/serve/templates/main.ts | 35 +++++++++++++--------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/internal/functions/serve/templates/main.ts b/internal/functions/serve/templates/main.ts index 87a0c5498..03d4bc9a1 100644 --- a/internal/functions/serve/templates/main.ts +++ b/internal/functions/serve/templates/main.ts @@ -1,28 +1,30 @@ -import { - STATUS_CODE, - STATUS_TEXT, -} from "https://deno.land/std/http/status.ts"; +import { STATUS_CODE, STATUS_TEXT } from "https://deno.land/std/http/status.ts"; import * as posix from "https://deno.land/std/path/posix/mod.ts"; import * as jose from "https://deno.land/x/jose@v4.13.1/index.ts"; const SB_SPECIFIC_ERROR_CODE = { - BootError: STATUS_CODE.ServiceUnavailable, /** Service Unavailable (RFC 7231, 6.6.4) */ - WorkerRequestCancelled: STATUS_CODE.BadGateway, /** Bad Gateway (RFC 7231, 6.6.3) */ + BootError: + STATUS_CODE.ServiceUnavailable, /** Service Unavailable (RFC 7231, 6.6.4) */ + InvalidWorkerResponse: + STATUS_CODE.InternalServerError, /** Internal Server Error (RFC 7231, 6.6.1) */ WorkerLimit: 546, /** Extended */ }; const SB_SPECIFIC_ERROR_TEXT = { [SB_SPECIFIC_ERROR_CODE.BootError]: "BOOT_ERROR", - [SB_SPECIFIC_ERROR_CODE.WorkerRequestCancelled]: "WORKER_REQUEST_CANCELLED", + [SB_SPECIFIC_ERROR_CODE.InvalidWorkerResponse]: "WORKER_ERROR", [SB_SPECIFIC_ERROR_CODE.WorkerLimit]: "WORKER_LIMIT", }; const SB_SPECIFIC_ERROR_REASON = { - [SB_SPECIFIC_ERROR_CODE.BootError]: "Worker failed to boot (please check logs)", - [SB_SPECIFIC_ERROR_CODE.WorkerRequestCancelled]: "Request cancelled by the proxy due to an error or resource limit of worker (please check logs)", - [SB_SPECIFIC_ERROR_CODE.WorkerLimit]: "Worker failed to respond due to an error or resource limit (please check logs)", -} + [SB_SPECIFIC_ERROR_CODE.BootError]: + "Worker failed to boot (please check logs)", + [SB_SPECIFIC_ERROR_CODE.InvalidWorkerResponse]: + "Function exited due to an error (please check logs)", + [SB_SPECIFIC_ERROR_CODE.WorkerLimit]: + "Worker failed to respond due to a resource limit (please check logs)", +}; // OS stuff - we don't want to expose these to the functions. const EXCLUDED_ENVS = ["HOME", "HOSTNAME", "PATH", "PWD"]; @@ -34,12 +36,17 @@ const FUNCTIONS_CONFIG_STRING = Deno.env.get( "SUPABASE_INTERNAL_FUNCTIONS_CONFIG", )!; -const WALLCLOCK_LIMIT_SEC = parseInt(Deno.env.get("SUPABASE_INTERNAL_WALLCLOCK_LIMIT_SEC")); +const WALLCLOCK_LIMIT_SEC = parseInt( + Deno.env.get("SUPABASE_INTERNAL_WALLCLOCK_LIMIT_SEC"), +); const DENO_SB_ERROR_MAP = new Map([ [Deno.errors.InvalidWorkerCreation, SB_SPECIFIC_ERROR_CODE.BootError], - [Deno.errors.InvalidWorkerResponse, SB_SPECIFIC_ERROR_CODE.WorkerLimit], - [Deno.errors.WorkerRequestCancelled, SB_SPECIFIC_ERROR_CODE.WorkerRequestCancelled], + [Deno.errors.InvalidWorkerResponse, SB_SPECIFIC_ERROR_CODE.InvalidWorkerResponse], + [ + Deno.errors.WorkerRequestCancelled, + SB_SPECIFIC_ERROR_CODE.WorkerLimit, + ], ]); interface FunctionConfig { From 0da79bdc29ee7b9da2ad6400e4caefad94cb8ee3 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Fri, 15 Nov 2024 17:37:23 +0800 Subject: [PATCH 170/305] fix: increment auth version to v2.164.0 (#2890) Co-authored-by: Joel Lee --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 452ba6c53..670450d5a 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -15,7 +15,7 @@ const ( edgeRuntimeImage = "supabase/edge-runtime:v1.62.2" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" - gotrueImage = "supabase/gotrue:v2.163.2" + gotrueImage = "supabase/gotrue:v2.164.0" realtimeImage = "supabase/realtime:v2.30.34" storageImage = "supabase/storage-api:v1.11.13" logflareImage = "supabase/logflare:1.4.0" From c9b95b4044e052e6c97616d2583e6db565026ea3 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Fri, 15 Nov 2024 18:54:26 +0800 Subject: [PATCH 171/305] fix: remove unnecessary cancel context --- cmd/config.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/cmd/config.go b/cmd/config.go index d73daa546..1d0f60733 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -1,9 +1,6 @@ package cmd import ( - "os" - "os/signal" - "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/supabase/cli/internal/config/push" @@ -15,11 +12,6 @@ var ( GroupID: groupManagementAPI, Use: "config", Short: "Manage Supabase project configurations", - PersistentPreRunE: func(cmd *cobra.Command, args []string) error { - ctx, _ := signal.NotifyContext(cmd.Context(), os.Interrupt) - cmd.SetContext(ctx) - return cmd.Root().PersistentPreRunE(cmd, args) - }, } configPushCmd = &cobra.Command{ From e1f3fb4dac35ba7a1ee9c787299312c06ccacdfa Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Fri, 15 Nov 2024 18:55:36 +0800 Subject: [PATCH 172/305] chore: separate workflow to update npm tag --- .github/workflows/mirror.yml | 4 ---- .github/workflows/release.yml | 15 ++++----------- .github/workflows/tag-npm.yml | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/tag-npm.yml diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml index 85050a7c5..0eb46d868 100644 --- a/.github/workflows/mirror.yml +++ b/.github/workflows/mirror.yml @@ -17,10 +17,6 @@ on: pull_request_review: types: - submitted - paths: - - ".github/workflows/mirror.yml" - - "internal/utils/misc.go" - - "tools/listdep/**" workflow_dispatch: jobs: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 90719b102..8ef8b4383 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,17 +40,10 @@ jobs: name: Publish NPM needs: - settings - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: "16.x" - registry-url: "https://registry.npmjs.org" - - run: npm dist-tag add "supabase@${RELEASE_TAG#v}" latest - env: - RELEASE_TAG: ${{ needs.settings.outputs.release_tag }} - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + uses: ./.github/workflows/tag-npm.yml + with: + release: ${{ needs.settings.outputs.release_tag }} + secrets: inherit compose: name: Bump self-hosted versions diff --git a/.github/workflows/tag-npm.yml b/.github/workflows/tag-npm.yml new file mode 100644 index 000000000..9eda44cba --- /dev/null +++ b/.github/workflows/tag-npm.yml @@ -0,0 +1,29 @@ +name: Tag NPM + +on: + workflow_call: + inputs: + release: + required: true + type: string + workflow_dispatch: + inputs: + release: + description: "v1.0.0" + required: true + type: string + +jobs: + tag: + name: Move latest tag + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: "16.x" + registry-url: "https://registry.npmjs.org" + - run: npm dist-tag add "supabase@${RELEASE_TAG#v}" latest + env: + RELEASE_TAG: ${{ inputs.release }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} From 2dad0bf2d0984aeaf64b37cc6534760c8d42a4a3 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Fri, 15 Nov 2024 19:06:18 +0800 Subject: [PATCH 173/305] chore: block deploy requests from non-develop branch --- .github/workflows/deploy-check.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/deploy-check.yml diff --git a/.github/workflows/deploy-check.yml b/.github/workflows/deploy-check.yml new file mode 100644 index 000000000..44c2806ec --- /dev/null +++ b/.github/workflows/deploy-check.yml @@ -0,0 +1,20 @@ +name: Check Deploy + +on: + pull_request_target: + types: + - opened + - reopened + - synchronize + - edited + branches: + - main + +jobs: + check: + if: github.head_ref != 'develop' + runs-on: ubuntu-latest + steps: + - run: | + echo "Pull requests to main branch are only allowed from develop branch." + exit 1 From 91eabb13a218fa9c9af13bc1732872358cf3b2d0 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Sat, 16 Nov 2024 15:48:07 +0800 Subject: [PATCH 174/305] fix: drop webhooks request history on remote reset (#2892) --- pkg/migration/queries/drop.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/migration/queries/drop.sql b/pkg/migration/queries/drop.sql index 14d1803e2..ae2332524 100644 --- a/pkg/migration/queries/drop.sql +++ b/pkg/migration/queries/drop.sql @@ -33,12 +33,13 @@ begin execute format('drop table if exists %I.%I cascade', rec.relnamespace::regnamespace::name, rec.relname); end loop; - -- truncate tables in auth and migrations schema + -- truncate tables in auth, webhooks, and migrations schema for rec in select * from pg_class c where (c.relnamespace::regnamespace::name = 'auth' and c.relname != 'schema_migrations' + or c.relnamespace::regnamespace::name = 'supabase_functions' and c.relname != 'migrations' or c.relnamespace::regnamespace::name = 'supabase_migrations') and c.relkind = 'r' loop From f4b5ad471c28286545f74f1ee2b5926a0fa06eb8 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sat, 16 Nov 2024 18:09:12 +0800 Subject: [PATCH 175/305] feat: diff auth and storage config on link --- internal/link/link.go | 91 ++++++++++++++++++++++++------------------- pkg/config/api.go | 4 +- pkg/config/auth.go | 8 ++-- pkg/config/db.go | 4 +- pkg/config/storage.go | 4 +- 5 files changed, 62 insertions(+), 49 deletions(-) diff --git a/internal/link/link.go b/internal/link/link.go index 9d72302c4..b81f2a5d7 100644 --- a/internal/link/link.go +++ b/internal/link/link.go @@ -6,7 +6,6 @@ import ( "net/http" "os" "strconv" - "strings" "sync" "github.com/go-errors/errors" @@ -26,10 +25,9 @@ import ( ) func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { - original, err := cliConfig.ToTomlBytes(map[string]interface{}{ - "api": utils.Config.Api, - "db": utils.Config.Db, - }) + copy := utils.Config.Clone() + copy.Auth.HashSecrets(projectRef) + original, err := cliConfig.ToTomlBytes(copy) if err != nil { fmt.Fprintln(utils.GetDebugLogger(), err) } @@ -64,10 +62,7 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func( fmt.Fprintln(os.Stdout, "Finished "+utils.Aqua("supabase link")+".") // 4. Suggest config update - updated, err := cliConfig.ToTomlBytes(map[string]interface{}{ - "api": utils.Config.Api, - "db": utils.Config.Db, - }) + updated, err := cliConfig.ToTomlBytes(utils.Config.Clone()) if err != nil { fmt.Fprintln(utils.GetDebugLogger(), err) } @@ -82,10 +77,10 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func( func LinkServices(ctx context.Context, projectRef, anonKey string, fsys afero.Fs) { // Ignore non-fatal errors linking services var wg sync.WaitGroup - wg.Add(6) + wg.Add(8) go func() { defer wg.Done() - if err := linkDatabaseVersion(ctx, projectRef, fsys); err != nil && viper.GetBool("DEBUG") { + if err := linkDatabaseSettings(ctx, projectRef); err != nil && viper.GetBool("DEBUG") { fmt.Fprintln(os.Stderr, err) } }() @@ -95,6 +90,18 @@ func LinkServices(ctx context.Context, projectRef, anonKey string, fsys afero.Fs fmt.Fprintln(os.Stderr, err) } }() + go func() { + defer wg.Done() + if err := linkGotrue(ctx, projectRef); err != nil && viper.GetBool("DEBUG") { + fmt.Fprintln(os.Stderr, err) + } + }() + go func() { + defer wg.Done() + if err := linkStorage(ctx, projectRef); err != nil && viper.GetBool("DEBUG") { + fmt.Fprintln(os.Stderr, err) + } + }() go func() { defer wg.Done() if err := linkPooler(ctx, projectRef, fsys); err != nil && viper.GetBool("DEBUG") { @@ -126,12 +133,11 @@ func LinkServices(ctx context.Context, projectRef, anonKey string, fsys afero.Fs func linkPostgrest(ctx context.Context, projectRef string) error { resp, err := utils.GetSupabase().V1GetPostgrestServiceConfigWithResponse(ctx, projectRef) if err != nil { - return errors.Errorf("failed to get postgrest config: %w", err) - } - if resp.JSON200 == nil { - return errors.Errorf("%w: %s", tenant.ErrAuthToken, string(resp.Body)) + return errors.Errorf("failed to read API config: %w", err) + } else if resp.JSON200 == nil { + return errors.Errorf("unexpected API config status %d: %s", resp.StatusCode(), string(resp.Body)) } - updateApiConfig(*resp.JSON200) + utils.Config.Api.FromRemoteApiConfig(*resp.JSON200) return nil } @@ -143,22 +149,15 @@ func linkPostgrestVersion(ctx context.Context, api tenant.TenantAPI, fsys afero. return utils.WriteFile(utils.RestVersionPath, []byte(version), fsys) } -func updateApiConfig(config api.PostgrestConfigWithJWTSecretResponse) { - utils.Config.Api.MaxRows = cast.IntToUint(config.MaxRows) - utils.Config.Api.ExtraSearchPath = readCsv(config.DbExtraSearchPath) - utils.Config.Api.Schemas = readCsv(config.DbSchema) -} - -func readCsv(line string) []string { - var result []string - tokens := strings.Split(line, ",") - for _, t := range tokens { - trimmed := strings.TrimSpace(t) - if len(trimmed) > 0 { - result = append(result, trimmed) - } +func linkGotrue(ctx context.Context, projectRef string) error { + resp, err := utils.GetSupabase().V1GetAuthServiceConfigWithResponse(ctx, projectRef) + if err != nil { + return errors.Errorf("failed to read Auth config: %w", err) + } else if resp.JSON200 == nil { + return errors.Errorf("unexpected Auth config status %d: %s", resp.StatusCode(), string(resp.Body)) } - return result + utils.Config.Auth.FromRemoteAuthConfig(*resp.JSON200) + return nil } func linkGotrueVersion(ctx context.Context, api tenant.TenantAPI, fsys afero.Fs) error { @@ -169,6 +168,17 @@ func linkGotrueVersion(ctx context.Context, api tenant.TenantAPI, fsys afero.Fs) return utils.WriteFile(utils.GotrueVersionPath, []byte(version), fsys) } +func linkStorage(ctx context.Context, projectRef string) error { + resp, err := utils.GetSupabase().V1GetStorageConfigWithResponse(ctx, projectRef) + if err != nil { + return errors.Errorf("failed to read Storage config: %w", err) + } else if resp.JSON200 == nil { + return errors.Errorf("unexpected Storage config status %d: %s", resp.StatusCode(), string(resp.Body)) + } + utils.Config.Storage.FromRemoteStorageConfig(*resp.JSON200) + return nil +} + func linkStorageVersion(ctx context.Context, api tenant.TenantAPI, fsys afero.Fs) error { version, err := api.GetStorageVersion(ctx) if err != nil { @@ -177,6 +187,17 @@ func linkStorageVersion(ctx context.Context, api tenant.TenantAPI, fsys afero.Fs return utils.WriteFile(utils.StorageVersionPath, []byte(version), fsys) } +func linkDatabaseSettings(ctx context.Context, projectRef string) error { + resp, err := utils.GetSupabase().V1GetPostgresConfigWithResponse(ctx, projectRef) + if err != nil { + return errors.Errorf("failed to read DB config: %w", err) + } else if resp.JSON200 == nil { + return errors.Errorf("unexpected DB config status %d: %s", resp.StatusCode(), string(resp.Body)) + } + utils.Config.Db.Settings.FromRemotePostgresConfig(*resp.JSON200) + return nil +} + func linkDatabase(ctx context.Context, config pgconn.Config, options ...func(*pgx.ConnConfig)) error { conn, err := utils.ConnectByConfig(ctx, config, options...) if err != nil { @@ -191,14 +212,6 @@ func linkDatabase(ctx context.Context, config pgconn.Config, options ...func(*pg return migration.CreateSeedTable(ctx, conn) } -func linkDatabaseVersion(ctx context.Context, projectRef string, fsys afero.Fs) error { - version, err := tenant.GetDatabaseVersion(ctx, projectRef) - if err != nil { - return err - } - return utils.WriteFile(utils.PostgresVersionPath, []byte(version), fsys) -} - func updatePostgresConfig(conn *pgx.Conn) { serverVersion := conn.PgConn().ParameterStatus("server_version") // Safe to assume that supported Postgres version is 10.0 <= n < 100.0 diff --git a/pkg/config/api.go b/pkg/config/api.go index 405bcb7bd..ec7c4f86d 100644 --- a/pkg/config/api.go +++ b/pkg/config/api.go @@ -55,7 +55,7 @@ func (a *api) ToUpdatePostgrestConfigBody() v1API.UpdatePostgrestConfigBody { return body } -func (a *api) fromRemoteApiConfig(remoteConfig v1API.PostgrestConfigWithJWTSecretResponse) { +func (a *api) FromRemoteApiConfig(remoteConfig v1API.PostgrestConfigWithJWTSecretResponse) { if a.Enabled = len(remoteConfig.DbSchema) > 0; !a.Enabled { return } @@ -84,7 +84,7 @@ func (a *api) DiffWithRemote(remoteConfig v1API.PostgrestConfigWithJWTSecretResp if err != nil { return nil, err } - copy.fromRemoteApiConfig(remoteConfig) + copy.FromRemoteApiConfig(remoteConfig) remoteCompare, err := ToTomlBytes(copy) if err != nil { return nil, err diff --git a/pkg/config/auth.go b/pkg/config/auth.go index a2ea016f2..e78092bde 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -202,7 +202,7 @@ func (a *auth) ToUpdateAuthConfigBody() v1API.UpdateAuthConfigBody { return body } -func (a *auth) fromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) { +func (a *auth) FromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) { a.SiteUrl = cast.Val(remoteConfig.SiteUrl, "") a.AdditionalRedirectUrls = strToArr(cast.Val(remoteConfig.UriAllowList, "")) a.JwtExpiry = cast.IntToUint(cast.Val(remoteConfig.JwtExp, 0)) @@ -775,13 +775,13 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { func (a *auth) DiffWithRemote(projectRef string, remoteConfig v1API.AuthConfigResponse) ([]byte, error) { copy := a.Clone() - copy.hashSecrets(projectRef) + copy.HashSecrets(projectRef) // Convert the config values into easily comparable remoteConfig values currentValue, err := ToTomlBytes(copy) if err != nil { return nil, err } - copy.fromRemoteAuthConfig(remoteConfig) + copy.FromRemoteAuthConfig(remoteConfig) remoteCompare, err := ToTomlBytes(copy) if err != nil { return nil, err @@ -791,7 +791,7 @@ func (a *auth) DiffWithRemote(projectRef string, remoteConfig v1API.AuthConfigRe const hashPrefix = "hash:" -func (a *auth) hashSecrets(key string) { +func (a *auth) HashSecrets(key string) { hash := func(v string) string { return hashPrefix + sha256Hmac(key, v) } diff --git a/pkg/config/db.go b/pkg/config/db.go index 4e22dd53f..2a1d31cad 100644 --- a/pkg/config/db.go +++ b/pkg/config/db.go @@ -112,7 +112,7 @@ func (a *settings) ToUpdatePostgresConfigBody() v1API.UpdatePostgresConfigBody { return body } -func (a *settings) fromRemoteConfig(remoteConfig v1API.PostgresConfigResponse) { +func (a *settings) FromRemotePostgresConfig(remoteConfig v1API.PostgresConfigResponse) { a.EffectiveCacheSize = remoteConfig.EffectiveCacheSize a.LogicalDecodingWorkMem = remoteConfig.LogicalDecodingWorkMem a.MaintenanceWorkMem = remoteConfig.MaintenanceWorkMem @@ -155,7 +155,7 @@ func (a *settings) DiffWithRemote(remoteConfig v1API.PostgresConfigResponse) ([] if err != nil { return nil, err } - copy.fromRemoteConfig(remoteConfig) + copy.FromRemotePostgresConfig(remoteConfig) remoteCompare, err := ToTomlBytes(copy) if err != nil { return nil, err diff --git a/pkg/config/storage.go b/pkg/config/storage.go index 3398dee42..b11b28a10 100644 --- a/pkg/config/storage.go +++ b/pkg/config/storage.go @@ -44,7 +44,7 @@ func (s *storage) ToUpdateStorageConfigBody() v1API.UpdateStorageConfigBody { return body } -func (s *storage) fromRemoteStorageConfig(remoteConfig v1API.StorageConfigResponse) { +func (s *storage) FromRemoteStorageConfig(remoteConfig v1API.StorageConfigResponse) { s.FileSizeLimit = sizeInBytes(remoteConfig.FileSizeLimit) s.ImageTransformation.Enabled = remoteConfig.Features.ImageTransformation.Enabled } @@ -56,7 +56,7 @@ func (s *storage) DiffWithRemote(remoteConfig v1API.StorageConfigResponse) ([]by if err != nil { return nil, err } - copy.fromRemoteStorageConfig(remoteConfig) + copy.FromRemoteStorageConfig(remoteConfig) remoteCompare, err := ToTomlBytes(copy) if err != nil { return nil, err From 652c0cf473f792353dedde16d3e86ce547fae1e1 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sat, 16 Nov 2024 18:12:21 +0800 Subject: [PATCH 176/305] fix: update postgres image if linked project is healthy --- internal/link/link.go | 8 ++- internal/link/link_test.go | 108 ++++++++++++++++++++++++++++--------- 2 files changed, 88 insertions(+), 28 deletions(-) diff --git a/internal/link/link.go b/internal/link/link.go index b81f2a5d7..12fa59ca1 100644 --- a/internal/link/link.go +++ b/internal/link/link.go @@ -32,7 +32,7 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func( fmt.Fprintln(utils.GetDebugLogger(), err) } - if err := checkRemoteProjectStatus(ctx, projectRef); err != nil { + if err := checkRemoteProjectStatus(ctx, projectRef, fsys); err != nil { return err } @@ -254,7 +254,7 @@ func updatePoolerConfig(config api.SupavisorConfigResponse) { var errProjectPaused = errors.New("project is paused") -func checkRemoteProjectStatus(ctx context.Context, projectRef string) error { +func checkRemoteProjectStatus(ctx context.Context, projectRef string, fsys afero.Fs) error { resp, err := utils.GetSupabase().V1GetProjectWithResponse(ctx, projectRef) if err != nil { return errors.Errorf("failed to retrieve remote project status: %w", err) @@ -279,5 +279,9 @@ func checkRemoteProjectStatus(ctx context.Context, projectRef string) error { fmt.Fprintf(os.Stderr, "%s: Project status is %s instead of Active Healthy. Some operations might fail.\n", utils.Yellow("WARNING"), resp.JSON200.Status) } + // Update postgres image version to match the remote project + if version := resp.JSON200.Database.Version; len(version) > 0 { + return utils.WriteFile(utils.PostgresVersionPath, []byte(version), fsys) + } return nil } diff --git a/internal/link/link_test.go b/internal/link/link_test.go index c8a867f6b..28282da4f 100644 --- a/internal/link/link_test.go +++ b/internal/link/link_test.go @@ -51,19 +51,38 @@ func TestLinkCommand(t *testing.T) { // Flush pending mocks after test execution defer gock.OffAll() // Mock project status + postgres := api.V1DatabaseResponse{ + Host: utils.GetSupabaseDbHost(project), + Version: "15.1.0.117", + } gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project). Reply(200). - JSON(api.V1ProjectResponse{Status: api.V1ProjectResponseStatusACTIVEHEALTHY}) + JSON(api.V1ProjectResponse{ + Status: api.V1ProjectResponseStatusACTIVEHEALTHY, + Database: &postgres, + }) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/api-keys"). Reply(200). JSON([]api.ApiKeyResponse{{Name: "anon", ApiKey: "anon-key"}}) // Link configs + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project + "/config/database/postgres"). + Reply(200). + JSON(api.PostgresConfigResponse{}) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/postgrest"). Reply(200). JSON(api.V1PostgrestConfigResponse{}) + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project + "/config/auth"). + Reply(200). + JSON(api.AuthConfigResponse{}) + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project + "/config/storage"). + Reply(200). + JSON(api.StorageConfigResponse{}) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/config/database/pooler"). Reply(200). @@ -83,23 +102,6 @@ func TestLinkCommand(t *testing.T) { Get("/storage/v1/version"). Reply(200). BodyString("0.40.4") - postgres := api.V1DatabaseResponse{ - Host: utils.GetSupabaseDbHost(project), - Version: "15.1.0.117", - } - gock.New(utils.DefaultApiHost). - Get("/v1/projects"). - Reply(200). - JSON([]api.V1ProjectResponse{ - { - Id: project, - Database: &postgres, - OrganizationId: "combined-fuchsia-lion", - Name: "Test Project", - Region: "us-west-1", - CreatedAt: "2022-04-25T02:14:55.906498Z", - }, - }) // Run test err := Run(context.Background(), project, fsys, conn.Intercept) // Check error @@ -130,15 +132,27 @@ func TestLinkCommand(t *testing.T) { gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project). Reply(200). - JSON(api.V1ProjectResponse{Status: api.V1ProjectResponseStatusACTIVEHEALTHY}) + JSON(api.V1ProjectResponse{ + Status: api.V1ProjectResponseStatusACTIVEHEALTHY, + Database: &api.V1DatabaseResponse{}, + }) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/api-keys"). Reply(200). JSON([]api.ApiKeyResponse{{Name: "anon", ApiKey: "anon-key"}}) // Link configs + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project + "/config/database/postgres"). + ReplyError(errors.New("network error")) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/postgrest"). ReplyError(errors.New("network error")) + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project + "/config/auth"). + ReplyError(errors.New("network error")) + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project + "/config/storage"). + ReplyError(errors.New("network error")) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/config/database/pooler"). ReplyError(errors.New("network error")) @@ -152,9 +166,6 @@ func TestLinkCommand(t *testing.T) { gock.New("https://" + utils.GetSupabaseHost(project)). Get("/storage/v1/version"). ReplyError(errors.New("network error")) - gock.New(utils.DefaultApiHost). - Get("/v1/projects"). - ReplyError(errors.New("network error")) // Run test err := Run(context.Background(), project, fsys, func(cc *pgx.ConnConfig) { cc.LookupFunc = func(ctx context.Context, host string) (addrs []string, err error) { @@ -175,15 +186,27 @@ func TestLinkCommand(t *testing.T) { gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project). Reply(200). - JSON(api.V1ProjectResponse{Status: api.V1ProjectResponseStatusACTIVEHEALTHY}) + JSON(api.V1ProjectResponse{ + Status: api.V1ProjectResponseStatusACTIVEHEALTHY, + Database: &api.V1DatabaseResponse{}, + }) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/api-keys"). Reply(200). JSON([]api.ApiKeyResponse{{Name: "anon", ApiKey: "anon-key"}}) // Link configs + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project + "/config/database/postgres"). + ReplyError(errors.New("network error")) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/postgrest"). ReplyError(errors.New("network error")) + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project + "/config/auth"). + ReplyError(errors.New("network error")) + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project + "/config/storage"). + ReplyError(errors.New("network error")) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/config/database/pooler"). ReplyError(errors.New("network error")) @@ -215,7 +238,32 @@ func TestLinkCommand(t *testing.T) { func TestStatusCheck(t *testing.T) { project := "test-project" + t.Run("updates postgres version when healthy", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewMemMapFs() + // Flush pending mocks after test execution + defer gock.OffAll() + // Mock project status + gock.New(utils.DefaultApiHost). + Get("/v1/projects/" + project). + Reply(http.StatusOK). + JSON(api.V1ProjectResponse{ + Status: api.V1ProjectResponseStatusACTIVEHEALTHY, + Database: &api.V1DatabaseResponse{Version: "15.6.1.139"}, + }) + // Run test + err := checkRemoteProjectStatus(context.Background(), project, fsys) + // Check error + assert.NoError(t, err) + version, err := afero.ReadFile(fsys, utils.PostgresVersionPath) + assert.NoError(t, err) + assert.Equal(t, "15.6.1.139", string(version)) + assert.Empty(t, apitest.ListUnmatchedRequests()) + }) + t.Run("ignores project not found", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewMemMapFs() // Flush pending mocks after test execution defer gock.OffAll() // Mock project status @@ -223,13 +271,18 @@ func TestStatusCheck(t *testing.T) { Get("/v1/projects/" + project). Reply(http.StatusNotFound) // Run test - err := checkRemoteProjectStatus(context.Background(), project) + err := checkRemoteProjectStatus(context.Background(), project, fsys) // Check error assert.NoError(t, err) + exists, err := afero.Exists(fsys, utils.PostgresVersionPath) + assert.NoError(t, err) + assert.False(t, exists) assert.Empty(t, apitest.ListUnmatchedRequests()) }) t.Run("throws error on project inactive", func(t *testing.T) { + // Setup in-memory fs + fsys := afero.NewMemMapFs() // Flush pending mocks after test execution defer gock.OffAll() // Mock project status @@ -238,9 +291,12 @@ func TestStatusCheck(t *testing.T) { Reply(http.StatusOK). JSON(api.V1ProjectResponse{Status: api.V1ProjectResponseStatusINACTIVE}) // Run test - err := checkRemoteProjectStatus(context.Background(), project) + err := checkRemoteProjectStatus(context.Background(), project, fsys) // Check error assert.ErrorIs(t, err, errProjectPaused) + exists, err := afero.Exists(fsys, utils.PostgresVersionPath) + assert.NoError(t, err) + assert.False(t, exists) assert.Empty(t, apitest.ListUnmatchedRequests()) }) } @@ -309,7 +365,7 @@ func TestLinkPostgrest(t *testing.T) { // Run test err := linkPostgrest(context.Background(), project) // Validate api - assert.ErrorIs(t, err, tenant.ErrAuthToken) + assert.ErrorContains(t, err, `unexpected API config status 500: {"message":"unavailable"}`) assert.Empty(t, apitest.ListUnmatchedRequests()) }) } From 8dbf6b2750ad34f3645f1dbc19fdab0afc905da8 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Tue, 19 Nov 2024 13:33:37 +0800 Subject: [PATCH 177/305] chore: adjust default sms template to match platform --- pkg/config/templates/config.toml | 2 +- pkg/config/testdata/config.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index 43854f7d6..979e4bdfd 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -146,7 +146,7 @@ enable_signup = false # If enabled, users need to confirm their phone number before signing in. enable_confirmations = false # Template for sending OTP to users -template = "Your code is {{ `{{ .Code }}` }} ." +template = "Your code is {{ `{{ .Code }}` }}" # Controls the minimum amount of time that must pass before sending another sms otp. max_frequency = "5s" diff --git a/pkg/config/testdata/config.toml b/pkg/config/testdata/config.toml index 9aba86c3d..a97042954 100644 --- a/pkg/config/testdata/config.toml +++ b/pkg/config/testdata/config.toml @@ -142,7 +142,7 @@ enable_signup = true # If enabled, users need to confirm their phone number before signing in. enable_confirmations = false # Template for sending OTP to users -template = "Your code is {{ `{{ .Code }}` }} ." +template = "Your code is {{ `{{ .Code }}` }}" # Controls the minimum amount of time that must pass before sending another sms otp. max_frequency = "5s" From 47bcb30b4bad92c340250586f8f35f3c705bdbee Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Mon, 25 Nov 2024 03:12:33 +0100 Subject: [PATCH 178/305] chore: update api/beta.yaml from staging v1-yaml (#2906) * chore: update api/beta.yaml from staging v1-yaml * chore: revert to single quote --------- Co-authored-by: Qiao Han --- api/beta.yaml | 233 ++++++++++++++--- cmd/projects.go | 30 +-- internal/bootstrap/bootstrap.go | 2 +- internal/link/link.go | 4 +- internal/link/link_test.go | 26 +- internal/projects/apiKeys/api_keys.go | 2 +- internal/projects/create/create.go | 8 +- internal/projects/create/create_test.go | 4 +- internal/projects/list/list.go | 8 +- internal/utils/tenant/client.go | 2 +- pkg/api/client.gen.go | 334 ++++++++++++++++++++---- pkg/api/types.gen.go | 311 +++++++++++++++------- 12 files changed, 731 insertions(+), 233 deletions(-) diff --git a/api/beta.yaml b/api/beta.yaml index 257a46e84..cd6c20a15 100644 --- a/api/beta.yaml +++ b/api/beta.yaml @@ -118,7 +118,7 @@ paths: schema: type: array items: - $ref: '#/components/schemas/V1ProjectResponse' + $ref: '#/components/schemas/V1ProjectWithDatabaseResponse' tags: - Projects security: @@ -132,7 +132,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/V1CreateProjectBody' + $ref: '#/components/schemas/V1CreateProjectBodyDto' responses: '201': description: '' @@ -174,7 +174,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/CreateOrganizationBodyV1' + $ref: '#/components/schemas/CreateOrganizationV1Dto' responses: '201': description: '' @@ -331,6 +331,11 @@ paths: minLength: 20 maxLength: 20 type: string + - name: reveal + required: true + in: query + schema: + type: boolean responses: '200': description: '' @@ -356,6 +361,11 @@ paths: minLength: 20 maxLength: 20 type: string + - name: reveal + required: true + in: query + schema: + type: boolean requestBody: required: true content: @@ -391,6 +401,11 @@ paths: in: path schema: type: string + - name: reveal + required: true + in: query + schema: + type: boolean requestBody: required: true content: @@ -408,6 +423,39 @@ paths: - Secrets security: - bearer: [] + get: + operationId: getApiKey + summary: '[Alpha] Get API key' + parameters: + - name: ref + required: true + in: path + description: Project ref + schema: + minLength: 20 + maxLength: 20 + type: string + - name: id + required: true + in: path + schema: + type: string + - name: reveal + required: true + in: query + schema: + type: boolean + responses: + '200': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ApiKeyResponse' + tags: + - Secrets + security: + - bearer: [] delete: operationId: deleteApiKey summary: '[Alpha] Deletes an API key for the project' @@ -425,6 +473,11 @@ paths: in: path schema: type: string + - name: reveal + required: true + in: query + schema: + type: boolean responses: '200': description: '' @@ -927,7 +980,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/V1ProjectResponse' + $ref: '#/components/schemas/V1ProjectWithDatabaseResponse' '500': description: Failed to retrieve project tags: @@ -2012,6 +2065,13 @@ paths: in: query schema: type: string + - name: compute_multiplier + required: false + in: query + schema: + minimum: 1 + maximum: 4 + type: number requestBody: required: true content: @@ -2153,6 +2213,13 @@ paths: in: query schema: type: string + - name: compute_multiplier + required: false + in: query + schema: + minimum: 1 + maximum: 4 + type: number requestBody: required: true content: @@ -2728,7 +2795,7 @@ components: - version - postgres_engine - release_channel - V1ProjectResponse: + V1ProjectWithDatabaseResponse: type: object properties: id: @@ -2774,36 +2841,9 @@ components: - name - region - created_at + - database - status - DesiredInstanceSize: - type: string - enum: - - micro - - small - - medium - - large - - xlarge - - 2xlarge - - 4xlarge - - 8xlarge - - 12xlarge - - 16xlarge - ReleaseChannel: - type: string - enum: - - internal - - alpha - - beta - - ga - - withdrawn - PostgresEngine: - type: string - description: >- - Postgres engine version. If not provided, the latest version will be - used. - enum: - - '15' - V1CreateProjectBody: + V1CreateProjectBodyDto: type: object properties: db_pass: @@ -2820,13 +2860,13 @@ components: enum: - free - pro + deprecated: true description: >- Subscription Plan is now set on organization level and is ignored in this request - example: free - deprecated: true region: type: string + description: Region you want your server to reside in enum: - us-east-1 - us-east-2 @@ -2846,28 +2886,96 @@ components: - ca-central-1 - ap-south-1 - sa-east-1 - description: Region you want your server to reside in - example: us-east-1 kps_enabled: type: boolean deprecated: true description: This field is deprecated and is ignored in this request desired_instance_size: - $ref: '#/components/schemas/DesiredInstanceSize' + type: string + enum: + - micro + - small + - medium + - large + - xlarge + - 2xlarge + - 4xlarge + - 8xlarge + - 12xlarge + - 16xlarge template_url: type: string + format: uri description: Template URL used to create the project from the CLI. example: >- https://github.com/supabase/supabase/tree/master/examples/slack-clone/nextjs-slack-clone release_channel: - $ref: '#/components/schemas/ReleaseChannel' + type: string + enum: + - internal + - alpha + - beta + - ga + - withdrawn + description: Release channel. If not provided, GA will be used. postgres_engine: - $ref: '#/components/schemas/PostgresEngine' + type: string + enum: + - '15' + description: >- + Postgres engine version. If not provided, the latest version will be + used. required: - db_pass - name - organization_id - region + additionalProperties: false + V1ProjectResponse: + type: object + properties: + id: + type: string + description: Id of your project + organization_id: + type: string + description: Slug of your organization + name: + type: string + description: Name of your project + region: + type: string + description: Region of your project + example: us-east-1 + created_at: + type: string + description: Creation timestamp + example: '2023-03-29T16:32:59Z' + status: + enum: + - ACTIVE_HEALTHY + - ACTIVE_UNHEALTHY + - COMING_UP + - GOING_DOWN + - INACTIVE + - INIT_FAILED + - REMOVED + - RESTARTING + - UNKNOWN + - UPGRADING + - PAUSING + - RESTORING + - RESTORE_FAILED + - PAUSE_FAILED + - RESIZING + type: string + required: + - id + - organization_id + - name + - region + - created_at + - status OrganizationResponseV1: type: object properties: @@ -2878,13 +2986,14 @@ components: required: - id - name - CreateOrganizationBodyV1: + CreateOrganizationV1Dto: type: object properties: name: type: string required: - name + additionalProperties: false OAuthTokenBody: type: object properties: @@ -3128,6 +3237,34 @@ components: nullable: true allOf: - $ref: '#/components/schemas/ApiKeySecretJWTTemplate' + DesiredInstanceSize: + type: string + enum: + - micro + - small + - medium + - large + - xlarge + - 2xlarge + - 4xlarge + - 8xlarge + - 12xlarge + - 16xlarge + ReleaseChannel: + type: string + enum: + - internal + - alpha + - beta + - ga + - withdrawn + PostgresEngine: + type: string + description: >- + Postgres engine version. If not provided, the latest version will be + used. + enum: + - '15' CreateBranchBody: type: object properties: @@ -5090,6 +5227,10 @@ components: type: string verify_jwt: type: boolean + compute_multiplier: + type: number + minimum: 1 + maximum: 4 required: - slug - name @@ -5125,6 +5266,8 @@ components: type: string import_map_path: type: string + compute_multiplier: + type: number required: - version - created_at @@ -5164,6 +5307,8 @@ components: type: string import_map_path: type: string + compute_multiplier: + type: number required: - version - created_at @@ -5181,6 +5326,10 @@ components: type: string verify_jwt: type: boolean + compute_multiplier: + type: number + minimum: 1 + maximum: 4 V1StorageBucketResponse: type: object properties: diff --git a/cmd/projects.go b/cmd/projects.go index 08ec10dd8..c119e7171 100644 --- a/cmd/projects.go +++ b/cmd/projects.go @@ -33,21 +33,21 @@ var ( Allowed: awsRegions(), } plan = utils.EnumFlag{ - Allowed: []string{string(api.V1CreateProjectBodyPlanFree), string(api.V1CreateProjectBodyPlanPro)}, - Value: string(api.V1CreateProjectBodyPlanFree), + Allowed: []string{string(api.V1CreateProjectBodyDtoPlanFree), string(api.V1CreateProjectBodyDtoPlanPro)}, + Value: string(api.V1CreateProjectBodyDtoPlanFree), } size = utils.EnumFlag{ Allowed: []string{ - string(api.Micro), - string(api.Small), - string(api.Medium), - string(api.Large), - string(api.Xlarge), - string(api.N2xlarge), - string(api.N4xlarge), - string(api.N8xlarge), - string(api.N12xlarge), - string(api.N16xlarge), + string(api.DesiredInstanceSizeMicro), + string(api.DesiredInstanceSizeSmall), + string(api.DesiredInstanceSizeMedium), + string(api.DesiredInstanceSizeLarge), + string(api.DesiredInstanceSizeXlarge), + string(api.DesiredInstanceSizeN2xlarge), + string(api.DesiredInstanceSizeN4xlarge), + string(api.DesiredInstanceSizeN8xlarge), + string(api.DesiredInstanceSizeN12xlarge), + string(api.DesiredInstanceSizeN16xlarge), }, } @@ -69,14 +69,14 @@ var ( if len(args) > 0 { projectName = args[0] } - body := api.V1CreateProjectBody{ + body := api.V1CreateProjectBodyDto{ Name: projectName, OrganizationId: orgId, DbPass: dbPassword, - Region: api.V1CreateProjectBodyRegion(region.Value), + Region: api.V1CreateProjectBodyDtoRegion(region.Value), } if cmd.Flags().Changed("size") { - body.DesiredInstanceSize = (*api.DesiredInstanceSize)(&size.Value) + body.DesiredInstanceSize = (*api.V1CreateProjectBodyDtoDesiredInstanceSize)(&size.Value) } return create.Run(cmd.Context(), body, afero.NewOsFs()) }, diff --git a/internal/bootstrap/bootstrap.go b/internal/bootstrap/bootstrap.go index 4769a81d1..677ef1530 100644 --- a/internal/bootstrap/bootstrap.go +++ b/internal/bootstrap/bootstrap.go @@ -77,7 +77,7 @@ func Run(ctx context.Context, starter StarterTemplate, fsys afero.Fs, options .. return err } // 2. Create project - params := api.V1CreateProjectBody{ + params := api.V1CreateProjectBodyDto{ Name: filepath.Base(workdir), TemplateUrl: &starter.Url, } diff --git a/internal/link/link.go b/internal/link/link.go index 12fa59ca1..e791271b8 100644 --- a/internal/link/link.go +++ b/internal/link/link.go @@ -270,10 +270,10 @@ func checkRemoteProjectStatus(ctx context.Context, projectRef string, fsys afero } switch resp.JSON200.Status { - case api.V1ProjectResponseStatusINACTIVE: + case api.V1ProjectWithDatabaseResponseStatusINACTIVE: utils.CmdSuggestion = fmt.Sprintf("An admin must unpause it from the Supabase dashboard at %s", utils.Aqua(fmt.Sprintf("%s/project/%s", utils.GetSupabaseDashboardURL(), projectRef))) return errors.New(errProjectPaused) - case api.V1ProjectResponseStatusACTIVEHEALTHY: + case api.V1ProjectWithDatabaseResponseStatusACTIVEHEALTHY: // Project is in the desired state, do nothing default: fmt.Fprintf(os.Stderr, "%s: Project status is %s instead of Active Healthy. Some operations might fail.\n", utils.Yellow("WARNING"), resp.JSON200.Status) diff --git a/internal/link/link_test.go b/internal/link/link_test.go index 28282da4f..18c090ad3 100644 --- a/internal/link/link_test.go +++ b/internal/link/link_test.go @@ -58,9 +58,9 @@ func TestLinkCommand(t *testing.T) { gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project). Reply(200). - JSON(api.V1ProjectResponse{ - Status: api.V1ProjectResponseStatusACTIVEHEALTHY, - Database: &postgres, + JSON(api.V1ProjectWithDatabaseResponse{ + Status: api.V1ProjectWithDatabaseResponseStatusACTIVEHEALTHY, + Database: postgres, }) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/api-keys"). @@ -132,9 +132,9 @@ func TestLinkCommand(t *testing.T) { gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project). Reply(200). - JSON(api.V1ProjectResponse{ - Status: api.V1ProjectResponseStatusACTIVEHEALTHY, - Database: &api.V1DatabaseResponse{}, + JSON(api.V1ProjectWithDatabaseResponse{ + Status: api.V1ProjectWithDatabaseResponseStatusACTIVEHEALTHY, + Database: api.V1DatabaseResponse{}, }) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/api-keys"). @@ -186,9 +186,9 @@ func TestLinkCommand(t *testing.T) { gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project). Reply(200). - JSON(api.V1ProjectResponse{ - Status: api.V1ProjectResponseStatusACTIVEHEALTHY, - Database: &api.V1DatabaseResponse{}, + JSON(api.V1ProjectWithDatabaseResponse{ + Status: api.V1ProjectWithDatabaseResponseStatusACTIVEHEALTHY, + Database: api.V1DatabaseResponse{}, }) gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project + "/api-keys"). @@ -247,9 +247,9 @@ func TestStatusCheck(t *testing.T) { gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project). Reply(http.StatusOK). - JSON(api.V1ProjectResponse{ - Status: api.V1ProjectResponseStatusACTIVEHEALTHY, - Database: &api.V1DatabaseResponse{Version: "15.6.1.139"}, + JSON(api.V1ProjectWithDatabaseResponse{ + Status: api.V1ProjectWithDatabaseResponseStatusACTIVEHEALTHY, + Database: api.V1DatabaseResponse{Version: "15.6.1.139"}, }) // Run test err := checkRemoteProjectStatus(context.Background(), project, fsys) @@ -289,7 +289,7 @@ func TestStatusCheck(t *testing.T) { gock.New(utils.DefaultApiHost). Get("/v1/projects/" + project). Reply(http.StatusOK). - JSON(api.V1ProjectResponse{Status: api.V1ProjectResponseStatusINACTIVE}) + JSON(api.V1ProjectWithDatabaseResponse{Status: api.V1ProjectWithDatabaseResponseStatusINACTIVE}) // Run test err := checkRemoteProjectStatus(context.Background(), project, fsys) // Check error diff --git a/internal/projects/apiKeys/api_keys.go b/internal/projects/apiKeys/api_keys.go index 4fcbfe06a..7daddce21 100644 --- a/internal/projects/apiKeys/api_keys.go +++ b/internal/projects/apiKeys/api_keys.go @@ -34,7 +34,7 @@ func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { } func RunGetApiKeys(ctx context.Context, projectRef string) ([]api.ApiKeyResponse, error) { - resp, err := utils.GetSupabase().V1GetProjectApiKeysWithResponse(ctx, projectRef) + resp, err := utils.GetSupabase().V1GetProjectApiKeysWithResponse(ctx, projectRef, &api.V1GetProjectApiKeysParams{}) if err != nil { return nil, errors.Errorf("failed to get api keys: %w", err) } diff --git a/internal/projects/create/create.go b/internal/projects/create/create.go index 01ebf6308..ddbd46b47 100644 --- a/internal/projects/create/create.go +++ b/internal/projects/create/create.go @@ -15,7 +15,7 @@ import ( "github.com/supabase/cli/pkg/api" ) -func Run(ctx context.Context, params api.V1CreateProjectBody, fsys afero.Fs) error { +func Run(ctx context.Context, params api.V1CreateProjectBodyDto, fsys afero.Fs) error { if err := promptMissingParams(ctx, ¶ms); err != nil { return err } @@ -49,7 +49,7 @@ func printKeyValue(key, value string) string { return key + ":" + spaces + value } -func promptMissingParams(ctx context.Context, body *api.V1CreateProjectBody) error { +func promptMissingParams(ctx context.Context, body *api.V1CreateProjectBodyDto) error { var err error if len(body.Name) == 0 { if body.Name, err = promptProjectName(ctx); err != nil { @@ -106,7 +106,7 @@ func promptOrgId(ctx context.Context) (string, error) { return choice.Details, nil } -func promptProjectRegion(ctx context.Context) (api.V1CreateProjectBodyRegion, error) { +func promptProjectRegion(ctx context.Context) (api.V1CreateProjectBodyDtoRegion, error) { title := "Which region do you want to host the project in?" items := make([]utils.PromptItem, len(utils.RegionMap)) i := 0 @@ -118,5 +118,5 @@ func promptProjectRegion(ctx context.Context) (api.V1CreateProjectBodyRegion, er if err != nil { return "", err } - return api.V1CreateProjectBodyRegion(choice.Summary), nil + return api.V1CreateProjectBodyDtoRegion(choice.Summary), nil } diff --git a/internal/projects/create/create_test.go b/internal/projects/create/create_test.go index c67c7a35e..879421d72 100644 --- a/internal/projects/create/create_test.go +++ b/internal/projects/create/create_test.go @@ -14,11 +14,11 @@ import ( ) func TestProjectCreateCommand(t *testing.T) { - var params = api.V1CreateProjectBody{ + var params = api.V1CreateProjectBodyDto{ Name: "Test Project", OrganizationId: "combined-fuchsia-lion", DbPass: "redacted", - Region: api.V1CreateProjectBodyRegionUsWest1, + Region: api.V1CreateProjectBodyDtoRegionUsWest1, } t.Run("creates a new project", func(t *testing.T) { diff --git a/internal/projects/list/list.go b/internal/projects/list/list.go index b16b6d4fc..d211f71e9 100644 --- a/internal/projects/list/list.go +++ b/internal/projects/list/list.go @@ -15,8 +15,8 @@ import ( ) type linkedProject struct { - api.V1ProjectResponse `yaml:",inline"` - Linked bool `json:"linked"` + api.V1ProjectWithDatabaseResponse `yaml:",inline"` + Linked bool `json:"linked"` } func Run(ctx context.Context, fsys afero.Fs) error { @@ -37,8 +37,8 @@ func Run(ctx context.Context, fsys afero.Fs) error { var projects []linkedProject for _, project := range *resp.JSON200 { projects = append(projects, linkedProject{ - V1ProjectResponse: project, - Linked: project.Id == projectRef, + V1ProjectWithDatabaseResponse: project, + Linked: project.Id == projectRef, }) } diff --git a/internal/utils/tenant/client.go b/internal/utils/tenant/client.go index 9fc86a670..ad0ef6aa7 100644 --- a/internal/utils/tenant/client.go +++ b/internal/utils/tenant/client.go @@ -39,7 +39,7 @@ func NewApiKey(resp []api.ApiKeyResponse) ApiKey { } func GetApiKeys(ctx context.Context, projectRef string) (ApiKey, error) { - resp, err := utils.GetSupabase().V1GetProjectApiKeysWithResponse(ctx, projectRef) + resp, err := utils.GetSupabase().V1GetProjectApiKeysWithResponse(ctx, projectRef, &api.V1GetProjectApiKeysParams{}) if err != nil { return ApiKey{}, errors.Errorf("failed to get api keys: %w", err) } diff --git a/pkg/api/client.gen.go b/pkg/api/client.gen.go index 05ed76708..fcbe8eaeb 100644 --- a/pkg/api/client.gen.go +++ b/pkg/api/client.gen.go @@ -140,20 +140,23 @@ type ClientInterface interface { V1GetProject(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) // V1GetProjectApiKeys request - V1GetProjectApiKeys(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + V1GetProjectApiKeys(ctx context.Context, ref string, params *V1GetProjectApiKeysParams, reqEditors ...RequestEditorFn) (*http.Response, error) // CreateApiKeyWithBody request with any body - CreateApiKeyWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + CreateApiKeyWithBody(ctx context.Context, ref string, params *CreateApiKeyParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - CreateApiKey(ctx context.Context, ref string, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + CreateApiKey(ctx context.Context, ref string, params *CreateApiKeyParams, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) // DeleteApiKey request - DeleteApiKey(ctx context.Context, ref string, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + DeleteApiKey(ctx context.Context, ref string, id string, params *DeleteApiKeyParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetApiKey request + GetApiKey(ctx context.Context, ref string, id string, params *GetApiKeyParams, reqEditors ...RequestEditorFn) (*http.Response, error) // UpdateApiKeyWithBody request with any body - UpdateApiKeyWithBody(ctx context.Context, ref string, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + UpdateApiKeyWithBody(ctx context.Context, ref string, id string, params *UpdateApiKeyParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - UpdateApiKey(ctx context.Context, ref string, id string, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + UpdateApiKey(ctx context.Context, ref string, id string, params *UpdateApiKeyParams, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) // V1DisablePreviewBranching request V1DisablePreviewBranching(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -617,8 +620,20 @@ func (c *Client) V1GetProject(ctx context.Context, ref string, reqEditors ...Req return c.Client.Do(req) } -func (c *Client) V1GetProjectApiKeys(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewV1GetProjectApiKeysRequest(c.Server, ref) +func (c *Client) V1GetProjectApiKeys(ctx context.Context, ref string, params *V1GetProjectApiKeysParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1GetProjectApiKeysRequest(c.Server, ref, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) CreateApiKeyWithBody(ctx context.Context, ref string, params *CreateApiKeyParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateApiKeyRequestWithBody(c.Server, ref, params, contentType, body) if err != nil { return nil, err } @@ -629,8 +644,8 @@ func (c *Client) V1GetProjectApiKeys(ctx context.Context, ref string, reqEditors return c.Client.Do(req) } -func (c *Client) CreateApiKeyWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateApiKeyRequestWithBody(c.Server, ref, contentType, body) +func (c *Client) CreateApiKey(ctx context.Context, ref string, params *CreateApiKeyParams, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateApiKeyRequest(c.Server, ref, params, body) if err != nil { return nil, err } @@ -641,8 +656,8 @@ func (c *Client) CreateApiKeyWithBody(ctx context.Context, ref string, contentTy return c.Client.Do(req) } -func (c *Client) CreateApiKey(ctx context.Context, ref string, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateApiKeyRequest(c.Server, ref, body) +func (c *Client) DeleteApiKey(ctx context.Context, ref string, id string, params *DeleteApiKeyParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteApiKeyRequest(c.Server, ref, id, params) if err != nil { return nil, err } @@ -653,8 +668,8 @@ func (c *Client) CreateApiKey(ctx context.Context, ref string, body CreateApiKey return c.Client.Do(req) } -func (c *Client) DeleteApiKey(ctx context.Context, ref string, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteApiKeyRequest(c.Server, ref, id) +func (c *Client) GetApiKey(ctx context.Context, ref string, id string, params *GetApiKeyParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetApiKeyRequest(c.Server, ref, id, params) if err != nil { return nil, err } @@ -665,8 +680,8 @@ func (c *Client) DeleteApiKey(ctx context.Context, ref string, id string, reqEdi return c.Client.Do(req) } -func (c *Client) UpdateApiKeyWithBody(ctx context.Context, ref string, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUpdateApiKeyRequestWithBody(c.Server, ref, id, contentType, body) +func (c *Client) UpdateApiKeyWithBody(ctx context.Context, ref string, id string, params *UpdateApiKeyParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateApiKeyRequestWithBody(c.Server, ref, id, params, contentType, body) if err != nil { return nil, err } @@ -677,8 +692,8 @@ func (c *Client) UpdateApiKeyWithBody(ctx context.Context, ref string, id string return c.Client.Do(req) } -func (c *Client) UpdateApiKey(ctx context.Context, ref string, id string, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUpdateApiKeyRequest(c.Server, ref, id, body) +func (c *Client) UpdateApiKey(ctx context.Context, ref string, id string, params *UpdateApiKeyParams, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateApiKeyRequest(c.Server, ref, id, params, body) if err != nil { return nil, err } @@ -2378,7 +2393,7 @@ func NewV1GetProjectRequest(server string, ref string) (*http.Request, error) { } // NewV1GetProjectApiKeysRequest generates requests for V1GetProjectApiKeys -func NewV1GetProjectApiKeysRequest(server string, ref string) (*http.Request, error) { +func NewV1GetProjectApiKeysRequest(server string, ref string, params *V1GetProjectApiKeysParams) (*http.Request, error) { var err error var pathParam0 string @@ -2403,6 +2418,24 @@ func NewV1GetProjectApiKeysRequest(server string, ref string) (*http.Request, er return nil, err } + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "reveal", runtime.ParamLocationQuery, params.Reveal); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + } + req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err @@ -2412,18 +2445,18 @@ func NewV1GetProjectApiKeysRequest(server string, ref string) (*http.Request, er } // NewCreateApiKeyRequest calls the generic CreateApiKey builder with application/json body -func NewCreateApiKeyRequest(server string, ref string, body CreateApiKeyJSONRequestBody) (*http.Request, error) { +func NewCreateApiKeyRequest(server string, ref string, params *CreateApiKeyParams, body CreateApiKeyJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewCreateApiKeyRequestWithBody(server, ref, "application/json", bodyReader) + return NewCreateApiKeyRequestWithBody(server, ref, params, "application/json", bodyReader) } // NewCreateApiKeyRequestWithBody generates requests for CreateApiKey with any type of body -func NewCreateApiKeyRequestWithBody(server string, ref string, contentType string, body io.Reader) (*http.Request, error) { +func NewCreateApiKeyRequestWithBody(server string, ref string, params *CreateApiKeyParams, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -2448,6 +2481,24 @@ func NewCreateApiKeyRequestWithBody(server string, ref string, contentType strin return nil, err } + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "reveal", runtime.ParamLocationQuery, params.Reveal); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + } + req, err := http.NewRequest("POST", queryURL.String(), body) if err != nil { return nil, err @@ -2459,7 +2510,7 @@ func NewCreateApiKeyRequestWithBody(server string, ref string, contentType strin } // NewDeleteApiKeyRequest generates requests for DeleteApiKey -func NewDeleteApiKeyRequest(server string, ref string, id string) (*http.Request, error) { +func NewDeleteApiKeyRequest(server string, ref string, id string, params *DeleteApiKeyParams) (*http.Request, error) { var err error var pathParam0 string @@ -2491,6 +2542,24 @@ func NewDeleteApiKeyRequest(server string, ref string, id string) (*http.Request return nil, err } + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "reveal", runtime.ParamLocationQuery, params.Reveal); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + } + req, err := http.NewRequest("DELETE", queryURL.String(), nil) if err != nil { return nil, err @@ -2499,19 +2568,78 @@ func NewDeleteApiKeyRequest(server string, ref string, id string) (*http.Request return req, nil } +// NewGetApiKeyRequest generates requests for GetApiKey +func NewGetApiKeyRequest(server string, ref string, id string, params *GetApiKeyParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "id", runtime.ParamLocationPath, id) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/api-keys/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "reveal", runtime.ParamLocationQuery, params.Reveal); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewUpdateApiKeyRequest calls the generic UpdateApiKey builder with application/json body -func NewUpdateApiKeyRequest(server string, ref string, id string, body UpdateApiKeyJSONRequestBody) (*http.Request, error) { +func NewUpdateApiKeyRequest(server string, ref string, id string, params *UpdateApiKeyParams, body UpdateApiKeyJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewUpdateApiKeyRequestWithBody(server, ref, id, "application/json", bodyReader) + return NewUpdateApiKeyRequestWithBody(server, ref, id, params, "application/json", bodyReader) } // NewUpdateApiKeyRequestWithBody generates requests for UpdateApiKey with any type of body -func NewUpdateApiKeyRequestWithBody(server string, ref string, id string, contentType string, body io.Reader) (*http.Request, error) { +func NewUpdateApiKeyRequestWithBody(server string, ref string, id string, params *UpdateApiKeyParams, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -2543,6 +2671,24 @@ func NewUpdateApiKeyRequestWithBody(server string, ref string, id string, conten return nil, err } + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "reveal", runtime.ParamLocationQuery, params.Reveal); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + } + req, err := http.NewRequest("PATCH", queryURL.String(), body) if err != nil { return nil, err @@ -3921,6 +4067,22 @@ func NewV1CreateAFunctionRequestWithBody(server string, ref string, params *V1Cr } + if params.ComputeMultiplier != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "compute_multiplier", runtime.ParamLocationQuery, *params.ComputeMultiplier); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + queryURL.RawQuery = queryValues.Encode() } @@ -4159,6 +4321,22 @@ func NewV1UpdateAFunctionRequestWithBody(server string, ref string, functionSlug } + if params.ComputeMultiplier != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "compute_multiplier", runtime.ParamLocationQuery, *params.ComputeMultiplier); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + queryURL.RawQuery = queryValues.Encode() } @@ -5542,20 +5720,23 @@ type ClientWithResponsesInterface interface { V1GetProjectWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetProjectResponse, error) // V1GetProjectApiKeysWithResponse request - V1GetProjectApiKeysWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetProjectApiKeysResponse, error) + V1GetProjectApiKeysWithResponse(ctx context.Context, ref string, params *V1GetProjectApiKeysParams, reqEditors ...RequestEditorFn) (*V1GetProjectApiKeysResponse, error) // CreateApiKeyWithBodyWithResponse request with any body - CreateApiKeyWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) + CreateApiKeyWithBodyWithResponse(ctx context.Context, ref string, params *CreateApiKeyParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) - CreateApiKeyWithResponse(ctx context.Context, ref string, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) + CreateApiKeyWithResponse(ctx context.Context, ref string, params *CreateApiKeyParams, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) // DeleteApiKeyWithResponse request - DeleteApiKeyWithResponse(ctx context.Context, ref string, id string, reqEditors ...RequestEditorFn) (*DeleteApiKeyResponse, error) + DeleteApiKeyWithResponse(ctx context.Context, ref string, id string, params *DeleteApiKeyParams, reqEditors ...RequestEditorFn) (*DeleteApiKeyResponse, error) + + // GetApiKeyWithResponse request + GetApiKeyWithResponse(ctx context.Context, ref string, id string, params *GetApiKeyParams, reqEditors ...RequestEditorFn) (*GetApiKeyResponse, error) // UpdateApiKeyWithBodyWithResponse request with any body - UpdateApiKeyWithBodyWithResponse(ctx context.Context, ref string, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) + UpdateApiKeyWithBodyWithResponse(ctx context.Context, ref string, id string, params *UpdateApiKeyParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) - UpdateApiKeyWithResponse(ctx context.Context, ref string, id string, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) + UpdateApiKeyWithResponse(ctx context.Context, ref string, id string, params *UpdateApiKeyParams, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) // V1DisablePreviewBranchingWithResponse request V1DisablePreviewBranchingWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1DisablePreviewBranchingResponse, error) @@ -6025,7 +6206,7 @@ func (r V1ListOrganizationMembersResponse) StatusCode() int { type V1ListAllProjectsResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *[]V1ProjectResponse + JSON200 *[]V1ProjectWithDatabaseResponse } // Status returns HTTPResponse.Status @@ -6091,7 +6272,7 @@ func (r V1DeleteAProjectResponse) StatusCode() int { type V1GetProjectResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *V1ProjectResponse + JSON200 *V1ProjectWithDatabaseResponse } // Status returns HTTPResponse.Status @@ -6176,6 +6357,28 @@ func (r DeleteApiKeyResponse) StatusCode() int { return 0 } +type GetApiKeyResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ApiKeyResponse +} + +// Status returns HTTPResponse.Status +func (r GetApiKeyResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetApiKeyResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type UpdateApiKeyResponse struct { Body []byte HTTPResponse *http.Response @@ -7774,8 +7977,8 @@ func (c *ClientWithResponses) V1GetProjectWithResponse(ctx context.Context, ref } // V1GetProjectApiKeysWithResponse request returning *V1GetProjectApiKeysResponse -func (c *ClientWithResponses) V1GetProjectApiKeysWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetProjectApiKeysResponse, error) { - rsp, err := c.V1GetProjectApiKeys(ctx, ref, reqEditors...) +func (c *ClientWithResponses) V1GetProjectApiKeysWithResponse(ctx context.Context, ref string, params *V1GetProjectApiKeysParams, reqEditors ...RequestEditorFn) (*V1GetProjectApiKeysResponse, error) { + rsp, err := c.V1GetProjectApiKeys(ctx, ref, params, reqEditors...) if err != nil { return nil, err } @@ -7783,16 +7986,16 @@ func (c *ClientWithResponses) V1GetProjectApiKeysWithResponse(ctx context.Contex } // CreateApiKeyWithBodyWithResponse request with arbitrary body returning *CreateApiKeyResponse -func (c *ClientWithResponses) CreateApiKeyWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) { - rsp, err := c.CreateApiKeyWithBody(ctx, ref, contentType, body, reqEditors...) +func (c *ClientWithResponses) CreateApiKeyWithBodyWithResponse(ctx context.Context, ref string, params *CreateApiKeyParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) { + rsp, err := c.CreateApiKeyWithBody(ctx, ref, params, contentType, body, reqEditors...) if err != nil { return nil, err } return ParseCreateApiKeyResponse(rsp) } -func (c *ClientWithResponses) CreateApiKeyWithResponse(ctx context.Context, ref string, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) { - rsp, err := c.CreateApiKey(ctx, ref, body, reqEditors...) +func (c *ClientWithResponses) CreateApiKeyWithResponse(ctx context.Context, ref string, params *CreateApiKeyParams, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) { + rsp, err := c.CreateApiKey(ctx, ref, params, body, reqEditors...) if err != nil { return nil, err } @@ -7800,25 +8003,34 @@ func (c *ClientWithResponses) CreateApiKeyWithResponse(ctx context.Context, ref } // DeleteApiKeyWithResponse request returning *DeleteApiKeyResponse -func (c *ClientWithResponses) DeleteApiKeyWithResponse(ctx context.Context, ref string, id string, reqEditors ...RequestEditorFn) (*DeleteApiKeyResponse, error) { - rsp, err := c.DeleteApiKey(ctx, ref, id, reqEditors...) +func (c *ClientWithResponses) DeleteApiKeyWithResponse(ctx context.Context, ref string, id string, params *DeleteApiKeyParams, reqEditors ...RequestEditorFn) (*DeleteApiKeyResponse, error) { + rsp, err := c.DeleteApiKey(ctx, ref, id, params, reqEditors...) if err != nil { return nil, err } return ParseDeleteApiKeyResponse(rsp) } +// GetApiKeyWithResponse request returning *GetApiKeyResponse +func (c *ClientWithResponses) GetApiKeyWithResponse(ctx context.Context, ref string, id string, params *GetApiKeyParams, reqEditors ...RequestEditorFn) (*GetApiKeyResponse, error) { + rsp, err := c.GetApiKey(ctx, ref, id, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetApiKeyResponse(rsp) +} + // UpdateApiKeyWithBodyWithResponse request with arbitrary body returning *UpdateApiKeyResponse -func (c *ClientWithResponses) UpdateApiKeyWithBodyWithResponse(ctx context.Context, ref string, id string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) { - rsp, err := c.UpdateApiKeyWithBody(ctx, ref, id, contentType, body, reqEditors...) +func (c *ClientWithResponses) UpdateApiKeyWithBodyWithResponse(ctx context.Context, ref string, id string, params *UpdateApiKeyParams, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) { + rsp, err := c.UpdateApiKeyWithBody(ctx, ref, id, params, contentType, body, reqEditors...) if err != nil { return nil, err } return ParseUpdateApiKeyResponse(rsp) } -func (c *ClientWithResponses) UpdateApiKeyWithResponse(ctx context.Context, ref string, id string, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) { - rsp, err := c.UpdateApiKey(ctx, ref, id, body, reqEditors...) +func (c *ClientWithResponses) UpdateApiKeyWithResponse(ctx context.Context, ref string, id string, params *UpdateApiKeyParams, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) { + rsp, err := c.UpdateApiKey(ctx, ref, id, params, body, reqEditors...) if err != nil { return nil, err } @@ -8875,7 +9087,7 @@ func ParseV1ListAllProjectsResponse(rsp *http.Response) (*V1ListAllProjectsRespo switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []V1ProjectResponse + var dest []V1ProjectWithDatabaseResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -8953,7 +9165,7 @@ func ParseV1GetProjectResponse(rsp *http.Response) (*V1GetProjectResponse, error switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest V1ProjectResponse + var dest V1ProjectWithDatabaseResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -9042,6 +9254,32 @@ func ParseDeleteApiKeyResponse(rsp *http.Response) (*DeleteApiKeyResponse, error return response, nil } +// ParseGetApiKeyResponse parses an HTTP response from a GetApiKeyWithResponse call +func ParseGetApiKeyResponse(rsp *http.Response) (*GetApiKeyResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetApiKeyResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ApiKeyResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParseUpdateApiKeyResponse parses an HTTP response from a UpdateApiKeyWithResponse call func ParseUpdateApiKeyResponse(rsp *http.Response) (*UpdateApiKeyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/pkg/api/types.gen.go b/pkg/api/types.gen.go index 9334b80b8..4cfa1556b 100644 --- a/pkg/api/types.gen.go +++ b/pkg/api/types.gen.go @@ -111,16 +111,16 @@ const ( // Defines values for DesiredInstanceSize. const ( - Large DesiredInstanceSize = "large" - Medium DesiredInstanceSize = "medium" - Micro DesiredInstanceSize = "micro" - N12xlarge DesiredInstanceSize = "12xlarge" - N16xlarge DesiredInstanceSize = "16xlarge" - N2xlarge DesiredInstanceSize = "2xlarge" - N4xlarge DesiredInstanceSize = "4xlarge" - N8xlarge DesiredInstanceSize = "8xlarge" - Small DesiredInstanceSize = "small" - Xlarge DesiredInstanceSize = "xlarge" + DesiredInstanceSizeLarge DesiredInstanceSize = "large" + DesiredInstanceSizeMedium DesiredInstanceSize = "medium" + DesiredInstanceSizeMicro DesiredInstanceSize = "micro" + DesiredInstanceSizeN12xlarge DesiredInstanceSize = "12xlarge" + DesiredInstanceSizeN16xlarge DesiredInstanceSize = "16xlarge" + DesiredInstanceSizeN2xlarge DesiredInstanceSize = "2xlarge" + DesiredInstanceSizeN4xlarge DesiredInstanceSize = "4xlarge" + DesiredInstanceSizeN8xlarge DesiredInstanceSize = "8xlarge" + DesiredInstanceSizeSmall DesiredInstanceSize = "small" + DesiredInstanceSizeXlarge DesiredInstanceSize = "xlarge" ) // Defines values for FunctionResponseStatus. @@ -169,16 +169,16 @@ const ( // Defines values for PostgresEngine. const ( - N15 PostgresEngine = "15" + PostgresEngineN15 PostgresEngine = "15" ) // Defines values for ReleaseChannel. const ( - Alpha ReleaseChannel = "alpha" - Beta ReleaseChannel = "beta" - Ga ReleaseChannel = "ga" - Internal ReleaseChannel = "internal" - Withdrawn ReleaseChannel = "withdrawn" + ReleaseChannelAlpha ReleaseChannel = "alpha" + ReleaseChannelBeta ReleaseChannel = "beta" + ReleaseChannelGa ReleaseChannel = "ga" + ReleaseChannelInternal ReleaseChannel = "internal" + ReleaseChannelWithdrawn ReleaseChannel = "withdrawn" ) // Defines values for SetUpReadReplicaBodyReadReplicaRegion. @@ -297,32 +297,60 @@ const ( V1BackupStatusREMOVED V1BackupStatus = "REMOVED" ) -// Defines values for V1CreateProjectBodyPlan. +// Defines values for V1CreateProjectBodyDtoDesiredInstanceSize. const ( - V1CreateProjectBodyPlanFree V1CreateProjectBodyPlan = "free" - V1CreateProjectBodyPlanPro V1CreateProjectBodyPlan = "pro" + V1CreateProjectBodyDtoDesiredInstanceSizeLarge V1CreateProjectBodyDtoDesiredInstanceSize = "large" + V1CreateProjectBodyDtoDesiredInstanceSizeMedium V1CreateProjectBodyDtoDesiredInstanceSize = "medium" + V1CreateProjectBodyDtoDesiredInstanceSizeMicro V1CreateProjectBodyDtoDesiredInstanceSize = "micro" + V1CreateProjectBodyDtoDesiredInstanceSizeN12xlarge V1CreateProjectBodyDtoDesiredInstanceSize = "12xlarge" + V1CreateProjectBodyDtoDesiredInstanceSizeN16xlarge V1CreateProjectBodyDtoDesiredInstanceSize = "16xlarge" + V1CreateProjectBodyDtoDesiredInstanceSizeN2xlarge V1CreateProjectBodyDtoDesiredInstanceSize = "2xlarge" + V1CreateProjectBodyDtoDesiredInstanceSizeN4xlarge V1CreateProjectBodyDtoDesiredInstanceSize = "4xlarge" + V1CreateProjectBodyDtoDesiredInstanceSizeN8xlarge V1CreateProjectBodyDtoDesiredInstanceSize = "8xlarge" + V1CreateProjectBodyDtoDesiredInstanceSizeSmall V1CreateProjectBodyDtoDesiredInstanceSize = "small" + V1CreateProjectBodyDtoDesiredInstanceSizeXlarge V1CreateProjectBodyDtoDesiredInstanceSize = "xlarge" ) -// Defines values for V1CreateProjectBodyRegion. +// Defines values for V1CreateProjectBodyDtoPlan. const ( - V1CreateProjectBodyRegionApEast1 V1CreateProjectBodyRegion = "ap-east-1" - V1CreateProjectBodyRegionApNortheast1 V1CreateProjectBodyRegion = "ap-northeast-1" - V1CreateProjectBodyRegionApNortheast2 V1CreateProjectBodyRegion = "ap-northeast-2" - V1CreateProjectBodyRegionApSouth1 V1CreateProjectBodyRegion = "ap-south-1" - V1CreateProjectBodyRegionApSoutheast1 V1CreateProjectBodyRegion = "ap-southeast-1" - V1CreateProjectBodyRegionApSoutheast2 V1CreateProjectBodyRegion = "ap-southeast-2" - V1CreateProjectBodyRegionCaCentral1 V1CreateProjectBodyRegion = "ca-central-1" - V1CreateProjectBodyRegionEuCentral1 V1CreateProjectBodyRegion = "eu-central-1" - V1CreateProjectBodyRegionEuCentral2 V1CreateProjectBodyRegion = "eu-central-2" - V1CreateProjectBodyRegionEuNorth1 V1CreateProjectBodyRegion = "eu-north-1" - V1CreateProjectBodyRegionEuWest1 V1CreateProjectBodyRegion = "eu-west-1" - V1CreateProjectBodyRegionEuWest2 V1CreateProjectBodyRegion = "eu-west-2" - V1CreateProjectBodyRegionEuWest3 V1CreateProjectBodyRegion = "eu-west-3" - V1CreateProjectBodyRegionSaEast1 V1CreateProjectBodyRegion = "sa-east-1" - V1CreateProjectBodyRegionUsEast1 V1CreateProjectBodyRegion = "us-east-1" - V1CreateProjectBodyRegionUsEast2 V1CreateProjectBodyRegion = "us-east-2" - V1CreateProjectBodyRegionUsWest1 V1CreateProjectBodyRegion = "us-west-1" - V1CreateProjectBodyRegionUsWest2 V1CreateProjectBodyRegion = "us-west-2" + V1CreateProjectBodyDtoPlanFree V1CreateProjectBodyDtoPlan = "free" + V1CreateProjectBodyDtoPlanPro V1CreateProjectBodyDtoPlan = "pro" +) + +// Defines values for V1CreateProjectBodyDtoPostgresEngine. +const ( + V1CreateProjectBodyDtoPostgresEngineN15 V1CreateProjectBodyDtoPostgresEngine = "15" +) + +// Defines values for V1CreateProjectBodyDtoRegion. +const ( + V1CreateProjectBodyDtoRegionApEast1 V1CreateProjectBodyDtoRegion = "ap-east-1" + V1CreateProjectBodyDtoRegionApNortheast1 V1CreateProjectBodyDtoRegion = "ap-northeast-1" + V1CreateProjectBodyDtoRegionApNortheast2 V1CreateProjectBodyDtoRegion = "ap-northeast-2" + V1CreateProjectBodyDtoRegionApSouth1 V1CreateProjectBodyDtoRegion = "ap-south-1" + V1CreateProjectBodyDtoRegionApSoutheast1 V1CreateProjectBodyDtoRegion = "ap-southeast-1" + V1CreateProjectBodyDtoRegionApSoutheast2 V1CreateProjectBodyDtoRegion = "ap-southeast-2" + V1CreateProjectBodyDtoRegionCaCentral1 V1CreateProjectBodyDtoRegion = "ca-central-1" + V1CreateProjectBodyDtoRegionEuCentral1 V1CreateProjectBodyDtoRegion = "eu-central-1" + V1CreateProjectBodyDtoRegionEuCentral2 V1CreateProjectBodyDtoRegion = "eu-central-2" + V1CreateProjectBodyDtoRegionEuNorth1 V1CreateProjectBodyDtoRegion = "eu-north-1" + V1CreateProjectBodyDtoRegionEuWest1 V1CreateProjectBodyDtoRegion = "eu-west-1" + V1CreateProjectBodyDtoRegionEuWest2 V1CreateProjectBodyDtoRegion = "eu-west-2" + V1CreateProjectBodyDtoRegionEuWest3 V1CreateProjectBodyDtoRegion = "eu-west-3" + V1CreateProjectBodyDtoRegionSaEast1 V1CreateProjectBodyDtoRegion = "sa-east-1" + V1CreateProjectBodyDtoRegionUsEast1 V1CreateProjectBodyDtoRegion = "us-east-1" + V1CreateProjectBodyDtoRegionUsEast2 V1CreateProjectBodyDtoRegion = "us-east-2" + V1CreateProjectBodyDtoRegionUsWest1 V1CreateProjectBodyDtoRegion = "us-west-1" + V1CreateProjectBodyDtoRegionUsWest2 V1CreateProjectBodyDtoRegion = "us-west-2" +) + +// Defines values for V1CreateProjectBodyDtoReleaseChannel. +const ( + V1CreateProjectBodyDtoReleaseChannelAlpha V1CreateProjectBodyDtoReleaseChannel = "alpha" + V1CreateProjectBodyDtoReleaseChannelBeta V1CreateProjectBodyDtoReleaseChannel = "beta" + V1CreateProjectBodyDtoReleaseChannelGa V1CreateProjectBodyDtoReleaseChannel = "ga" + V1CreateProjectBodyDtoReleaseChannelInternal V1CreateProjectBodyDtoReleaseChannel = "internal" + V1CreateProjectBodyDtoReleaseChannelWithdrawn V1CreateProjectBodyDtoReleaseChannel = "withdrawn" ) // Defines values for V1OrganizationSlugResponseOptInTags. @@ -356,6 +384,25 @@ const ( V1ProjectResponseStatusUPGRADING V1ProjectResponseStatus = "UPGRADING" ) +// Defines values for V1ProjectWithDatabaseResponseStatus. +const ( + V1ProjectWithDatabaseResponseStatusACTIVEHEALTHY V1ProjectWithDatabaseResponseStatus = "ACTIVE_HEALTHY" + V1ProjectWithDatabaseResponseStatusACTIVEUNHEALTHY V1ProjectWithDatabaseResponseStatus = "ACTIVE_UNHEALTHY" + V1ProjectWithDatabaseResponseStatusCOMINGUP V1ProjectWithDatabaseResponseStatus = "COMING_UP" + V1ProjectWithDatabaseResponseStatusGOINGDOWN V1ProjectWithDatabaseResponseStatus = "GOING_DOWN" + V1ProjectWithDatabaseResponseStatusINACTIVE V1ProjectWithDatabaseResponseStatus = "INACTIVE" + V1ProjectWithDatabaseResponseStatusINITFAILED V1ProjectWithDatabaseResponseStatus = "INIT_FAILED" + V1ProjectWithDatabaseResponseStatusPAUSEFAILED V1ProjectWithDatabaseResponseStatus = "PAUSE_FAILED" + V1ProjectWithDatabaseResponseStatusPAUSING V1ProjectWithDatabaseResponseStatus = "PAUSING" + V1ProjectWithDatabaseResponseStatusREMOVED V1ProjectWithDatabaseResponseStatus = "REMOVED" + V1ProjectWithDatabaseResponseStatusRESIZING V1ProjectWithDatabaseResponseStatus = "RESIZING" + V1ProjectWithDatabaseResponseStatusRESTARTING V1ProjectWithDatabaseResponseStatus = "RESTARTING" + V1ProjectWithDatabaseResponseStatusRESTOREFAILED V1ProjectWithDatabaseResponseStatus = "RESTORE_FAILED" + V1ProjectWithDatabaseResponseStatusRESTORING V1ProjectWithDatabaseResponseStatus = "RESTORING" + V1ProjectWithDatabaseResponseStatusUNKNOWN V1ProjectWithDatabaseResponseStatus = "UNKNOWN" + V1ProjectWithDatabaseResponseStatusUPGRADING V1ProjectWithDatabaseResponseStatus = "UPGRADING" +) + // Defines values for V1ServiceHealthResponseName. const ( V1ServiceHealthResponseNameAuth V1ServiceHealthResponseName = "auth" @@ -368,9 +415,9 @@ const ( // Defines values for V1ServiceHealthResponseStatus. const ( - V1ServiceHealthResponseStatusACTIVEHEALTHY V1ServiceHealthResponseStatus = "ACTIVE_HEALTHY" - V1ServiceHealthResponseStatusCOMINGUP V1ServiceHealthResponseStatus = "COMING_UP" - V1ServiceHealthResponseStatusUNHEALTHY V1ServiceHealthResponseStatus = "UNHEALTHY" + ACTIVEHEALTHY V1ServiceHealthResponseStatus = "ACTIVE_HEALTHY" + COMINGUP V1ServiceHealthResponseStatus = "COMING_UP" + UNHEALTHY V1ServiceHealthResponseStatus = "UNHEALTHY" ) // Defines values for VanitySubdomainConfigResponseStatus. @@ -725,8 +772,8 @@ type CreateBranchBody struct { ReleaseChannel *ReleaseChannel `json:"release_channel,omitempty"` } -// CreateOrganizationBodyV1 defines model for CreateOrganizationBodyV1. -type CreateOrganizationBodyV1 struct { +// CreateOrganizationV1Dto defines model for CreateOrganizationV1Dto. +type CreateOrganizationV1Dto struct { Name string `json:"name"` } @@ -824,17 +871,18 @@ type Domain struct { // FunctionResponse defines model for FunctionResponse. type FunctionResponse struct { - CreatedAt int64 `json:"created_at"` - EntrypointPath *string `json:"entrypoint_path,omitempty"` - Id string `json:"id"` - ImportMap *bool `json:"import_map,omitempty"` - ImportMapPath *string `json:"import_map_path,omitempty"` - Name string `json:"name"` - Slug string `json:"slug"` - Status FunctionResponseStatus `json:"status"` - UpdatedAt int64 `json:"updated_at"` - VerifyJwt *bool `json:"verify_jwt,omitempty"` - Version int `json:"version"` + ComputeMultiplier *float32 `json:"compute_multiplier,omitempty"` + CreatedAt int64 `json:"created_at"` + EntrypointPath *string `json:"entrypoint_path,omitempty"` + Id string `json:"id"` + ImportMap *bool `json:"import_map,omitempty"` + ImportMapPath *string `json:"import_map_path,omitempty"` + Name string `json:"name"` + Slug string `json:"slug"` + Status FunctionResponseStatus `json:"status"` + UpdatedAt int64 `json:"updated_at"` + VerifyJwt *bool `json:"verify_jwt,omitempty"` + Version int `json:"version"` } // FunctionResponseStatus defines model for FunctionResponse.Status. @@ -842,17 +890,18 @@ type FunctionResponseStatus string // FunctionSlugResponse defines model for FunctionSlugResponse. type FunctionSlugResponse struct { - CreatedAt int64 `json:"created_at"` - EntrypointPath *string `json:"entrypoint_path,omitempty"` - Id string `json:"id"` - ImportMap *bool `json:"import_map,omitempty"` - ImportMapPath *string `json:"import_map_path,omitempty"` - Name string `json:"name"` - Slug string `json:"slug"` - Status FunctionSlugResponseStatus `json:"status"` - UpdatedAt int64 `json:"updated_at"` - VerifyJwt *bool `json:"verify_jwt,omitempty"` - Version int `json:"version"` + ComputeMultiplier *float32 `json:"compute_multiplier,omitempty"` + CreatedAt int64 `json:"created_at"` + EntrypointPath *string `json:"entrypoint_path,omitempty"` + Id string `json:"id"` + ImportMap *bool `json:"import_map,omitempty"` + ImportMapPath *string `json:"import_map_path,omitempty"` + Name string `json:"name"` + Slug string `json:"slug"` + Status FunctionSlugResponseStatus `json:"status"` + UpdatedAt int64 `json:"updated_at"` + VerifyJwt *bool `json:"verify_jwt,omitempty"` + Version int `json:"version"` } // FunctionSlugResponseStatus defines model for FunctionSlugResponse.Status. @@ -1539,17 +1588,18 @@ type V1BackupsResponse struct { // V1CreateFunctionBody defines model for V1CreateFunctionBody. type V1CreateFunctionBody struct { - Body string `json:"body"` - Name string `json:"name"` - Slug string `json:"slug"` - VerifyJwt *bool `json:"verify_jwt,omitempty"` + Body string `json:"body"` + ComputeMultiplier *float32 `json:"compute_multiplier,omitempty"` + Name string `json:"name"` + Slug string `json:"slug"` + VerifyJwt *bool `json:"verify_jwt,omitempty"` } -// V1CreateProjectBody defines model for V1CreateProjectBody. -type V1CreateProjectBody struct { +// V1CreateProjectBodyDto defines model for V1CreateProjectBodyDto. +type V1CreateProjectBodyDto struct { // DbPass Database password - DbPass string `json:"db_pass"` - DesiredInstanceSize *DesiredInstanceSize `json:"desired_instance_size,omitempty"` + DbPass string `json:"db_pass"` + DesiredInstanceSize *V1CreateProjectBodyDtoDesiredInstanceSize `json:"desired_instance_size,omitempty"` // KpsEnabled This field is deprecated and is ignored in this request // Deprecated: @@ -1563,24 +1613,35 @@ type V1CreateProjectBody struct { // Plan Subscription Plan is now set on organization level and is ignored in this request // Deprecated: - Plan *V1CreateProjectBodyPlan `json:"plan,omitempty"` + Plan *V1CreateProjectBodyDtoPlan `json:"plan,omitempty"` // PostgresEngine Postgres engine version. If not provided, the latest version will be used. - PostgresEngine *PostgresEngine `json:"postgres_engine,omitempty"` + PostgresEngine *V1CreateProjectBodyDtoPostgresEngine `json:"postgres_engine,omitempty"` // Region Region you want your server to reside in - Region V1CreateProjectBodyRegion `json:"region"` - ReleaseChannel *ReleaseChannel `json:"release_channel,omitempty"` + Region V1CreateProjectBodyDtoRegion `json:"region"` + + // ReleaseChannel Release channel. If not provided, GA will be used. + ReleaseChannel *V1CreateProjectBodyDtoReleaseChannel `json:"release_channel,omitempty"` // TemplateUrl Template URL used to create the project from the CLI. TemplateUrl *string `json:"template_url,omitempty"` } -// V1CreateProjectBodyPlan Subscription Plan is now set on organization level and is ignored in this request -type V1CreateProjectBodyPlan string +// V1CreateProjectBodyDtoDesiredInstanceSize defines model for V1CreateProjectBodyDto.DesiredInstanceSize. +type V1CreateProjectBodyDtoDesiredInstanceSize string + +// V1CreateProjectBodyDtoPlan Subscription Plan is now set on organization level and is ignored in this request +type V1CreateProjectBodyDtoPlan string + +// V1CreateProjectBodyDtoPostgresEngine Postgres engine version. If not provided, the latest version will be used. +type V1CreateProjectBodyDtoPostgresEngine string -// V1CreateProjectBodyRegion Region you want your server to reside in -type V1CreateProjectBodyRegion string +// V1CreateProjectBodyDtoRegion Region you want your server to reside in +type V1CreateProjectBodyDtoRegion string + +// V1CreateProjectBodyDtoReleaseChannel Release channel. If not provided, GA will be used. +type V1CreateProjectBodyDtoReleaseChannel string // V1DatabaseResponse defines model for V1DatabaseResponse. type V1DatabaseResponse struct { @@ -1656,8 +1717,7 @@ type V1ProjectRefResponse struct { // V1ProjectResponse defines model for V1ProjectResponse. type V1ProjectResponse struct { // CreatedAt Creation timestamp - CreatedAt string `json:"created_at"` - Database *V1DatabaseResponse `json:"database,omitempty"` + CreatedAt string `json:"created_at"` // Id Id of your project Id string `json:"id"` @@ -1676,6 +1736,29 @@ type V1ProjectResponse struct { // V1ProjectResponseStatus defines model for V1ProjectResponse.Status. type V1ProjectResponseStatus string +// V1ProjectWithDatabaseResponse defines model for V1ProjectWithDatabaseResponse. +type V1ProjectWithDatabaseResponse struct { + // CreatedAt Creation timestamp + CreatedAt string `json:"created_at"` + Database V1DatabaseResponse `json:"database"` + + // Id Id of your project + Id string `json:"id"` + + // Name Name of your project + Name string `json:"name"` + + // OrganizationId Slug of your organization + OrganizationId string `json:"organization_id"` + + // Region Region of your project + Region string `json:"region"` + Status V1ProjectWithDatabaseResponseStatus `json:"status"` +} + +// V1ProjectWithDatabaseResponseStatus defines model for V1ProjectWithDatabaseResponse.Status. +type V1ProjectWithDatabaseResponseStatus string + // V1RestorePitrBody defines model for V1RestorePitrBody. type V1RestorePitrBody struct { RecoveryTimeTargetUnix int64 `json:"recovery_time_target_unix"` @@ -1718,9 +1801,10 @@ type V1StorageBucketResponse struct { // V1UpdateFunctionBody defines model for V1UpdateFunctionBody. type V1UpdateFunctionBody struct { - Body *string `json:"body,omitempty"` - Name *string `json:"name,omitempty"` - VerifyJwt *bool `json:"verify_jwt,omitempty"` + Body *string `json:"body,omitempty"` + ComputeMultiplier *float32 `json:"compute_multiplier,omitempty"` + Name *string `json:"name,omitempty"` + VerifyJwt *bool `json:"verify_jwt,omitempty"` } // ValidationError defines model for ValidationError. @@ -1766,24 +1850,51 @@ type V1AuthorizeUserParamsResponseType string // V1AuthorizeUserParamsCodeChallengeMethod defines parameters for V1AuthorizeUser. type V1AuthorizeUserParamsCodeChallengeMethod string +// V1GetProjectApiKeysParams defines parameters for V1GetProjectApiKeys. +type V1GetProjectApiKeysParams struct { + Reveal bool `form:"reveal" json:"reveal"` +} + +// CreateApiKeyParams defines parameters for CreateApiKey. +type CreateApiKeyParams struct { + Reveal bool `form:"reveal" json:"reveal"` +} + +// DeleteApiKeyParams defines parameters for DeleteApiKey. +type DeleteApiKeyParams struct { + Reveal bool `form:"reveal" json:"reveal"` +} + +// GetApiKeyParams defines parameters for GetApiKey. +type GetApiKeyParams struct { + Reveal bool `form:"reveal" json:"reveal"` +} + +// UpdateApiKeyParams defines parameters for UpdateApiKey. +type UpdateApiKeyParams struct { + Reveal bool `form:"reveal" json:"reveal"` +} + // V1CreateAFunctionParams defines parameters for V1CreateAFunction. type V1CreateAFunctionParams struct { - Slug *string `form:"slug,omitempty" json:"slug,omitempty"` - Name *string `form:"name,omitempty" json:"name,omitempty"` - VerifyJwt *bool `form:"verify_jwt,omitempty" json:"verify_jwt,omitempty"` - ImportMap *bool `form:"import_map,omitempty" json:"import_map,omitempty"` - EntrypointPath *string `form:"entrypoint_path,omitempty" json:"entrypoint_path,omitempty"` - ImportMapPath *string `form:"import_map_path,omitempty" json:"import_map_path,omitempty"` + Slug *string `form:"slug,omitempty" json:"slug,omitempty"` + Name *string `form:"name,omitempty" json:"name,omitempty"` + VerifyJwt *bool `form:"verify_jwt,omitempty" json:"verify_jwt,omitempty"` + ImportMap *bool `form:"import_map,omitempty" json:"import_map,omitempty"` + EntrypointPath *string `form:"entrypoint_path,omitempty" json:"entrypoint_path,omitempty"` + ImportMapPath *string `form:"import_map_path,omitempty" json:"import_map_path,omitempty"` + ComputeMultiplier *float32 `form:"compute_multiplier,omitempty" json:"compute_multiplier,omitempty"` } // V1UpdateAFunctionParams defines parameters for V1UpdateAFunction. type V1UpdateAFunctionParams struct { - Slug *string `form:"slug,omitempty" json:"slug,omitempty"` - Name *string `form:"name,omitempty" json:"name,omitempty"` - VerifyJwt *bool `form:"verify_jwt,omitempty" json:"verify_jwt,omitempty"` - ImportMap *bool `form:"import_map,omitempty" json:"import_map,omitempty"` - EntrypointPath *string `form:"entrypoint_path,omitempty" json:"entrypoint_path,omitempty"` - ImportMapPath *string `form:"import_map_path,omitempty" json:"import_map_path,omitempty"` + Slug *string `form:"slug,omitempty" json:"slug,omitempty"` + Name *string `form:"name,omitempty" json:"name,omitempty"` + VerifyJwt *bool `form:"verify_jwt,omitempty" json:"verify_jwt,omitempty"` + ImportMap *bool `form:"import_map,omitempty" json:"import_map,omitempty"` + EntrypointPath *string `form:"entrypoint_path,omitempty" json:"entrypoint_path,omitempty"` + ImportMapPath *string `form:"import_map_path,omitempty" json:"import_map_path,omitempty"` + ComputeMultiplier *float32 `form:"compute_multiplier,omitempty" json:"compute_multiplier,omitempty"` } // V1GetServicesHealthParams defines parameters for V1GetServicesHealth. @@ -1823,10 +1934,10 @@ type V1UpdateABranchConfigJSONRequestBody = UpdateBranchBody type V1ExchangeOauthTokenFormdataRequestBody = OAuthTokenBody // V1CreateAnOrganizationJSONRequestBody defines body for V1CreateAnOrganization for application/json ContentType. -type V1CreateAnOrganizationJSONRequestBody = CreateOrganizationBodyV1 +type V1CreateAnOrganizationJSONRequestBody = CreateOrganizationV1Dto // V1CreateAProjectJSONRequestBody defines body for V1CreateAProject for application/json ContentType. -type V1CreateAProjectJSONRequestBody = V1CreateProjectBody +type V1CreateAProjectJSONRequestBody = V1CreateProjectBodyDto // CreateApiKeyJSONRequestBody defines body for CreateApiKey for application/json ContentType. type CreateApiKeyJSONRequestBody = CreateApiKeyBody From ff190bd5a9cb3ba98df82761984411ff4b0324ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Mon, 25 Nov 2024 11:24:07 +0900 Subject: [PATCH 179/305] fix: bump edge-runtime to 1.64.1 (#2911) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 670450d5a..e9172c1ae 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241106-f29003e" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.62.2" + edgeRuntimeImage = "supabase/edge-runtime:v1.64.1" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.164.0" From e6a510a633942c32d35e7c1cec119b76f1f0fbd8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 04:36:54 +0000 Subject: [PATCH 180/305] chore(deps): bump github.com/stretchr/testify from 1.9.0 to 1.10.0 (#2913) Bumps [github.com/stretchr/testify](https://github.com/stretchr/testify) from 1.9.0 to 1.10.0. - [Release notes](https://github.com/stretchr/testify/releases) - [Commits](https://github.com/stretchr/testify/compare/v1.9.0...v1.10.0) --- updated-dependencies: - dependency-name: github.com/stretchr/testify dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4e58e4562..8d20dbf8a 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,7 @@ require ( github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.19.0 - github.com/stretchr/testify v1.9.0 + github.com/stretchr/testify v1.10.0 github.com/stripe/pg-schema-diff v0.7.0 github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 github.com/zalando/go-keyring v0.2.6 diff --git a/go.sum b/go.sum index e224d065e..0d5081f18 100644 --- a/go.sum +++ b/go.sum @@ -947,8 +947,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stripe/pg-schema-diff v0.7.0 h1:00Z+LGGe9GhMsN5gLtx/ZwF/+xPOMgod/g8x8H1JmV4= github.com/stripe/pg-schema-diff v0.7.0/go.mod h1:HuTBuWLuvnY9g9nptbSD58xugN19zSJNkF4w/sYRtdU= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= From 76121570a99b444d5e9a3a002c6734d9f2ffc31c Mon Sep 17 00:00:00 2001 From: Chris Gwilliams <517923+encima@users.noreply.github.com> Date: Mon, 25 Nov 2024 08:00:51 +0200 Subject: [PATCH 181/305] chore: remove trailing semicolon from role_configs.sql (#2907) Update role_configs.sql --- internal/inspect/role_configs/role_configs.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/inspect/role_configs/role_configs.sql b/internal/inspect/role_configs/role_configs.sql index d568d6862..fd7f964d0 100644 --- a/internal/inspect/role_configs/role_configs.sql +++ b/internal/inspect/role_configs/role_configs.sql @@ -2,4 +2,4 @@ select rolname as role_name, array_to_string(rolconfig, ',', '*') as custom_config from - pg_roles where rolconfig is not null; + pg_roles where rolconfig is not null From e3f8f348dd16a84396f4679e5a92b676c8df8665 Mon Sep 17 00:00:00 2001 From: Andrey Tarasevich Date: Sun, 24 Nov 2024 22:01:27 -0800 Subject: [PATCH 182/305] fix(realtime): bump realtime image to 2.33.51 (#2905) chore(deps): bump realtime image to 2.33.51 --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index e9172c1ae..0a779fe63 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -16,7 +16,7 @@ const ( vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.164.0" - realtimeImage = "supabase/realtime:v2.30.34" + realtimeImage = "supabase/realtime:v2.33.51" storageImage = "supabase/storage-api:v1.11.13" logflareImage = "supabase/logflare:1.4.0" // Append to JobImages when adding new dependencies below From b9e89fcdf9192d98beea9f2a8dec185f6051f9bd Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Mon, 25 Nov 2024 08:56:14 +0100 Subject: [PATCH 183/305] fix(reset): ensure _supabase connections disconnect before reset (#2904) * fix(reset): ensure _supabase connections disconnect before reset Closes #2903 * fix: switch tests * fix: refactor reset for multiples db * chore: refactor terminate backend query --------- Co-authored-by: Qiao Han --- internal/db/branch/switch_/switch__test.go | 38 +++++++++++++------- internal/db/diff/diff.go | 4 +-- internal/db/reset/reset.go | 35 +++++++++++++++---- internal/db/reset/reset_test.go | 40 ++++++++++++++-------- internal/db/start/start.go | 13 ++++--- internal/utils/misc.go | 12 +------ 6 files changed, 92 insertions(+), 50 deletions(-) diff --git a/internal/db/branch/switch_/switch__test.go b/internal/db/branch/switch_/switch__test.go index 429606627..7c70959ce 100644 --- a/internal/db/branch/switch_/switch__test.go +++ b/internal/db/branch/switch_/switch__test.go @@ -2,7 +2,6 @@ package switch_ import ( "context" - "fmt" "net/http" "os" "path/filepath" @@ -14,6 +13,7 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/supabase/cli/internal/db/reset" "github.com/supabase/cli/internal/testing/apitest" "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/pkg/pgtest" @@ -42,10 +42,14 @@ func TestSwitchCommand(t *testing.T) { // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) - conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false;"). + conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false"). Reply("ALTER DATABASE"). - Query(fmt.Sprintf(utils.TerminateDbSqlFmt, "postgres")). - Reply("DO"). + Query("ALTER DATABASE _supabase ALLOW_CONNECTIONS false"). + Reply("ALTER DATABASE"). + Query(reset.TERMINATE_BACKENDS). + Reply("SELECT 1"). + Query(reset.COUNT_REPLICATION_SLOTS). + Reply("SELECT 1", []interface{}{0}). Query("ALTER DATABASE postgres RENAME TO main;"). Reply("ALTER DATABASE"). Query("ALTER DATABASE " + branch + " RENAME TO postgres;"). @@ -218,8 +222,10 @@ func TestSwitchDatabase(t *testing.T) { // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) - conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false;"). - ReplyError(pgerrcode.InvalidParameterValue, `cannot disallow connections for current database`) + conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false"). + ReplyError(pgerrcode.InvalidParameterValue, `cannot disallow connections for current database`). + Query("ALTER DATABASE _supabase ALLOW_CONNECTIONS false"). + Query(reset.TERMINATE_BACKENDS) // Run test err := switchDatabase(context.Background(), "main", "target", conn.Intercept) // Check error @@ -234,10 +240,14 @@ func TestSwitchDatabase(t *testing.T) { // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) - conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false;"). + conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false"). + Reply("ALTER DATABASE"). + Query("ALTER DATABASE _supabase ALLOW_CONNECTIONS false"). Reply("ALTER DATABASE"). - Query(fmt.Sprintf(utils.TerminateDbSqlFmt, "postgres")). - Reply("DO"). + Query(reset.TERMINATE_BACKENDS). + Reply("SELECT 1"). + Query(reset.COUNT_REPLICATION_SLOTS). + Reply("SELECT 1", []interface{}{0}). Query("ALTER DATABASE postgres RENAME TO main;"). ReplyError(pgerrcode.DuplicateDatabase, `database "main" already exists`) // Setup mock docker @@ -260,10 +270,14 @@ func TestSwitchDatabase(t *testing.T) { // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) - conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false;"). + conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false"). + Reply("ALTER DATABASE"). + Query("ALTER DATABASE _supabase ALLOW_CONNECTIONS false"). Reply("ALTER DATABASE"). - Query(fmt.Sprintf(utils.TerminateDbSqlFmt, "postgres")). - Reply("DO"). + Query(reset.TERMINATE_BACKENDS). + Reply("SELECT 1"). + Query(reset.COUNT_REPLICATION_SLOTS). + Reply("SELECT 1", []interface{}{0}). Query("ALTER DATABASE postgres RENAME TO main;"). Reply("ALTER DATABASE"). Query("ALTER DATABASE target RENAME TO postgres;"). diff --git a/internal/db/diff/diff.go b/internal/db/diff/diff.go index 38a3bed58..6c5faa892 100644 --- a/internal/db/diff/diff.go +++ b/internal/db/diff/diff.go @@ -146,12 +146,12 @@ func CreateShadowDatabase(ctx context.Context, port uint16) (string, error) { func ConnectShadowDatabase(ctx context.Context, timeout time.Duration, options ...func(*pgx.ConnConfig)) (conn *pgx.Conn, err error) { // Retry until connected, cancelled, or timeout - policy := backoff.WithMaxRetries(backoff.NewConstantBackOff(time.Second), uint64(timeout.Seconds())) + policy := start.NewBackoffPolicy(ctx, timeout) config := pgconn.Config{Port: utils.Config.Db.ShadowPort} connect := func() (*pgx.Conn, error) { return utils.ConnectLocalPostgres(ctx, config, options...) } - return backoff.RetryWithData(connect, backoff.WithContext(policy, ctx)) + return backoff.RetryWithData(connect, policy) } func MigrateShadowDatabase(ctx context.Context, container string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/db/reset/reset.go b/internal/db/reset/reset.go index a9d2f4f4f..a475ca80d 100644 --- a/internal/db/reset/reset.go +++ b/internal/db/reset/reset.go @@ -10,6 +10,7 @@ import ( "strings" "time" + "github.com/cenkalti/backoff/v4" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" @@ -164,20 +165,40 @@ func recreateDatabase(ctx context.Context, options ...func(*pgx.ConnConfig)) err return sql.ExecBatch(ctx, conn) } +const ( + TERMINATE_BACKENDS = "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname IN ('postgres', '_supabase')" + COUNT_REPLICATION_SLOTS = "SELECT COUNT(*) FROM pg_replication_slots WHERE database IN ('postgres', '_supabase')" +) + func DisconnectClients(ctx context.Context, conn *pgx.Conn) error { - // Must be executed separately because running in transaction is unsupported - disconn := "ALTER DATABASE postgres ALLOW_CONNECTIONS false;" - if _, err := conn.Exec(ctx, disconn); err != nil { + // Must be executed separately because looping in transaction is unsupported + // https://dba.stackexchange.com/a/11895 + disconn := migration.MigrationFile{ + Statements: []string{ + "ALTER DATABASE postgres ALLOW_CONNECTIONS false", + "ALTER DATABASE _supabase ALLOW_CONNECTIONS false", + TERMINATE_BACKENDS, + }, + } + if err := disconn.ExecBatch(ctx, conn); err != nil { var pgErr *pgconn.PgError if errors.As(err, &pgErr) && pgErr.Code != pgerrcode.InvalidCatalogName { return errors.Errorf("failed to disconnect clients: %w", err) } } - term := fmt.Sprintf(utils.TerminateDbSqlFmt, "postgres") - if _, err := conn.Exec(ctx, term); err != nil { - return errors.Errorf("failed to terminate backend: %w", err) + // Wait for WAL senders to drop their replication slots + policy := start.NewBackoffPolicy(ctx, 10*time.Second) + waitForDrop := func() error { + var count int + if err := conn.QueryRow(ctx, COUNT_REPLICATION_SLOTS).Scan(&count); err != nil { + err = errors.Errorf("failed to count replication slots: %w", err) + return &backoff.PermanentError{Err: err} + } else if count > 0 { + return errors.Errorf("replication slots still active: %d", count) + } + return nil } - return nil + return backoff.Retry(waitForDrop, policy) } func RestartDatabase(ctx context.Context, w io.Writer) error { diff --git a/internal/db/reset/reset_test.go b/internal/db/reset/reset_test.go index c65aa0ef9..4e3558be3 100644 --- a/internal/db/reset/reset_test.go +++ b/internal/db/reset/reset_test.go @@ -3,7 +3,6 @@ package reset import ( "context" "errors" - "fmt" "io" "net/http" "path/filepath" @@ -202,10 +201,14 @@ func TestRecreateDatabase(t *testing.T) { // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) - conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false;"). + conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false"). Reply("ALTER DATABASE"). - Query(fmt.Sprintf(utils.TerminateDbSqlFmt, "postgres")). - Reply("DO"). + Query("ALTER DATABASE _supabase ALLOW_CONNECTIONS false"). + Reply("ALTER DATABASE"). + Query(TERMINATE_BACKENDS). + Reply("SELECT 1"). + Query(COUNT_REPLICATION_SLOTS). + Reply("SELECT 1", []interface{}{0}). Query("DROP DATABASE IF EXISTS postgres WITH (FORCE)"). Reply("DROP DATABASE"). Query("CREATE DATABASE postgres WITH OWNER postgres"). @@ -228,14 +231,17 @@ func TestRecreateDatabase(t *testing.T) { // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) - conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false;"). - ReplyError(pgerrcode.InvalidCatalogName, `database "postgres" does not exist`). - Query(fmt.Sprintf(utils.TerminateDbSqlFmt, "postgres")). - ReplyError(pgerrcode.UndefinedTable, `relation "pg_stat_activity" does not exist`) + conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false"). + Reply("ALTER DATABASE"). + Query("ALTER DATABASE _supabase ALLOW_CONNECTIONS false"). + ReplyError(pgerrcode.InvalidCatalogName, `database "_supabase" does not exist`). + Query(TERMINATE_BACKENDS). + Query(COUNT_REPLICATION_SLOTS). + ReplyError(pgerrcode.UndefinedTable, `relation "pg_replication_slots" does not exist`) // Run test err := recreateDatabase(context.Background(), conn.Intercept) // Check error - assert.ErrorContains(t, err, `ERROR: relation "pg_stat_activity" does not exist (SQLSTATE 42P01)`) + assert.ErrorContains(t, err, `ERROR: relation "pg_replication_slots" does not exist (SQLSTATE 42P01)`) }) t.Run("throws error on failure to disconnect", func(t *testing.T) { @@ -243,8 +249,10 @@ func TestRecreateDatabase(t *testing.T) { // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) - conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false;"). - ReplyError(pgerrcode.InvalidParameterValue, `cannot disallow connections for current database`) + conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false"). + ReplyError(pgerrcode.InvalidParameterValue, `cannot disallow connections for current database`). + Query("ALTER DATABASE _supabase ALLOW_CONNECTIONS false"). + Query(TERMINATE_BACKENDS) // Run test err := recreateDatabase(context.Background(), conn.Intercept) // Check error @@ -256,10 +264,14 @@ func TestRecreateDatabase(t *testing.T) { // Setup mock postgres conn := pgtest.NewConn() defer conn.Close(t) - conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false;"). + conn.Query("ALTER DATABASE postgres ALLOW_CONNECTIONS false"). + Reply("ALTER DATABASE"). + Query("ALTER DATABASE _supabase ALLOW_CONNECTIONS false"). Reply("ALTER DATABASE"). - Query(fmt.Sprintf(utils.TerminateDbSqlFmt, "postgres")). - Reply("DO"). + Query(TERMINATE_BACKENDS). + Reply("SELECT 1"). + Query(COUNT_REPLICATION_SLOTS). + Reply("SELECT 1", []interface{}{0}). Query("DROP DATABASE IF EXISTS postgres WITH (FORCE)"). ReplyError(pgerrcode.ObjectInUse, `database "postgres" is used by an active logical replication slot`). Query("CREATE DATABASE postgres WITH OWNER postgres"). diff --git a/internal/db/start/start.go b/internal/db/start/start.go index a300f5594..f0fc488d2 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -160,6 +160,14 @@ EOF`} return initCurrentBranch(fsys) } +func NewBackoffPolicy(ctx context.Context, timeout time.Duration) backoff.BackOff { + policy := backoff.WithMaxRetries( + backoff.NewConstantBackOff(time.Second), + uint64(timeout.Seconds()), + ) + return backoff.WithContext(policy, ctx) +} + func WaitForHealthyService(ctx context.Context, timeout time.Duration, started ...string) error { probe := func() error { var errHealth []error @@ -173,10 +181,7 @@ func WaitForHealthyService(ctx context.Context, timeout time.Duration, started . started = unhealthy return errors.Join(errHealth...) } - policy := backoff.WithContext(backoff.WithMaxRetries( - backoff.NewConstantBackOff(time.Second), - uint64(timeout.Seconds()), - ), ctx) + policy := NewBackoffPolicy(ctx, timeout) err := backoff.Retry(probe, policy) if err != nil && !errors.Is(err, context.Canceled) { // Print container logs for easier debugging diff --git a/internal/utils/misc.go b/internal/utils/misc.go index 0993ae806..202d80d0a 100644 --- a/internal/utils/misc.go +++ b/internal/utils/misc.go @@ -31,17 +31,7 @@ func ShortContainerImageName(imageName string) string { return matches[1] } -const ( - // https://dba.stackexchange.com/a/11895 - // Args: dbname - TerminateDbSqlFmt = ` -SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '%[1]s'; --- Wait for WAL sender to drop replication slot. -DO 'BEGIN WHILE ( - SELECT COUNT(*) FROM pg_replication_slots WHERE database = ''%[1]s'' -) > 0 LOOP END LOOP; END';` - SuggestDebugFlag = "Try rerunning the command with --debug to troubleshoot the error." -) +const SuggestDebugFlag = "Try rerunning the command with --debug to troubleshoot the error." var ( CmdSuggestion string From c1fb5d01b2a0d9992c2a1a82ad3b19a3f59498bd Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Mon, 25 Nov 2024 12:32:18 +0100 Subject: [PATCH 184/305] feat(config): allow custom admin and sendername for inbucket (#2908) * feat(config): allow custom admin and sendername for inbucket * Update pkg/config/templates/config.toml Co-authored-by: Han Qiao --------- Co-authored-by: Han Qiao --- internal/start/start.go | 3 ++- pkg/config/config.go | 16 ++++++++++------ pkg/config/templates/config.toml | 2 ++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/internal/start/start.go b/internal/start/start.go index bdb0989aa..8342a18b1 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -532,7 +532,8 @@ EOF env = append(env, "GOTRUE_SMTP_HOST="+utils.InbucketId, "GOTRUE_SMTP_PORT=2500", - "GOTRUE_SMTP_ADMIN_EMAIL=admin@email.com", + fmt.Sprintf("GOTRUE_SMTP_ADMIN_EMAIL=%s", utils.Config.Inbucket.AdminEmail), + fmt.Sprintf("GOTRUE_SMTP_SENDER_NAME=%s", utils.Config.Inbucket.SenderName), ) } diff --git a/pkg/config/config.go b/pkg/config/config.go index b1e7ed570..ba2151e24 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -159,11 +159,13 @@ type ( } inbucket struct { - Enabled bool `toml:"enabled"` - Image string `toml:"-"` - Port uint16 `toml:"port"` - SmtpPort uint16 `toml:"smtp_port"` - Pop3Port uint16 `toml:"pop3_port"` + Enabled bool `toml:"enabled"` + Image string `toml:"-"` + Port uint16 `toml:"port"` + SmtpPort uint16 `toml:"smtp_port"` + Pop3Port uint16 `toml:"pop3_port"` + AdminEmail string `toml:"admin_email"` + SenderName string `toml:"sender_name"` } edgeRuntime struct { @@ -327,7 +329,9 @@ func NewConfig(editors ...ConfigEditor) config { JwtSecret: defaultJwtSecret, }, Inbucket: inbucket{ - Image: inbucketImage, + Image: inbucketImage, + AdminEmail: "admin@email.com", + SenderName: "Admin", }, Studio: studio{ Image: studioImage, diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index 979e4bdfd..cc674d59b 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -72,6 +72,8 @@ port = 54324 # Uncomment to expose additional ports for testing user applications that send emails. # smtp_port = 54325 # pop3_port = 54326 +# admin_email = "admin@email.com" +# sender_name = "Admin" [storage] enabled = true From 949b018d0372be765fa50598a3a9c83b16f30303 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Nov 2024 05:03:37 +0000 Subject: [PATCH 185/305] chore(deps): bump github.com/golangci/golangci-lint from 1.62.0 to 1.62.2 (#2917) chore(deps): bump github.com/golangci/golangci-lint Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.62.0 to 1.62.2. - [Release notes](https://github.com/golangci/golangci-lint/releases) - [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md) - [Commits](https://github.com/golangci/golangci-lint/compare/v1.62.0...v1.62.2) --- updated-dependencies: - dependency-name: github.com/golangci/golangci-lint dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 16 ++++++++-------- go.sum | 32 ++++++++++++++++---------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index 8d20dbf8a..54dd44b5f 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/go-git/go-git/v5 v5.12.0 github.com/go-xmlfmt/xmlfmt v1.1.2 github.com/golang-jwt/jwt/v5 v5.2.1 - github.com/golangci/golangci-lint v1.62.0 + github.com/golangci/golangci-lint v1.62.2 github.com/google/go-github/v62 v62.0.0 github.com/google/go-querystring v1.1.0 github.com/google/uuid v1.6.0 @@ -66,9 +66,9 @@ require ( github.com/Abirdcfly/dupword v0.1.3 // indirect github.com/Antonboom/errname v1.0.0 // indirect github.com/Antonboom/nilnil v1.0.0 // indirect - github.com/Antonboom/testifylint v1.5.0 // indirect + github.com/Antonboom/testifylint v1.5.2 // indirect github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect - github.com/Crocmagnon/fatcontext v0.5.2 // indirect + github.com/Crocmagnon/fatcontext v0.5.3 // indirect github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.0 // indirect github.com/Masterminds/semver/v3 v3.3.0 // indirect @@ -226,7 +226,7 @@ require ( github.com/mattn/go-localereader v0.0.1 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/mgechev/revive v1.5.0 // indirect + github.com/mgechev/revive v1.5.1 // indirect github.com/microcosm-cc/bluemonday v1.0.25 // indirect github.com/miekg/pkcs11 v1.1.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect @@ -245,7 +245,7 @@ require ( github.com/nakabonne/nestif v0.3.1 // indirect github.com/nishanths/exhaustive v0.12.0 // indirect github.com/nishanths/predeclared v0.2.2 // indirect - github.com/nunnatsa/ginkgolinter v0.18.0 // indirect + github.com/nunnatsa/ginkgolinter v0.18.3 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect @@ -254,7 +254,7 @@ require ( github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/polyfloyd/go-errorlint v1.6.0 // indirect + github.com/polyfloyd/go-errorlint v1.7.0 // indirect github.com/prometheus/client_golang v1.12.1 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.32.1 // indirect @@ -303,7 +303,7 @@ require ( github.com/ultraware/funlen v0.1.0 // indirect github.com/ultraware/whitespace v0.1.1 // indirect github.com/uudashr/gocognit v1.1.3 // indirect - github.com/uudashr/iface v1.2.0 // indirect + github.com/uudashr/iface v1.2.1 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect @@ -334,7 +334,7 @@ require ( golang.org/x/arch v0.8.0 // indirect golang.org/x/crypto v0.29.0 // indirect golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect - golang.org/x/exp/typeparams v0.0.0-20240909161429-701f63a606c0 // indirect + golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect golang.org/x/net v0.31.0 // indirect golang.org/x/sync v0.9.0 // indirect golang.org/x/sys v0.27.0 // indirect diff --git a/go.sum b/go.sum index 0d5081f18..757c27022 100644 --- a/go.sum +++ b/go.sum @@ -47,16 +47,16 @@ github.com/Antonboom/errname v1.0.0 h1:oJOOWR07vS1kRusl6YRSlat7HFnb3mSfMl6sDMRoT github.com/Antonboom/errname v1.0.0/go.mod h1:gMOBFzK/vrTiXN9Oh+HFs+e6Ndl0eTFbtsRTSRdXyGI= github.com/Antonboom/nilnil v1.0.0 h1:n+v+B12dsE5tbAqRODXmEKfZv9j2KcTBrp+LkoM4HZk= github.com/Antonboom/nilnil v1.0.0/go.mod h1:fDJ1FSFoLN6yoG65ANb1WihItf6qt9PJVTn/s2IrcII= -github.com/Antonboom/testifylint v1.5.0 h1:dlUIsDMtCrZWUnvkaCz3quJCoIjaGi41GzjPBGkkJ8A= -github.com/Antonboom/testifylint v1.5.0/go.mod h1:wqaJbu0Blb5Wag2wv7Z5xt+CIV+eVLxtGZrlK13z3AE= +github.com/Antonboom/testifylint v1.5.2 h1:4s3Xhuv5AvdIgbd8wOOEeo0uZG7PbDKQyKY5lGoQazk= +github.com/Antonboom/testifylint v1.5.2/go.mod h1:vxy8VJ0bc6NavlYqjZfmp6EfqXMtBgQ4+mhCojwC1P8= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs= github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/Crocmagnon/fatcontext v0.5.2 h1:vhSEg8Gqng8awhPju2w7MKHqMlg4/NI+gSDHtR3xgwA= -github.com/Crocmagnon/fatcontext v0.5.2/go.mod h1:87XhRMaInHP44Q7Tlc7jkgKKB7kZAOPiDkFMdKCC+74= +github.com/Crocmagnon/fatcontext v0.5.3 h1:zCh/wjc9oyeF+Gmp+V60wetm8ph2tlsxocgg/J0hOps= +github.com/Crocmagnon/fatcontext v0.5.3/go.mod h1:XoCQYY1J+XTfyv74qLXvNw4xFunr3L1wkopIIKG7wGM= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 h1:sHglBQTwgx+rWPdisA5ynNEsoARbiCBOyGcJM4/OzsM= github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24/go.mod h1:4UJr5HIiMZrwgkSPdsjy2uOQExX/WEILpIrO9UPGuXs= github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.0 h1:/fTUt5vmbkAcMBt4YQiuC23cV0kEsN1MVMNqeOW43cU= @@ -427,8 +427,8 @@ github.com/golangci/go-printf-func-name v0.1.0 h1:dVokQP+NMTO7jwO4bwsRwLWeudOVUP github.com/golangci/go-printf-func-name v0.1.0/go.mod h1:wqhWFH5mUdJQhweRnldEywnR5021wTdZSNgwYceV14s= github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9 h1:/1322Qns6BtQxUZDTAT4SdcoxknUki7IAoK4SAXr8ME= github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9/go.mod h1:Oesb/0uFAyWoaw1U1qS5zyjCg5NP9C9iwjnI4tIsXEE= -github.com/golangci/golangci-lint v1.62.0 h1:/G0g+bi1BhmGJqLdNQkKBWjcim8HjOPc4tsKuHDOhcI= -github.com/golangci/golangci-lint v1.62.0/go.mod h1:jtoOhQcKTz8B6dGNFyfQV3WZkQk+YvBDewDtNpiAJts= +github.com/golangci/golangci-lint v1.62.2 h1:b8K5K9PN+rZN1+mKLtsZHz2XXS9aYKzQ9i25x3Qnxxw= +github.com/golangci/golangci-lint v1.62.2/go.mod h1:ILWWyeFUrctpHVGMa1dg2xZPKoMUTc5OIMgW7HZr34g= github.com/golangci/misspell v0.6.0 h1:JCle2HUTNWirNlDIAUO44hUsKhOFqGPoC4LZxlaSXDs= github.com/golangci/misspell v0.6.0/go.mod h1:keMNyY6R9isGaSAu+4Q8NMBwMPkh15Gtc8UCVoDtAWo= github.com/golangci/modinfo v0.3.4 h1:oU5huX3fbxqQXdfspamej74DFX0kyGLkw1ppvXoJ8GA= @@ -703,8 +703,8 @@ github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh github.com/mattn/go-sqlite3 v1.6.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mgechev/revive v1.5.0 h1:oaSmjA7rP8+HyoRuCgC531VHwnLH1AlJdjj+1AnQceQ= -github.com/mgechev/revive v1.5.0/go.mod h1:L6T3H8EoerRO86c7WuGpvohIUmiploGiyoYbtIWFmV8= +github.com/mgechev/revive v1.5.1 h1:hE+QPeq0/wIzJwOphdVyUJ82njdd8Khp4fUIHGZHW3M= +github.com/mgechev/revive v1.5.1/go.mod h1:lC9AhkJIBs5zwx8wkudyHrU+IJkrEKmpCmGMnIJPk4o= github.com/microcosm-cc/bluemonday v1.0.25 h1:4NEwSfiJ+Wva0VxN5B8OwMicaJvD8r9tlJWm9rtloEg= github.com/microcosm-cc/bluemonday v1.0.25/go.mod h1:ZIOjCQp1OrzBBPIJmfX4qDYFuhU02nx4bn030ixfHLE= github.com/miekg/pkcs11 v1.0.2/go.mod h1:XsNlhZGX73bx86s2hdc/FuaLm2CPZJemRLMA+WTFxgs= @@ -755,8 +755,8 @@ github.com/nishanths/exhaustive v0.12.0 h1:vIY9sALmw6T/yxiASewa4TQcFsVYZQQRUQJhK github.com/nishanths/exhaustive v0.12.0/go.mod h1:mEZ95wPIZW+x8kC4TgC+9YCUgiST7ecevsVDTgc2obs= github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk= github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c= -github.com/nunnatsa/ginkgolinter v0.18.0 h1:ZXO1wKhPg3A6LpbN5dMuqwhfOjN5c3ous8YdKOuqk9k= -github.com/nunnatsa/ginkgolinter v0.18.0/go.mod h1:vPrWafSULmjMGCMsfGA908if95VnHQNAahvSBOjTuWs= +github.com/nunnatsa/ginkgolinter v0.18.3 h1:WgS7X3zzmni3vwHSBhvSgqrRgUecN6PQUcfB0j1noDw= +github.com/nunnatsa/ginkgolinter v0.18.3/go.mod h1:BE1xyB/PNtXXG1azrvrqJW5eFH0hSRylNzFy8QHPwzs= github.com/oapi-codegen/runtime v1.1.1 h1:EXLHh0DXIJnWhdRPN2w4MXAzFyE4CskzhNLUmtpMYro= github.com/oapi-codegen/runtime v1.1.1/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= @@ -801,8 +801,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/polyfloyd/go-errorlint v1.6.0 h1:tftWV9DE7txiFzPpztTAwyoRLKNj9gpVm2cg8/OwcYY= -github.com/polyfloyd/go-errorlint v1.6.0/go.mod h1:HR7u8wuP1kb1NeN1zqTd1ZMlqUKPPHF+Id4vIPvDqVw= +github.com/polyfloyd/go-errorlint v1.7.0 h1:Zp6lzCK4hpBDj8y8a237YK4EPrMXQWvOe3nGoH4pFrU= +github.com/polyfloyd/go-errorlint v1.7.0/go.mod h1:dGWKu85mGHnegQ2SWpEybFityCg3j7ZbwsVUxAOk9gY= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/prometheus/client_golang v0.9.0-pre1.0.20180209125602-c332b6f63c06/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= @@ -981,8 +981,8 @@ github.com/ultraware/whitespace v0.1.1 h1:bTPOGejYFulW3PkcrqkeQwOd6NKOOXvmGD9bo/ github.com/ultraware/whitespace v0.1.1/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= github.com/uudashr/gocognit v1.1.3 h1:l+a111VcDbKfynh+airAy/DJQKaXh2m9vkoysMPSZyM= github.com/uudashr/gocognit v1.1.3/go.mod h1:aKH8/e8xbTRBwjbCkwZ8qt4l2EpKXl31KMHgSS+lZ2U= -github.com/uudashr/iface v1.2.0 h1:ECJjh5q/1Zmnv/2yFpWV6H3oMg5+Mo+vL0aqw9Gjazo= -github.com/uudashr/iface v1.2.0/go.mod h1:Ux/7d/rAF3owK4m53cTVXL4YoVHKNqnoOeQHn2xrlp0= +github.com/uudashr/iface v1.2.1 h1:vHHyzAUmWZ64Olq6NZT3vg/z1Ws56kyPdBOd5kTXDF8= +github.com/uudashr/iface v1.2.1/go.mod h1:4QvspiRd3JLPAEXBQ9AiZpLbJlrWWgRChOKDJEuQTdg= github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 h1:MzD3XeOOSO3mAjOPpF07jFteSKZxsRHvlIcAR9RQzKM= github.com/withfig/autocomplete-tools/packages/cobra v1.2.0/go.mod h1:RoXh7+7qknOXL65uTzdzE1mPxqcPwS7FLCE9K5GfmKo= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= @@ -1117,8 +1117,8 @@ golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c h1:7dEasQXItcW1xKJ2+gg5VOiBn golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:NQtJDoLvd6faHhE7m4T/1IY708gDefGGjR/iUW8yQQ8= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= -golang.org/x/exp/typeparams v0.0.0-20240909161429-701f63a606c0 h1:bVwtbF629Xlyxk6xLQq2TDYmqP0uiWaet5LwRebuY0k= -golang.org/x/exp/typeparams v0.0.0-20240909161429-701f63a606c0/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= +golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f h1:WTyX8eCCyfdqiPYkRGm0MqElSfYFH3yR1+rl/mct9sA= +golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= From ab95a727f5407c2bad65f96ab33375b9686efabf Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Tue, 26 Nov 2024 19:05:55 +0800 Subject: [PATCH 186/305] fix: initialise test otp to an empty map (#2919) * fix: initialise test otp to an empty map * chore: update unit tests * chore: updater tests --- pkg/config/auth_test.go | 13 +++++-------- pkg/config/config.go | 3 +++ .../local_enabled_and_disabled.diff | 4 ++-- .../TestSmsDiff/local_disabled_remote_enabled.diff | 5 ++--- .../TestSmsDiff/local_enabled_remote_disabled.diff | 5 ++--- pkg/config/updater_test.go | 1 + pkg/config/utils.go | 3 --- 7 files changed, 15 insertions(+), 19 deletions(-) diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index e8d373b9f..119cdf65d 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -18,6 +18,9 @@ func newWithDefaults() auth { Email: email{ EnableConfirmations: true, }, + Sms: sms{ + TestOTP: map[string]string{}, + }, } } @@ -563,9 +566,7 @@ func TestSmsDiff(t *testing.T) { // This is not a valid config because platform requires a SMS provider. // For consistency, we handle this in config.Load and emit a warning. c := newWithDefaults() - c.Sms = sms{ - EnableSignup: true, - } + c.Sms.EnableSignup = true // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(false), @@ -578,11 +579,7 @@ func TestSmsDiff(t *testing.T) { t.Run("enable provider without sign up", func(t *testing.T) { c := newWithDefaults() - c.Sms = sms{ - Messagebird: messagebirdConfig{ - Enabled: true, - }, - } + c.Sms.Messagebird.Enabled = true // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(false), diff --git a/pkg/config/config.go b/pkg/config/config.go index ba2151e24..ff5fdee8c 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -303,6 +303,9 @@ func NewConfig(editors ...ConfigEditor) config { "reauthentication": {}, }, }, + Sms: sms{ + TestOTP: map[string]string{}, + }, External: map[string]provider{ "apple": {}, "azure": {}, diff --git a/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff index fcfb3d1d0..7be4a13c7 100644 --- a/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff +++ b/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -88,7 +88,7 @@ +@@ -89,7 +89,7 @@ [external] [external.apple] @@ -10,7 +10,7 @@ diff remote[auth] local[auth] client_id = "test-client-1,test-client-2" secret = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" url = "" -@@ -144,7 +144,7 @@ +@@ -145,7 +145,7 @@ redirect_uri = "" skip_nonce_check = false [external.google] diff --git a/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff b/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff index a173a8adf..f9a0428f3 100644 --- a/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff +++ b/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff @@ -19,11 +19,10 @@ diff remote[auth] local[auth] account_sid = "" message_service_sid = "" auth_token = "" -@@ -85,9 +85,6 @@ - from = "" +@@ -86,8 +86,6 @@ api_key = "" api_secret = "" --[sms.test_otp] + [sms.test_otp] -123 = "456" -456 = "123" diff --git a/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff index f9ee1d7f0..1c0de48f3 100644 --- a/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff +++ b/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff @@ -32,11 +32,10 @@ diff remote[auth] local[auth] [sms.textlocal] enabled = false sender = "" -@@ -85,6 +85,8 @@ - from = "" +@@ -86,6 +86,7 @@ api_key = "" api_secret = "" -+[sms.test_otp] + [sms.test_otp] +123 = "456" [third_party] diff --git a/pkg/config/updater_test.go b/pkg/config/updater_test.go index 3e549e055..471e84963 100644 --- a/pkg/config/updater_test.go +++ b/pkg/config/updater_test.go @@ -193,6 +193,7 @@ func TestUpdateAuthConfig(t *testing.T) { Enabled: true, EnableSignup: true, Email: email{EnableConfirmations: true}, + Sms: sms{TestOTP: map[string]string{}}, }) // Check result assert.NoError(t, err) diff --git a/pkg/config/utils.go b/pkg/config/utils.go index 2dd9c1aae..9a46d94a9 100644 --- a/pkg/config/utils.go +++ b/pkg/config/utils.go @@ -103,9 +103,6 @@ func mapToEnv(input map[string]string) string { func envToMap(input string) map[string]string { env := strToArr(input) - if len(env) == 0 { - return nil - } result := make(map[string]string, len(env)) for _, kv := range env { if parts := strings.Split(kv, "="); len(parts) > 1 { From a1537f5cba5c9f25832a6f9a9aa9b2be50692811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Caba=C3=A7o?= Date: Wed, 27 Nov 2024 02:49:38 +0000 Subject: [PATCH 187/305] fix(realtime): Bump up realtime version (#2921) --- internal/db/start/start.go | 1 + internal/start/start.go | 2 ++ pkg/config/constants.go | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/db/start/start.go b/internal/db/start/start.go index f0fc488d2..c4722f22f 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -256,6 +256,7 @@ func initRealtimeJob(host string) utils.DockerJob { "DNS_NODES=''", "RLIMIT_NOFILE=", "SEED_SELF_HOST=true", + "RUN_JANITOR=true", fmt.Sprintf("MAX_HEADER_LENGTH=%d", utils.Config.Realtime.MaxHeaderLength), }, Cmd: []string{"/app/bin/realtime", "eval", fmt.Sprintf(`{:ok, _} = Application.ensure_all_started(:realtime) diff --git a/internal/start/start.go b/internal/start/start.go index 8342a18b1..486f2a860 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -766,6 +766,7 @@ EOF "DNS_NODES=''", "RLIMIT_NOFILE=", "SEED_SELF_HOST=true", + "RUN_JANITOR=true", fmt.Sprintf("MAX_HEADER_LENGTH=%d", utils.Config.Realtime.MaxHeaderLength), }, ExposedPorts: nat.PortSet{"4000/tcp": {}}, @@ -1056,6 +1057,7 @@ EOF "API_JWT_SECRET=" + utils.Config.Auth.JwtSecret, "METRICS_JWT_SECRET=" + utils.Config.Auth.JwtSecret, "REGION=local", + "RUN_JANITOR=true", "ERL_AFLAGS=-proto_dist inet_tcp", }, Cmd: []string{ diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 0a779fe63..57f4b3809 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -16,7 +16,7 @@ const ( vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.164.0" - realtimeImage = "supabase/realtime:v2.33.51" + realtimeImage = "supabase/realtime:v2.33.58" storageImage = "supabase/storage-api:v1.11.13" logflareImage = "supabase/logflare:1.4.0" // Append to JobImages when adding new dependencies below From b87d67ada6459aba151c25c3d2c344998486397c Mon Sep 17 00:00:00 2001 From: Nyannyacha Date: Thu, 28 Nov 2024 14:00:57 +0900 Subject: [PATCH 188/305] fix: bump edge-runtime to 1.65.0 --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 57f4b3809..293a5820b 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241106-f29003e" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.64.1" + edgeRuntimeImage = "supabase/edge-runtime:v1.65.0" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.164.0" From fcf6bcef9ad8c26c707b99809073e84852c8105a Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Thu, 28 Nov 2024 16:15:18 +0800 Subject: [PATCH 189/305] chore: document function config in toml (#2925) --- pkg/config/templates/config.toml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index cc674d59b..ec89b2870 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -236,8 +236,18 @@ enabled = true # Configure one of the supported request policies: `oneshot`, `per_worker`. # Use `oneshot` for hot reload, or `per_worker` for load testing. policy = "oneshot" +# Port to attach the Chrome inspector for debugging edge functions. inspector_port = 8083 +# Use these configurations to customize your Edge Function. +# [functions.MY_FUNCTION_NAME] +# enabled = true +# verify_jwt = true +# import_map = "./functions/MY_FUNCTION_NAME/deno.json" +# Uncomment to specify a custom file path to the entrypoint. +# Supported file extensions are: .ts, .js, .mjs, .jsx, .tsx +# entrypoint = "./functions/MY_FUNCTION_NAME/index.ts" + [analytics] enabled = true port = 54327 From 8fb7f30411c7d38b255d65b8bc7f8492a978731c Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Thu, 28 Nov 2024 11:12:25 +0100 Subject: [PATCH 190/305] chore(docs): add link to the config reference in toml template (#2926) --- pkg/config/templates/config.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index ec89b2870..902330d3c 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -1,3 +1,5 @@ +# For detailed configuration reference documentation, visit: +# https://supabase.com/docs/guides/local-development/cli/config # A string used to distinguish different Supabase projects on the same host. Defaults to the # working directory name when running `supabase init`. project_id = "{{ .ProjectId }}" From b9e0aa073df68b75623e860e1473cf417b3d033f Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Thu, 28 Nov 2024 11:58:00 +0000 Subject: [PATCH 191/305] feat: add minimum password length and password requirements config (#2885) * feat: add minimal password length and password requirements config * Update auth config body * fix: change password requirements to a map * tests: update config and diff files * update diffs for tests * chore: convert between local and remote password * chore: refactor config fields * chore: add unit tests for password requirement * chore: add missing testdata --------- Co-authored-by: Qiao Han --- internal/start/start.go | 2 + pkg/config/auth.go | 56 +++++++++++-- pkg/config/auth_test.go | 83 +++++++++++++++++++ pkg/config/config.go | 4 + pkg/config/templates/config.toml | 5 ++ .../local_enabled_and_disabled.diff | 28 +++++++ .../local_disabled_remote_enabled.diff | 4 +- .../local_enabled_remote_disabled.diff | 2 +- .../local_enabled_and_disabled.diff | 4 +- .../local_enabled_and_disabled.diff | 4 +- .../local_enabled_and_disabled.diff | 2 +- .../enable_sign_up_without_provider.diff | 2 +- .../local_disabled_remote_enabled.diff | 4 +- .../local_enabled_remote_disabled.diff | 6 +- pkg/config/testdata/config.toml | 5 ++ 15 files changed, 189 insertions(+), 22 deletions(-) create mode 100644 pkg/config/testdata/TestAuthDiff/local_enabled_and_disabled.diff diff --git a/internal/start/start.go b/internal/start/start.go index 486f2a860..5521161f8 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -506,6 +506,8 @@ EOF fmt.Sprintf("GOTRUE_SMS_TEMPLATE=%v", utils.Config.Auth.Sms.Template), "GOTRUE_SMS_TEST_OTP=" + testOTP.String(), + fmt.Sprintf("GOTRUE_PASSWORD_MIN_LENGTH=%v", utils.Config.Auth.MinimumPasswordLength), + fmt.Sprintf("GOTRUE_PASSWORD_REQUIRED_CHARACTERS=%v", utils.Config.Auth.PasswordRequirements.ToChar()), fmt.Sprintf("GOTRUE_SECURITY_REFRESH_TOKEN_ROTATION_ENABLED=%v", utils.Config.Auth.EnableRefreshTokenRotation), fmt.Sprintf("GOTRUE_SECURITY_REFRESH_TOKEN_REUSE_INTERVAL=%v", utils.Config.Auth.RefreshTokenReuseInterval), fmt.Sprintf("GOTRUE_SECURITY_MANUAL_LINKING_ENABLED=%v", utils.Config.Auth.EnableManualLinking), diff --git a/pkg/config/auth.go b/pkg/config/auth.go index e78092bde..572b88950 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -10,19 +10,54 @@ import ( "github.com/supabase/cli/pkg/diff" ) +type PasswordRequirements string + +const ( + NoRequirements PasswordRequirements = "" + LettersDigits PasswordRequirements = "letters_digits" + LowerUpperLettersDigits PasswordRequirements = "lower_upper_letters_digits" + LowerUpperLettersDigitsSymbols PasswordRequirements = "lower_upper_letters_digits_symbols" +) + +func (r PasswordRequirements) ToChar() v1API.UpdateAuthConfigBodyPasswordRequiredCharacters { + switch r { + case LettersDigits: + return v1API.AbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 + case LowerUpperLettersDigits: + return v1API.AbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567891 + case LowerUpperLettersDigitsSymbols: + return v1API.AbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567892 + } + return v1API.Empty +} + +func NewPasswordRequirement(c v1API.UpdateAuthConfigBodyPasswordRequiredCharacters) PasswordRequirements { + switch c { + case v1API.AbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789: + return LettersDigits + case v1API.AbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567891: + return LowerUpperLettersDigits + case v1API.AbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567892: + return LowerUpperLettersDigitsSymbols + } + return NoRequirements +} + type ( auth struct { Enabled bool `toml:"enabled"` Image string `toml:"-"` - SiteUrl string `toml:"site_url"` - AdditionalRedirectUrls []string `toml:"additional_redirect_urls"` - JwtExpiry uint `toml:"jwt_expiry"` - EnableRefreshTokenRotation bool `toml:"enable_refresh_token_rotation"` - RefreshTokenReuseInterval uint `toml:"refresh_token_reuse_interval"` - EnableManualLinking bool `toml:"enable_manual_linking"` - EnableSignup bool `toml:"enable_signup"` - EnableAnonymousSignIns bool `toml:"enable_anonymous_sign_ins"` + SiteUrl string `toml:"site_url"` + AdditionalRedirectUrls []string `toml:"additional_redirect_urls"` + JwtExpiry uint `toml:"jwt_expiry"` + EnableRefreshTokenRotation bool `toml:"enable_refresh_token_rotation"` + RefreshTokenReuseInterval uint `toml:"refresh_token_reuse_interval"` + EnableManualLinking bool `toml:"enable_manual_linking"` + EnableSignup bool `toml:"enable_signup"` + EnableAnonymousSignIns bool `toml:"enable_anonymous_sign_ins"` + MinimumPasswordLength uint `toml:"minimum_password_length"` + PasswordRequirements PasswordRequirements `toml:"password_requirements"` Hook hook `toml:"hook"` MFA mfa `toml:"mfa"` @@ -192,6 +227,8 @@ func (a *auth) ToUpdateAuthConfigBody() v1API.UpdateAuthConfigBody { SecurityManualLinkingEnabled: &a.EnableManualLinking, DisableSignup: cast.Ptr(!a.EnableSignup), ExternalAnonymousUsersEnabled: &a.EnableAnonymousSignIns, + PasswordMinLength: cast.UintToIntPtr(&a.MinimumPasswordLength), + PasswordRequiredCharacters: cast.Ptr(a.PasswordRequirements.ToChar()), } a.Hook.toAuthConfigBody(&body) a.MFA.toAuthConfigBody(&body) @@ -211,6 +248,9 @@ func (a *auth) FromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) { a.EnableManualLinking = cast.Val(remoteConfig.SecurityManualLinkingEnabled, false) a.EnableSignup = !cast.Val(remoteConfig.DisableSignup, false) a.EnableAnonymousSignIns = cast.Val(remoteConfig.ExternalAnonymousUsersEnabled, false) + a.MinimumPasswordLength = cast.IntToUint(cast.Val(remoteConfig.PasswordMinLength, 0)) + prc := cast.Val(remoteConfig.PasswordRequiredCharacters, "") + a.PasswordRequirements = NewPasswordRequirement(v1API.UpdateAuthConfigBodyPasswordRequiredCharacters(prc)) a.Hook.fromAuthConfig(remoteConfig) a.MFA.fromAuthConfig(remoteConfig) a.Sessions.fromAuthConfig(remoteConfig) diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index 119cdf65d..cba5cd9a1 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -34,6 +34,89 @@ func assertSnapshotEqual(t *testing.T, actual []byte) { assert.Equal(t, string(expected), string(actual)) } +func TestAuthDiff(t *testing.T) { + t.Run("local and remote enabled", func(t *testing.T) { + c := newWithDefaults() + c.SiteUrl = "http://127.0.0.1:3000" + c.AdditionalRedirectUrls = []string{"https://127.0.0.1:3000"} + c.JwtExpiry = 3600 + c.EnableRefreshTokenRotation = true + c.RefreshTokenReuseInterval = 10 + c.EnableManualLinking = true + c.EnableSignup = true + c.EnableAnonymousSignIns = true + c.MinimumPasswordLength = 6 + c.PasswordRequirements = LettersDigits + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + SiteUrl: cast.Ptr("http://127.0.0.1:3000"), + UriAllowList: cast.Ptr("https://127.0.0.1:3000"), + JwtExp: cast.Ptr(3600), + RefreshTokenRotationEnabled: cast.Ptr(true), + SecurityRefreshTokenReuseInterval: cast.Ptr(10), + SecurityManualLinkingEnabled: cast.Ptr(true), + DisableSignup: cast.Ptr(false), + ExternalAnonymousUsersEnabled: cast.Ptr(true), + PasswordMinLength: cast.Ptr(6), + PasswordRequiredCharacters: cast.Ptr(string(v1API.AbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789)), + }) + // Check error + assert.NoError(t, err) + assert.Empty(t, string(diff)) + }) + + t.Run("local enabled and disabled", func(t *testing.T) { + c := newWithDefaults() + c.SiteUrl = "http://127.0.0.1:3000" + c.AdditionalRedirectUrls = []string{"https://127.0.0.1:3000"} + c.JwtExpiry = 3600 + c.EnableRefreshTokenRotation = false + c.RefreshTokenReuseInterval = 10 + c.EnableManualLinking = false + c.EnableSignup = false + c.EnableAnonymousSignIns = false + c.MinimumPasswordLength = 6 + c.PasswordRequirements = LowerUpperLettersDigitsSymbols + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + SiteUrl: cast.Ptr(""), + UriAllowList: cast.Ptr("https://127.0.0.1:3000,https://ref.supabase.co"), + JwtExp: cast.Ptr(0), + RefreshTokenRotationEnabled: cast.Ptr(true), + SecurityRefreshTokenReuseInterval: cast.Ptr(0), + SecurityManualLinkingEnabled: cast.Ptr(true), + DisableSignup: cast.Ptr(false), + ExternalAnonymousUsersEnabled: cast.Ptr(true), + PasswordMinLength: cast.Ptr(8), + PasswordRequiredCharacters: cast.Ptr(string(v1API.AbcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789)), + }) + // Check error + assert.NoError(t, err) + assertSnapshotEqual(t, diff) + }) + + t.Run("local and remote disabled", func(t *testing.T) { + c := newWithDefaults() + c.EnableSignup = false + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + SiteUrl: cast.Ptr(""), + UriAllowList: cast.Ptr(""), + JwtExp: cast.Ptr(0), + RefreshTokenRotationEnabled: cast.Ptr(false), + SecurityRefreshTokenReuseInterval: cast.Ptr(0), + SecurityManualLinkingEnabled: cast.Ptr(false), + DisableSignup: cast.Ptr(true), + ExternalAnonymousUsersEnabled: cast.Ptr(false), + PasswordMinLength: cast.Ptr(0), + PasswordRequiredCharacters: cast.Ptr(""), + }) + // Check error + assert.NoError(t, err) + assert.Empty(t, string(diff)) + }) +} + func TestHookDiff(t *testing.T) { t.Run("local and remote enabled", func(t *testing.T) { c := newWithDefaults() diff --git a/pkg/config/config.go b/pkg/config/config.go index ff5fdee8c..8d809c595 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -673,6 +673,10 @@ func (c *baseConfig) Validate(fsys fs.FS) error { return errors.Errorf("Invalid config for auth.additional_redirect_urls[%d]: %v", i, err) } } + allowed := []PasswordRequirements{NoRequirements, LettersDigits, LowerUpperLettersDigits, LowerUpperLettersDigitsSymbols} + if !sliceContains(allowed, c.Auth.PasswordRequirements) { + return errors.Errorf("Invalid config for auth.password_requirements. Must be one of: %v", allowed) + } if err := c.Auth.Hook.validate(); err != nil { return err } diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index 902330d3c..12decc3f4 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -112,6 +112,11 @@ enable_signup = true enable_anonymous_sign_ins = false # Allow/disallow testing manual linking of accounts enable_manual_linking = false +# Passwords shorter than this value will be rejected as weak. Minimum 6, recommended 8 or more. +minimum_password_length = 6 +# Passwords that do not meet the following requirements will be rejected as weak. Supported values +# are: `letters_digits`, `lower_upper_letters_digits`, `lower_upper_letters_digits_symbols` +password_requirements = "" [auth.email] # Allow/disallow new user signups via email to your project. diff --git a/pkg/config/testdata/TestAuthDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestAuthDiff/local_enabled_and_disabled.diff new file mode 100644 index 000000000..3db4d5462 --- /dev/null +++ b/pkg/config/testdata/TestAuthDiff/local_enabled_and_disabled.diff @@ -0,0 +1,28 @@ +diff remote[auth] local[auth] +--- remote[auth] ++++ local[auth] +@@ -1,14 +1,14 @@ + enabled = false +-site_url = "" +-additional_redirect_urls = ["https://127.0.0.1:3000", "https://ref.supabase.co"] +-jwt_expiry = 0 +-enable_refresh_token_rotation = true +-refresh_token_reuse_interval = 0 +-enable_manual_linking = true +-enable_signup = true +-enable_anonymous_sign_ins = true +-minimum_password_length = 8 +-password_requirements = "letters_digits" ++site_url = "http://127.0.0.1:3000" ++additional_redirect_urls = ["https://127.0.0.1:3000"] ++jwt_expiry = 3600 ++enable_refresh_token_rotation = false ++refresh_token_reuse_interval = 10 ++enable_manual_linking = false ++enable_signup = false ++enable_anonymous_sign_ins = false ++minimum_password_length = 6 ++password_requirements = "lower_upper_letters_digits_symbols" + + [hook] + [hook.mfa_verification_attempt] diff --git a/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff b/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff index d6c7f6dca..3123336fa 100644 --- a/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff +++ b/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -49,13 +49,13 @@ +@@ -51,13 +51,13 @@ inactivity_timeout = "0s" [email] @@ -22,7 +22,7 @@ diff remote[auth] local[auth] [email.template] [email.template.confirmation] content_path = "" -@@ -69,13 +69,6 @@ +@@ -71,13 +71,6 @@ content_path = "" [email.template.recovery] content_path = "" diff --git a/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff index 9bcf8ccba..24386ae91 100644 --- a/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff +++ b/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -49,28 +49,43 @@ +@@ -51,28 +51,43 @@ inactivity_timeout = "0s" [email] diff --git a/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff index 7be4a13c7..234e422f4 100644 --- a/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff +++ b/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -89,7 +89,7 @@ +@@ -91,7 +91,7 @@ [external] [external.apple] @@ -10,7 +10,7 @@ diff remote[auth] local[auth] client_id = "test-client-1,test-client-2" secret = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" url = "" -@@ -145,7 +145,7 @@ +@@ -147,7 +147,7 @@ redirect_uri = "" skip_nonce_check = false [external.google] diff --git a/pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff index b45808d4c..b21cd4073 100644 --- a/pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff +++ b/pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -9,7 +9,7 @@ +@@ -11,7 +11,7 @@ [hook] [hook.mfa_verification_attempt] @@ -10,7 +10,7 @@ diff remote[auth] local[auth] uri = "" secrets = "" [hook.password_verification_attempt] -@@ -17,7 +17,7 @@ +@@ -19,7 +19,7 @@ uri = "" secrets = "" [hook.custom_access_token] diff --git a/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff index f7935bfa4..866ce8fae 100644 --- a/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff +++ b/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -30,16 +30,16 @@ +@@ -32,16 +32,16 @@ secrets = "" [mfa] diff --git a/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff b/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff index 2e44496fd..637a0206e 100644 --- a/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff +++ b/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -58,7 +58,7 @@ +@@ -60,7 +60,7 @@ otp_expiry = 0 [sms] diff --git a/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff b/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff index f9a0428f3..4348c80ba 100644 --- a/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff +++ b/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -58,12 +58,12 @@ +@@ -60,12 +60,12 @@ otp_expiry = 0 [sms] @@ -19,7 +19,7 @@ diff remote[auth] local[auth] account_sid = "" message_service_sid = "" auth_token = "" -@@ -86,8 +86,6 @@ +@@ -88,8 +88,6 @@ api_key = "" api_secret = "" [sms.test_otp] diff --git a/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff index 1c0de48f3..e29c287ed 100644 --- a/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff +++ b/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -58,12 +58,12 @@ +@@ -60,12 +60,12 @@ otp_expiry = 0 [sms] @@ -19,7 +19,7 @@ diff remote[auth] local[auth] account_sid = "" message_service_sid = "" auth_token = "" -@@ -73,9 +73,9 @@ +@@ -75,9 +75,9 @@ message_service_sid = "" auth_token = "" [sms.messagebird] @@ -32,7 +32,7 @@ diff remote[auth] local[auth] [sms.textlocal] enabled = false sender = "" -@@ -86,6 +86,7 @@ +@@ -88,6 +88,7 @@ api_key = "" api_secret = "" [sms.test_otp] diff --git a/pkg/config/testdata/config.toml b/pkg/config/testdata/config.toml index a97042954..ce845743e 100644 --- a/pkg/config/testdata/config.toml +++ b/pkg/config/testdata/config.toml @@ -106,6 +106,11 @@ refresh_token_reuse_interval = 10 enable_signup = true # Allow/disallow testing manual linking of accounts enable_manual_linking = true +# Passwords shorter than this value will be rejected as weak. Minimum 6, recommended 8 or more. +minimum_password_length = 6 +# Passwords that do not meet the following requirements will be rejected as weak. Supported values +# are: `letters_digits`, `lower_upper_letters_digits`, `lower_upper_letters_digits_symbols` +password_requirements = "" [auth.email] # Allow/disallow new user signups via email to your project. From d3cd223609f6b643e83899b3be5661433d0ba4e5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 28 Nov 2024 19:58:45 +0800 Subject: [PATCH 192/305] chore(deps): bump github.com/stripe/pg-schema-diff from 0.7.0 to 0.8.0 (#2922) Bumps [github.com/stripe/pg-schema-diff](https://github.com/stripe/pg-schema-diff) from 0.7.0 to 0.8.0. - [Release notes](https://github.com/stripe/pg-schema-diff/releases) - [Commits](https://github.com/stripe/pg-schema-diff/compare/v0.7.0...v0.8.0) --- updated-dependencies: - dependency-name: github.com/stripe/pg-schema-diff dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 54dd44b5f..e53ea37d2 100644 --- a/go.mod +++ b/go.mod @@ -45,7 +45,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.10.0 - github.com/stripe/pg-schema-diff v0.7.0 + github.com/stripe/pg-schema-diff v0.8.0 github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 github.com/zalando/go-keyring v0.2.6 go.opentelemetry.io/otel v1.32.0 diff --git a/go.sum b/go.sum index 757c27022..4241f7e44 100644 --- a/go.sum +++ b/go.sum @@ -949,8 +949,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/stripe/pg-schema-diff v0.7.0 h1:00Z+LGGe9GhMsN5gLtx/ZwF/+xPOMgod/g8x8H1JmV4= -github.com/stripe/pg-schema-diff v0.7.0/go.mod h1:HuTBuWLuvnY9g9nptbSD58xugN19zSJNkF4w/sYRtdU= +github.com/stripe/pg-schema-diff v0.8.0 h1:Ggm4yDbPtaflYQLV3auEMTLxQPaentV/wmDEoCF5jxQ= +github.com/stripe/pg-schema-diff v0.8.0/go.mod h1:HuTBuWLuvnY9g9nptbSD58xugN19zSJNkF4w/sYRtdU= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= github.com/tdakkota/asciicheck v0.2.0 h1:o8jvnUANo0qXtnslk2d3nMKTFNlOnJjRrNcj0j9qkHM= From 26a20ea16ed477e4c9cd4de8504c681078fd8596 Mon Sep 17 00:00:00 2001 From: Nyannyacha Date: Fri, 29 Nov 2024 08:31:34 +0900 Subject: [PATCH 193/305] fix: bump edge-runtime to 1.65.1 --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 293a5820b..7d7883a36 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241106-f29003e" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.65.0" + edgeRuntimeImage = "supabase/edge-runtime:v1.65.1" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.164.0" From eae2bac10161e71cd74b34d259b974b7eb80e823 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 29 Nov 2024 04:35:22 +0000 Subject: [PATCH 194/305] chore(deps): bump github.com/go-xmlfmt/xmlfmt from 1.1.2 to 1.1.3 (#2929) Bumps [github.com/go-xmlfmt/xmlfmt](https://github.com/go-xmlfmt/xmlfmt) from 1.1.2 to 1.1.3. - [Release notes](https://github.com/go-xmlfmt/xmlfmt/releases) - [Commits](https://github.com/go-xmlfmt/xmlfmt/compare/v1.1.2...v1.1.3) --- updated-dependencies: - dependency-name: github.com/go-xmlfmt/xmlfmt dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e53ea37d2..d8bfd6274 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( github.com/gin-gonic/gin v1.10.0 github.com/go-errors/errors v1.5.1 github.com/go-git/go-git/v5 v5.12.0 - github.com/go-xmlfmt/xmlfmt v1.1.2 + github.com/go-xmlfmt/xmlfmt v1.1.3 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/golangci/golangci-lint v1.62.2 github.com/google/go-github/v62 v62.0.0 diff --git a/go.sum b/go.sum index 4241f7e44..28de4b7ef 100644 --- a/go.sum +++ b/go.sum @@ -371,8 +371,8 @@ github.com/go-toolsmith/typep v1.1.0 h1:fIRYDyF+JywLfqzyhdiHzRop/GQDxxNhLGQ6gFUN github.com/go-toolsmith/typep v1.1.0/go.mod h1:fVIw+7zjdsMxDA3ITWnH1yOiw1rnTQKCsF/sk2H/qig= github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss= github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= -github.com/go-xmlfmt/xmlfmt v1.1.2 h1:Nea7b4icn8s57fTx1M5AI4qQT5HEM3rVUO8MuE6g80U= -github.com/go-xmlfmt/xmlfmt v1.1.2/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= +github.com/go-xmlfmt/xmlfmt v1.1.3 h1:t8Ey3Uy7jDSEisW2K3somuMKIpzktkWptA0iFCnRUWY= +github.com/go-xmlfmt/xmlfmt v1.1.3/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= From 8c3a49e72ed8bac8a5034b5abc18f1ab2ba16b9e Mon Sep 17 00:00:00 2001 From: Nyannyacha Date: Fri, 29 Nov 2024 14:02:43 +0900 Subject: [PATCH 195/305] fix: bump edge-runtime to 1.65.3 --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 7d7883a36..da0a9bf4a 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241106-f29003e" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.65.1" + edgeRuntimeImage = "supabase/edge-runtime:v1.65.3" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.164.0" From 2ff5960b39b9a00f5a1ddcae2c33bbb84c3f4c0c Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Mon, 2 Dec 2024 06:59:07 +0100 Subject: [PATCH 196/305] fix(config): syncing for postgres hook without secrets (#2931) * fix(config): syncing for postgres hook without secrets * chore: apply pr comments * chore: stricter hook secrets validation * chore: update unit tests and error handling --------- Co-authored-by: Qiao Han --- pkg/config/auth.go | 55 ++++++++---- pkg/config/auth_test.go | 88 ++++++++++++++----- pkg/config/config.go | 32 ++++--- pkg/config/config_test.go | 87 +++++++++++------- .../local_enabled_and_disabled.diff | 25 ++++-- 5 files changed, 197 insertions(+), 90 deletions(-) diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 572b88950..10611c23b 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -262,53 +262,76 @@ func (a *auth) FromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) { func (h hook) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if body.HookCustomAccessTokenEnabled = &h.CustomAccessToken.Enabled; *body.HookCustomAccessTokenEnabled { body.HookCustomAccessTokenUri = &h.CustomAccessToken.URI - body.HookCustomAccessTokenSecrets = &h.CustomAccessToken.Secrets + if len(h.CustomAccessToken.Secrets) > 0 { + body.HookCustomAccessTokenSecrets = &h.CustomAccessToken.Secrets + } } if body.HookSendEmailEnabled = &h.SendEmail.Enabled; *body.HookSendEmailEnabled { body.HookSendEmailUri = &h.SendEmail.URI - body.HookSendEmailSecrets = &h.SendEmail.Secrets + if len(h.SendEmail.Secrets) > 0 { + body.HookSendEmailSecrets = &h.SendEmail.Secrets + } } if body.HookSendSmsEnabled = &h.SendSMS.Enabled; *body.HookSendSmsEnabled { body.HookSendSmsUri = &h.SendSMS.URI - body.HookSendSmsSecrets = &h.SendSMS.Secrets + if len(h.SendSMS.Secrets) > 0 { + body.HookSendSmsSecrets = &h.SendSMS.Secrets + } } // Enterprise and team only features if body.HookMfaVerificationAttemptEnabled = &h.MFAVerificationAttempt.Enabled; *body.HookMfaVerificationAttemptEnabled { body.HookMfaVerificationAttemptUri = &h.MFAVerificationAttempt.URI - body.HookMfaVerificationAttemptSecrets = &h.MFAVerificationAttempt.Secrets + if len(h.MFAVerificationAttempt.Secrets) > 0 { + body.HookMfaVerificationAttemptSecrets = &h.MFAVerificationAttempt.Secrets + } } if body.HookPasswordVerificationAttemptEnabled = &h.PasswordVerificationAttempt.Enabled; *body.HookPasswordVerificationAttemptEnabled { body.HookPasswordVerificationAttemptUri = &h.PasswordVerificationAttempt.URI - body.HookPasswordVerificationAttemptSecrets = &h.PasswordVerificationAttempt.Secrets + if len(h.PasswordVerificationAttempt.Secrets) > 0 { + body.HookPasswordVerificationAttemptSecrets = &h.PasswordVerificationAttempt.Secrets + } } } - func (h *hook) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { // Ignore disabled hooks because their envs are not loaded if h.CustomAccessToken.Enabled { h.CustomAccessToken.URI = cast.Val(remoteConfig.HookCustomAccessTokenUri, "") - h.CustomAccessToken.Secrets = hashPrefix + cast.Val(remoteConfig.HookCustomAccessTokenSecrets, "") + if remoteConfig.HookCustomAccessTokenSecrets != nil { + h.CustomAccessToken.Secrets = hashPrefix + cast.Val(remoteConfig.HookCustomAccessTokenSecrets, "") + } } h.CustomAccessToken.Enabled = cast.Val(remoteConfig.HookCustomAccessTokenEnabled, false) + if h.SendEmail.Enabled { h.SendEmail.URI = cast.Val(remoteConfig.HookSendEmailUri, "") - h.SendEmail.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendEmailSecrets, "") + if remoteConfig.HookSendEmailSecrets != nil { + h.SendEmail.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendEmailSecrets, "") + } } h.SendEmail.Enabled = cast.Val(remoteConfig.HookSendEmailEnabled, false) + if h.SendSMS.Enabled { h.SendSMS.URI = cast.Val(remoteConfig.HookSendSmsUri, "") - h.SendSMS.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendSmsSecrets, "") + if remoteConfig.HookSendSmsSecrets != nil { + h.SendSMS.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendSmsSecrets, "") + } } h.SendSMS.Enabled = cast.Val(remoteConfig.HookSendSmsEnabled, false) + // Enterprise and team only features if h.MFAVerificationAttempt.Enabled { h.MFAVerificationAttempt.URI = cast.Val(remoteConfig.HookMfaVerificationAttemptUri, "") - h.MFAVerificationAttempt.Secrets = hashPrefix + cast.Val(remoteConfig.HookMfaVerificationAttemptSecrets, "") + if remoteConfig.HookMfaVerificationAttemptSecrets != nil { + h.MFAVerificationAttempt.Secrets = hashPrefix + cast.Val(remoteConfig.HookMfaVerificationAttemptSecrets, "") + } } h.MFAVerificationAttempt.Enabled = cast.Val(remoteConfig.HookMfaVerificationAttemptEnabled, false) + if h.PasswordVerificationAttempt.Enabled { h.PasswordVerificationAttempt.URI = cast.Val(remoteConfig.HookPasswordVerificationAttemptUri, "") - h.PasswordVerificationAttempt.Secrets = hashPrefix + cast.Val(remoteConfig.HookPasswordVerificationAttemptSecrets, "") + if remoteConfig.HookPasswordVerificationAttemptSecrets != nil { + h.PasswordVerificationAttempt.Secrets = hashPrefix + cast.Val(remoteConfig.HookPasswordVerificationAttemptSecrets, "") + } } h.PasswordVerificationAttempt.Enabled = cast.Val(remoteConfig.HookPasswordVerificationAttemptEnabled, false) } @@ -851,19 +874,19 @@ func (a *auth) HashSecrets(key string) { case a.Sms.Vonage.Enabled: a.Sms.Vonage.ApiSecret = hash(a.Sms.Vonage.ApiSecret) } - if a.Hook.MFAVerificationAttempt.Enabled { + if a.Hook.MFAVerificationAttempt.Enabled && len(a.Hook.MFAVerificationAttempt.Secrets) > 0 { a.Hook.MFAVerificationAttempt.Secrets = hash(a.Hook.MFAVerificationAttempt.Secrets) } - if a.Hook.PasswordVerificationAttempt.Enabled { + if a.Hook.PasswordVerificationAttempt.Enabled && len(a.Hook.PasswordVerificationAttempt.Secrets) > 0 { a.Hook.PasswordVerificationAttempt.Secrets = hash(a.Hook.PasswordVerificationAttempt.Secrets) } - if a.Hook.CustomAccessToken.Enabled { + if a.Hook.CustomAccessToken.Enabled && len(a.Hook.CustomAccessToken.Secrets) > 0 { a.Hook.CustomAccessToken.Secrets = hash(a.Hook.CustomAccessToken.Secrets) } - if a.Hook.SendSMS.Enabled { + if a.Hook.SendSMS.Enabled && len(a.Hook.SendSMS.Secrets) > 0 { a.Hook.SendSMS.Secrets = hash(a.Hook.SendSMS.Secrets) } - if a.Hook.SendEmail.Enabled { + if a.Hook.SendEmail.Enabled && len(a.Hook.SendEmail.Secrets) > 0 { a.Hook.SendEmail.Secrets = hash(a.Hook.SendEmail.Secrets) } for name, provider := range a.External { diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index cba5cd9a1..057c5ccdd 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -121,29 +121,47 @@ func TestHookDiff(t *testing.T) { t.Run("local and remote enabled", func(t *testing.T) { c := newWithDefaults() c.Hook = hook{ - CustomAccessToken: hookConfig{Enabled: true}, - SendSMS: hookConfig{Enabled: true}, - SendEmail: hookConfig{Enabled: true}, - MFAVerificationAttempt: hookConfig{Enabled: true}, - PasswordVerificationAttempt: hookConfig{Enabled: true}, + CustomAccessToken: hookConfig{ + Enabled: true, + URI: "http://example.com", + Secrets: "test-secret", + }, + SendSMS: hookConfig{ + Enabled: true, + URI: "http://example.com", + Secrets: "test-secret", + }, + SendEmail: hookConfig{ + Enabled: true, + URI: "https://example.com", + Secrets: "test-secret", + }, + MFAVerificationAttempt: hookConfig{ + Enabled: true, + URI: "https://example.com", + Secrets: "test-secret", + }, + PasswordVerificationAttempt: hookConfig{ + Enabled: true, + URI: "pg-functions://verifyPassword", + }, } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ HookCustomAccessTokenEnabled: cast.Ptr(true), - HookCustomAccessTokenUri: cast.Ptr(""), - HookCustomAccessTokenSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + HookCustomAccessTokenUri: cast.Ptr("http://example.com"), + HookCustomAccessTokenSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), HookSendEmailEnabled: cast.Ptr(true), - HookSendEmailUri: cast.Ptr(""), - HookSendEmailSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + HookSendEmailUri: cast.Ptr("https://example.com"), + HookSendEmailSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), HookSendSmsEnabled: cast.Ptr(true), - HookSendSmsUri: cast.Ptr(""), - HookSendSmsSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + HookSendSmsUri: cast.Ptr("http://example.com"), + HookSendSmsSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), HookMfaVerificationAttemptEnabled: cast.Ptr(true), - HookMfaVerificationAttemptUri: cast.Ptr(""), - HookMfaVerificationAttemptSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + HookMfaVerificationAttemptUri: cast.Ptr("https://example.com"), + HookMfaVerificationAttemptSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), HookPasswordVerificationAttemptEnabled: cast.Ptr(true), - HookPasswordVerificationAttemptUri: cast.Ptr(""), - HookPasswordVerificationAttemptSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + HookPasswordVerificationAttemptUri: cast.Ptr("pg-functions://verifyPassword"), }) // Check error assert.NoError(t, err) @@ -153,17 +171,41 @@ func TestHookDiff(t *testing.T) { t.Run("local enabled and disabled", func(t *testing.T) { c := newWithDefaults() c.Hook = hook{ - CustomAccessToken: hookConfig{Enabled: true}, - MFAVerificationAttempt: hookConfig{Enabled: false}, + CustomAccessToken: hookConfig{ + Enabled: true, + URI: "http://example.com", + Secrets: "test-secret", + }, + SendSMS: hookConfig{ + Enabled: false, + URI: "https://example.com", + Secrets: "test-secret", + }, + SendEmail: hookConfig{ + Enabled: true, + URI: "pg-functions://sendEmail", + }, + MFAVerificationAttempt: hookConfig{ + Enabled: false, + URI: "pg-functions://verifyMFA", + }, + PasswordVerificationAttempt: hookConfig{Enabled: false}, } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ - HookCustomAccessTokenEnabled: cast.Ptr(false), - HookCustomAccessTokenUri: cast.Ptr(""), - HookCustomAccessTokenSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), - HookMfaVerificationAttemptEnabled: cast.Ptr(true), - HookMfaVerificationAttemptUri: cast.Ptr(""), - HookMfaVerificationAttemptSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + HookCustomAccessTokenEnabled: cast.Ptr(false), + HookCustomAccessTokenUri: cast.Ptr(""), + HookCustomAccessTokenSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + HookSendEmailEnabled: cast.Ptr(false), + HookSendEmailUri: cast.Ptr(""), + HookSendSmsEnabled: cast.Ptr(true), + HookSendSmsUri: cast.Ptr("http://example.com"), + HookSendSmsSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), + HookMfaVerificationAttemptEnabled: cast.Ptr(true), + HookMfaVerificationAttemptUri: cast.Ptr("pg-functions://verifyMFA"), + HookPasswordVerificationAttemptEnabled: cast.Ptr(true), + HookPasswordVerificationAttemptUri: cast.Ptr("https://example.com"), + HookPasswordVerificationAttemptSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), }) // Check error assert.NoError(t, err) diff --git a/pkg/config/config.go b/pkg/config/config.go index 8d809c595..f5a56dfc0 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -993,14 +993,25 @@ func (h *hookConfig) validate(hookType string) (err error) { return nil } if h.URI == "" { - return errors.Errorf("missing required field in config: auth.hook.%s.uri", hookType) - } else if parsed, err := url.Parse(h.URI); err != nil { + return errors.Errorf("Missing required field in config: auth.hook.%s.uri", hookType) + } + parsed, err := url.Parse(h.URI) + if err != nil { return errors.Errorf("failed to parse template url: %w", err) - } else if !(parsed.Scheme == "http" || parsed.Scheme == "https" || parsed.Scheme == "pg-functions") { - return errors.Errorf("Invalid HTTP hook config: auth.hook.%v should be a Postgres function URI, or a HTTP or HTTPS URL", hookType) } - if h.Secrets, err = maybeLoadEnv(h.Secrets); err != nil { - return errors.Errorf("missing required field in config: auth.hook.%s.secrets", hookType) + switch strings.ToLower(parsed.Scheme) { + case "http", "https": + if len(h.Secrets) == 0 { + return errors.Errorf("Missing required field in config: auth.hook.%s.secrets", hookType) + } else if h.Secrets, err = maybeLoadEnv(h.Secrets); err != nil { + return err + } + case "pg-functions": + if len(h.Secrets) > 0 { + return errors.Errorf("Invalid hook config: auth.hook.%s.secrets is unsupported for pg-functions URI", hookType) + } + default: + return errors.Errorf("Invalid hook config: auth.hook.%v should be a HTTP, HTTPS, or pg-functions URI", hookType) } return nil } @@ -1070,19 +1081,16 @@ func (c *tpaCognito) issuerURL() string { return fmt.Sprintf("https://cognito-idp.%s.amazonaws.com/%s", c.UserPoolRegion, c.UserPoolID) } -func (c *tpaCognito) validate() error { +func (c *tpaCognito) validate() (err error) { if c.UserPoolID == "" { return errors.New("Invalid config: auth.third_party.cognito is enabled but without a user_pool_id.") - } - var err error - if c.UserPoolID, err = maybeLoadEnv(c.UserPoolID); err != nil { + } else if c.UserPoolID, err = maybeLoadEnv(c.UserPoolID); err != nil { return err } if c.UserPoolRegion == "" { return errors.New("Invalid config: auth.third_party.cognito is enabled but without a user_pool_region.") - } - if c.UserPoolRegion, err = maybeLoadEnv(c.UserPoolRegion); err != nil { + } else if c.UserPoolRegion, err = maybeLoadEnv(c.UserPoolRegion); err != nil { return err } diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 8f1169d5e..4aa7ce243 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -205,55 +205,74 @@ func TestSigningJWT(t *testing.T) { func TestValidateHookURI(t *testing.T) { tests := []struct { - name string - uri string - hookName string - shouldErr bool - errorMsg string + hookConfig + name string + errorMsg string }{ { - name: "valid http URL", - uri: "http://example.com", - hookName: "testHook", - shouldErr: false, + name: "valid http URL", + hookConfig: hookConfig{ + Enabled: true, + URI: "http://example.com", + Secrets: "test-secret", + }, }, { - name: "valid https URL", - uri: "https://example.com", - hookName: "testHook", - shouldErr: false, + name: "valid https URL", + hookConfig: hookConfig{ + Enabled: true, + URI: "https://example.com", + Secrets: "test-secret", + }, + }, + { + name: "valid pg-functions URI", + hookConfig: hookConfig{ + Enabled: true, + URI: "pg-functions://functionName", + }, + }, + { + name: "invalid URI with unsupported scheme", + hookConfig: hookConfig{ + Enabled: true, + URI: "ftp://example.com", + Secrets: "test-secret", + }, + errorMsg: "Invalid hook config: auth.hook.invalid URI with unsupported scheme should be a HTTP, HTTPS, or pg-functions URI", }, { - name: "valid pg-functions URI", - uri: "pg-functions://functionName", - hookName: "pgHook", - shouldErr: false, + name: "invalid URI with parsing error", + hookConfig: hookConfig{ + Enabled: true, + URI: "http://a b.com", + Secrets: "test-secret", + }, + errorMsg: "failed to parse template url: parse \"http://a b.com\": invalid character \" \" in host name", }, { - name: "invalid URI with unsupported scheme", - uri: "ftp://example.com", - hookName: "malformedHook", - shouldErr: true, - errorMsg: "Invalid HTTP hook config: auth.hook.malformedHook should be a Postgres function URI, or a HTTP or HTTPS URL", + name: "valid http URL with missing secrets", + hookConfig: hookConfig{ + Enabled: true, + URI: "http://example.com", + }, + errorMsg: "Missing required field in config: auth.hook.valid http URL with missing secrets.secrets", }, { - name: "invalid URI with parsing error", - uri: "http://a b.com", - hookName: "errorHook", - shouldErr: true, - errorMsg: "failed to parse template url: parse \"http://a b.com\": invalid character \" \" in host name", + name: "valid pg-functions URI with unsupported secrets", + hookConfig: hookConfig{ + Enabled: true, + URI: "pg-functions://functionName", + Secrets: "test-secret", + }, + errorMsg: "Invalid hook config: auth.hook.valid pg-functions URI with unsupported secrets.secrets is unsupported for pg-functions URI", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - h := hookConfig{ - Enabled: true, - URI: tt.uri, - Secrets: "test-secret", - } - err := h.validate(tt.hookName) - if tt.shouldErr { + err := tt.hookConfig.validate(tt.name) + if len(tt.errorMsg) > 0 { assert.Error(t, err, "Expected an error for %v", tt.name) assert.EqualError(t, err, tt.errorMsg, "Expected error message does not match for %v", tt.name) } else { diff --git a/pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff index b21cd4073..e3afeb491 100644 --- a/pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff +++ b/pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff @@ -1,21 +1,36 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -11,7 +11,7 @@ +@@ -11,24 +11,24 @@ [hook] [hook.mfa_verification_attempt] -enabled = true +enabled = false - uri = "" + uri = "pg-functions://verifyMFA" secrets = "" [hook.password_verification_attempt] -@@ -19,7 +19,7 @@ +-enabled = true ++enabled = false uri = "" secrets = "" [hook.custom_access_token] -enabled = false +-uri = "" +-secrets = "hash:b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad" +enabled = true - uri = "" - secrets = "hash:b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad" ++uri = "http://example.com" ++secrets = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" [hook.send_sms] +-enabled = true ++enabled = false + uri = "https://example.com" + secrets = "test-secret" + [hook.send_email] +-enabled = false +-uri = "" ++enabled = true ++uri = "pg-functions://sendEmail" + secrets = "" + + [mfa] From c66a6c40b170138da0deeb20ac210b1200d38002 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Mon, 2 Dec 2024 15:06:55 +0800 Subject: [PATCH 197/305] chore: update docs for remote db reset (#2936) --- docs/supabase/db/reset.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/supabase/db/reset.md b/docs/supabase/db/reset.md index 98a8003ca..acb9b9832 100644 --- a/docs/supabase/db/reset.md +++ b/docs/supabase/db/reset.md @@ -6,4 +6,4 @@ Requires the local development stack to be started by running `supabase start`. Recreates the local Postgres container and applies all local migrations found in `supabase/migrations` directory. If test data is defined in `supabase/seed.sql`, it will be seeded after the migrations are run. Any other data or schema changes made during local development will be discarded. -Note that since Postgres roles are cluster level entities, those changes will persist between resets. In order to reset custom roles, you need to restart the local development stack. +When running db reset with `--linked` or `--db-url` flag, a SQL script is executed to identify and drop all user created entities in the remote database. Since Postgres roles are cluster level entities, any custom roles created through the dashboard or `supabase/roles.sql` will not be deleted by remote reset. From 15833d1896185018c343352cc1d1f38d4de83ecb Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Tue, 3 Dec 2024 07:15:24 +0100 Subject: [PATCH 198/305] fix(studio): Bump studio version to 20241202-71e5240 (#2937) Bump studio version --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index da0a9bf4a..23f60f25f 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -10,7 +10,7 @@ const ( inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" pgmetaImage = "supabase/postgres-meta:v0.84.2" - studioImage = "supabase/studio:20241106-f29003e" + studioImage = "supabase/studio:20241202-71e5240" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.65.3" vectorImage = "timberio/vector:0.28.1-alpine" From 06db5a562a97a2323c59f23df54322475e8450b2 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 4 Dec 2024 15:20:47 +0800 Subject: [PATCH 199/305] feat: bump cli to v2 BREAKING CHANGE: deprecate fly regions for branches (#2942) --- cmd/branches.go | 23 +++-------------------- internal/utils/api.go | 35 ----------------------------------- 2 files changed, 3 insertions(+), 55 deletions(-) diff --git a/cmd/branches.go b/cmd/branches.go index df2b48a8f..0248e7f31 100644 --- a/cmd/branches.go +++ b/cmd/branches.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "os" - "sort" "github.com/go-errors/errors" "github.com/spf13/afero" @@ -29,7 +28,7 @@ var ( } branchRegion = utils.EnumFlag{ - Allowed: flyRegions(), + Allowed: awsRegions(), } persistent bool @@ -96,9 +95,8 @@ var ( string(api.BranchResponseStatusFUNCTIONSFAILED), }, } - branchName string - gitBranch string - resetOnPush bool + branchName string + gitBranch string branchUpdateCmd = &cobra.Command{ Use: "update [branch-id]", @@ -114,9 +112,6 @@ var ( if cmdFlags.Changed("git-branch") { body.GitBranch = &gitBranch } - if cmdFlags.Changed("reset-on-push") { - body.ResetOnPush = &resetOnPush - } if cmdFlags.Changed("persistent") { body.Persistent = &persistent } @@ -176,7 +171,6 @@ func init() { updateFlags := branchUpdateCmd.Flags() updateFlags.StringVar(&branchName, "name", "", "Rename the preview branch.") updateFlags.StringVar(&gitBranch, "git-branch", "", "Change the associated git branch.") - updateFlags.BoolVar(&resetOnPush, "reset-on-push", false, "Reset the preview branch on git push.") updateFlags.BoolVar(&persistent, "persistent", false, "Switch between ephemeral and persistent branch.") updateFlags.Var(&branchStatus, "status", "Override the current branch status.") branchesCmd.AddCommand(branchUpdateCmd) @@ -185,17 +179,6 @@ func init() { rootCmd.AddCommand(branchesCmd) } -func flyRegions() []string { - result := make([]string, len(utils.FlyRegions)) - i := 0 - for k := range utils.FlyRegions { - result[i] = k - i++ - } - sort.Strings(result) - return result -} - func promptBranchId(ctx context.Context, ref string) error { resp, err := utils.GetSupabase().V1ListAllBranchesWithResponse(ctx, ref) if err != nil { diff --git a/internal/utils/api.go b/internal/utils/api.go index 7dc59a088..32b199b69 100644 --- a/internal/utils/api.go +++ b/internal/utils/api.go @@ -217,41 +217,6 @@ var RegionMap = map[string]string{ "us-west-2": "West US (Oregon)", } -var FlyRegions = map[string]string{ - "ams": "Amsterdam, Netherlands", - "arn": "Stockholm, Sweden", - "bog": "Bogotá, Colombia", - "bos": "Boston, Massachusetts (US)", - "cdg": "Paris, France", - "den": "Denver, Colorado (US)", - "dfw": "Dallas, Texas (US", - "ewr": "Secaucus, NJ (US)", - "fra": "Frankfurt, Germany", - "gdl": "Guadalajara, Mexico", - "gig": "Rio de Janeiro, Brazil", - "gru": "Sao Paulo, Brazil", - "hkg": "Hong Kong, Hong Kong", - "iad": "Ashburn, Virginia (US", - "jnb": "Johannesburg, South Africa", - "lax": "Los Angeles, California (US", - "lhr": "London, United Kingdom", - "maa": "Chennai (Madras), India", - "mad": "Madrid, Spain", - "mia": "Miami, Florida (US)", - "nrt": "Tokyo, Japan", - "ord": "Chicago, Illinois (US", - "otp": "Bucharest, Romania", - "qro": "Querétaro, Mexico", - "scl": "Santiago, Chile", - "sea": "Seattle, Washington (US", - "sin": "Singapore, Singapore", - "sjc": "San Jose, California (US", - "syd": "Sydney, Australia", - "waw": "Warsaw, Poland", - "yul": "Montreal, Canada", - "yyz": "Toronto, Canada", -} - func GetSupabaseAPIHost() string { apiHost := viper.GetString("INTERNAL_API_HOST") if apiHost == "" { From 0218be8c46351a9eada6924586db6c3bc8c0a7f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 04:40:01 +0000 Subject: [PATCH 200/305] chore(deps): bump google.golang.org/grpc from 1.68.0 to 1.68.1 (#2947) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.68.0 to 1.68.1. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.68.0...v1.68.1) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d8bfd6274..284eeb31f 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( golang.org/x/mod v0.22.0 golang.org/x/oauth2 v0.24.0 golang.org/x/term v0.26.0 - google.golang.org/grpc v1.68.0 + google.golang.org/grpc v1.68.1 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.12.0 ) diff --git a/go.sum b/go.sum index 28de4b7ef..f5fc4ac40 100644 --- a/go.sum +++ b/go.sum @@ -1481,8 +1481,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0= -google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA= +google.golang.org/grpc v1.68.1 h1:oI5oTa11+ng8r8XMMN7jAOmWfPZWbYpCFaMUTACxkM0= +google.golang.org/grpc v1.68.1/go.mod h1:+q1XYFJjShcqn0QZHvCyeR4CXPA+llXIeUIfIe00waw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From 1f05988ec2fdf66347fc57bc39bcb55e86e45e1a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:36:06 +0800 Subject: [PATCH 201/305] chore(deps): bump golang.org/x/term from 0.26.0 to 0.27.0 (#2946) Bumps [golang.org/x/term](https://github.com/golang/term) from 0.26.0 to 0.27.0. - [Commits](https://github.com/golang/term/compare/v0.26.0...v0.27.0) --- updated-dependencies: - dependency-name: golang.org/x/term dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 284eeb31f..5bf03b3dc 100644 --- a/go.mod +++ b/go.mod @@ -51,7 +51,7 @@ require ( go.opentelemetry.io/otel v1.32.0 golang.org/x/mod v0.22.0 golang.org/x/oauth2 v0.24.0 - golang.org/x/term v0.26.0 + golang.org/x/term v0.27.0 google.golang.org/grpc v1.68.1 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.12.0 @@ -337,7 +337,7 @@ require ( golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect golang.org/x/net v0.31.0 // indirect golang.org/x/sync v0.9.0 // indirect - golang.org/x/sys v0.27.0 // indirect + golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.20.0 // indirect golang.org/x/tools v0.27.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect diff --git a/go.sum b/go.sum index f5fc4ac40..d043fab57 100644 --- a/go.sum +++ b/go.sum @@ -1295,8 +1295,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.27.0 h1:wBqf8DvsY9Y/2P8gAfPDEYNuS30J4lPHJxXSb/nJZ+s= -golang.org/x/sys v0.27.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1311,8 +1311,8 @@ golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= -golang.org/x/term v0.26.0 h1:WEQa6V3Gja/BhNxg540hBip/kkaYtRg3cxg4oXSw4AU= -golang.org/x/term v0.26.0/go.mod h1:Si5m1o57C5nBNQo5z1iq+XDijt21BDBDp2bK0QI8e3E= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 6bef0d202b81b5a1122608ca91d3386a6cbd9b80 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:36:38 +0800 Subject: [PATCH 202/305] chore(deps): bump github.com/getsentry/sentry-go from 0.29.1 to 0.30.0 (#2941) Bumps [github.com/getsentry/sentry-go](https://github.com/getsentry/sentry-go) from 0.29.1 to 0.30.0. - [Release notes](https://github.com/getsentry/sentry-go/releases) - [Changelog](https://github.com/getsentry/sentry-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-go/compare/v0.29.1...v0.30.0) --- updated-dependencies: - dependency-name: github.com/getsentry/sentry-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 5bf03b3dc..1c55174b8 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/docker/docker v27.3.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 - github.com/getsentry/sentry-go v0.29.1 + github.com/getsentry/sentry-go v0.30.0 github.com/gin-gonic/gin v1.10.0 github.com/go-errors/errors v1.5.1 github.com/go-git/go-git/v5 v5.12.0 diff --git a/go.sum b/go.sum index d043fab57..9313587d7 100644 --- a/go.sum +++ b/go.sum @@ -291,8 +291,8 @@ github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uq github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj9kz/M= github.com/getkin/kin-openapi v0.124.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM= -github.com/getsentry/sentry-go v0.29.1 h1:DyZuChN8Hz3ARxGVV8ePaNXh1dQ7d76AiB117xcREwA= -github.com/getsentry/sentry-go v0.29.1/go.mod h1:x3AtIzN01d6SiWkderzaH28Tm0lgkafpJ5Bm3li39O0= +github.com/getsentry/sentry-go v0.30.0 h1:lWUwDnY7sKHaVIoZ9wYqRHJ5iEmoc0pqcRqFkosKzBo= +github.com/getsentry/sentry-go v0.30.0/go.mod h1:WU9B9/1/sHDqeV8T+3VwwbjeR5MSXs/6aqG3mqZrezA= github.com/ghostiam/protogetter v0.3.8 h1:LYcXbYvybUyTIxN2Mj9h6rHrDZBDwZloPoKctWrFyJY= github.com/ghostiam/protogetter v0.3.8/go.mod h1:WZ0nw9pfzsgxuRsPOFQomgDVSWtDLJRfQJEhsGbmQMA= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= From c1363893030d197903e8ad9949b73758544206ff Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Thu, 5 Dec 2024 13:54:48 +0800 Subject: [PATCH 203/305] chore: update config comments (#2944) --- pkg/config/templates/config.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index 12decc3f4..f59dab08b 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -9,15 +9,16 @@ enabled = true # Port to use for the API URL. port = 54321 # Schemas to expose in your API. Tables, views and stored procedures in this schema will get API -# endpoints. `public` is always included. +# endpoints. `public` and `graphql_public` schemas are included by default. schemas = ["public", "graphql_public"] -# Extra schemas to add to the search_path of every request. `public` is always included. +# Extra schemas to add to the search_path of every request. extra_search_path = ["public", "extensions"] # The maximum number of rows returns from a view, table, or stored procedure. Limits payload size # for accidental or malicious requests. max_rows = 1000 [api.tls] +# Enable HTTPS endpoints locally using a self-signed certificate. enabled = false [db] @@ -45,8 +46,7 @@ max_client_conn = 100 # If enabled, seeds the database after migrations during a db reset. enabled = true # Specifies an ordered list of seed files to load during db reset. -# Supports glob patterns relative to supabase directory. For example: -# sql_paths = ['./seeds/*.sql', '../project-src/seeds/*-load-testing.sql'] +# Supports glob patterns relative to supabase directory: './seeds/*.sql' sql_paths = ['./seed.sql'] [realtime] From bc1facc7795e8244ec8f3957a712c6aa89f3d612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Thu, 5 Dec 2024 14:54:59 +0900 Subject: [PATCH 204/305] fix: bump edge-runtime to 1.65.4 (#2940) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 23f60f25f..6754dcb75 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241202-71e5240" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.65.3" + edgeRuntimeImage = "supabase/edge-runtime:v1.65.4" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.164.0" From 9324c89aef4feb4fec25f52bea85c763ce420b43 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Fri, 6 Dec 2024 20:00:37 +0800 Subject: [PATCH 205/305] fix: bump default postgres for pgmq support (#2948) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 6754dcb75..44b61997e 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -3,7 +3,7 @@ package config const ( pg13Image = "supabase/postgres:13.3.0" pg14Image = "supabase/postgres:14.1.0.89" - Pg15Image = "supabase/postgres:15.6.1.139" + Pg15Image = "supabase/postgres:15.6.1.143" // Append to ServiceImages when adding new dependencies below // TODO: try https://github.com/axllent/mailpit kongImage = "library/kong:2.8.1" From a3fd06a87238b013cb6eb4b970071ad743c54ec7 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sat, 7 Dec 2024 14:25:22 +0800 Subject: [PATCH 206/305] fix: optional project ref flag for snippets command --- cmd/snippets.go | 2 ++ internal/snippets/list/list.go | 7 ++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/snippets.go b/cmd/snippets.go index 86f439c67..f69b232af 100644 --- a/cmd/snippets.go +++ b/cmd/snippets.go @@ -5,6 +5,7 @@ import ( "github.com/spf13/cobra" "github.com/supabase/cli/internal/snippets/download" "github.com/supabase/cli/internal/snippets/list" + "github.com/supabase/cli/internal/utils/flags" ) var ( @@ -35,6 +36,7 @@ var ( ) func init() { + snippetsCmd.PersistentFlags().StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.") snippetsCmd.AddCommand(snippetsListCmd) snippetsCmd.AddCommand(snippetsDownloadCmd) rootCmd.AddCommand(snippetsCmd) diff --git a/internal/snippets/list/list.go b/internal/snippets/list/list.go index 1bd47060f..f54325eaa 100644 --- a/internal/snippets/list/list.go +++ b/internal/snippets/list/list.go @@ -14,11 +14,8 @@ import ( ) func Run(ctx context.Context, fsys afero.Fs) error { - ref, err := flags.LoadProjectRef(fsys) - if err != nil { - return err - } - resp, err := utils.GetSupabase().V1ListAllSnippetsWithResponse(ctx, &api.V1ListAllSnippetsParams{ProjectRef: &ref}) + opts := api.V1ListAllSnippetsParams{ProjectRef: &flags.ProjectRef} + resp, err := utils.GetSupabase().V1ListAllSnippetsWithResponse(ctx, &opts) if err != nil { return errors.Errorf("failed to list snippets: %w", err) } From bfa2c42c7eded5476e4c49728304748b864fbaa3 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sat, 7 Dec 2024 16:03:01 +0800 Subject: [PATCH 207/305] chore: reuse services command for version check --- cmd/root.go | 3 +- internal/services/services.go | 73 +++++++++++++++++++++-------------- internal/start/start.go | 26 +------------ pkg/config/config.go | 15 +++++++ 4 files changed, 63 insertions(+), 54 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index d3ef3fce9..35540a897 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -15,7 +15,6 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/supabase/cli/internal/services" "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/internal/utils/flags" "golang.org/x/mod/semver" @@ -250,7 +249,7 @@ func GetRootCmd() *cobra.Command { } func addSentryScope(scope *sentry.Scope) { - serviceImages := services.GetServiceImages() + serviceImages := utils.Config.GetServiceImages() imageToVersion := make(map[string]interface{}, len(serviceImages)) for _, image := range serviceImages { parts := strings.Split(image, ":") diff --git a/internal/services/services.go b/internal/services/services.go index 1e6dc531d..b9bfae6e6 100644 --- a/internal/services/services.go +++ b/internal/services/services.go @@ -2,7 +2,9 @@ package services import ( "context" + "errors" "fmt" + "os" "strings" "sync" @@ -13,50 +15,56 @@ import ( "github.com/supabase/cli/internal/utils/tenant" ) -var suggestLinkCommand = fmt.Sprintf("Run %s to sync your local image versions with the linked project.", utils.Aqua("supabase link")) - func Run(ctx context.Context, fsys afero.Fs) error { - _ = utils.LoadConfigFS(fsys) - serviceImages := GetServiceImages() - - var linked map[string]string - if projectRef, err := flags.LoadProjectRef(fsys); err == nil { - linked = GetRemoteImages(ctx, projectRef) + if _, err := flags.LoadProjectRef(fsys); err != nil && !errors.Is(err, utils.ErrNotLinked) { + fmt.Fprintln(os.Stderr, err) + } + if err := utils.Config.Load("", utils.NewRootFS(fsys)); err != nil && !errors.Is(err, os.ErrNotExist) { + fmt.Fprintln(os.Stderr, err) } + serviceImages := CheckVersions(ctx, fsys) table := `|SERVICE IMAGE|LOCAL|LINKED| |-|-|-| ` for _, image := range serviceImages { - parts := strings.Split(image, ":") - version, ok := linked[image] - if !ok { - version = "-" - } else if parts[1] != version && image != utils.Config.Db.Image { - utils.CmdSuggestion = suggestLinkCommand + remote := image.Remote + if len(remote) == 0 { + remote = "-" } - table += fmt.Sprintf("|`%s`|`%s`|`%s`|\n", parts[0], parts[1], version) + table += fmt.Sprintf("|`%s`|`%s`|`%s`|\n", image.Name, image.Local, remote) } return list.RenderTable(table) } -func GetServiceImages() []string { - return []string{ - utils.Config.Db.Image, - utils.Config.Auth.Image, - utils.Config.Api.Image, - utils.Config.Realtime.Image, - utils.Config.Storage.Image, - utils.Config.EdgeRuntime.Image, - utils.Config.Studio.Image, - utils.Config.Studio.PgmetaImage, - utils.Config.Analytics.Image, - utils.Config.Db.Pooler.Image, +type imageVersion struct { + Name string `json:"name"` + Local string `json:"local"` + Remote string `json:"remote"` +} + +func CheckVersions(ctx context.Context, fsys afero.Fs) []imageVersion { + var remote map[string]string + if _, err := utils.LoadAccessTokenFS(fsys); err == nil && len(flags.ProjectRef) > 0 { + remote = listRemoteImages(ctx, flags.ProjectRef) } + var result []imageVersion + for _, image := range utils.Config.GetServiceImages() { + parts := strings.Split(image, ":") + v := imageVersion{Name: parts[0], Local: parts[1]} + if v.Remote = remote[image]; v.Remote == v.Local { + delete(remote, image) + } + result = append(result, v) + } + if len(remote) > 0 { + fmt.Fprintln(os.Stderr, suggestUpdateCmd(remote)) + } + return result } -func GetRemoteImages(ctx context.Context, projectRef string) map[string]string { +func listRemoteImages(ctx context.Context, projectRef string) map[string]string { linked := make(map[string]string, 4) var wg sync.WaitGroup wg.Add(1) @@ -94,3 +102,12 @@ func GetRemoteImages(ctx context.Context, projectRef string) map[string]string { wg.Wait() return linked } + +func suggestUpdateCmd(serviceImages map[string]string) string { + cmd := fmt.Sprintln(utils.Yellow("WARNING:"), "You are running different service versions locally than your linked project:") + for k, v := range serviceImages { + cmd += fmt.Sprintf("%s => %s\n", k, v) + } + cmd += fmt.Sprintf("Run %s to update them.", utils.Aqua("supabase link")) + return cmd +} diff --git a/internal/start/start.go b/internal/start/start.go index 5521161f8..5877b47e4 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -34,18 +34,10 @@ import ( "golang.org/x/mod/semver" ) -func suggestUpdateCmd(serviceImages map[string]string) string { - cmd := fmt.Sprintln(utils.Yellow("WARNING:"), "You are running different service versions locally than your linked project:") - for k, v := range serviceImages { - cmd += fmt.Sprintf("%s => %s\n", k, v) - } - cmd += fmt.Sprintf("Run %s to update them.", utils.Aqua("supabase link")) - return cmd -} - func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string, ignoreHealthCheck bool) error { // Sanity checks. { + _, _ = flags.LoadProjectRef(fsys) if err := utils.LoadConfigFS(fsys); err != nil { return err } @@ -56,21 +48,7 @@ func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string, ignore } else if !errors.Is(err, utils.ErrNotRunning) { return err } - if _, err := utils.LoadAccessTokenFS(fsys); err == nil { - if ref, err := flags.LoadProjectRef(fsys); err == nil { - local := services.GetServiceImages() - remote := services.GetRemoteImages(ctx, ref) - for _, image := range local { - parts := strings.Split(image, ":") - if version, ok := remote[image]; ok && version == parts[1] { - delete(remote, image) - } - } - if len(remote) > 0 { - fmt.Fprintln(os.Stderr, suggestUpdateCmd(remote)) - } - } - } + _ = services.CheckVersions(ctx, fsys) } if err := utils.RunProgram(ctx, func(p utils.Program, ctx context.Context) error { diff --git a/pkg/config/config.go b/pkg/config/config.go index f5a56dfc0..938016e83 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -1234,6 +1234,21 @@ func (a *auth) ResolveJWKS(ctx context.Context) (string, error) { return string(jwksEncoded), nil } +func (c *baseConfig) GetServiceImages() []string { + return []string{ + c.Db.Image, + c.Auth.Image, + c.Api.Image, + c.Realtime.Image, + c.Storage.Image, + c.EdgeRuntime.Image, + c.Studio.Image, + c.Studio.PgmetaImage, + c.Analytics.Image, + c.Db.Pooler.Image, + } +} + // Retrieve the final base config to use taking into account the remotes override func (c *config) GetRemoteByProjectRef(projectRef string) (baseConfig, error) { var result []string From 9becfabec03674e7e06e199e8f7c31d49d6b29b7 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sat, 7 Dec 2024 16:35:32 +0800 Subject: [PATCH 208/305] chore: skip loading project ref if flag is set --- internal/projects/list/list.go | 5 ++--- internal/services/services.go | 2 +- internal/start/start.go | 5 +++-- internal/utils/flags/db_url.go | 16 +++++-------- internal/utils/flags/project_ref.go | 35 +++++++++++++---------------- 5 files changed, 28 insertions(+), 35 deletions(-) diff --git a/internal/projects/list/list.go b/internal/projects/list/list.go index d211f71e9..ef356dfcf 100644 --- a/internal/projects/list/list.go +++ b/internal/projects/list/list.go @@ -29,8 +29,7 @@ func Run(ctx context.Context, fsys afero.Fs) error { return errors.New("Unexpected error retrieving projects: " + string(resp.Body)) } - projectRef, err := flags.LoadProjectRef(fsys) - if err != nil && err != utils.ErrNotLinked { + if err := flags.LoadProjectRef(fsys); err != nil && err != utils.ErrNotLinked { fmt.Fprintln(os.Stderr, err) } @@ -38,7 +37,7 @@ func Run(ctx context.Context, fsys afero.Fs) error { for _, project := range *resp.JSON200 { projects = append(projects, linkedProject{ V1ProjectWithDatabaseResponse: project, - Linked: project.Id == projectRef, + Linked: project.Id == flags.ProjectRef, }) } diff --git a/internal/services/services.go b/internal/services/services.go index b9bfae6e6..ebc08efca 100644 --- a/internal/services/services.go +++ b/internal/services/services.go @@ -16,7 +16,7 @@ import ( ) func Run(ctx context.Context, fsys afero.Fs) error { - if _, err := flags.LoadProjectRef(fsys); err != nil && !errors.Is(err, utils.ErrNotLinked) { + if err := flags.LoadProjectRef(fsys); err != nil && !errors.Is(err, utils.ErrNotLinked) { fmt.Fprintln(os.Stderr, err) } if err := utils.Config.Load("", utils.NewRootFS(fsys)); err != nil && !errors.Is(err, os.ErrNotExist) { diff --git a/internal/start/start.go b/internal/start/start.go index 5877b47e4..4315d31b7 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -37,7 +37,6 @@ import ( func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string, ignoreHealthCheck bool) error { // Sanity checks. { - _, _ = flags.LoadProjectRef(fsys) if err := utils.LoadConfigFS(fsys); err != nil { return err } @@ -48,7 +47,9 @@ func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string, ignore } else if !errors.Is(err, utils.ErrNotRunning) { return err } - _ = services.CheckVersions(ctx, fsys) + if err := flags.LoadProjectRef(fsys); err == nil { + _ = services.CheckVersions(ctx, fsys) + } } if err := utils.RunProgram(ctx, func(p utils.Program, ctx context.Context) error { diff --git a/internal/utils/flags/db_url.go b/internal/utils/flags/db_url.go index d089f2d13..013453b86 100644 --- a/internal/utils/flags/db_url.go +++ b/internal/utils/flags/db_url.go @@ -50,10 +50,8 @@ func ParseDatabaseConfig(flagSet *pflag.FlagSet, fsys afero.Fs) error { // Update connection config switch connType { case direct: - if err := utils.Config.Load("", utils.NewRootFS(fsys)); err != nil { - if !errors.Is(err, os.ErrNotExist) { - return err - } + if err := utils.Config.Load("", utils.NewRootFS(fsys)); err != nil && !errors.Is(err, os.ErrNotExist) { + return err } if flag := flagSet.Lookup("db-url"); flag != nil { config, err := pgconn.ParseConfig(flag.Value.String()) @@ -76,25 +74,23 @@ func ParseDatabaseConfig(flagSet *pflag.FlagSet, fsys afero.Fs) error { if err := utils.LoadConfigFS(fsys); err != nil { return err } - projectRef, err := LoadProjectRef(fsys) - if err != nil { + if err := LoadProjectRef(fsys); err != nil { return err } - DbConfig = NewDbConfigWithPassword(projectRef) + DbConfig = NewDbConfigWithPassword(ProjectRef) case proxy: token, err := utils.LoadAccessTokenFS(fsys) if err != nil { return err } - projectRef, err := LoadProjectRef(fsys) - if err != nil { + if err := LoadProjectRef(fsys); err != nil { return err } DbConfig.Host = utils.GetSupabaseAPIHost() DbConfig.Port = 443 DbConfig.User = "postgres" DbConfig.Password = token - DbConfig.Database = projectRef + DbConfig.Database = ProjectRef } return nil } diff --git a/internal/utils/flags/project_ref.go b/internal/utils/flags/project_ref.go index 437bbb668..73df72353 100644 --- a/internal/utils/flags/project_ref.go +++ b/internal/utils/flags/project_ref.go @@ -16,12 +16,7 @@ import ( var ProjectRef string func ParseProjectRef(ctx context.Context, fsys afero.Fs) error { - // Flag takes highest precedence - if len(ProjectRef) > 0 { - return utils.AssertProjectRefIsValid(ProjectRef) - } - // Followed by linked ref file - if _, err := LoadProjectRef(fsys); !errors.Is(err, utils.ErrNotLinked) { + if err := LoadProjectRef(fsys); !errors.Is(err, utils.ErrNotLinked) { return err } // Prompt as the last resort @@ -55,20 +50,22 @@ func PromptProjectRef(ctx context.Context, title string) error { return nil } -func LoadProjectRef(fsys afero.Fs) (string, error) { +func LoadProjectRef(fsys afero.Fs) error { + // Flag takes highest precedence + if len(ProjectRef) > 0 { + return utils.AssertProjectRefIsValid(ProjectRef) + } // Env var takes precedence over ref file - ProjectRef = viper.GetString("PROJECT_ID") - if len(ProjectRef) == 0 { - projectRefBytes, err := afero.ReadFile(fsys, utils.ProjectRefPath) - if errors.Is(err, os.ErrNotExist) { - return "", errors.New(utils.ErrNotLinked) - } else if err != nil { - return "", errors.Errorf("failed to load project ref: %w", err) - } - ProjectRef = string(bytes.TrimSpace(projectRefBytes)) + if ProjectRef = viper.GetString("PROJECT_ID"); len(ProjectRef) > 0 { + return utils.AssertProjectRefIsValid(ProjectRef) } - if err := utils.AssertProjectRefIsValid(ProjectRef); err != nil { - return "", err + // Load from local file last + projectRefBytes, err := afero.ReadFile(fsys, utils.ProjectRefPath) + if errors.Is(err, os.ErrNotExist) { + return errors.New(utils.ErrNotLinked) + } else if err != nil { + return errors.Errorf("failed to load project ref: %w", err) } - return ProjectRef, nil + ProjectRef = string(bytes.TrimSpace(projectRefBytes)) + return utils.AssertProjectRefIsValid(ProjectRef) } From 0eac017b1271b76b0e223cde3e0d3b077c57ad7b Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sat, 7 Dec 2024 18:32:52 +0800 Subject: [PATCH 209/305] fix: account for remote config when pushing --- internal/db/reset/reset.go | 23 ++++++++++++++++++++++- internal/functions/deploy/deploy.go | 7 +++++-- internal/gen/types/types.go | 3 ++- internal/seed/buckets/buckets.go | 5 +++-- internal/storage/cp/cp.go | 3 ++- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/internal/db/reset/reset.go b/internal/db/reset/reset.go index a475ca80d..3830a019d 100644 --- a/internal/db/reset/reset.go +++ b/internal/db/reset/reset.go @@ -23,9 +23,11 @@ import ( "github.com/supabase/cli/internal/db/start" "github.com/supabase/cli/internal/gen/keys" "github.com/supabase/cli/internal/migration/apply" + "github.com/supabase/cli/internal/migration/list" "github.com/supabase/cli/internal/migration/repair" "github.com/supabase/cli/internal/seed/buckets" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/migration" ) @@ -241,7 +243,26 @@ func resetRemote(ctx context.Context, version string, config pgconn.Config, fsys if err := migration.DropUserSchemas(ctx, conn); err != nil { return err } - return apply.MigrateAndSeed(ctx, version, conn, fsys) + migrations, err := list.LoadPartialMigrations(version, fsys) + if err != nil { + return err + } + if err := migration.ApplyMigrations(ctx, migrations, conn, afero.NewIOFS(fsys)); err != nil { + return err + } + remote, _ := utils.Config.GetRemoteByProjectRef(flags.ProjectRef) + if !remote.Db.Seed.Enabled { + fmt.Fprintln(os.Stderr, "Skipping seed because it is disabled in config.toml for project:", remote.ProjectId) + return nil + } else if !utils.Config.Db.Seed.Enabled { + // Skip because --no-seed flag is set + return nil + } + seeds, err := migration.GetPendingSeeds(ctx, remote.Db.Seed.SqlPaths, conn, afero.NewIOFS(fsys)) + if err != nil { + return err + } + return migration.SeedData(ctx, seeds, conn, afero.NewIOFS(fsys)) } func LikeEscapeSchema(schemas []string) (result []string) { diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index 6713d47d3..529b78976 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -10,6 +10,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/cast" "github.com/supabase/cli/pkg/config" "github.com/supabase/cli/pkg/function" @@ -59,7 +60,8 @@ func GetFunctionSlugs(fsys afero.Fs) (slugs []string, err error) { } } // Add all function slugs declared in config file - for slug := range utils.Config.Functions { + remote, _ := utils.Config.GetRemoteByProjectRef(flags.ProjectRef) + for slug := range remote.Functions { slugs = append(slugs, slug) } return slugs, nil @@ -78,9 +80,10 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, if len(importMapPath) > 0 && !filepath.IsAbs(importMapPath) { importMapPath = filepath.Join(utils.CurrentDirAbs, importMapPath) } + remote, _ := utils.Config.GetRemoteByProjectRef(flags.ProjectRef) functionConfig := make(config.FunctionConfig, len(slugs)) for _, name := range slugs { - function := utils.Config.Functions[name] + function := remote.Functions[name] // Precedence order: flag > config > fallback functionDir := filepath.Join(utils.FunctionsDir, name) if len(function.Entrypoint) == 0 { diff --git a/internal/gen/types/types.go b/internal/gen/types/types.go index 9ffc7dc72..b399cfb5c 100644 --- a/internal/gen/types/types.go +++ b/internal/gen/types/types.go @@ -31,7 +31,8 @@ func Run(ctx context.Context, projectId string, dbConfig pgconn.Config, lang str originalURL := utils.ToPostgresURL(dbConfig) // Add default schemas if --schema flag is not specified if len(schemas) == 0 { - schemas = utils.RemoveDuplicates(append([]string{"public"}, utils.Config.Api.Schemas...)) + remote, _ := utils.Config.GetRemoteByProjectRef(projectId) + schemas = utils.RemoveDuplicates(append([]string{"public"}, remote.Api.Schemas...)) } included := strings.Join(schemas, ",") diff --git a/internal/seed/buckets/buckets.go b/internal/seed/buckets/buckets.go index 365c3a395..b460fdc79 100644 --- a/internal/seed/buckets/buckets.go +++ b/internal/seed/buckets/buckets.go @@ -26,8 +26,9 @@ func Run(ctx context.Context, projectRef string, interactive bool, fsys afero.Fs } return shouldOverwrite } - if err := api.UpsertBuckets(ctx, utils.Config.Storage.Buckets, filter); err != nil { + remote, _ := utils.Config.GetRemoteByProjectRef(projectRef) + if err := api.UpsertBuckets(ctx, remote.Storage.Buckets, filter); err != nil { return err } - return api.UpsertObjects(ctx, utils.Config.Storage.Buckets, utils.NewRootFS(fsys)) + return api.UpsertObjects(ctx, remote.Storage.Buckets, utils.NewRootFS(fsys)) } diff --git a/internal/storage/cp/cp.go b/internal/storage/cp/cp.go index 8aed7a6fa..e55120a1c 100644 --- a/internal/storage/cp/cp.go +++ b/internal/storage/cp/cp.go @@ -115,6 +115,7 @@ func UploadStorageObjectAll(ctx context.Context, api storage.StorageAPI, remoteP return err } } + remote, _ := utils.Config.GetRemoteByProjectRef(flags.ProjectRef) // Overwrites existing object when using --recursive flag opts = append(opts, func(fo *storage.FileOptions) { fo.Overwrite = true @@ -153,7 +154,7 @@ func UploadStorageObjectAll(ctx context.Context, api storage.StorageAPI, remoteP // Retry after creating bucket if bucket, prefix := client.SplitBucketPrefix(dstPath); len(prefix) > 0 { body := storage.CreateBucketRequest{Name: bucket} - if config, ok := utils.Config.Storage.Buckets[bucket]; ok { + if config, ok := remote.Storage.Buckets[bucket]; ok { body.Public = config.Public body.FileSizeLimit = int64(config.FileSizeLimit) body.AllowedMimeTypes = config.AllowedMimeTypes From 4a7e73ec5d12f86119fd2712f3dc9539a3d1c352 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sat, 7 Dec 2024 19:18:19 +0800 Subject: [PATCH 210/305] fix: allow mapstructure override for site url --- pkg/config/auth.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 10611c23b..5cb551cd1 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -48,7 +48,7 @@ type ( Enabled bool `toml:"enabled"` Image string `toml:"-"` - SiteUrl string `toml:"site_url"` + SiteUrl string `toml:"site_url" mapstructure:"site_url"` AdditionalRedirectUrls []string `toml:"additional_redirect_urls"` JwtExpiry uint `toml:"jwt_expiry"` EnableRefreshTokenRotation bool `toml:"enable_refresh_token_rotation"` From b40c676531582a99efd63a626e151fbad57c2fb5 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sat, 7 Dec 2024 22:05:44 +0800 Subject: [PATCH 211/305] chore: remove unmaintained tests --- test/branch_test.go | 38 --------- test/db_test.go | 144 --------------------------------- test/init_test.go | 50 ------------ test/link_test.go | 105 ------------------------ test/login_test.go | 110 ------------------------- test/main_test.go | 103 ----------------------- test/migration_test.go | 56 ------------- test/mocks/docker/httputils.go | 67 --------------- test/mocks/docker/server.go | 99 ----------------------- test/mocks/supabase/server.go | 74 ----------------- test/secrets_test.go | 121 --------------------------- test/status_test.go | 108 ------------------------- 12 files changed, 1075 deletions(-) delete mode 100644 test/branch_test.go delete mode 100644 test/db_test.go delete mode 100644 test/init_test.go delete mode 100644 test/link_test.go delete mode 100644 test/login_test.go delete mode 100644 test/main_test.go delete mode 100644 test/migration_test.go delete mode 100644 test/mocks/docker/httputils.go delete mode 100644 test/mocks/docker/server.go delete mode 100644 test/mocks/supabase/server.go delete mode 100644 test/secrets_test.go delete mode 100644 test/status_test.go diff --git a/test/branch_test.go b/test/branch_test.go deleted file mode 100644 index 07d3608d2..000000000 --- a/test/branch_test.go +++ /dev/null @@ -1,38 +0,0 @@ -package integration - -import ( - "context" - "encoding/json" - "os" - - "github.com/docker/docker/api/types/container" - "github.com/stretchr/testify/require" -) - -// this is the part of Database test suite - DBTestSuite -// test functions -func (suite *DBTestSuite) TestBranchCreate() { - suite.T().Skip("Local branching is deprecated") - // create branch - branch := "test-branch" - create, args, err := suite.cmd.Traverse([]string{"db", "branch", "create", branch}) - require.NoError(suite.T(), err) - create.SetContext(context.Background()) - err = create.RunE(create, args) - require.NoError(suite.T(), err) - - // check if branch dir exists - _, err = os.Stat("supabase/.branches/" + branch) - require.NoError(suite.T(), err) - - // check if all exec calls were made to docker api - ids := suite.constructParams() - require.ElementsMatch(suite.T(), suite.params, ids) - - // check commands in exec calls - require.Equal(suite.T(), 2, len(suite.bodies)) - var execBody container.ExecOptions - require.NoError(suite.T(), json.Unmarshal([]byte(suite.bodies[0]), &execBody)) - var startBody container.ExecStartOptions - require.NoError(suite.T(), json.Unmarshal([]byte(suite.bodies[1]), &startBody)) -} diff --git a/test/db_test.go b/test/db_test.go deleted file mode 100644 index 45de0ef2d..000000000 --- a/test/db_test.go +++ /dev/null @@ -1,144 +0,0 @@ -package integration - -// Basic imports -import ( - "context" - "io" - "net/http" - "os" - "path/filepath" - "sync" - "testing" - - "github.com/gin-gonic/gin" - gonanoid "github.com/matoous/go-nanoid/v2" - "github.com/spf13/cobra" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - clicmd "github.com/supabase/cli/cmd" - "github.com/supabase/cli/test/mocks/docker" -) - -type DBTestSuite struct { - suite.Suite - cmd *cobra.Command - tempDir string - ids []string - bodies []string - params []gin.Params - mtx sync.RWMutex -} - -// test functions -// add tests here <- - -// hooks -func (suite *DBTestSuite) SetupTest() { - suite.tempDir = NewTempDir(Logger, TempDir) - suite.mtx.Lock() - suite.ids = []string{} - suite.bodies = []string{} - suite.params = []gin.Params{} - suite.mtx.Unlock() - - // add docker mock handlers - DockerMock.ExecCreateHandler = func(c *gin.Context) { - suite.addParams(c.Copy()) - body, err := io.ReadAll(c.Request.Body) - if err != nil { - c.JSON(http.StatusBadRequest, gin.H{ - "message": "error reading body", - }) - return - } - suite.addBody(body) - - id := gonanoid.MustGenerate(docker.IDAlphabet, docker.IDLength) - c.JSON(http.StatusCreated, gin.H{ - "Id": id, - }) - suite.addID(id) - } - - DockerMock.ExecStartHandler = func(c *gin.Context) { - suite.addParams(c.Copy()) - body, err := io.ReadAll(c.Request.Body) - if err != nil { - c.JSON(http.StatusBadRequest, gin.H{ - "message": "error reading body", - }) - return - } - suite.addBody(body) - - docker.HijackedResponse(c, "0") - } - - DockerMock.ContainerInspectHandler = func(c *gin.Context) { - c.JSON(http.StatusOK, gin.H{}) - } - - // create supabase dir - suite.cmd = clicmd.GetRootCmd() - init, _, err := suite.cmd.Find([]string{"init"}) - require.NoError(suite.T(), err) - init.SetContext(context.Background()) - err = init.RunE(init, []string{}) - require.NoError(suite.T(), err) - - err = os.Mkdir("supabase/.branches", os.FileMode(0755)) - require.NoError(suite.T(), err) -} - -func (suite *DBTestSuite) TeardownTest() { - require.NoError(suite.T(), os.Chdir(TempDir)) -} - -// In order for 'go test' to run this suite, we need to create -// a normal test function and pass our suite to suite.Run -func TestDBTestSuite(t *testing.T) { - suite.Run(t, new(DBTestSuite)) -} - -// helper functions -func (suite *DBTestSuite) addParams(c *gin.Context) { - suite.mtx.Lock() - defer suite.mtx.Unlock() - suite.params = append(suite.params, c.Params) -} - -func (suite *DBTestSuite) addBody(body []byte) { - suite.mtx.Lock() - defer suite.mtx.Unlock() - suite.bodies = append(suite.bodies, string(body)) -} - -func (suite *DBTestSuite) addID(id string) { - suite.mtx.Lock() - defer suite.mtx.Unlock() - suite.ids = append(suite.ids, id) -} - -func (suite *DBTestSuite) constructParams() []gin.Params { - ids := []gin.Params{} - // for each exec docker call we have to calls to docker api: - // one to create exec, one to start exec - for _, id := range suite.ids { - // this one represents call to create exec - ids = append(ids, gin.Params{ - gin.Param{ - Key: "id", - Value: "supabase_db_" + filepath.Base(suite.tempDir), - }, - }) - - // this one represents call to start exec - ids = append(ids, gin.Params{ - gin.Param{ - Key: "id", - Value: id, - }, - }) - } - return ids -} diff --git a/test/init_test.go b/test/init_test.go deleted file mode 100644 index bdc8b7b7d..000000000 --- a/test/init_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package integration - -// Basic imports -import ( - "context" - "os" - "testing" - - "github.com/spf13/cobra" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - clicmd "github.com/supabase/cli/cmd" - "github.com/supabase/cli/internal/utils" -) - -type InitTestSuite struct { - suite.Suite - tempDir string - cmd *cobra.Command -} - -// test functions -func (suite *InitTestSuite) TestInit() { - // init supabase - init, _, err := suite.cmd.Find([]string{"init"}) - require.NoError(suite.T(), err) - init.SetContext(context.Background()) - require.NoError(suite.T(), init.RunE(init, []string{})) - - // check if init dir exists - _, err = os.Stat(utils.ConfigPath) - require.NoError(suite.T(), err) -} - -// hooks -func (suite *InitTestSuite) SetupTest() { - // init cli - suite.cmd = clicmd.GetRootCmd() - suite.tempDir = NewTempDir(Logger, TempDir) -} - -func (suite *InitTestSuite) TeardownTest() { - require.NoError(suite.T(), os.Chdir(TempDir)) -} - -// In order for 'go test' to run this suite, we need to create -// a normal test function and pass our suite to suite.Run -func TestInitTestSuite(t *testing.T) { - suite.Run(t, new(InitTestSuite)) -} diff --git a/test/link_test.go b/test/link_test.go deleted file mode 100644 index afef6c6f8..000000000 --- a/test/link_test.go +++ /dev/null @@ -1,105 +0,0 @@ -package integration - -// Basic imports -import ( - "context" - "fmt" - "net/http" - "os" - "sync" - "testing" - - "github.com/gin-gonic/gin" - gonanoid "github.com/matoous/go-nanoid/v2" - "github.com/spf13/cobra" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - clicmd "github.com/supabase/cli/cmd" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/test/mocks/supabase" -) - -type LinkTestSuite struct { - suite.Suite - tempDir string - cmd *cobra.Command - - ids []string - headers []http.Header - - mtx sync.RWMutex -} - -// test functions -func (suite *LinkTestSuite) TestLink() { - // run command - link, _, err := suite.cmd.Find([]string{"link"}) - link.SetContext(context.Background()) - require.NoError(suite.T(), err) - - id := gonanoid.MustGenerate(supabase.IDAlphabet, supabase.IDLength) - require.NoError(suite.T(), link.Flags().Set("project-ref", id)) - require.NoError(suite.T(), link.Flags().Set("password", "postgres")) - - require.NoError(suite.T(), link.RunE(link, []string{})) - - // check request details - suite.mtx.RLock() - defer suite.mtx.RUnlock() - require.Contains(suite.T(), suite.ids, id) - require.Contains(suite.T(), suite.headers, http.Header{ - "Authorization": []string{fmt.Sprintf("Bearer %s", supabase.AccessToken)}, - "Accept-Encoding": []string{"gzip"}, - "User-Agent": []string{"Go-http-client/1.1"}, - }) - _, err = os.Stat(utils.ProjectRefPath) - require.NoError(suite.T(), err) - ref, err := os.ReadFile(utils.ProjectRefPath) - require.NoError(suite.T(), err) - require.Equal(suite.T(), id, string(ref)) -} - -// hooks -func (suite *LinkTestSuite) SetupTest() { - // init cli - suite.cmd = clicmd.GetRootCmd() - suite.tempDir = NewTempDir(Logger, TempDir) - - // init supabase - init, _, err := suite.cmd.Find([]string{"init"}) - init.SetContext(context.Background()) - require.NoError(suite.T(), err) - require.NoError(suite.T(), init.RunE(init, []string{})) - - // implement mocks - SupaMock.FunctionsHandler = func(c *gin.Context) { - suite.addHeaders(c.Request.Header) - suite.addID(c.Params.ByName("id")) - - c.JSON(http.StatusOK, []api.FunctionResponse{}) - } -} - -func (suite *LinkTestSuite) TeardownTest() { - require.NoError(suite.T(), os.Chdir(TempDir)) -} - -// In order for 'go test' to run this suite, we need to create -// a normal test function and pass our suite to suite.Run -func TestLinkTestSuite(t *testing.T) { - // suite.Run(t, new(LinkTestSuite)) -} - -// helper functions -func (suite *LinkTestSuite) addID(id string) { - suite.mtx.Lock() - defer suite.mtx.Unlock() - suite.ids = append(suite.ids, id) -} - -func (suite *LinkTestSuite) addHeaders(headers http.Header) { - suite.mtx.Lock() - defer suite.mtx.Unlock() - suite.headers = append(suite.headers, headers) -} diff --git a/test/login_test.go b/test/login_test.go deleted file mode 100644 index 2f1e018fb..000000000 --- a/test/login_test.go +++ /dev/null @@ -1,110 +0,0 @@ -package integration - -// Basic imports -import ( - "context" - "net/http" - "os" - "sync" - "testing" - - "github.com/gin-gonic/gin" - gonanoid "github.com/matoous/go-nanoid/v2" - "github.com/spf13/cobra" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - clicmd "github.com/supabase/cli/cmd" - "github.com/supabase/cli/test/mocks/supabase" -) - -type LoginTestSuite struct { - suite.Suite - tempDir string - cmd *cobra.Command - - ids []string - headers []http.Header - - mtx sync.RWMutex -} - -// test functions -func (suite *LoginTestSuite) TestLink() { - // run command - login, _, err := suite.cmd.Find([]string{"login"}) - require.NoError(suite.T(), err) - login.SetContext(context.Background()) - key := "sbp_" + gonanoid.MustGenerate(supabase.KeyAlphabet, supabase.KeyLength) - - // change stdin to read from a file - content := []byte(key) - tmpfile, err := os.CreateTemp(suite.tempDir, "key") - require.NoError(suite.T(), err) - defer os.Remove(tmpfile.Name()) // clean up - - _, err = tmpfile.Write(content) - require.NoError(suite.T(), err) - _, err = tmpfile.Seek(0, 0) - require.NoError(suite.T(), err) - - oldStdin := os.Stdin - defer func() { os.Stdin = oldStdin }() - os.Stdin = tmpfile - - err = login.Flags().Set("token", key) - require.NoError(suite.T(), err) - require.NoError(suite.T(), login.RunE(login, []string{})) - - // check token is saved - // home, err := os.UserHomeDir() - // require.NoError(suite.T(), err) - // _, err = os.Stat(filepath.Join(home, ".supabase/access-token")) - // require.NoError(suite.T(), err) - // token, err := os.ReadFile(filepath.Join(home, ".supabase/access-token")) - // require.NoError(suite.T(), err) - // require.Equal(suite.T(), key, string(token)) -} - -// hooks -func (suite *LoginTestSuite) SetupTest() { - // init cli - suite.cmd = clicmd.GetRootCmd() - suite.tempDir = NewTempDir(Logger, TempDir) - - // init supabase - init, _, err := suite.cmd.Find([]string{"init"}) - require.NoError(suite.T(), err) - init.SetContext(context.Background()) - require.NoError(suite.T(), init.RunE(init, []string{})) - - // implement mocks - SupaMock.FunctionsHandler = func(c *gin.Context) { - suite.addHeaders(c.Request.Header) - suite.addID(c.Params.ByName("id")) - - c.JSON(http.StatusOK, gin.H{}) - } -} - -func (suite *LoginTestSuite) TeardownTest() { - require.NoError(suite.T(), os.Chdir(TempDir)) -} - -// In order for 'go test' to run this suite, we need to create -// a normal test function and pass our suite to suite.Run -func TestLoginTestSuite(t *testing.T) { - suite.Run(t, new(LoginTestSuite)) -} - -// helper functions -func (suite *LoginTestSuite) addID(id string) { - suite.mtx.Lock() - defer suite.mtx.Unlock() - suite.ids = append(suite.ids, id) -} - -func (suite *LoginTestSuite) addHeaders(headers http.Header) { - suite.mtx.Lock() - defer suite.mtx.Unlock() - suite.headers = append(suite.headers, headers) -} diff --git a/test/main_test.go b/test/main_test.go deleted file mode 100644 index 6d694e709..000000000 --- a/test/main_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package integration - -import ( - "log" - "os" - "testing" - - "github.com/docker/docker/client" - "github.com/spf13/viper" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/test/mocks/docker" - "github.com/supabase/cli/test/mocks/supabase" -) - -const ( - DockerPort = ":2375" - SupabasePort = ":2376" -) - -var ( - TempDir string -) - -var ( - Logger *log.Logger - DockerMock *docker.Server - SupaMock *supabase.Server -) - -func TestMain(m *testing.M) { - Logger := log.New(os.Stdout, "", 0) - - Logger.Println("Global tests setup") - - DockerMock = newDockerMock(Logger) - SupaMock = newSupabaseMock(Logger) - TempDir = NewTempDir(Logger, "") - - // redirect clients to mock servers - os.Setenv("DOCKER_HOST", "tcp://127.0.0.1"+DockerPort) - utils.Docker = utils.NewDocker() - if err := client.WithVersion(docker.APIVersion)(utils.Docker); err != nil { - Logger.Fatal(err) - } - viper.Set("INTERNAL_API_HOST", "http://127.0.0.1"+SupabasePort) - os.Setenv("SUPABASE_ACCESS_TOKEN", supabase.AccessToken) - os.Setenv("HOME", TempDir) - - // run tests - exitVal := m.Run() - - Logger.Println("Global teardown") - os.RemoveAll(TempDir) - - // exit process with tests exit code - os.Exit(exitVal) -} - -func newDockerMock(Logger *log.Logger) *docker.Server { - dockerMock := docker.NewServer() - dockerRouter := dockerMock.NewRouter() - go func() { - err := dockerRouter.Run(DockerPort) - if err != nil { - Logger.Fatal(err) - } - }() - - return dockerMock -} - -func newSupabaseMock(Logger *log.Logger) *supabase.Server { - supaMock := supabase.NewServer() - supaRouter := supaMock.NewRouter() - go func() { - err := supaRouter.Run(SupabasePort) - if err != nil { - Logger.Fatal(err) - } - }() - - return supaMock -} - -func NewTempDir(Logger *log.Logger, baseDir string) string { - wd := baseDir - var err error - if baseDir == "" { - wd, err = os.Getwd() - } - if err != nil { - Logger.Fatal(err) - } - tempDir, err := os.MkdirTemp(wd, "cli-test-") - if err != nil { - Logger.Fatal(err) - } - err = os.Chdir(tempDir) - if err != nil { - Logger.Fatal(err) - } - return tempDir -} diff --git a/test/migration_test.go b/test/migration_test.go deleted file mode 100644 index 2321735d0..000000000 --- a/test/migration_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package integration - -// Basic imports -import ( - "os" - "testing" - - gonanoid "github.com/matoous/go-nanoid/v2" - "github.com/spf13/cobra" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - clicmd "github.com/supabase/cli/cmd" - "github.com/supabase/cli/test/mocks/supabase" -) - -type MigrationTestSuite struct { - suite.Suite - tempDir string - cmd *cobra.Command -} - -// test functions -func (suite *MigrationTestSuite) TestNewMigration() { - // run command - migration, _, err := suite.cmd.Find([]string{"migration", "new"}) - require.NoError(suite.T(), err) - name := gonanoid.MustGenerate(supabase.IDAlphabet, 10) - require.NoError(suite.T(), migration.RunE(migration, []string{name})) - - // check migrations file created - subs, err := os.ReadDir("supabase/migrations") - require.NoError(suite.T(), err) - require.Regexp(suite.T(), `[0-9]{14}_`+name+".sql", subs[0].Name()) -} - -// hooks -func (suite *MigrationTestSuite) SetupTest() { - // init cli - suite.cmd = clicmd.GetRootCmd() - suite.tempDir = NewTempDir(Logger, TempDir) - - // init supabase - init, _, err := suite.cmd.Find([]string{"init"}) - require.NoError(suite.T(), err) - require.NoError(suite.T(), init.RunE(init, []string{})) -} - -func (suite *MigrationTestSuite) TeardownTest() { - require.NoError(suite.T(), os.Chdir(TempDir)) -} - -// In order for 'go test' to run this suite, we need to create -// a normal test function and pass our suite to suite.Run -func TestMigrationTestSuite(t *testing.T) { - suite.Run(t, new(MigrationTestSuite)) -} diff --git a/test/mocks/docker/httputils.go b/test/mocks/docker/httputils.go deleted file mode 100644 index c8a4496aa..000000000 --- a/test/mocks/docker/httputils.go +++ /dev/null @@ -1,67 +0,0 @@ -package docker - -import ( - "fmt" - "io" - "net/http" - - "github.com/docker/docker/pkg/ioutils" - "github.com/docker/docker/pkg/stdcopy" - "github.com/gin-gonic/gin" -) - -func CloseStreams(streams ...interface{}) { - for _, stream := range streams { - if tcpc, ok := stream.(interface { - CloseWrite() error - }); ok { - _ = tcpc.CloseWrite() - } else if closer, ok := stream.(io.Closer); ok { - _ = closer.Close() - } - } -} - -func HijackedResponse(c *gin.Context, exitCode string, output ...string) { - // hijack the connection - hijacker, ok := c.Writer.(http.Hijacker) - if !ok { - c.JSON(http.StatusBadRequest, gin.H{ - "message": "error hijacking connection", - }) - return - } - conn, _, err := hijacker.Hijack() - if err != nil { - c.JSON(http.StatusBadRequest, gin.H{ - "message": "error hijacking connection", - }) - return - } - _, err = conn.Write([]byte{}) - if err != nil { - c.JSON(http.StatusBadRequest, gin.H{ - "message": "error hijacking connection", - }) - return - } - - // write success code signalizing that the connection is established and ready to stream data - fmt.Fprintf(conn, "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.docker.raw-stream\r\n\r\n") - - // setup closer - closer := func() error { - CloseStreams(conn) - return nil - } - - // write some output if command suppose to write to stdout - outStream := stdcopy.NewStdWriter(conn, stdcopy.Stdout) - if len(output) > 0 { - fmt.Fprint(outStream, output) - } - // finish with exit code and close stream and connection as the command is done - fmt.Fprintf(outStream, "exit code %s", exitCode) - rc := ioutils.NewReadCloserWrapper(conn, closer) - rc.Close() -} diff --git a/test/mocks/docker/server.go b/test/mocks/docker/server.go deleted file mode 100644 index 705c7b4e1..000000000 --- a/test/mocks/docker/server.go +++ /dev/null @@ -1,99 +0,0 @@ -package docker - -import ( - "net/http" - - "github.com/gin-gonic/gin" -) - -const ( - APIVersion = "1.44" - IDAlphabet = "abcdef0123456789" - IDLength = 12 -) - -// Server struct with route handlers -type Server struct { - PingHandler func(c *gin.Context) - ContainerInspectHandler func(c *gin.Context) - ExecCreateHandler func(c *gin.Context) - ExecStartHandler func(c *gin.Context) -} - -var defaultHandler = func(c *gin.Context) { - c.JSON(http.StatusNotImplemented, gin.H{ - "message": "Not implemented", - }) -} - -// NewServer creates a new server with default handlers -func NewServer() *Server { - s := Server{ - ExecCreateHandler: defaultHandler, - ExecStartHandler: defaultHandler, - ContainerInspectHandler: defaultHandler, - } - return &s -} - -// NewRouter creating a new router and setting the routes for the server. -func (s *Server) NewRouter() *gin.Engine { - root := gin.Default() - root.HEAD("/_ping", s.ping) - root.GET("/_ping", s.ping) - - router := root.Group("/v" + APIVersion) - - containers := router.Group("/containers") - containers.GET("/:id/json", s.inspectContainer) - containers.POST("/:id/exec", s.createExec) - - exec := router.Group("/exec") - exec.POST("/:id/start", s.startExec) - exec.GET("/:id/json", s.inspectContainer) - - return root -} - -// ping -func (s *Server) ping(c *gin.Context) { - if s.PingHandler == nil { - c.Header("API-Version", APIVersion) - c.Header("OSType", "linux") - c.Status(http.StatusOK) - } else { - s.PingHandler(c) - } -} - -// container -func (s *Server) inspectContainer(c *gin.Context) { - if s.ContainerInspectHandler == nil { - c.JSON(http.StatusInternalServerError, gin.H{ - "message": "handler is nil", - }) - } else { - s.ContainerInspectHandler(c) - } -} - -// exec -func (s *Server) createExec(c *gin.Context) { - if s.ExecCreateHandler == nil { - c.JSON(http.StatusInternalServerError, gin.H{ - "message": "handler is nil", - }) - } else { - s.ExecCreateHandler(c) - } -} - -func (s *Server) startExec(c *gin.Context) { - if s.ExecStartHandler == nil { - c.JSON(http.StatusInternalServerError, gin.H{ - "message": "handler is nil", - }) - } else { - s.ExecStartHandler(c) - } -} diff --git a/test/mocks/supabase/server.go b/test/mocks/supabase/server.go deleted file mode 100644 index 41eb8c542..000000000 --- a/test/mocks/supabase/server.go +++ /dev/null @@ -1,74 +0,0 @@ -package supabase - -import ( - "net/http" - - "github.com/gin-gonic/gin" - gonanoid "github.com/matoous/go-nanoid/v2" -) - -const ( - IDAlphabet = "abcdefghijklmnopqrstuvwxyz" - IDLength = 20 - KeyAlphabet = "abcdef0123456789" - KeyLength = 40 -) - -var AccessToken = "sbp_" + gonanoid.MustGenerate(KeyAlphabet, KeyLength) - -// Server struct with route handlers -type Server struct { - FunctionsHandler func(c *gin.Context) - SecretsHandler func(c *gin.Context) -} - -var defaultHandler = func(c *gin.Context) { - c.JSON(http.StatusNotImplemented, gin.H{ - "message": "Not implemented", - }) -} - -// NewServer creates a new server with default handlers -func NewServer() *Server { - s := Server{ - FunctionsHandler: defaultHandler, - SecretsHandler: defaultHandler, - } - return &s -} - -// NewRouter creating a new router and setting the routes for the server. -func (s *Server) NewRouter() *gin.Engine { - root := gin.Default() - router := root.Group("/v1") - - projects := router.Group("/projects") - projects.GET("/:id/functions", s.functions) - projects.GET("/:id/secrets", s.secrets) - projects.GET("/:id/api-keys", func(c *gin.Context) { - c.JSON(http.StatusOK, []gin.H{}) - }) - - return root -} - -// project routes -func (s *Server) functions(c *gin.Context) { - if s.FunctionsHandler == nil { - c.JSON(http.StatusInternalServerError, gin.H{ - "message": "handler is nil", - }) - } else { - s.FunctionsHandler(c) - } -} - -func (s *Server) secrets(c *gin.Context) { - if s.SecretsHandler == nil { - c.JSON(http.StatusInternalServerError, gin.H{ - "message": "handler is nil", - }) - } else { - s.SecretsHandler(c) - } -} diff --git a/test/secrets_test.go b/test/secrets_test.go deleted file mode 100644 index b195e23ea..000000000 --- a/test/secrets_test.go +++ /dev/null @@ -1,121 +0,0 @@ -package integration - -// Basic imports -import ( - "context" - "fmt" - "net/http" - "os" - "sync" - "testing" - - "github.com/gin-gonic/gin" - gonanoid "github.com/matoous/go-nanoid/v2" - "github.com/spf13/cobra" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - clicmd "github.com/supabase/cli/cmd" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/test/mocks/supabase" -) - -type SecretsTestSuite struct { - suite.Suite - tempDir string - cmd *cobra.Command - - ids []string - headers []http.Header - - mtx sync.RWMutex -} - -// test functions -func (suite *SecretsTestSuite) TestList() { - // run command - list, _, err := suite.cmd.Find([]string{"secrets", "list"}) - list.SetContext(context.Background()) - require.NoError(suite.T(), err) - - // set stdout to write into file so we can capture cmd output - tmpfile, err := os.CreateTemp(suite.tempDir, "output") - require.NoError(suite.T(), err) - defer os.Remove(tmpfile.Name()) // clean up - oldStdout := os.Stdout - defer func() { os.Stdout = oldStdout }() - os.Stdout = tmpfile - - flags.ProjectRef = gonanoid.MustGenerate(supabase.IDAlphabet, supabase.IDLength) - require.NoError(suite.T(), list.RunE(list, []string{})) - - // check request details - suite.mtx.RLock() - defer suite.mtx.RUnlock() - require.Contains(suite.T(), suite.ids, flags.ProjectRef) - require.Contains(suite.T(), suite.headers, http.Header{ - "Authorization": []string{fmt.Sprintf("Bearer %s", supabase.AccessToken)}, - "Accept-Encoding": []string{"gzip"}, - "User-Agent": []string{"SupabaseCLI/"}, - }) - - contents, err := os.ReadFile(tmpfile.Name()) - require.NoError(suite.T(), err) - require.Contains(suite.T(), string(contents), "some-key") - require.Contains(suite.T(), string(contents), "another") -} - -// hooks -func (suite *SecretsTestSuite) SetupTest() { - // init cli - suite.cmd = clicmd.GetRootCmd() - suite.tempDir = NewTempDir(Logger, TempDir) - - // init supabase - init, _, err := suite.cmd.Find([]string{"init"}) - require.NoError(suite.T(), err) - init.SetContext(context.Background()) - require.NoError(suite.T(), init.RunE(init, []string{})) - - // add `link` dir - require.NoError(suite.T(), os.MkdirAll("supabase/.temp", os.FileMode(0755))) - - // implement mocks - SupaMock.SecretsHandler = func(c *gin.Context) { - suite.addHeaders(c.Request.Header) - suite.addID(c.Params.ByName("id")) - - c.JSON(http.StatusOK, []gin.H{ - { - "Name": "some-key", - "Value": gonanoid.Must(), - }, - { - "Name": "another", - "Value": gonanoid.Must(), - }, - }) - } -} - -func (suite *SecretsTestSuite) TeardownTest() { - require.NoError(suite.T(), os.Chdir(TempDir)) -} - -// In order for 'go test' to run this suite, we need to create -// a normal test function and pass our suite to suite.Run -func TestSecretsTestSuite(t *testing.T) { - suite.Run(t, new(SecretsTestSuite)) -} - -// helper functions -func (suite *SecretsTestSuite) addID(id string) { - suite.mtx.Lock() - defer suite.mtx.Unlock() - suite.ids = append(suite.ids, id) -} - -func (suite *SecretsTestSuite) addHeaders(headers http.Header) { - suite.mtx.Lock() - defer suite.mtx.Unlock() - suite.headers = append(suite.headers, headers) -} diff --git a/test/status_test.go b/test/status_test.go deleted file mode 100644 index 509345d18..000000000 --- a/test/status_test.go +++ /dev/null @@ -1,108 +0,0 @@ -package integration - -// Basic imports -import ( - "context" - "net/http" - "os" - "path/filepath" - "sync" - "testing" - - "github.com/docker/docker/api/types" - "github.com/gin-gonic/gin" - "github.com/spf13/cobra" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - clicmd "github.com/supabase/cli/cmd" -) - -type StatusTestSuite struct { - suite.Suite - tempDir string - cmd *cobra.Command - - params []gin.Params - mtx sync.RWMutex -} - -// test functions -func (suite *StatusTestSuite) TestStatus() { - suite.T().Skip("Status command is no longer mocked") - // run command - status, _, err := suite.cmd.Find([]string{"status"}) - status.SetContext(context.Background()) - require.NoError(suite.T(), err) - - // set stdout to write into file so we can capture cmd output - tmpfile, err := os.CreateTemp(suite.tempDir, "output") - require.NoError(suite.T(), err) - defer os.Remove(tmpfile.Name()) // clean up - oldStdout := os.Stdout - defer func() { os.Stdout = oldStdout }() - os.Stdout = tmpfile - - // run command - require.NoError(suite.T(), status.RunE(status, []string{})) - - // check request details - suite.mtx.RLock() - defer suite.mtx.RUnlock() - require.Contains(suite.T(), suite.params, gin.Params{ - gin.Param{ - Key: "id", - Value: "supabase_db_" + filepath.Base(suite.tempDir), - }, - }) - - contents, err := os.ReadFile(tmpfile.Name()) - require.NoError(suite.T(), err) - require.Contains(suite.T(), string(contents), "API URL: http://127.0.0.1:54321") - require.Contains(suite.T(), string(contents), "GraphQL URL: http://127.0.0.1:54321/graphql/v1") - require.Contains(suite.T(), string(contents), "DB URL: postgresql://postgres:postgres@127.0.0.1:54322/postgres") - require.Contains(suite.T(), string(contents), "Studio URL: http://127.0.0.1:54323") - require.Contains(suite.T(), string(contents), "Inbucket URL: http://127.0.0.1:54324") - require.Contains(suite.T(), string(contents), "JWT secret: super-secret-jwt-token-with-at-least-32-characters-long") - require.Contains(suite.T(), string(contents), "anon key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9") - require.Contains(suite.T(), string(contents), "service_role key: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9") -} - -// hooks -func (suite *StatusTestSuite) SetupTest() { - // init cli - suite.cmd = clicmd.GetRootCmd() - suite.tempDir = NewTempDir(Logger, TempDir) - - // init supabase - init, _, err := suite.cmd.Find([]string{"init"}) - require.NoError(suite.T(), err) - init.SetContext(context.Background()) - require.NoError(suite.T(), init.RunE(init, []string{})) - - // implement mocks - DockerMock.ContainerInspectHandler = func(c *gin.Context) { - suite.addParams(c.Copy()) - c.JSON(http.StatusOK, types.ContainerJSON{ - ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{Running: true}, - }, - }) - } -} - -func (suite *StatusTestSuite) TeardownTest() { - require.NoError(suite.T(), os.Chdir(TempDir)) -} - -// In order for 'go test' to run this suite, we need to create -// a normal test function and pass our suite to suite.Run -func TestStatusTestSuite(t *testing.T) { - suite.Run(t, new(StatusTestSuite)) -} - -// helper functions -func (suite *StatusTestSuite) addParams(c *gin.Context) { - suite.mtx.Lock() - defer suite.mtx.Unlock() - suite.params = append(suite.params, c.Params) -} From e4c39e6ab3401bce21b9b6fd53ceedc29f5c993a Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sat, 7 Dec 2024 22:07:04 +0800 Subject: [PATCH 212/305] chore: bump cli module to v2 --- cmd/bans.go | 6 +-- cmd/bootstrap.go | 4 +- cmd/branches.go | 20 ++++---- cmd/config.go | 4 +- cmd/db.go | 32 ++++++------- cmd/domains.go | 12 ++--- cmd/encryption.go | 6 +-- cmd/functions.go | 18 ++++---- cmd/gen.go | 8 ++-- cmd/init.go | 4 +- cmd/inspect.go | 46 +++++++++---------- cmd/link.go | 6 +-- cmd/login.go | 4 +- cmd/logout.go | 2 +- cmd/migration.go | 16 +++---- cmd/orgs.go | 4 +- cmd/postgres.go | 6 +-- cmd/projects.go | 14 +++--- cmd/restrictions.go | 6 +-- cmd/root.go | 4 +- cmd/secrets.go | 8 ++-- cmd/seed.go | 6 +-- cmd/services.go | 2 +- cmd/snippets.go | 6 +-- cmd/sslEnforcement.go | 6 +-- cmd/sso.go | 16 +++---- cmd/start.go | 4 +- cmd/status.go | 4 +- cmd/stop.go | 2 +- cmd/storage.go | 12 ++--- cmd/test.go | 4 +- cmd/unlink.go | 2 +- cmd/vanitySubdomains.go | 10 ++-- docs/main.go | 4 +- examples/functions-deploy/main.go | 6 +-- examples/migrations-up/main.go | 4 +- examples/seed-buckets/main.go | 6 +-- go.mod | 21 +-------- go.sum | 42 ----------------- internal/bans/get/get.go | 2 +- internal/bans/update/update.go | 4 +- internal/bootstrap/bootstrap.go | 24 +++++----- internal/bootstrap/bootstrap_test.go | 4 +- internal/branches/create/create.go | 8 ++-- internal/branches/create/create_test.go | 10 ++-- internal/branches/delete/delete.go | 2 +- internal/branches/disable/disable.go | 4 +- internal/branches/get/get.go | 4 +- internal/branches/list/list.go | 6 +-- internal/branches/update/update.go | 4 +- internal/config/push/push.go | 4 +- internal/db/branch/create/create.go | 2 +- internal/db/branch/create/create_test.go | 4 +- internal/db/branch/delete/delete.go | 2 +- internal/db/branch/delete/delete_test.go | 4 +- internal/db/branch/list/list.go | 2 +- internal/db/branch/list/list_test.go | 2 +- internal/db/branch/switch_/switch_.go | 4 +- internal/db/branch/switch_/switch__test.go | 8 ++-- internal/db/diff/diff.go | 10 ++-- internal/db/diff/diff_test.go | 16 +++---- internal/db/diff/migra.go | 4 +- internal/db/diff/pgadmin.go | 8 ++-- internal/db/dump/dump.go | 4 +- internal/db/dump/dump_test.go | 4 +- internal/db/lint/lint.go | 4 +- internal/db/lint/lint_test.go | 6 +-- internal/db/pull/pull.go | 14 +++--- internal/db/pull/pull_test.go | 10 ++-- internal/db/push/push.go | 8 ++-- internal/db/push/push_test.go | 10 ++-- internal/db/remote/changes/changes.go | 6 +-- internal/db/remote/commit/commit.go | 12 ++--- internal/db/reset/reset.go | 18 ++++---- internal/db/reset/reset_test.go | 16 +++---- internal/db/start/start.go | 8 ++-- internal/db/start/start_test.go | 10 ++-- internal/db/test/test.go | 4 +- internal/db/test/test_test.go | 8 ++-- internal/debug/postgres_test.go | 2 +- internal/encryption/get/get.go | 2 +- internal/encryption/get/get_test.go | 6 +-- internal/encryption/update/update.go | 6 +-- internal/encryption/update/update_test.go | 6 +-- internal/functions/delete/delete.go | 2 +- internal/functions/delete/delete_test.go | 4 +- internal/functions/deploy/bundle.go | 4 +- internal/functions/deploy/bundle_test.go | 4 +- internal/functions/deploy/deploy.go | 10 ++-- internal/functions/deploy/deploy_test.go | 10 ++-- internal/functions/download/download.go | 4 +- internal/functions/download/download_test.go | 6 +-- internal/functions/list/list.go | 4 +- internal/functions/list/list_test.go | 6 +-- internal/functions/new/new.go | 2 +- internal/functions/new/new_test.go | 2 +- internal/functions/serve/serve.go | 6 +-- internal/functions/serve/serve_test.go | 6 +-- internal/gen/keys/keys.go | 4 +- internal/gen/types/types.go | 4 +- internal/gen/types/types_test.go | 8 ++-- internal/hostnames/activate/activate.go | 4 +- internal/hostnames/common.go | 4 +- internal/hostnames/create/create.go | 6 +-- internal/hostnames/delete/delete.go | 2 +- internal/hostnames/get/get.go | 2 +- internal/hostnames/reverify/reverify.go | 4 +- internal/init/init.go | 2 +- internal/init/init_test.go | 6 +-- internal/inspect/bloat/bloat.go | 8 ++-- internal/inspect/bloat/bloat_test.go | 6 +-- internal/inspect/blocking/blocking.go | 6 +-- internal/inspect/blocking/blocking_test.go | 2 +- internal/inspect/cache/cache.go | 6 +-- internal/inspect/cache/cache_test.go | 2 +- internal/inspect/calls/calls.go | 6 +-- internal/inspect/calls/calls_test.go | 2 +- internal/inspect/index_sizes/index_sizes.go | 8 ++-- .../inspect/index_sizes/index_sizes_test.go | 6 +-- internal/inspect/index_usage/index_usage.go | 8 ++-- .../inspect/index_usage/index_usage_test.go | 6 +-- internal/inspect/locks/locks.go | 6 +-- internal/inspect/locks/locks_test.go | 2 +- .../long_running_queries.go | 6 +-- .../long_running_queries_test.go | 2 +- internal/inspect/outliers/outliers.go | 6 +-- internal/inspect/outliers/outliers_test.go | 2 +- .../replication_slots/replication_slots.go | 6 +-- .../replication_slots_test.go | 2 +- internal/inspect/report.go | 4 +- internal/inspect/report_test.go | 42 ++++++++--------- internal/inspect/role_configs/role_configs.go | 6 +-- .../inspect/role_configs/role_configs_test.go | 2 +- .../role_connections/role_connections.go | 6 +-- .../role_connections/role_connections_test.go | 2 +- internal/inspect/seq_scans/seq_scans.go | 8 ++-- internal/inspect/seq_scans/seq_scans_test.go | 6 +-- .../table_index_sizes/table_index_sizes.go | 8 ++-- .../table_index_sizes_test.go | 6 +-- .../table_record_counts.go | 8 ++-- .../table_record_counts_test.go | 6 +-- internal/inspect/table_sizes/table_sizes.go | 8 ++-- .../inspect/table_sizes/table_sizes_test.go | 6 +-- .../total_index_size/total_index_size.go | 8 ++-- .../total_index_size/total_index_size_test.go | 6 +-- .../total_table_sizes/total_table_sizes.go | 8 ++-- .../total_table_sizes_test.go | 6 +-- .../inspect/unused_indexes/unused_indexes.go | 8 ++-- .../unused_indexes/unused_indexes_test.go | 6 +-- internal/inspect/vacuum_stats/vacuum_stats.go | 8 ++-- .../inspect/vacuum_stats/vacuum_stats_test.go | 6 +-- internal/link/link.go | 18 ++++---- internal/link/link_test.go | 16 +++---- internal/login/login.go | 6 +-- internal/login/login_test.go | 6 +-- internal/logout/logout.go | 4 +- internal/logout/logout_test.go | 8 ++-- internal/migration/apply/apply.go | 6 +-- internal/migration/apply/apply_test.go | 10 ++-- internal/migration/fetch/fetch.go | 4 +- internal/migration/list/list.go | 4 +- internal/migration/list/list_test.go | 8 ++-- internal/migration/new/new.go | 2 +- internal/migration/new/new_test.go | 2 +- internal/migration/repair/repair.go | 6 +-- internal/migration/repair/repair_test.go | 10 ++-- internal/migration/squash/squash.go | 14 +++--- internal/migration/squash/squash_test.go | 16 +++---- internal/migration/up/up.go | 4 +- internal/migration/up/up_test.go | 8 ++-- internal/orgs/create/create.go | 4 +- internal/orgs/create/create_test.go | 6 +-- internal/orgs/list/list.go | 4 +- internal/orgs/list/list_test.go | 6 +-- internal/postgresConfig/get/get.go | 4 +- internal/postgresConfig/update/update.go | 4 +- internal/projects/apiKeys/api_keys.go | 6 +-- internal/projects/apiKeys/api_keys_test.go | 6 +-- internal/projects/create/create.go | 8 ++-- internal/projects/create/create_test.go | 6 +-- internal/projects/delete/delete.go | 6 +-- internal/projects/delete/delete_test.go | 6 +-- internal/projects/list/list.go | 8 ++-- internal/projects/list/list_test.go | 6 +-- internal/restrictions/get/get.go | 2 +- internal/restrictions/update/update.go | 4 +- internal/restrictions/update/update_test.go | 6 +-- internal/secrets/list/list.go | 6 +-- internal/secrets/list/list_test.go | 6 +-- internal/secrets/set/set.go | 4 +- internal/secrets/set/set_test.go | 6 +-- internal/secrets/unset/unset.go | 4 +- internal/secrets/unset/unset_test.go | 6 +-- internal/seed/buckets/buckets.go | 4 +- internal/seed/buckets/buckets_test.go | 6 +-- internal/services/services.go | 8 ++-- internal/snippets/download/download.go | 2 +- internal/snippets/list/list.go | 8 ++-- internal/ssl_enforcement/get/get.go | 2 +- internal/ssl_enforcement/update/update.go | 4 +- internal/sso/create/create.go | 8 ++-- internal/sso/get/get.go | 6 +-- internal/sso/get/get_test.go | 4 +- internal/sso/info/info.go | 4 +- internal/sso/internal/render/render.go | 6 +-- internal/sso/internal/saml/files.go | 4 +- internal/sso/list/list.go | 4 +- internal/sso/list/list_test.go | 4 +- internal/sso/remove/remove.go | 6 +-- internal/sso/remove/remove_test.go | 4 +- internal/sso/update/update.go | 8 ++-- internal/sso/update/update_test.go | 6 +-- internal/start/start.go | 16 +++---- internal/start/start_test.go | 10 ++-- internal/status/status.go | 4 +- internal/status/status_test.go | 4 +- internal/stop/stop.go | 2 +- internal/stop/stop_test.go | 4 +- internal/storage/client/api.go | 10 ++-- internal/storage/cp/cp.go | 12 ++--- internal/storage/cp/cp_test.go | 14 +++--- internal/storage/ls/ls.go | 6 +-- internal/storage/ls/ls_test.go | 16 +++---- internal/storage/mv/mv.go | 8 ++-- internal/storage/mv/mv_test.go | 14 +++--- internal/storage/rm/rm.go | 12 ++--- internal/storage/rm/rm_test.go | 16 +++---- internal/test/new/new.go | 2 +- internal/test/new/new_test.go | 2 +- internal/testing/helper/history.go | 4 +- internal/unlink/unlink.go | 4 +- internal/unlink/unlink_test.go | 6 +-- internal/utils/access_token.go | 2 +- internal/utils/access_token_test.go | 6 +-- internal/utils/api.go | 6 +-- internal/utils/api_test.go | 4 +- internal/utils/cloudflare/api.go | 2 +- internal/utils/cloudflare/dns.go | 2 +- internal/utils/config.go | 2 +- internal/utils/connect.go | 4 +- internal/utils/connect_test.go | 6 +-- internal/utils/console.go | 2 +- internal/utils/console_test.go | 2 +- internal/utils/docker_test.go | 2 +- internal/utils/flags/db_url.go | 6 +-- internal/utils/flags/project_ref.go | 2 +- internal/utils/flags/project_ref_test.go | 8 ++-- internal/utils/release_test.go | 4 +- internal/utils/tenant/client.go | 6 +-- internal/utils/tenant/database.go | 2 +- internal/utils/tenant/gotrue.go | 2 +- internal/utils/tenant/gotrue_test.go | 2 +- internal/utils/tenant/postgrest.go | 2 +- .../vanity_subdomains/activate/activate.go | 4 +- internal/vanity_subdomains/check/check.go | 4 +- internal/vanity_subdomains/delete/delete.go | 2 +- internal/vanity_subdomains/get/get.go | 2 +- main.go | 2 +- pkg/config/api.go | 6 +-- pkg/config/api_test.go | 2 +- pkg/config/auth.go | 6 +-- pkg/config/auth_test.go | 4 +- pkg/config/config.go | 4 +- pkg/config/db.go | 6 +-- pkg/config/db_test.go | 4 +- pkg/config/storage.go | 6 +-- pkg/config/updater.go | 2 +- pkg/config/updater_test.go | 4 +- pkg/function/api.go | 2 +- pkg/function/batch.go | 4 +- pkg/function/batch_test.go | 4 +- pkg/migration/apply_test.go | 2 +- pkg/migration/drop.go | 2 +- pkg/migration/drop_test.go | 2 +- pkg/migration/file.go | 2 +- pkg/migration/file_test.go | 4 +- pkg/migration/history.go | 2 +- pkg/migration/list.go | 2 +- pkg/migration/list_test.go | 2 +- pkg/migration/seed_test.go | 2 +- pkg/parser/token.go | 2 +- pkg/pgtest/mock.go | 2 +- pkg/storage/api.go | 2 +- pkg/storage/batch.go | 4 +- pkg/storage/buckets.go | 2 +- pkg/storage/objects.go | 2 +- tools/bumpdoc/main.go | 4 +- tools/changelog/main.go | 2 +- tools/listdep/main.go | 2 +- tools/publish/main.go | 6 +-- tools/selfhost/main.go | 6 +-- 291 files changed, 878 insertions(+), 939 deletions(-) diff --git a/cmd/bans.go b/cmd/bans.go index 603e2dd4d..6f930c042 100644 --- a/cmd/bans.go +++ b/cmd/bans.go @@ -3,9 +3,9 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/bans/get" - "github.com/supabase/cli/internal/bans/update" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/bans/get" + "github.com/supabase/cli/v2/internal/bans/update" + "github.com/supabase/cli/v2/internal/utils/flags" ) var ( diff --git a/cmd/bootstrap.go b/cmd/bootstrap.go index fd9f74912..21d24fb1f 100644 --- a/cmd/bootstrap.go +++ b/cmd/bootstrap.go @@ -11,8 +11,8 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/supabase/cli/internal/bootstrap" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/bootstrap" + "github.com/supabase/cli/v2/internal/utils" ) var ( diff --git a/cmd/branches.go b/cmd/branches.go index 0248e7f31..dd0897d9f 100644 --- a/cmd/branches.go +++ b/cmd/branches.go @@ -8,16 +8,16 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/branches/create" - "github.com/supabase/cli/internal/branches/delete" - "github.com/supabase/cli/internal/branches/disable" - "github.com/supabase/cli/internal/branches/get" - "github.com/supabase/cli/internal/branches/list" - "github.com/supabase/cli/internal/branches/update" - "github.com/supabase/cli/internal/gen/keys" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/branches/create" + "github.com/supabase/cli/v2/internal/branches/delete" + "github.com/supabase/cli/v2/internal/branches/disable" + "github.com/supabase/cli/v2/internal/branches/get" + "github.com/supabase/cli/v2/internal/branches/list" + "github.com/supabase/cli/v2/internal/branches/update" + "github.com/supabase/cli/v2/internal/gen/keys" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/api" ) var ( diff --git a/cmd/config.go b/cmd/config.go index 1d0f60733..0b0657506 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -3,8 +3,8 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/config/push" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/config/push" + "github.com/supabase/cli/v2/internal/utils/flags" ) var ( diff --git a/cmd/db.go b/cmd/db.go index 2d64edd74..6737f543e 100644 --- a/cmd/db.go +++ b/cmd/db.go @@ -8,22 +8,22 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/supabase/cli/internal/db/branch/create" - "github.com/supabase/cli/internal/db/branch/delete" - "github.com/supabase/cli/internal/db/branch/list" - "github.com/supabase/cli/internal/db/branch/switch_" - "github.com/supabase/cli/internal/db/diff" - "github.com/supabase/cli/internal/db/dump" - "github.com/supabase/cli/internal/db/lint" - "github.com/supabase/cli/internal/db/pull" - "github.com/supabase/cli/internal/db/push" - "github.com/supabase/cli/internal/db/remote/changes" - "github.com/supabase/cli/internal/db/remote/commit" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/db/start" - "github.com/supabase/cli/internal/db/test" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/db/branch/create" + "github.com/supabase/cli/v2/internal/db/branch/delete" + "github.com/supabase/cli/v2/internal/db/branch/list" + "github.com/supabase/cli/v2/internal/db/branch/switch_" + "github.com/supabase/cli/v2/internal/db/diff" + "github.com/supabase/cli/v2/internal/db/dump" + "github.com/supabase/cli/v2/internal/db/lint" + "github.com/supabase/cli/v2/internal/db/pull" + "github.com/supabase/cli/v2/internal/db/push" + "github.com/supabase/cli/v2/internal/db/remote/changes" + "github.com/supabase/cli/v2/internal/db/remote/commit" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/db/start" + "github.com/supabase/cli/v2/internal/db/test" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" ) var ( diff --git a/cmd/domains.go b/cmd/domains.go index 9ec4a097d..cbc9ecb6e 100644 --- a/cmd/domains.go +++ b/cmd/domains.go @@ -3,12 +3,12 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/hostnames/activate" - "github.com/supabase/cli/internal/hostnames/create" - "github.com/supabase/cli/internal/hostnames/delete" - "github.com/supabase/cli/internal/hostnames/get" - "github.com/supabase/cli/internal/hostnames/reverify" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/hostnames/activate" + "github.com/supabase/cli/v2/internal/hostnames/create" + "github.com/supabase/cli/v2/internal/hostnames/delete" + "github.com/supabase/cli/v2/internal/hostnames/get" + "github.com/supabase/cli/v2/internal/hostnames/reverify" + "github.com/supabase/cli/v2/internal/utils/flags" ) var ( diff --git a/cmd/encryption.go b/cmd/encryption.go index d3b654afc..5e93d432a 100644 --- a/cmd/encryption.go +++ b/cmd/encryption.go @@ -4,9 +4,9 @@ import ( "os" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/encryption/get" - "github.com/supabase/cli/internal/encryption/update" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/encryption/get" + "github.com/supabase/cli/v2/internal/encryption/update" + "github.com/supabase/cli/v2/internal/utils/flags" ) var ( diff --git a/cmd/functions.go b/cmd/functions.go index 36dc47f94..b765a41ed 100644 --- a/cmd/functions.go +++ b/cmd/functions.go @@ -5,15 +5,15 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/functions/delete" - "github.com/supabase/cli/internal/functions/deploy" - "github.com/supabase/cli/internal/functions/download" - "github.com/supabase/cli/internal/functions/list" - new_ "github.com/supabase/cli/internal/functions/new" - "github.com/supabase/cli/internal/functions/serve" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/v2/internal/functions/delete" + "github.com/supabase/cli/v2/internal/functions/deploy" + "github.com/supabase/cli/v2/internal/functions/download" + "github.com/supabase/cli/v2/internal/functions/list" + new_ "github.com/supabase/cli/v2/internal/functions/new" + "github.com/supabase/cli/v2/internal/functions/serve" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/cast" ) var ( diff --git a/cmd/gen.go b/cmd/gen.go index 1789e29ca..9c6e66129 100644 --- a/cmd/gen.go +++ b/cmd/gen.go @@ -8,10 +8,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/gen/keys" - "github.com/supabase/cli/internal/gen/types" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/gen/keys" + "github.com/supabase/cli/v2/internal/gen/types" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" ) var ( diff --git a/cmd/init.go b/cmd/init.go index a9d2d90a8..ed9684c23 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -8,8 +8,8 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - _init "github.com/supabase/cli/internal/init" - "github.com/supabase/cli/internal/utils" + _init "github.com/supabase/cli/v2/internal/init" + "github.com/supabase/cli/v2/internal/utils" ) var ( diff --git a/cmd/inspect.go b/cmd/inspect.go index 2b55c3876..29b69795a 100644 --- a/cmd/inspect.go +++ b/cmd/inspect.go @@ -8,30 +8,30 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/inspect/bloat" - "github.com/supabase/cli/internal/inspect/blocking" - "github.com/supabase/cli/internal/inspect/cache" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/inspect/bloat" + "github.com/supabase/cli/v2/internal/inspect/blocking" + "github.com/supabase/cli/v2/internal/inspect/cache" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/internal/inspect" - "github.com/supabase/cli/internal/inspect/calls" - "github.com/supabase/cli/internal/inspect/index_sizes" - "github.com/supabase/cli/internal/inspect/index_usage" - "github.com/supabase/cli/internal/inspect/locks" - "github.com/supabase/cli/internal/inspect/long_running_queries" - "github.com/supabase/cli/internal/inspect/outliers" - "github.com/supabase/cli/internal/inspect/replication_slots" - "github.com/supabase/cli/internal/inspect/role_configs" - "github.com/supabase/cli/internal/inspect/role_connections" - "github.com/supabase/cli/internal/inspect/seq_scans" - "github.com/supabase/cli/internal/inspect/table_index_sizes" - "github.com/supabase/cli/internal/inspect/table_record_counts" - "github.com/supabase/cli/internal/inspect/table_sizes" - "github.com/supabase/cli/internal/inspect/total_index_size" - "github.com/supabase/cli/internal/inspect/total_table_sizes" - "github.com/supabase/cli/internal/inspect/unused_indexes" - "github.com/supabase/cli/internal/inspect/vacuum_stats" + "github.com/supabase/cli/v2/internal/inspect" + "github.com/supabase/cli/v2/internal/inspect/calls" + "github.com/supabase/cli/v2/internal/inspect/index_sizes" + "github.com/supabase/cli/v2/internal/inspect/index_usage" + "github.com/supabase/cli/v2/internal/inspect/locks" + "github.com/supabase/cli/v2/internal/inspect/long_running_queries" + "github.com/supabase/cli/v2/internal/inspect/outliers" + "github.com/supabase/cli/v2/internal/inspect/replication_slots" + "github.com/supabase/cli/v2/internal/inspect/role_configs" + "github.com/supabase/cli/v2/internal/inspect/role_connections" + "github.com/supabase/cli/v2/internal/inspect/seq_scans" + "github.com/supabase/cli/v2/internal/inspect/table_index_sizes" + "github.com/supabase/cli/v2/internal/inspect/table_record_counts" + "github.com/supabase/cli/v2/internal/inspect/table_sizes" + "github.com/supabase/cli/v2/internal/inspect/total_index_size" + "github.com/supabase/cli/v2/internal/inspect/total_table_sizes" + "github.com/supabase/cli/v2/internal/inspect/unused_indexes" + "github.com/supabase/cli/v2/internal/inspect/vacuum_stats" ) var ( diff --git a/cmd/link.go b/cmd/link.go index b1aec1d7a..ee947c060 100644 --- a/cmd/link.go +++ b/cmd/link.go @@ -7,9 +7,9 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/supabase/cli/internal/link" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/link" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" "golang.org/x/term" ) diff --git a/cmd/login.go b/cmd/login.go index ca9aea666..e186d0d04 100644 --- a/cmd/login.go +++ b/cmd/login.go @@ -6,8 +6,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/login" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/login" + "github.com/supabase/cli/v2/internal/utils" "golang.org/x/term" ) diff --git a/cmd/logout.go b/cmd/logout.go index dda3dd4cc..52559d204 100644 --- a/cmd/logout.go +++ b/cmd/logout.go @@ -5,7 +5,7 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/logout" + "github.com/supabase/cli/v2/internal/logout" ) var ( diff --git a/cmd/migration.go b/cmd/migration.go index 30b7716ac..1224c6659 100644 --- a/cmd/migration.go +++ b/cmd/migration.go @@ -8,14 +8,14 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/supabase/cli/internal/migration/fetch" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/migration/new" - "github.com/supabase/cli/internal/migration/repair" - "github.com/supabase/cli/internal/migration/squash" - "github.com/supabase/cli/internal/migration/up" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/migration/fetch" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/migration/new" + "github.com/supabase/cli/v2/internal/migration/repair" + "github.com/supabase/cli/v2/internal/migration/squash" + "github.com/supabase/cli/v2/internal/migration/up" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" ) var ( diff --git a/cmd/orgs.go b/cmd/orgs.go index 5d0750dbb..ace1cd960 100644 --- a/cmd/orgs.go +++ b/cmd/orgs.go @@ -2,8 +2,8 @@ package cmd import ( "github.com/spf13/cobra" - "github.com/supabase/cli/internal/orgs/create" - "github.com/supabase/cli/internal/orgs/list" + "github.com/supabase/cli/v2/internal/orgs/create" + "github.com/supabase/cli/v2/internal/orgs/list" ) var ( diff --git a/cmd/postgres.go b/cmd/postgres.go index 1c2e0e127..c1e84ca72 100644 --- a/cmd/postgres.go +++ b/cmd/postgres.go @@ -3,9 +3,9 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/postgresConfig/get" - "github.com/supabase/cli/internal/postgresConfig/update" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/postgresConfig/get" + "github.com/supabase/cli/v2/internal/postgresConfig/update" + "github.com/supabase/cli/v2/internal/utils/flags" ) var ( diff --git a/cmd/projects.go b/cmd/projects.go index c119e7171..4b214c517 100644 --- a/cmd/projects.go +++ b/cmd/projects.go @@ -7,13 +7,13 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/supabase/cli/internal/projects/apiKeys" - "github.com/supabase/cli/internal/projects/create" - "github.com/supabase/cli/internal/projects/delete" - "github.com/supabase/cli/internal/projects/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/projects/apiKeys" + "github.com/supabase/cli/v2/internal/projects/create" + "github.com/supabase/cli/v2/internal/projects/delete" + "github.com/supabase/cli/v2/internal/projects/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/api" "golang.org/x/term" ) diff --git a/cmd/restrictions.go b/cmd/restrictions.go index 4358d6132..beb1bbf7d 100644 --- a/cmd/restrictions.go +++ b/cmd/restrictions.go @@ -2,9 +2,9 @@ package cmd import ( "github.com/spf13/cobra" - "github.com/supabase/cli/internal/restrictions/get" - "github.com/supabase/cli/internal/restrictions/update" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/restrictions/get" + "github.com/supabase/cli/v2/internal/restrictions/update" + "github.com/supabase/cli/v2/internal/utils/flags" ) var ( diff --git a/cmd/root.go b/cmd/root.go index 35540a897..8906ef32e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -15,8 +15,8 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" "golang.org/x/mod/semver" ) diff --git a/cmd/secrets.go b/cmd/secrets.go index df4084e46..f4ee8d09e 100644 --- a/cmd/secrets.go +++ b/cmd/secrets.go @@ -3,10 +3,10 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/secrets/list" - "github.com/supabase/cli/internal/secrets/set" - "github.com/supabase/cli/internal/secrets/unset" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/secrets/list" + "github.com/supabase/cli/v2/internal/secrets/set" + "github.com/supabase/cli/v2/internal/secrets/unset" + "github.com/supabase/cli/v2/internal/utils/flags" ) var ( diff --git a/cmd/seed.go b/cmd/seed.go index c36b70741..7cac7c325 100644 --- a/cmd/seed.go +++ b/cmd/seed.go @@ -6,9 +6,9 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/seed/buckets" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/seed/buckets" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" ) var ( diff --git a/cmd/services.go b/cmd/services.go index fe298cb43..2fc80e6b0 100644 --- a/cmd/services.go +++ b/cmd/services.go @@ -3,7 +3,7 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/services" + "github.com/supabase/cli/v2/internal/services" ) var ( diff --git a/cmd/snippets.go b/cmd/snippets.go index f69b232af..848e9b7d9 100644 --- a/cmd/snippets.go +++ b/cmd/snippets.go @@ -3,9 +3,9 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/snippets/download" - "github.com/supabase/cli/internal/snippets/list" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/snippets/download" + "github.com/supabase/cli/v2/internal/snippets/list" + "github.com/supabase/cli/v2/internal/utils/flags" ) var ( diff --git a/cmd/sslEnforcement.go b/cmd/sslEnforcement.go index 7b44d6ddb..3a7351484 100644 --- a/cmd/sslEnforcement.go +++ b/cmd/sslEnforcement.go @@ -4,9 +4,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/ssl_enforcement/get" - "github.com/supabase/cli/internal/ssl_enforcement/update" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/ssl_enforcement/get" + "github.com/supabase/cli/v2/internal/ssl_enforcement/update" + "github.com/supabase/cli/v2/internal/utils/flags" ) var ( diff --git a/cmd/sso.go b/cmd/sso.go index a9b4db7d3..8c7f3109f 100644 --- a/cmd/sso.go +++ b/cmd/sso.go @@ -4,14 +4,14 @@ import ( "github.com/go-errors/errors" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/sso/create" - "github.com/supabase/cli/internal/sso/get" - "github.com/supabase/cli/internal/sso/info" - "github.com/supabase/cli/internal/sso/list" - "github.com/supabase/cli/internal/sso/remove" - "github.com/supabase/cli/internal/sso/update" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/sso/create" + "github.com/supabase/cli/v2/internal/sso/get" + "github.com/supabase/cli/v2/internal/sso/info" + "github.com/supabase/cli/v2/internal/sso/list" + "github.com/supabase/cli/v2/internal/sso/remove" + "github.com/supabase/cli/v2/internal/sso/update" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" ) var ( diff --git a/cmd/start.go b/cmd/start.go index a7af80e0c..bbdf54d0f 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -8,8 +8,8 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/start" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/start" + "github.com/supabase/cli/v2/internal/utils" ) func validateExcludedContainers(excludedContainers []string) { diff --git a/cmd/status.go b/cmd/status.go index 13540bfb1..f082a432e 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -7,8 +7,8 @@ import ( env "github.com/Netflix/go-env" "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/status" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/status" + "github.com/supabase/cli/v2/internal/utils" ) var ( diff --git a/cmd/stop.go b/cmd/stop.go index 6a6f4aa55..797651107 100644 --- a/cmd/stop.go +++ b/cmd/stop.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/stop" + "github.com/supabase/cli/v2/internal/stop" ) var ( diff --git a/cmd/storage.go b/cmd/storage.go index 3e6eb8fea..8269baac0 100644 --- a/cmd/storage.go +++ b/cmd/storage.go @@ -3,12 +3,12 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/storage/client" - "github.com/supabase/cli/internal/storage/cp" - "github.com/supabase/cli/internal/storage/ls" - "github.com/supabase/cli/internal/storage/mv" - "github.com/supabase/cli/internal/storage/rm" - "github.com/supabase/cli/pkg/storage" + "github.com/supabase/cli/v2/internal/storage/client" + "github.com/supabase/cli/v2/internal/storage/cp" + "github.com/supabase/cli/v2/internal/storage/ls" + "github.com/supabase/cli/v2/internal/storage/mv" + "github.com/supabase/cli/v2/internal/storage/rm" + "github.com/supabase/cli/v2/pkg/storage" ) var ( diff --git a/cmd/test.go b/cmd/test.go index 06fb77730..91ac6def8 100644 --- a/cmd/test.go +++ b/cmd/test.go @@ -6,8 +6,8 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/test/new" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/test/new" + "github.com/supabase/cli/v2/internal/utils" ) var ( diff --git a/cmd/unlink.go b/cmd/unlink.go index e017e75ed..8b0f726f7 100644 --- a/cmd/unlink.go +++ b/cmd/unlink.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/unlink" + "github.com/supabase/cli/v2/internal/unlink" ) var ( diff --git a/cmd/vanitySubdomains.go b/cmd/vanitySubdomains.go index dd3608c53..47f3de7b7 100644 --- a/cmd/vanitySubdomains.go +++ b/cmd/vanitySubdomains.go @@ -3,11 +3,11 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/internal/vanity_subdomains/activate" - "github.com/supabase/cli/internal/vanity_subdomains/check" - "github.com/supabase/cli/internal/vanity_subdomains/delete" - "github.com/supabase/cli/internal/vanity_subdomains/get" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/internal/vanity_subdomains/activate" + "github.com/supabase/cli/v2/internal/vanity_subdomains/check" + "github.com/supabase/cli/v2/internal/vanity_subdomains/delete" + "github.com/supabase/cli/v2/internal/vanity_subdomains/get" ) var ( diff --git a/docs/main.go b/docs/main.go index bfacba311..c7cacc82b 100644 --- a/docs/main.go +++ b/docs/main.go @@ -11,8 +11,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" - cli "github.com/supabase/cli/cmd" - "github.com/supabase/cli/internal/utils" + cli "github.com/supabase/cli/v2/cmd" + "github.com/supabase/cli/v2/internal/utils" "gopkg.in/yaml.v3" ) diff --git a/examples/functions-deploy/main.go b/examples/functions-deploy/main.go index 716ef1462..e3f7b0469 100644 --- a/examples/functions-deploy/main.go +++ b/examples/functions-deploy/main.go @@ -8,9 +8,9 @@ import ( "os" "time" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/config" - "github.com/supabase/cli/pkg/function" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/v2/pkg/function" ) func main() { diff --git a/examples/migrations-up/main.go b/examples/migrations-up/main.go index 3ef03242b..4ff759e95 100644 --- a/examples/migrations-up/main.go +++ b/examples/migrations-up/main.go @@ -6,8 +6,8 @@ import ( "log" "os" - "github.com/supabase/cli/pkg/migration" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/v2/pkg/pgxv5" ) func main() { diff --git a/examples/seed-buckets/main.go b/examples/seed-buckets/main.go index 2c62b1084..8cd8f69e1 100644 --- a/examples/seed-buckets/main.go +++ b/examples/seed-buckets/main.go @@ -8,9 +8,9 @@ import ( "os" "time" - "github.com/supabase/cli/pkg/config" - "github.com/supabase/cli/pkg/fetcher" - "github.com/supabase/cli/pkg/storage" + "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/storage" ) func main() { diff --git a/go.mod b/go.mod index 1c55174b8..c33559c93 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/supabase/cli +module github.com/supabase/cli/v2 go 1.23.2 @@ -18,7 +18,6 @@ require ( github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 github.com/getsentry/sentry-go v0.30.0 - github.com/gin-gonic/gin v1.10.0 github.com/go-errors/errors v1.5.1 github.com/go-git/go-git/v5 v5.12.0 github.com/go-xmlfmt/xmlfmt v1.1.3 @@ -35,7 +34,6 @@ require ( github.com/jackc/pgtype v1.14.4 github.com/jackc/pgx/v4 v4.18.3 github.com/joho/godotenv v1.5.1 - github.com/matoous/go-nanoid/v2 v2.1.0 github.com/mitchellh/mapstructure v1.5.0 github.com/muesli/reflow v0.3.0 github.com/oapi-codegen/runtime v1.1.1 @@ -95,8 +93,6 @@ require ( github.com/breml/errchkjson v0.4.0 // indirect github.com/butuzov/ireturn v0.3.0 // indirect github.com/butuzov/mirror v1.2.0 // indirect - github.com/bytedance/sonic v1.11.6 // indirect - github.com/bytedance/sonic/loader v0.1.1 // indirect github.com/catenacyber/perfsprint v0.7.1 // indirect github.com/ccojocar/zxcvbn-go v1.0.2 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect @@ -106,8 +102,6 @@ require ( github.com/chavacava/garif v0.1.0 // indirect github.com/ckaznocha/intrange v0.2.1 // indirect github.com/cloudflare/circl v1.3.7 // indirect - github.com/cloudwego/base64x v0.1.4 // indirect - github.com/cloudwego/iasm v0.2.0 // indirect github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect github.com/containerd/log v0.1.0 // indirect github.com/containers/storage v1.56.0 // indirect @@ -133,10 +127,8 @@ require ( github.com/fsnotify/fsnotify v1.8.0 // indirect github.com/fvbommel/sortorder v1.1.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/getkin/kin-openapi v0.124.0 // indirect github.com/ghostiam/protogetter v0.3.8 // indirect - github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-critic/go-critic v0.11.5 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect @@ -144,9 +136,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect - github.com/go-playground/locales v0.14.1 // indirect - github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.20.0 // indirect github.com/go-toolsmith/astcast v1.1.0 // indirect github.com/go-toolsmith/astcopy v1.1.0 // indirect github.com/go-toolsmith/astequal v1.2.0 // indirect @@ -156,7 +145,6 @@ require ( github.com/go-toolsmith/typep v1.1.0 // indirect github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/goccy/go-json v0.10.2 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/gofrs/flock v0.12.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -196,13 +184,11 @@ require ( github.com/jingyugao/rowserrcheck v1.1.1 // indirect github.com/jjti/go-spancheck v0.6.2 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect github.com/julz/importas v0.1.0 // indirect github.com/karamaru-alpha/copyloopvar v1.1.0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/kisielk/errcheck v1.8.0 // indirect github.com/kkHAIKE/contextcheck v1.1.5 // indirect - github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/kulti/thelper v0.6.3 // indirect @@ -211,7 +197,6 @@ require ( github.com/lasiar/canonicalheader v1.1.2 // indirect github.com/ldez/gomoddirectives v0.2.4 // indirect github.com/ldez/tagliatelle v0.5.0 // indirect - github.com/leodido/go-urn v1.4.0 // indirect github.com/leonklingele/grouper v1.1.2 // indirect github.com/lib/pq v1.10.9 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect @@ -234,8 +219,6 @@ require ( github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/sys/sequential v0.6.0 // indirect github.com/moby/term v0.5.0 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/moricho/tparallel v0.3.2 // indirect github.com/morikuni/aec v1.0.0 // indirect @@ -298,7 +281,6 @@ require ( github.com/timonwong/loggercheck v0.10.1 // indirect github.com/tomarrell/wrapcheck/v2 v2.9.0 // indirect github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect - github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect github.com/ultraware/funlen v0.1.0 // indirect github.com/ultraware/whitespace v0.1.1 // indirect @@ -331,7 +313,6 @@ require ( go.uber.org/automaxprocs v1.6.0 // indirect go.uber.org/multierr v1.9.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/arch v0.8.0 // indirect golang.org/x/crypto v0.29.0 // indirect golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect diff --git a/go.sum b/go.sum index 9313587d7..29f788f41 100644 --- a/go.sum +++ b/go.sum @@ -147,10 +147,6 @@ github.com/butuzov/ireturn v0.3.0/go.mod h1:A09nIiwiqzN/IoVo9ogpa0Hzi9fex1kd9PSD github.com/butuzov/mirror v1.2.0 h1:9YVK1qIjNspaqWutSv8gsge2e/Xpq1eqEkslEUHy5cs= github.com/butuzov/mirror v1.2.0/go.mod h1:DqZZDtzm42wIAIyHXeN8W/qb1EPlb9Qn/if9icBOpdQ= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= -github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= -github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= -github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/catenacyber/perfsprint v0.7.1 h1:PGW5G/Kxn+YrN04cRAZKC+ZuvlVwolYMrIyyTJ/rMmc= github.com/catenacyber/perfsprint v0.7.1/go.mod h1:/wclWYompEyjUD2FuIIDVKNkqz7IgBIWXIH3V0Zol50= github.com/ccojocar/zxcvbn-go v1.0.2 h1:na/czXU8RrhXO4EZme6eQJLR4PzcGsahsBOAwU6I3Vg= @@ -189,10 +185,6 @@ github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= -github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= -github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= -github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= @@ -287,18 +279,12 @@ github.com/fvbommel/sortorder v1.1.0 h1:fUmoe+HLsBTctBDoaBwpQo5N+nrCp8g/BjKb/6ZQ github.com/fvbommel/sortorder v1.1.0/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0= github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= -github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= -github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj9kz/M= github.com/getkin/kin-openapi v0.124.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM= github.com/getsentry/sentry-go v0.30.0 h1:lWUwDnY7sKHaVIoZ9wYqRHJ5iEmoc0pqcRqFkosKzBo= github.com/getsentry/sentry-go v0.30.0/go.mod h1:WU9B9/1/sHDqeV8T+3VwwbjeR5MSXs/6aqG3mqZrezA= github.com/ghostiam/protogetter v0.3.8 h1:LYcXbYvybUyTIxN2Mj9h6rHrDZBDwZloPoKctWrFyJY= github.com/ghostiam/protogetter v0.3.8/go.mod h1:WZ0nw9pfzsgxuRsPOFQomgDVSWtDLJRfQJEhsGbmQMA= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= -github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= github.com/go-critic/go-critic v0.11.5 h1:TkDTOn5v7EEngMxu8KbuFqFR43USaaH8XRJLz1jhVYA= @@ -331,14 +317,6 @@ github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1 github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= -github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= -github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= -github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= -github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= github.com/go-sql-driver/mysql v1.3.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= @@ -375,8 +353,6 @@ github.com/go-xmlfmt/xmlfmt v1.1.3 h1:t8Ey3Uy7jDSEisW2K3somuMKIpzktkWptA0iFCnRUW github.com/go-xmlfmt/xmlfmt v1.1.3/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= @@ -602,7 +578,6 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= @@ -622,10 +597,6 @@ github.com/kisielk/errcheck v1.8.0/go.mod h1:1kLL+jV4e+CFfueBmI1dSK2ADDyQnlrnrY/ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkHAIKE/contextcheck v1.1.5 h1:CdnJh63tcDe53vG+RebdpdXJTc9atMgGqdx8LXxiilg= github.com/kkHAIKE/contextcheck v1.1.5/go.mod h1:O930cpht4xb1YQpK+1+AgoM3mFsvxr7uyFptcnWTYUA= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= -github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -652,8 +623,6 @@ github.com/ldez/gomoddirectives v0.2.4 h1:j3YjBIjEBbqZ0NKtBNzr8rtMHTOrLPeiwTkfUJ github.com/ldez/gomoddirectives v0.2.4/go.mod h1:oWu9i62VcQDYp9EQ0ONTfqLNh+mDLWWDO+SO0qSQw5g= github.com/ldez/tagliatelle v0.5.0 h1:epgfuYt9v0CG3fms0pEgIMNPuFf/LpPIfjk4kyqSioo= github.com/ldez/tagliatelle v0.5.0/go.mod h1:rj1HmWiL1MiKQuOONhd09iySTEkUuE/8+5jtPYz9xa4= -github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= -github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/leonklingele/grouper v1.1.2 h1:o1ARBDLOmmasUaNDesWqWCIFH3u7hoFlM84YrjT3mIY= github.com/leonklingele/grouper v1.1.2/go.mod h1:6D0M/HVkhs2yRKRFZUoGjeDy7EZTfFBE9gl4kjmIGkA= github.com/lib/pq v0.0.0-20150723085316-0dad96c0b94f/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -676,8 +645,6 @@ github.com/maratori/testableexamples v1.0.0 h1:dU5alXRrD8WKSjOUnmJZuzdxWOEQ57+7s github.com/maratori/testableexamples v1.0.0/go.mod h1:4rhjL1n20TUTT4vdh3RDqSizKLyXp7K2u6HgraZCGzE= github.com/maratori/testpackage v1.1.1 h1:S58XVV5AD7HADMmD0fNnziNHqKvSdDuEKdPD1rNTU04= github.com/maratori/testpackage v1.1.1/go.mod h1:s4gRK/ym6AMrqpOa/kEbQTV4Q4jb7WeLZzVhVVVOQMc= -github.com/matoous/go-nanoid/v2 v2.1.0 h1:P64+dmq21hhWdtvZfEAofnvJULaRR1Yib0+PnU669bE= -github.com/matoous/go-nanoid/v2 v2.1.0/go.mod h1:KlbGNQ+FhrUNIHUxZdL63t7tl4LaPkZNpUULS8H4uVM= github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26 h1:gWg6ZQ4JhDfJPqlo2srm/LN17lpybq15AryXIRcWYLE= github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s= github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= @@ -724,11 +691,9 @@ github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiT github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= @@ -971,8 +936,6 @@ github.com/tomarrell/wrapcheck/v2 v2.9.0 h1:801U2YCAjLhdN8zhZ/7tdjB3EnAoRlJHt/s+ github.com/tomarrell/wrapcheck/v2 v2.9.0/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo= github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= -github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= -github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ultraware/funlen v0.1.0 h1:BuqclbkY6pO+cvxoq7OsktIXZpgBSkYTQtmwhAK81vI= @@ -1074,9 +1037,6 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= -golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -1548,8 +1508,6 @@ mvdan.cc/gofumpt v0.7.0 h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU= mvdan.cc/gofumpt v0.7.0/go.mod h1:txVFJy/Sc/mvaycET54pV8SW8gWxTlUuGHVEcncmNUo= mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f h1:lMpcwN6GxNbWtbpI1+xzFLSW8XzX0u72NttUGVFjO3U= mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f/go.mod h1:RSLa7mKKCNeTTMHBw5Hsy2rfJmd6O2ivt9Dw9ZqCQpQ= -nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/internal/bans/get/get.go b/internal/bans/get/get.go index a9e52901d..f6f63c401 100644 --- a/internal/bans/get/get.go +++ b/internal/bans/get/get.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/bans/update/update.go b/internal/bans/update/update.go index dfb31d8cf..496f187ed 100644 --- a/internal/bans/update/update.go +++ b/internal/bans/update/update.go @@ -7,8 +7,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func validateIps(ips []string) error { diff --git a/internal/bootstrap/bootstrap.go b/internal/bootstrap/bootstrap.go index 677ef1530..aecbdd6e1 100644 --- a/internal/bootstrap/bootstrap.go +++ b/internal/bootstrap/bootstrap.go @@ -19,18 +19,18 @@ import ( "github.com/joho/godotenv" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/internal/db/push" - initBlank "github.com/supabase/cli/internal/init" - "github.com/supabase/cli/internal/link" - "github.com/supabase/cli/internal/login" - "github.com/supabase/cli/internal/projects/apiKeys" - "github.com/supabase/cli/internal/projects/create" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/internal/utils/tenant" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/fetcher" - "github.com/supabase/cli/pkg/queue" + "github.com/supabase/cli/v2/internal/db/push" + initBlank "github.com/supabase/cli/v2/internal/init" + "github.com/supabase/cli/v2/internal/link" + "github.com/supabase/cli/v2/internal/login" + "github.com/supabase/cli/v2/internal/projects/apiKeys" + "github.com/supabase/cli/v2/internal/projects/create" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/internal/utils/tenant" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/queue" "golang.org/x/term" ) diff --git a/internal/bootstrap/bootstrap_test.go b/internal/bootstrap/bootstrap_test.go index 6cf6eb6e4..8dd89d46d 100644 --- a/internal/bootstrap/bootstrap_test.go +++ b/internal/bootstrap/bootstrap_test.go @@ -10,8 +10,8 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/api" ) func TestSuggestAppStart(t *testing.T) { diff --git a/internal/branches/create/create.go b/internal/branches/create/create.go index bf2931b68..63dbaad6f 100644 --- a/internal/branches/create/create.go +++ b/internal/branches/create/create.go @@ -6,10 +6,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/gen/keys" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/gen/keys" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, body api.CreateBranchBody, fsys afero.Fs) error { diff --git a/internal/branches/create/create_test.go b/internal/branches/create/create_test.go index e07e10387..d58ed55ad 100644 --- a/internal/branches/create/create_test.go +++ b/internal/branches/create/create_test.go @@ -10,11 +10,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" ) func TestCreateCommand(t *testing.T) { diff --git a/internal/branches/delete/delete.go b/internal/branches/delete/delete.go index b7fdd6671..568fd56c0 100644 --- a/internal/branches/delete/delete.go +++ b/internal/branches/delete/delete.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, branchId string) error { diff --git a/internal/branches/disable/disable.go b/internal/branches/disable/disable.go index d94c1e6c5..b7d54f293 100644 --- a/internal/branches/disable/disable.go +++ b/internal/branches/disable/disable.go @@ -7,8 +7,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" ) func Run(ctx context.Context, fsys afero.Fs) error { diff --git a/internal/branches/get/get.go b/internal/branches/get/get.go index ee5bc332c..19f04a58e 100644 --- a/internal/branches/get/get.go +++ b/internal/branches/get/get.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, branchId string) error { diff --git a/internal/branches/list/list.go b/internal/branches/list/list.go index 7a153138f..d40b3824a 100644 --- a/internal/branches/list/list.go +++ b/internal/branches/list/list.go @@ -7,9 +7,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" ) func Run(ctx context.Context, fsys afero.Fs) error { diff --git a/internal/branches/update/update.go b/internal/branches/update/update.go index 6c0f5fc4a..2ddb03f19 100644 --- a/internal/branches/update/update.go +++ b/internal/branches/update/update.go @@ -6,8 +6,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, branchId string, body api.UpdateBranchBody, fsys afero.Fs) error { diff --git a/internal/config/push/push.go b/internal/config/push/push.go index a4c901473..5ddc9070c 100644 --- a/internal/config/push/push.go +++ b/internal/config/push/push.go @@ -6,8 +6,8 @@ import ( "os" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/config" ) func Run(ctx context.Context, ref string, fsys afero.Fs) error { diff --git a/internal/db/branch/create/create.go b/internal/db/branch/create/create.go index 085e10f9d..66635bad1 100644 --- a/internal/db/branch/create/create.go +++ b/internal/db/branch/create/create.go @@ -13,7 +13,7 @@ import ( "github.com/docker/docker/pkg/stdcopy" "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) var ( diff --git a/internal/db/branch/create/create_test.go b/internal/db/branch/create/create_test.go index 8e3842345..20bfd4ac3 100644 --- a/internal/db/branch/create/create_test.go +++ b/internal/db/branch/create/create_test.go @@ -10,8 +10,8 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" ) func TestBranchValidation(t *testing.T) { diff --git a/internal/db/branch/delete/delete.go b/internal/db/branch/delete/delete.go index f59f5e51c..9655cd793 100644 --- a/internal/db/branch/delete/delete.go +++ b/internal/db/branch/delete/delete.go @@ -11,7 +11,7 @@ import ( "github.com/docker/docker/pkg/stdcopy" "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func Run(branch string, fsys afero.Fs) error { diff --git a/internal/db/branch/delete/delete_test.go b/internal/db/branch/delete/delete_test.go index 76957e246..709a3a520 100644 --- a/internal/db/branch/delete/delete_test.go +++ b/internal/db/branch/delete/delete_test.go @@ -9,8 +9,8 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" ) func TestBranchDir(t *testing.T) { diff --git a/internal/db/branch/list/list.go b/internal/db/branch/list/list.go index b1037ac1b..f88104229 100644 --- a/internal/db/branch/list/list.go +++ b/internal/db/branch/list/list.go @@ -8,7 +8,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func Run(fsys afero.Fs, out io.Writer) error { diff --git a/internal/db/branch/list/list_test.go b/internal/db/branch/list/list_test.go index 24e34d5e5..fa16586a5 100644 --- a/internal/db/branch/list/list_test.go +++ b/internal/db/branch/list/list_test.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func TestListCommand(t *testing.T) { diff --git a/internal/db/branch/switch_/switch_.go b/internal/db/branch/switch_/switch_.go index 462b26c69..b1255ea63 100644 --- a/internal/db/branch/switch_/switch_.go +++ b/internal/db/branch/switch_/switch_.go @@ -10,8 +10,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, target string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/db/branch/switch_/switch__test.go b/internal/db/branch/switch_/switch__test.go index 7c70959ce..8f22f3214 100644 --- a/internal/db/branch/switch_/switch__test.go +++ b/internal/db/branch/switch_/switch__test.go @@ -13,10 +13,10 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgtest" ) func TestSwitchCommand(t *testing.T) { diff --git a/internal/db/diff/diff.go b/internal/db/diff/diff.go index 6c5faa892..05da60459 100644 --- a/internal/db/diff/diff.go +++ b/internal/db/diff/diff.go @@ -21,11 +21,11 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/start" - "github.com/supabase/cli/internal/gen/keys" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" - "github.com/supabase/cli/pkg/parser" + "github.com/supabase/cli/v2/internal/db/start" + "github.com/supabase/cli/v2/internal/gen/keys" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/v2/pkg/parser" ) type DiffFunc func(context.Context, string, string, []string) (string, error) diff --git a/internal/db/diff/diff_test.go b/internal/db/diff/diff_test.go index 6ada103c7..3db4d954a 100644 --- a/internal/db/diff/diff_test.go +++ b/internal/db/diff/diff_test.go @@ -17,14 +17,14 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/db/start" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/testing/helper" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/config" - "github.com/supabase/cli/pkg/migration" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/db/start" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/testing/helper" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/db/diff/migra.go b/internal/db/diff/migra.go index 4e7842693..47f8ba1bf 100644 --- a/internal/db/diff/migra.go +++ b/internal/db/diff/migra.go @@ -9,8 +9,8 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/config" ) //go:embed templates/migra.sh diff --git a/internal/db/diff/pgadmin.go b/internal/db/diff/pgadmin.go index 298023580..baa984849 100644 --- a/internal/db/diff/pgadmin.go +++ b/internal/db/diff/pgadmin.go @@ -8,10 +8,10 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/start" - "github.com/supabase/cli/internal/migration/new" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/v2/internal/db/start" + "github.com/supabase/cli/v2/internal/migration/new" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/config" ) var warnDiff = `WARNING: The diff tool is not foolproof, so you may need to manually rearrange and modify the generated migration. diff --git a/internal/db/dump/dump.go b/internal/db/dump/dump.go index 94e2ba7af..bef685fe9 100644 --- a/internal/db/dump/dump.go +++ b/internal/db/dump/dump.go @@ -13,8 +13,8 @@ import ( "github.com/go-errors/errors" "github.com/jackc/pgconn" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - cliConfig "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/v2/internal/utils" + cliConfig "github.com/supabase/cli/v2/pkg/config" ) var ( diff --git a/internal/db/dump/dump_test.go b/internal/db/dump/dump_test.go index 3a7c3cc65..62c1240a3 100644 --- a/internal/db/dump/dump_test.go +++ b/internal/db/dump/dump_test.go @@ -10,8 +10,8 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" ) var dbConfig = pgconn.Config{ diff --git a/internal/db/lint/lint.go b/internal/db/lint/lint.go index 5701d89be..5fe21d182 100644 --- a/internal/db/lint/lint.go +++ b/internal/db/lint/lint.go @@ -13,8 +13,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" ) const ENABLE_PGSQL_CHECK = "CREATE EXTENSION IF NOT EXISTS plpgsql_check" diff --git a/internal/db/lint/lint_test.go b/internal/db/lint/lint_test.go index 8d7abef8f..807540a44 100644 --- a/internal/db/lint/lint_test.go +++ b/internal/db/lint/lint_test.go @@ -14,9 +14,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/db/pull/pull.go b/internal/db/pull/pull.go index f6a235e11..ad5e07103 100644 --- a/internal/db/pull/pull.go +++ b/internal/db/pull/pull.go @@ -12,13 +12,13 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/diff" - "github.com/supabase/cli/internal/db/dump" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/migration/new" - "github.com/supabase/cli/internal/migration/repair" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/v2/internal/db/diff" + "github.com/supabase/cli/v2/internal/db/dump" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/migration/new" + "github.com/supabase/cli/v2/internal/migration/repair" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" ) var ( diff --git a/internal/db/pull/pull_test.go b/internal/db/pull/pull_test.go index 2e55fcfed..f6248fe9d 100644 --- a/internal/db/pull/pull_test.go +++ b/internal/db/pull/pull_test.go @@ -13,11 +13,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/db/push/push.go b/internal/db/push/push.go index 2141255ae..29555b5be 100644 --- a/internal/db/push/push.go +++ b/internal/db/push/push.go @@ -10,10 +10,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/up" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/v2/internal/migration/up" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/migration" ) func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, includeSeed bool, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/db/push/push_test.go b/internal/db/push/push_test.go index 3a3ff3cda..dad8f2e49 100644 --- a/internal/db/push/push_test.go +++ b/internal/db/push/push_test.go @@ -13,11 +13,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/testing/helper" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/testing/helper" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/db/remote/changes/changes.go b/internal/db/remote/changes/changes.go index c735b5984..c711470c8 100644 --- a/internal/db/remote/changes/changes.go +++ b/internal/db/remote/changes/changes.go @@ -6,9 +6,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/diff" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/v2/internal/db/diff" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" ) var output string diff --git a/internal/db/remote/commit/commit.go b/internal/db/remote/commit/commit.go index f9062d492..75b9232d8 100644 --- a/internal/db/remote/commit/commit.go +++ b/internal/db/remote/commit/commit.go @@ -10,12 +10,12 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/diff" - "github.com/supabase/cli/internal/db/dump" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/migration/repair" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/v2/internal/db/diff" + "github.com/supabase/cli/v2/internal/db/dump" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/migration/repair" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" ) func Run(ctx context.Context, schema []string, config pgconn.Config, fsys afero.Fs) error { diff --git a/internal/db/reset/reset.go b/internal/db/reset/reset.go index 3830a019d..81b8e1457 100644 --- a/internal/db/reset/reset.go +++ b/internal/db/reset/reset.go @@ -20,15 +20,15 @@ import ( "github.com/jackc/pgerrcode" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/start" - "github.com/supabase/cli/internal/gen/keys" - "github.com/supabase/cli/internal/migration/apply" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/migration/repair" - "github.com/supabase/cli/internal/seed/buckets" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/v2/internal/db/start" + "github.com/supabase/cli/v2/internal/gen/keys" + "github.com/supabase/cli/v2/internal/migration/apply" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/migration/repair" + "github.com/supabase/cli/v2/internal/seed/buckets" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/migration" ) func Run(ctx context.Context, version string, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/db/reset/reset_test.go b/internal/db/reset/reset_test.go index 4e3558be3..3693ac8b5 100644 --- a/internal/db/reset/reset_test.go +++ b/internal/db/reset/reset_test.go @@ -16,14 +16,14 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/db/start" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/testing/helper" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" - "github.com/supabase/cli/pkg/pgtest" - "github.com/supabase/cli/pkg/storage" + "github.com/supabase/cli/v2/internal/db/start" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/testing/helper" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/storage" ) func TestResetCommand(t *testing.T) { diff --git a/internal/db/start/start.go b/internal/db/start/start.go index c4722f22f..f286b1fcb 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -19,10 +19,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/apply" - "github.com/supabase/cli/internal/status" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/v2/internal/migration/apply" + "github.com/supabase/cli/v2/internal/status" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" ) var ( diff --git a/internal/db/start/start_test.go b/internal/db/start/start_test.go index 475562f2f..e52ecbbbd 100644 --- a/internal/db/start/start_test.go +++ b/internal/db/start/start_test.go @@ -14,11 +14,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/cast" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/v2/pkg/pgtest" ) func TestInitBranch(t *testing.T) { diff --git a/internal/db/test/test.go b/internal/db/test/test.go index 263305736..4374e7c98 100644 --- a/internal/db/test/test.go +++ b/internal/db/test/test.go @@ -15,8 +15,8 @@ import ( "github.com/jackc/pgx/v4" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/internal/utils" - cliConfig "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/v2/internal/utils" + cliConfig "github.com/supabase/cli/v2/pkg/config" ) const ( diff --git a/internal/db/test/test_test.go b/internal/db/test/test_test.go index 7c9310991..30f781fdf 100644 --- a/internal/db/test/test_test.go +++ b/internal/db/test/test_test.go @@ -11,10 +11,10 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/config" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/debug/postgres_test.go b/internal/debug/postgres_test.go index 9f46fd6b8..4d836ce7d 100644 --- a/internal/debug/postgres_test.go +++ b/internal/debug/postgres_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgx/v4" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/pgtest" ) func TestPostgresProxy(t *testing.T) { diff --git a/internal/encryption/get/get.go b/internal/encryption/get/get.go index 93c698635..22b827860 100644 --- a/internal/encryption/get/get.go +++ b/internal/encryption/get/get.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, projectRef string) error { diff --git a/internal/encryption/get/get_test.go b/internal/encryption/get/get_test.go index 8f280189b..a3656dc0b 100644 --- a/internal/encryption/get/get_test.go +++ b/internal/encryption/get/get_test.go @@ -7,9 +7,9 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func TestGetRootKey(t *testing.T) { diff --git a/internal/encryption/update/update.go b/internal/encryption/update/update.go index ed576823f..172c6429e 100644 --- a/internal/encryption/update/update.go +++ b/internal/encryption/update/update.go @@ -7,9 +7,9 @@ import ( "strings" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/credentials" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/credentials" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, projectRef string, stdin *os.File) error { diff --git a/internal/encryption/update/update_test.go b/internal/encryption/update/update_test.go index 8a6f60930..5e8bf3434 100644 --- a/internal/encryption/update/update_test.go +++ b/internal/encryption/update/update_test.go @@ -9,9 +9,9 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func TestUpdateRootKey(t *testing.T) { diff --git a/internal/functions/delete/delete.go b/internal/functions/delete/delete.go index 47d5957ef..0242d5a7a 100644 --- a/internal/functions/delete/delete.go +++ b/internal/functions/delete/delete.go @@ -7,7 +7,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, slug string, projectRef string, fsys afero.Fs) error { diff --git a/internal/functions/delete/delete_test.go b/internal/functions/delete/delete_test.go index 110208ea9..ac39d5ce2 100644 --- a/internal/functions/delete/delete_test.go +++ b/internal/functions/delete/delete_test.go @@ -9,8 +9,8 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" ) func TestDeleteCommand(t *testing.T) { diff --git a/internal/functions/deploy/bundle.go b/internal/functions/deploy/bundle.go index 0119a559c..4a75e82e4 100644 --- a/internal/functions/deploy/bundle.go +++ b/internal/functions/deploy/bundle.go @@ -13,8 +13,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/function" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/function" ) type dockerBundler struct { diff --git a/internal/functions/deploy/bundle_test.go b/internal/functions/deploy/bundle_test.go index f8a68f439..bb286cc21 100644 --- a/internal/functions/deploy/bundle_test.go +++ b/internal/functions/deploy/bundle_test.go @@ -11,8 +11,8 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" ) func TestDockerBundle(t *testing.T) { diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index 529b78976..2c97931c8 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -9,11 +9,11 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/cast" - "github.com/supabase/cli/pkg/config" - "github.com/supabase/cli/pkg/function" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/v2/pkg/function" ) func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bool, importMapPath string, fsys afero.Fs) error { diff --git a/internal/functions/deploy/deploy_test.go b/internal/functions/deploy/deploy_test.go index 558a33f32..542094f1a 100644 --- a/internal/functions/deploy/deploy_test.go +++ b/internal/functions/deploy/deploy_test.go @@ -12,11 +12,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" - "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/v2/pkg/config" ) func TestDeployCommand(t *testing.T) { diff --git a/internal/functions/download/download.go b/internal/functions/download/download.go index e3b68cae9..169df9d8b 100644 --- a/internal/functions/download/download.go +++ b/internal/functions/download/download.go @@ -15,8 +15,8 @@ import ( "github.com/docker/docker/api/types/network" "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) var ( diff --git a/internal/functions/download/download_test.go b/internal/functions/download/download_test.go index b727f95c3..73c8afd80 100644 --- a/internal/functions/download/download_test.go +++ b/internal/functions/download/download_test.go @@ -13,9 +13,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func TestMain(m *testing.M) { diff --git a/internal/functions/list/list.go b/internal/functions/list/list.go index d0d2d9ecc..603de90aa 100644 --- a/internal/functions/list/list.go +++ b/internal/functions/list/list.go @@ -7,8 +7,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/functions/list/list_test.go b/internal/functions/list/list_test.go index e9c7f26b7..8f9d26174 100644 --- a/internal/functions/list/list_test.go +++ b/internal/functions/list/list_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func TestFunctionsListCommand(t *testing.T) { diff --git a/internal/functions/new/new.go b/internal/functions/new/new.go index 3656e9b5f..d876a9916 100644 --- a/internal/functions/new/new.go +++ b/internal/functions/new/new.go @@ -10,7 +10,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) var ( diff --git a/internal/functions/new/new_test.go b/internal/functions/new/new_test.go index d5e9c2fc8..fbb5f5e2d 100644 --- a/internal/functions/new/new_test.go +++ b/internal/functions/new/new_test.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func TestNewCommand(t *testing.T) { diff --git a/internal/functions/serve/serve.go b/internal/functions/serve/serve.go index 62811d769..1d9b28258 100644 --- a/internal/functions/serve/serve.go +++ b/internal/functions/serve/serve.go @@ -16,9 +16,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/internal/functions/deploy" - "github.com/supabase/cli/internal/secrets/set" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/functions/deploy" + "github.com/supabase/cli/v2/internal/secrets/set" + "github.com/supabase/cli/v2/internal/utils" ) type InspectMode string diff --git a/internal/functions/serve/serve_test.go b/internal/functions/serve/serve_test.go index 570c4b927..dbc14852a 100644 --- a/internal/functions/serve/serve_test.go +++ b/internal/functions/serve/serve_test.go @@ -12,9 +12,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/cast" ) func TestServeCommand(t *testing.T) { diff --git a/internal/gen/keys/keys.go b/internal/gen/keys/keys.go index 81ed52988..a1079e627 100644 --- a/internal/gen/keys/keys.go +++ b/internal/gen/keys/keys.go @@ -11,8 +11,8 @@ import ( "github.com/go-errors/errors" "github.com/go-git/go-git/v5" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/config" ) type CustomName struct { diff --git a/internal/gen/types/types.go b/internal/gen/types/types.go index b399cfb5c..1e158dd10 100644 --- a/internal/gen/types/types.go +++ b/internal/gen/types/types.go @@ -12,8 +12,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) const ( diff --git a/internal/gen/types/types_test.go b/internal/gen/types/types_test.go index 811ae061d..07ed9e02f 100644 --- a/internal/gen/types/types_test.go +++ b/internal/gen/types/types_test.go @@ -12,10 +12,10 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/pgtest" ) func TestGenLocalCommand(t *testing.T) { diff --git a/internal/hostnames/activate/activate.go b/internal/hostnames/activate/activate.go index 3cc01c206..1b951085e 100644 --- a/internal/hostnames/activate/activate.go +++ b/internal/hostnames/activate/activate.go @@ -6,8 +6,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/hostnames" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/hostnames" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, projectRef string, includeRawOutput bool, fsys afero.Fs) error { diff --git a/internal/hostnames/common.go b/internal/hostnames/common.go index c01e6a0da..b1f55e241 100644 --- a/internal/hostnames/common.go +++ b/internal/hostnames/common.go @@ -7,8 +7,8 @@ import ( "strings" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func GetCustomHostnameConfig(ctx context.Context, projectRef string) (*api.V1GetHostnameConfigResponse, error) { diff --git a/internal/hostnames/create/create.go b/internal/hostnames/create/create.go index 563b524bc..4f3e7c3e0 100644 --- a/internal/hostnames/create/create.go +++ b/internal/hostnames/create/create.go @@ -7,9 +7,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/hostnames" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/hostnames" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, projectRef string, customHostname string, includeRawOutput bool, fsys afero.Fs) error { diff --git a/internal/hostnames/delete/delete.go b/internal/hostnames/delete/delete.go index 3b9f3653c..6e472bc6c 100644 --- a/internal/hostnames/delete/delete.go +++ b/internal/hostnames/delete/delete.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/hostnames/get/get.go b/internal/hostnames/get/get.go index 9e17c19f2..def0af734 100644 --- a/internal/hostnames/get/get.go +++ b/internal/hostnames/get/get.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/afero" - "github.com/supabase/cli/internal/hostnames" + "github.com/supabase/cli/v2/internal/hostnames" ) func Run(ctx context.Context, projectRef string, includeRawOutput bool, fsys afero.Fs) error { diff --git a/internal/hostnames/reverify/reverify.go b/internal/hostnames/reverify/reverify.go index 7f4329903..c7abe8217 100644 --- a/internal/hostnames/reverify/reverify.go +++ b/internal/hostnames/reverify/reverify.go @@ -6,8 +6,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/hostnames" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/hostnames" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, projectRef string, includeRawOutput bool, fsys afero.Fs) error { diff --git a/internal/init/init.go b/internal/init/init.go index f4e470b02..ed99ecb9c 100644 --- a/internal/init/init.go +++ b/internal/init/init.go @@ -11,7 +11,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) var ( diff --git a/internal/init/init_test.go b/internal/init/init_test.go index 99a96dce5..b47c2f0f4 100644 --- a/internal/init/init_test.go +++ b/internal/init/init_test.go @@ -9,9 +9,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/cast" ) func TestInitCommand(t *testing.T) { diff --git a/internal/inspect/bloat/bloat.go b/internal/inspect/bloat/bloat.go index 6a97e41c8..ed680d005 100644 --- a/internal/inspect/bloat/bloat.go +++ b/internal/inspect/bloat/bloat.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed bloat.sql diff --git a/internal/inspect/bloat/bloat_test.go b/internal/inspect/bloat/bloat_test.go index 8646565ce..e5b75d799 100644 --- a/internal/inspect/bloat/bloat_test.go +++ b/internal/inspect/bloat/bloat_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/blocking/blocking.go b/internal/inspect/blocking/blocking.go index 37baed1f9..9aa6baba2 100644 --- a/internal/inspect/blocking/blocking.go +++ b/internal/inspect/blocking/blocking.go @@ -10,9 +10,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed blocking.sql diff --git a/internal/inspect/blocking/blocking_test.go b/internal/inspect/blocking/blocking_test.go index 46b63441f..15bd69712 100644 --- a/internal/inspect/blocking/blocking_test.go +++ b/internal/inspect/blocking/blocking_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/cache/cache.go b/internal/inspect/cache/cache.go index ce30c1f4a..c36339a66 100644 --- a/internal/inspect/cache/cache.go +++ b/internal/inspect/cache/cache.go @@ -9,9 +9,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed cache.sql diff --git a/internal/inspect/cache/cache_test.go b/internal/inspect/cache/cache_test.go index 28fa1cb73..cc332c857 100644 --- a/internal/inspect/cache/cache_test.go +++ b/internal/inspect/cache/cache_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/calls/calls.go b/internal/inspect/calls/calls.go index 2fd0c8df8..a1fe4d9e2 100644 --- a/internal/inspect/calls/calls.go +++ b/internal/inspect/calls/calls.go @@ -10,9 +10,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed calls.sql diff --git a/internal/inspect/calls/calls_test.go b/internal/inspect/calls/calls_test.go index ded271009..3d5a8408b 100644 --- a/internal/inspect/calls/calls_test.go +++ b/internal/inspect/calls/calls_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/index_sizes/index_sizes.go b/internal/inspect/index_sizes/index_sizes.go index 2cfc06e8d..56467f381 100644 --- a/internal/inspect/index_sizes/index_sizes.go +++ b/internal/inspect/index_sizes/index_sizes.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed index_sizes.sql diff --git a/internal/inspect/index_sizes/index_sizes_test.go b/internal/inspect/index_sizes/index_sizes_test.go index 9071c5710..fe3cf71ed 100644 --- a/internal/inspect/index_sizes/index_sizes_test.go +++ b/internal/inspect/index_sizes/index_sizes_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/index_usage/index_usage.go b/internal/inspect/index_usage/index_usage.go index cd8875f79..76019e5cf 100644 --- a/internal/inspect/index_usage/index_usage.go +++ b/internal/inspect/index_usage/index_usage.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed index_usage.sql diff --git a/internal/inspect/index_usage/index_usage_test.go b/internal/inspect/index_usage/index_usage_test.go index 5b735bb60..be965bf39 100644 --- a/internal/inspect/index_usage/index_usage_test.go +++ b/internal/inspect/index_usage/index_usage_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/locks/locks.go b/internal/inspect/locks/locks.go index 0b2db71c6..57aa8ed67 100644 --- a/internal/inspect/locks/locks.go +++ b/internal/inspect/locks/locks.go @@ -10,9 +10,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed locks.sql diff --git a/internal/inspect/locks/locks_test.go b/internal/inspect/locks/locks_test.go index e4c55c6bd..398c9dce9 100644 --- a/internal/inspect/locks/locks_test.go +++ b/internal/inspect/locks/locks_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/long_running_queries/long_running_queries.go b/internal/inspect/long_running_queries/long_running_queries.go index acf4be456..31b0095a0 100644 --- a/internal/inspect/long_running_queries/long_running_queries.go +++ b/internal/inspect/long_running_queries/long_running_queries.go @@ -9,9 +9,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed long_running_queries.sql diff --git a/internal/inspect/long_running_queries/long_running_queries_test.go b/internal/inspect/long_running_queries/long_running_queries_test.go index d936c61a3..afb2e249f 100644 --- a/internal/inspect/long_running_queries/long_running_queries_test.go +++ b/internal/inspect/long_running_queries/long_running_queries_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/outliers/outliers.go b/internal/inspect/outliers/outliers.go index 06f015c18..2e5c849d8 100644 --- a/internal/inspect/outliers/outliers.go +++ b/internal/inspect/outliers/outliers.go @@ -10,9 +10,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed outliers.sql diff --git a/internal/inspect/outliers/outliers_test.go b/internal/inspect/outliers/outliers_test.go index e5d46432a..f6f83cf34 100644 --- a/internal/inspect/outliers/outliers_test.go +++ b/internal/inspect/outliers/outliers_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/replication_slots/replication_slots.go b/internal/inspect/replication_slots/replication_slots.go index 927ad052a..e0ef52ee2 100644 --- a/internal/inspect/replication_slots/replication_slots.go +++ b/internal/inspect/replication_slots/replication_slots.go @@ -9,9 +9,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed replication_slots.sql diff --git a/internal/inspect/replication_slots/replication_slots_test.go b/internal/inspect/replication_slots/replication_slots_test.go index d9e9b3225..a7891b4c8 100644 --- a/internal/inspect/replication_slots/replication_slots_test.go +++ b/internal/inspect/replication_slots/replication_slots_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/report.go b/internal/inspect/report.go index de721d954..718ea5344 100644 --- a/internal/inspect/report.go +++ b/internal/inspect/report.go @@ -14,8 +14,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/utils" ) //go:embed **/*.sql diff --git a/internal/inspect/report_test.go b/internal/inspect/report_test.go index 6b4220451..898734c69 100644 --- a/internal/inspect/report_test.go +++ b/internal/inspect/report_test.go @@ -8,27 +8,27 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/inspect/bloat" - "github.com/supabase/cli/internal/inspect/blocking" - "github.com/supabase/cli/internal/inspect/cache" - "github.com/supabase/cli/internal/inspect/calls" - "github.com/supabase/cli/internal/inspect/index_sizes" - "github.com/supabase/cli/internal/inspect/index_usage" - "github.com/supabase/cli/internal/inspect/locks" - "github.com/supabase/cli/internal/inspect/long_running_queries" - "github.com/supabase/cli/internal/inspect/outliers" - "github.com/supabase/cli/internal/inspect/replication_slots" - "github.com/supabase/cli/internal/inspect/role_configs" - "github.com/supabase/cli/internal/inspect/role_connections" - "github.com/supabase/cli/internal/inspect/seq_scans" - "github.com/supabase/cli/internal/inspect/table_index_sizes" - "github.com/supabase/cli/internal/inspect/table_record_counts" - "github.com/supabase/cli/internal/inspect/table_sizes" - "github.com/supabase/cli/internal/inspect/total_index_size" - "github.com/supabase/cli/internal/inspect/total_table_sizes" - "github.com/supabase/cli/internal/inspect/unused_indexes" - "github.com/supabase/cli/internal/inspect/vacuum_stats" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/inspect/bloat" + "github.com/supabase/cli/v2/internal/inspect/blocking" + "github.com/supabase/cli/v2/internal/inspect/cache" + "github.com/supabase/cli/v2/internal/inspect/calls" + "github.com/supabase/cli/v2/internal/inspect/index_sizes" + "github.com/supabase/cli/v2/internal/inspect/index_usage" + "github.com/supabase/cli/v2/internal/inspect/locks" + "github.com/supabase/cli/v2/internal/inspect/long_running_queries" + "github.com/supabase/cli/v2/internal/inspect/outliers" + "github.com/supabase/cli/v2/internal/inspect/replication_slots" + "github.com/supabase/cli/v2/internal/inspect/role_configs" + "github.com/supabase/cli/v2/internal/inspect/role_connections" + "github.com/supabase/cli/v2/internal/inspect/seq_scans" + "github.com/supabase/cli/v2/internal/inspect/table_index_sizes" + "github.com/supabase/cli/v2/internal/inspect/table_record_counts" + "github.com/supabase/cli/v2/internal/inspect/table_sizes" + "github.com/supabase/cli/v2/internal/inspect/total_index_size" + "github.com/supabase/cli/v2/internal/inspect/total_table_sizes" + "github.com/supabase/cli/v2/internal/inspect/unused_indexes" + "github.com/supabase/cli/v2/internal/inspect/vacuum_stats" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/role_configs/role_configs.go b/internal/inspect/role_configs/role_configs.go index f4fb79382..9f605419f 100644 --- a/internal/inspect/role_configs/role_configs.go +++ b/internal/inspect/role_configs/role_configs.go @@ -9,9 +9,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed role_configs.sql diff --git a/internal/inspect/role_configs/role_configs_test.go b/internal/inspect/role_configs/role_configs_test.go index 554a12526..67d734301 100644 --- a/internal/inspect/role_configs/role_configs_test.go +++ b/internal/inspect/role_configs/role_configs_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/role_connections/role_connections.go b/internal/inspect/role_connections/role_connections.go index 5b0a56539..e5bec0934 100644 --- a/internal/inspect/role_connections/role_connections.go +++ b/internal/inspect/role_connections/role_connections.go @@ -9,9 +9,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed role_connections.sql diff --git a/internal/inspect/role_connections/role_connections_test.go b/internal/inspect/role_connections/role_connections_test.go index 32ecab768..b7d1ec884 100644 --- a/internal/inspect/role_connections/role_connections_test.go +++ b/internal/inspect/role_connections/role_connections_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/seq_scans/seq_scans.go b/internal/inspect/seq_scans/seq_scans.go index 6b52538ee..240112d5b 100644 --- a/internal/inspect/seq_scans/seq_scans.go +++ b/internal/inspect/seq_scans/seq_scans.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed seq_scans.sql diff --git a/internal/inspect/seq_scans/seq_scans_test.go b/internal/inspect/seq_scans/seq_scans_test.go index 3db6caee5..0e2bdfb42 100644 --- a/internal/inspect/seq_scans/seq_scans_test.go +++ b/internal/inspect/seq_scans/seq_scans_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/table_index_sizes/table_index_sizes.go b/internal/inspect/table_index_sizes/table_index_sizes.go index e61f23361..8a5b3a096 100644 --- a/internal/inspect/table_index_sizes/table_index_sizes.go +++ b/internal/inspect/table_index_sizes/table_index_sizes.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed table_index_sizes.sql diff --git a/internal/inspect/table_index_sizes/table_index_sizes_test.go b/internal/inspect/table_index_sizes/table_index_sizes_test.go index 20ad80fc9..92e58ef56 100644 --- a/internal/inspect/table_index_sizes/table_index_sizes_test.go +++ b/internal/inspect/table_index_sizes/table_index_sizes_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/table_record_counts/table_record_counts.go b/internal/inspect/table_record_counts/table_record_counts.go index e0b394374..19e32a5b3 100644 --- a/internal/inspect/table_record_counts/table_record_counts.go +++ b/internal/inspect/table_record_counts/table_record_counts.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed table_record_counts.sql diff --git a/internal/inspect/table_record_counts/table_record_counts_test.go b/internal/inspect/table_record_counts/table_record_counts_test.go index a03714d97..753074e77 100644 --- a/internal/inspect/table_record_counts/table_record_counts_test.go +++ b/internal/inspect/table_record_counts/table_record_counts_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/table_sizes/table_sizes.go b/internal/inspect/table_sizes/table_sizes.go index 7741f0119..7ce49e225 100644 --- a/internal/inspect/table_sizes/table_sizes.go +++ b/internal/inspect/table_sizes/table_sizes.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed table_sizes.sql diff --git a/internal/inspect/table_sizes/table_sizes_test.go b/internal/inspect/table_sizes/table_sizes_test.go index 5cc6426ad..057f32d14 100644 --- a/internal/inspect/table_sizes/table_sizes_test.go +++ b/internal/inspect/table_sizes/table_sizes_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/total_index_size/total_index_size.go b/internal/inspect/total_index_size/total_index_size.go index fbc66b259..bd6a13fd9 100644 --- a/internal/inspect/total_index_size/total_index_size.go +++ b/internal/inspect/total_index_size/total_index_size.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed total_index_size.sql diff --git a/internal/inspect/total_index_size/total_index_size_test.go b/internal/inspect/total_index_size/total_index_size_test.go index 8eb0e0aa9..c59401469 100644 --- a/internal/inspect/total_index_size/total_index_size_test.go +++ b/internal/inspect/total_index_size/total_index_size_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/total_table_sizes/total_table_sizes.go b/internal/inspect/total_table_sizes/total_table_sizes.go index 80b1c89a8..3b96dcadd 100644 --- a/internal/inspect/total_table_sizes/total_table_sizes.go +++ b/internal/inspect/total_table_sizes/total_table_sizes.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed total_table_sizes.sql diff --git a/internal/inspect/total_table_sizes/total_table_sizes_test.go b/internal/inspect/total_table_sizes/total_table_sizes_test.go index bc548af60..3419fc762 100644 --- a/internal/inspect/total_table_sizes/total_table_sizes_test.go +++ b/internal/inspect/total_table_sizes/total_table_sizes_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/unused_indexes/unused_indexes.go b/internal/inspect/unused_indexes/unused_indexes.go index 2a30a46d7..d7589888d 100644 --- a/internal/inspect/unused_indexes/unused_indexes.go +++ b/internal/inspect/unused_indexes/unused_indexes.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed unused_indexes.sql diff --git a/internal/inspect/unused_indexes/unused_indexes_test.go b/internal/inspect/unused_indexes/unused_indexes_test.go index ee4182094..af3936166 100644 --- a/internal/inspect/unused_indexes/unused_indexes_test.go +++ b/internal/inspect/unused_indexes/unused_indexes_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/vacuum_stats/vacuum_stats.go b/internal/inspect/vacuum_stats/vacuum_stats.go index dc9326d79..950956503 100644 --- a/internal/inspect/vacuum_stats/vacuum_stats.go +++ b/internal/inspect/vacuum_stats/vacuum_stats.go @@ -10,10 +10,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgxv5" ) //go:embed vacuum_stats.sql diff --git a/internal/inspect/vacuum_stats/vacuum_stats_test.go b/internal/inspect/vacuum_stats/vacuum_stats_test.go index 0d3cbec10..fba1e9a47 100644 --- a/internal/inspect/vacuum_stats/vacuum_stats_test.go +++ b/internal/inspect/vacuum_stats/vacuum_stats_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/db/reset" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/db/reset" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/link/link.go b/internal/link/link.go index e791271b8..5f156b11b 100644 --- a/internal/link/link.go +++ b/internal/link/link.go @@ -13,15 +13,15 @@ import ( "github.com/jackc/pgx/v4" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/credentials" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/internal/utils/tenant" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" - cliConfig "github.com/supabase/cli/pkg/config" - "github.com/supabase/cli/pkg/diff" - "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/credentials" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/internal/utils/tenant" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" + cliConfig "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/v2/pkg/diff" + "github.com/supabase/cli/v2/pkg/migration" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/link/link_test.go b/internal/link/link_test.go index 18c090ad3..4f05a296e 100644 --- a/internal/link/link_test.go +++ b/internal/link/link_test.go @@ -12,14 +12,14 @@ import ( "github.com/jackc/pgx/v4" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/testing/helper" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/tenant" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/migration" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/testing/helper" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/tenant" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/v2/pkg/pgtest" "github.com/zalando/go-keyring" ) diff --git a/internal/login/login.go b/internal/login/login.go index 6239b500a..be1265bec 100644 --- a/internal/login/login.go +++ b/internal/login/login.go @@ -20,9 +20,9 @@ import ( "github.com/go-errors/errors" "github.com/google/uuid" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/new" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/v2/internal/migration/new" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/fetcher" ) type RunParams struct { diff --git a/internal/login/login_test.go b/internal/login/login_test.go index 758fbc5c4..8dd02deab 100644 --- a/internal/login/login_test.go +++ b/internal/login/login_test.go @@ -12,9 +12,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/credentials" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/credentials" "github.com/zalando/go-keyring" ) diff --git a/internal/logout/logout.go b/internal/logout/logout.go index abbd191b8..ae71bf00b 100644 --- a/internal/logout/logout.go +++ b/internal/logout/logout.go @@ -7,8 +7,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/credentials" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/credentials" ) func Run(ctx context.Context, stdout *os.File, fsys afero.Fs) error { diff --git a/internal/logout/logout_test.go b/internal/logout/logout_test.go index 42f9f8ead..5a7835824 100644 --- a/internal/logout/logout_test.go +++ b/internal/logout/logout_test.go @@ -8,10 +8,10 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/credentials" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/credentials" "github.com/zalando/go-keyring" ) diff --git a/internal/migration/apply/apply.go b/internal/migration/apply/apply.go index 224b342f7..ea7f6cb8b 100644 --- a/internal/migration/apply/apply.go +++ b/internal/migration/apply/apply.go @@ -5,9 +5,9 @@ import ( "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" ) func MigrateAndSeed(ctx context.Context, version string, conn *pgx.Conn, fsys afero.Fs) error { diff --git a/internal/migration/apply/apply_test.go b/internal/migration/apply/apply_test.go index 286093743..49165f275 100644 --- a/internal/migration/apply/apply_test.go +++ b/internal/migration/apply/apply_test.go @@ -9,11 +9,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/testing/helper" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/testing/helper" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/v2/pkg/pgtest" ) func TestMigrateDatabase(t *testing.T) { diff --git a/internal/migration/fetch/fetch.go b/internal/migration/fetch/fetch.go index cb78c70d8..fac525787 100644 --- a/internal/migration/fetch/fetch.go +++ b/internal/migration/fetch/fetch.go @@ -10,8 +10,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" ) func Run(ctx context.Context, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/migration/list/list.go b/internal/migration/list/list.go index 3107d4ec6..d1202d068 100644 --- a/internal/migration/list/list.go +++ b/internal/migration/list/list.go @@ -11,8 +11,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" ) func Run(ctx context.Context, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/migration/list/list_test.go b/internal/migration/list/list_test.go index b23fa4a2d..c68ade375 100644 --- a/internal/migration/list/list_test.go +++ b/internal/migration/list/list_test.go @@ -12,10 +12,10 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/migration/new/new.go b/internal/migration/new/new.go index be232b591..026c54c7b 100644 --- a/internal/migration/new/new.go +++ b/internal/migration/new/new.go @@ -8,7 +8,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func Run(migrationName string, stdin afero.File, fsys afero.Fs) error { diff --git a/internal/migration/new/new_test.go b/internal/migration/new/new_test.go index 39e2fe115..232623cb1 100644 --- a/internal/migration/new/new_test.go +++ b/internal/migration/new/new_test.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func TestNewCommand(t *testing.T) { diff --git a/internal/migration/repair/repair.go b/internal/migration/repair/repair.go index c0670000a..b43779aa6 100644 --- a/internal/migration/repair/repair.go +++ b/internal/migration/repair/repair.go @@ -11,9 +11,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" ) const ( diff --git a/internal/migration/repair/repair_test.go b/internal/migration/repair/repair_test.go index 4dea63279..cb035c489 100644 --- a/internal/migration/repair/repair_test.go +++ b/internal/migration/repair/repair_test.go @@ -12,11 +12,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/testing/helper" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/testing/helper" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/migration/squash/squash.go b/internal/migration/squash/squash.go index 2ed9e6252..64429d260 100644 --- a/internal/migration/squash/squash.go +++ b/internal/migration/squash/squash.go @@ -14,13 +14,13 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/diff" - "github.com/supabase/cli/internal/db/dump" - "github.com/supabase/cli/internal/db/start" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/migration/repair" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/v2/internal/db/diff" + "github.com/supabase/cli/v2/internal/db/dump" + "github.com/supabase/cli/v2/internal/db/start" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/migration/repair" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" ) var ErrMissingVersion = errors.New("version not found") diff --git a/internal/migration/squash/squash_test.go b/internal/migration/squash/squash_test.go index cc0461f3b..1cbd85849 100644 --- a/internal/migration/squash/squash_test.go +++ b/internal/migration/squash/squash_test.go @@ -21,14 +21,14 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/db/start" - "github.com/supabase/cli/internal/migration/repair" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/testing/helper" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/db/start" + "github.com/supabase/cli/v2/internal/migration/repair" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/testing/helper" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/migration/up/up.go b/internal/migration/up/up.go index d33117f33..8229fd6ed 100644 --- a/internal/migration/up/up.go +++ b/internal/migration/up/up.go @@ -9,8 +9,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" ) func Run(ctx context.Context, includeAll bool, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/migration/up/up_test.go b/internal/migration/up/up_test.go index ea41680bc..69e9c5ecd 100644 --- a/internal/migration/up/up_test.go +++ b/internal/migration/up/up_test.go @@ -9,10 +9,10 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/migration" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/v2/pkg/pgtest" ) func TestPendingMigrations(t *testing.T) { diff --git a/internal/orgs/create/create.go b/internal/orgs/create/create.go index ed6008ab3..df7c1eec5 100644 --- a/internal/orgs/create/create.go +++ b/internal/orgs/create/create.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, name string) error { diff --git a/internal/orgs/create/create_test.go b/internal/orgs/create/create_test.go index f491bdc31..8792188f6 100644 --- a/internal/orgs/create/create_test.go +++ b/internal/orgs/create/create_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func TestOrganizationCreateCommand(t *testing.T) { diff --git a/internal/orgs/list/list.go b/internal/orgs/list/list.go index abd6c08df..4eb7487f0 100644 --- a/internal/orgs/list/list.go +++ b/internal/orgs/list/list.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context) error { diff --git a/internal/orgs/list/list_test.go b/internal/orgs/list/list_test.go index 00030dbd2..d538f5fea 100644 --- a/internal/orgs/list/list_test.go +++ b/internal/orgs/list/list_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func TestOrganizationListCommand(t *testing.T) { diff --git a/internal/postgresConfig/get/get.go b/internal/postgresConfig/get/get.go index ad311b396..535f0f171 100644 --- a/internal/postgresConfig/get/get.go +++ b/internal/postgresConfig/get/get.go @@ -9,8 +9,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/postgresConfig/update/update.go b/internal/postgresConfig/update/update.go index 94632d486..9c8bec823 100644 --- a/internal/postgresConfig/update/update.go +++ b/internal/postgresConfig/update/update.go @@ -9,8 +9,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/postgresConfig/get" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/postgresConfig/get" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, projectRef string, values []string, replaceOverrides, noRestart bool, fsys afero.Fs) error { diff --git a/internal/projects/apiKeys/api_keys.go b/internal/projects/apiKeys/api_keys.go index 7daddce21..be5035a5b 100644 --- a/internal/projects/apiKeys/api_keys.go +++ b/internal/projects/apiKeys/api_keys.go @@ -8,9 +8,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/projects/apiKeys/api_keys_test.go b/internal/projects/apiKeys/api_keys_test.go index 57130f158..e94a999ce 100644 --- a/internal/projects/apiKeys/api_keys_test.go +++ b/internal/projects/apiKeys/api_keys_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func TestProjectApiKeysCommand(t *testing.T) { diff --git a/internal/projects/create/create.go b/internal/projects/create/create.go index ddbd46b47..671020f1f 100644 --- a/internal/projects/create/create.go +++ b/internal/projects/create/create.go @@ -9,10 +9,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/credentials" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/credentials" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, params api.V1CreateProjectBodyDto, fsys afero.Fs) error { diff --git a/internal/projects/create/create_test.go b/internal/projects/create/create_test.go index 879421d72..8db8ef3da 100644 --- a/internal/projects/create/create_test.go +++ b/internal/projects/create/create_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func TestProjectCreateCommand(t *testing.T) { diff --git a/internal/projects/delete/delete.go b/internal/projects/delete/delete.go index f042f62e1..dda1dd297 100644 --- a/internal/projects/delete/delete.go +++ b/internal/projects/delete/delete.go @@ -8,9 +8,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/unlink" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/credentials" + "github.com/supabase/cli/v2/internal/unlink" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/credentials" "github.com/zalando/go-keyring" ) diff --git a/internal/projects/delete/delete_test.go b/internal/projects/delete/delete_test.go index b83d4cf8c..aaa441229 100644 --- a/internal/projects/delete/delete_test.go +++ b/internal/projects/delete/delete_test.go @@ -10,9 +10,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" "github.com/zalando/go-keyring" ) diff --git a/internal/projects/list/list.go b/internal/projects/list/list.go index ef356dfcf..23dae8f07 100644 --- a/internal/projects/list/list.go +++ b/internal/projects/list/list.go @@ -8,10 +8,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/api" ) type linkedProject struct { diff --git a/internal/projects/list/list_test.go b/internal/projects/list/list_test.go index d5450bfb4..31a1bc716 100644 --- a/internal/projects/list/list_test.go +++ b/internal/projects/list/list_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func TestProjectListCommand(t *testing.T) { diff --git a/internal/restrictions/get/get.go b/internal/restrictions/get/get.go index f8e27342d..ffd4d8fb0 100644 --- a/internal/restrictions/get/get.go +++ b/internal/restrictions/get/get.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, projectRef string) error { diff --git a/internal/restrictions/update/update.go b/internal/restrictions/update/update.go index 98a70da98..8b5718a76 100644 --- a/internal/restrictions/update/update.go +++ b/internal/restrictions/update/update.go @@ -6,8 +6,8 @@ import ( "net" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, projectRef string, dbCidrsToAllow []string, bypassCidrChecks bool) error { diff --git a/internal/restrictions/update/update_test.go b/internal/restrictions/update/update_test.go index 5a6583ea8..e23a3101e 100644 --- a/internal/restrictions/update/update_test.go +++ b/internal/restrictions/update/update_test.go @@ -8,9 +8,9 @@ import ( "github.com/go-errors/errors" "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func TestUpdateRestrictionsCommand(t *testing.T) { diff --git a/internal/secrets/list/list.go b/internal/secrets/list/list.go index e5b4d4538..9cf4efa6a 100644 --- a/internal/secrets/list/list.go +++ b/internal/secrets/list/list.go @@ -8,9 +8,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/secrets/list/list_test.go b/internal/secrets/list/list_test.go index 4e0da98b6..4e831d38c 100644 --- a/internal/secrets/list/list_test.go +++ b/internal/secrets/list/list_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func TestSecretListCommand(t *testing.T) { diff --git a/internal/secrets/set/set.go b/internal/secrets/set/set.go index d2877c314..14e715c7a 100644 --- a/internal/secrets/set/set.go +++ b/internal/secrets/set/set.go @@ -12,8 +12,8 @@ import ( "github.com/go-errors/errors" "github.com/joho/godotenv" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, projectRef, envFilePath string, args []string, fsys afero.Fs) error { diff --git a/internal/secrets/set/set_test.go b/internal/secrets/set/set_test.go index 6021804c1..beb15c7fd 100644 --- a/internal/secrets/set/set_test.go +++ b/internal/secrets/set/set_test.go @@ -10,9 +10,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func TestSecretSetCommand(t *testing.T) { diff --git a/internal/secrets/unset/unset.go b/internal/secrets/unset/unset.go index f6bbca8cf..e9f680d14 100644 --- a/internal/secrets/unset/unset.go +++ b/internal/secrets/unset/unset.go @@ -9,8 +9,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/secrets/list" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/secrets/list" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, projectRef string, args []string, fsys afero.Fs) error { diff --git a/internal/secrets/unset/unset_test.go b/internal/secrets/unset/unset_test.go index 3207f8df7..e3f6d9dff 100644 --- a/internal/secrets/unset/unset_test.go +++ b/internal/secrets/unset/unset_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func TestSecretUnsetCommand(t *testing.T) { diff --git a/internal/seed/buckets/buckets.go b/internal/seed/buckets/buckets.go index b460fdc79..f68344828 100644 --- a/internal/seed/buckets/buckets.go +++ b/internal/seed/buckets/buckets.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/spf13/afero" - "github.com/supabase/cli/internal/storage/client" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/storage/client" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, projectRef string, interactive bool, fsys afero.Fs) error { diff --git a/internal/seed/buckets/buckets_test.go b/internal/seed/buckets/buckets_test.go index e14a40e74..9e9c7b1a5 100644 --- a/internal/seed/buckets/buckets_test.go +++ b/internal/seed/buckets/buckets_test.go @@ -11,9 +11,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/storage" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/storage" ) func TestSeedBuckets(t *testing.T) { diff --git a/internal/services/services.go b/internal/services/services.go index ebc08efca..e32a3ad57 100644 --- a/internal/services/services.go +++ b/internal/services/services.go @@ -9,10 +9,10 @@ import ( "sync" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/internal/utils/tenant" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/internal/utils/tenant" ) func Run(ctx context.Context, fsys afero.Fs) error { diff --git a/internal/snippets/download/download.go b/internal/snippets/download/download.go index 7f1f3a463..f983d2101 100644 --- a/internal/snippets/download/download.go +++ b/internal/snippets/download/download.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, snippetId string, fsys afero.Fs) error { diff --git a/internal/snippets/list/list.go b/internal/snippets/list/list.go index f54325eaa..c3c651f7b 100644 --- a/internal/snippets/list/list.go +++ b/internal/snippets/list/list.go @@ -7,10 +7,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, fsys afero.Fs) error { diff --git a/internal/ssl_enforcement/get/get.go b/internal/ssl_enforcement/get/get.go index e6d58693e..50673d9c9 100644 --- a/internal/ssl_enforcement/get/get.go +++ b/internal/ssl_enforcement/get/get.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/ssl_enforcement/update/update.go b/internal/ssl_enforcement/update/update.go index 51b0b6725..f5805d108 100644 --- a/internal/ssl_enforcement/update/update.go +++ b/internal/ssl_enforcement/update/update.go @@ -6,8 +6,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, projectRef string, enforceDbSsl bool, fsys afero.Fs) error { diff --git a/internal/sso/create/create.go b/internal/sso/create/create.go index a33b6e7e7..1b24e12a9 100644 --- a/internal/sso/create/create.go +++ b/internal/sso/create/create.go @@ -7,10 +7,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/sso/internal/render" - "github.com/supabase/cli/internal/sso/internal/saml" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/sso/internal/render" + "github.com/supabase/cli/v2/internal/sso/internal/saml" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) var Fs = afero.NewOsFs() diff --git a/internal/sso/get/get.go b/internal/sso/get/get.go index 34370523e..43a8e206e 100644 --- a/internal/sso/get/get.go +++ b/internal/sso/get/get.go @@ -7,9 +7,9 @@ import ( "os" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/sso/internal/render" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/sso/internal/render" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, ref, providerId, format string) error { diff --git a/internal/sso/get/get_test.go b/internal/sso/get/get_test.go index bd6fd0ef3..3c506ce78 100644 --- a/internal/sso/get/get_test.go +++ b/internal/sso/get/get_test.go @@ -7,8 +7,8 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" ) func TestSSOProvidersShowCommand(t *testing.T) { diff --git a/internal/sso/info/info.go b/internal/sso/info/info.go index c8a25805f..ffe51b8b0 100644 --- a/internal/sso/info/info.go +++ b/internal/sso/info/info.go @@ -5,8 +5,8 @@ import ( "fmt" "os" - "github.com/supabase/cli/internal/sso/internal/render" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/sso/internal/render" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, ref string, format string) error { diff --git a/internal/sso/internal/render/render.go b/internal/sso/internal/render/render.go index 3f3a03db1..3e45b2e01 100644 --- a/internal/sso/internal/render/render.go +++ b/internal/sso/internal/render/render.go @@ -7,9 +7,9 @@ import ( "github.com/go-errors/errors" "github.com/go-xmlfmt/xmlfmt" - "github.com/supabase/cli/internal/migration/list" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/migration/list" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func formatProtocol(provider api.Provider) string { diff --git a/internal/sso/internal/saml/files.go b/internal/sso/internal/saml/files.go index 62e0846e3..3b47dbe9d 100644 --- a/internal/sso/internal/saml/files.go +++ b/internal/sso/internal/saml/files.go @@ -12,8 +12,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/fetcher" ) var DefaultClient = http.DefaultClient diff --git a/internal/sso/list/list.go b/internal/sso/list/list.go index efacb1a04..181a86aff 100644 --- a/internal/sso/list/list.go +++ b/internal/sso/list/list.go @@ -6,8 +6,8 @@ import ( "os" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/sso/internal/render" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/sso/internal/render" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, ref, format string) error { diff --git a/internal/sso/list/list_test.go b/internal/sso/list/list_test.go index 333ffd4a3..50ab8d745 100644 --- a/internal/sso/list/list_test.go +++ b/internal/sso/list/list_test.go @@ -6,8 +6,8 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" ) func TestSSOProvidersListCommand(t *testing.T) { diff --git a/internal/sso/remove/remove.go b/internal/sso/remove/remove.go index 1514314da..a8b5b1ccf 100644 --- a/internal/sso/remove/remove.go +++ b/internal/sso/remove/remove.go @@ -6,9 +6,9 @@ import ( "os" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/sso/internal/render" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/sso/internal/render" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, ref, providerId, format string) error { diff --git a/internal/sso/remove/remove_test.go b/internal/sso/remove/remove_test.go index f284f7e06..c606c8628 100644 --- a/internal/sso/remove/remove_test.go +++ b/internal/sso/remove/remove_test.go @@ -7,8 +7,8 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" ) func TestSSOProvidersRemoveCommand(t *testing.T) { diff --git a/internal/sso/update/update.go b/internal/sso/update/update.go index e8a745dc3..5a412fed7 100644 --- a/internal/sso/update/update.go +++ b/internal/sso/update/update.go @@ -7,10 +7,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/sso/internal/render" - "github.com/supabase/cli/internal/sso/internal/saml" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/sso/internal/render" + "github.com/supabase/cli/v2/internal/sso/internal/saml" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) var Fs = afero.NewOsFs() diff --git a/internal/sso/update/update_test.go b/internal/sso/update/update_test.go index 6754fd487..dd423dadd 100644 --- a/internal/sso/update/update_test.go +++ b/internal/sso/update/update_test.go @@ -10,9 +10,9 @@ import ( "github.com/google/uuid" "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func response(providerId string, domains []string) map[string]any { diff --git a/internal/start/start.go b/internal/start/start.go index 4315d31b7..c74f6287f 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -23,14 +23,14 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/internal/db/start" - "github.com/supabase/cli/internal/functions/serve" - "github.com/supabase/cli/internal/seed/buckets" - "github.com/supabase/cli/internal/services" - "github.com/supabase/cli/internal/status" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/v2/internal/db/start" + "github.com/supabase/cli/v2/internal/functions/serve" + "github.com/supabase/cli/v2/internal/seed/buckets" + "github.com/supabase/cli/v2/internal/services" + "github.com/supabase/cli/v2/internal/status" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/config" "golang.org/x/mod/semver" ) diff --git a/internal/start/start_test.go b/internal/start/start_test.go index 079eb3c79..93af236d9 100644 --- a/internal/start/start_test.go +++ b/internal/start/start_test.go @@ -17,11 +17,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/config" - "github.com/supabase/cli/pkg/pgtest" - "github.com/supabase/cli/pkg/storage" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/storage" ) func TestStartCommand(t *testing.T) { diff --git a/internal/status/status.go b/internal/status/status.go index 1b9d02f90..bcd8ff8bf 100644 --- a/internal/status/status.go +++ b/internal/status/status.go @@ -18,8 +18,8 @@ import ( "github.com/docker/docker/api/types/container" "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/fetcher" ) type CustomName struct { diff --git a/internal/status/status_test.go b/internal/status/status_test.go index 391a8c998..792b99c65 100644 --- a/internal/status/status_test.go +++ b/internal/status/status_test.go @@ -13,8 +13,8 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" ) func TestStatusCommand(t *testing.T) { diff --git a/internal/stop/stop.go b/internal/stop/stop.go index 39c5e00e5..fc9dfebd5 100644 --- a/internal/stop/stop.go +++ b/internal/stop/stop.go @@ -8,7 +8,7 @@ import ( "github.com/docker/docker/api/types/volume" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, backup bool, projectId string, all bool, fsys afero.Fs) error { diff --git a/internal/stop/stop_test.go b/internal/stop/stop_test.go index b607d87d7..cc287cb9e 100644 --- a/internal/stop/stop_test.go +++ b/internal/stop/stop_test.go @@ -18,8 +18,8 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" ) func TestStopCommand(t *testing.T) { diff --git a/internal/storage/client/api.go b/internal/storage/client/api.go index c8c2a02ef..ea44f3c7b 100644 --- a/internal/storage/client/api.go +++ b/internal/storage/client/api.go @@ -5,11 +5,11 @@ import ( "net/http" "github.com/spf13/viper" - "github.com/supabase/cli/internal/status" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/tenant" - "github.com/supabase/cli/pkg/fetcher" - "github.com/supabase/cli/pkg/storage" + "github.com/supabase/cli/v2/internal/status" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/tenant" + "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/storage" ) func NewStorageAPI(ctx context.Context, projectRef string) (storage.StorageAPI, error) { diff --git a/internal/storage/cp/cp.go b/internal/storage/cp/cp.go index e55120a1c..6c5df9f31 100644 --- a/internal/storage/cp/cp.go +++ b/internal/storage/cp/cp.go @@ -12,12 +12,12 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/storage/client" - "github.com/supabase/cli/internal/storage/ls" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/queue" - "github.com/supabase/cli/pkg/storage" + "github.com/supabase/cli/v2/internal/storage/client" + "github.com/supabase/cli/v2/internal/storage/ls" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/queue" + "github.com/supabase/cli/v2/pkg/storage" ) var errUnsupportedOperation = errors.New("Unsupported operation") diff --git a/internal/storage/cp/cp_test.go b/internal/storage/cp/cp_test.go index 75a0cf3cd..83e787692 100644 --- a/internal/storage/cp/cp_test.go +++ b/internal/storage/cp/cp_test.go @@ -10,13 +10,13 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" - "github.com/supabase/cli/pkg/fetcher" - "github.com/supabase/cli/pkg/storage" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/storage" ) var mockFile = storage.ObjectResponse{ diff --git a/internal/storage/ls/ls.go b/internal/storage/ls/ls.go index 396dc9b7c..0f521ce97 100644 --- a/internal/storage/ls/ls.go +++ b/internal/storage/ls/ls.go @@ -8,9 +8,9 @@ import ( "strings" "github.com/spf13/afero" - "github.com/supabase/cli/internal/storage/client" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/storage" + "github.com/supabase/cli/v2/internal/storage/client" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/storage" ) func Run(ctx context.Context, objectPath string, recursive bool, fsys afero.Fs) error { diff --git a/internal/storage/ls/ls_test.go b/internal/storage/ls/ls_test.go index e0e2cd207..bef37987d 100644 --- a/internal/storage/ls/ls_test.go +++ b/internal/storage/ls/ls_test.go @@ -9,14 +9,14 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/storage/client" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" - "github.com/supabase/cli/pkg/fetcher" - "github.com/supabase/cli/pkg/storage" + "github.com/supabase/cli/v2/internal/storage/client" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/storage" ) var mockFile = storage.ObjectResponse{ diff --git a/internal/storage/mv/mv.go b/internal/storage/mv/mv.go index a6dc8773c..91f0ef3b2 100644 --- a/internal/storage/mv/mv.go +++ b/internal/storage/mv/mv.go @@ -9,10 +9,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/storage/client" - "github.com/supabase/cli/internal/storage/ls" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/storage" + "github.com/supabase/cli/v2/internal/storage/client" + "github.com/supabase/cli/v2/internal/storage/ls" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/storage" ) var ( diff --git a/internal/storage/mv/mv_test.go b/internal/storage/mv/mv_test.go index fd8ecfbcc..65164cc46 100644 --- a/internal/storage/mv/mv_test.go +++ b/internal/storage/mv/mv_test.go @@ -8,13 +8,13 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" - "github.com/supabase/cli/pkg/fetcher" - "github.com/supabase/cli/pkg/storage" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/storage" ) var mockFile = storage.ObjectResponse{ diff --git a/internal/storage/rm/rm.go b/internal/storage/rm/rm.go index 720bbce02..8734cc8ca 100644 --- a/internal/storage/rm/rm.go +++ b/internal/storage/rm/rm.go @@ -8,12 +8,12 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/storage/client" - "github.com/supabase/cli/internal/storage/cp" - "github.com/supabase/cli/internal/storage/ls" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/storage" + "github.com/supabase/cli/v2/internal/storage/client" + "github.com/supabase/cli/v2/internal/storage/cp" + "github.com/supabase/cli/v2/internal/storage/ls" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/storage" ) var ( diff --git a/internal/storage/rm/rm_test.go b/internal/storage/rm/rm_test.go index 46d204cf0..c04a79a6a 100644 --- a/internal/storage/rm/rm_test.go +++ b/internal/storage/rm/rm_test.go @@ -8,14 +8,14 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" - "github.com/supabase/cli/pkg/fetcher" - "github.com/supabase/cli/pkg/storage" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/storage" ) var mockFile = storage.ObjectResponse{ diff --git a/internal/test/new/new.go b/internal/test/new/new.go index 506a9e02e..babe62194 100644 --- a/internal/test/new/new.go +++ b/internal/test/new/new.go @@ -8,7 +8,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) const ( diff --git a/internal/test/new/new_test.go b/internal/test/new/new_test.go index d3f980157..a03e63dbf 100644 --- a/internal/test/new/new_test.go +++ b/internal/test/new/new_test.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func TestCreatePgTAP(t *testing.T) { diff --git a/internal/testing/helper/history.go b/internal/testing/helper/history.go index 95c846b7a..7c5436dc4 100644 --- a/internal/testing/helper/history.go +++ b/internal/testing/helper/history.go @@ -1,8 +1,8 @@ package helper import ( - "github.com/supabase/cli/pkg/migration" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/v2/pkg/pgtest" ) func MockMigrationHistory(conn *pgtest.MockConn) *pgtest.MockConn { diff --git a/internal/unlink/unlink.go b/internal/unlink/unlink.go index b59f4d1f0..5750f647d 100644 --- a/internal/unlink/unlink.go +++ b/internal/unlink/unlink.go @@ -7,8 +7,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/credentials" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/credentials" "github.com/zalando/go-keyring" ) diff --git a/internal/unlink/unlink_test.go b/internal/unlink/unlink_test.go index 9b526e109..e5967005a 100644 --- a/internal/unlink/unlink_test.go +++ b/internal/unlink/unlink_test.go @@ -8,9 +8,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/credentials" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/credentials" "github.com/zalando/go-keyring" ) diff --git a/internal/utils/access_token.go b/internal/utils/access_token.go index f7ef90a01..bd48823cb 100644 --- a/internal/utils/access_token.go +++ b/internal/utils/access_token.go @@ -7,7 +7,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils/credentials" + "github.com/supabase/cli/v2/internal/utils/credentials" "github.com/zalando/go-keyring" ) diff --git a/internal/utils/access_token_test.go b/internal/utils/access_token_test.go index f31988876..d05e5f3cd 100644 --- a/internal/utils/access_token_test.go +++ b/internal/utils/access_token_test.go @@ -7,9 +7,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/utils/credentials" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/utils/credentials" "github.com/zalando/go-keyring" ) diff --git a/internal/utils/api.go b/internal/utils/api.go index 32b199b69..271d8cebf 100644 --- a/internal/utils/api.go +++ b/internal/utils/api.go @@ -14,9 +14,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/viper" - "github.com/supabase/cli/internal/utils/cloudflare" - supabase "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/v2/internal/utils/cloudflare" + supabase "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" ) const ( diff --git a/internal/utils/api_test.go b/internal/utils/api_test.go index 09365897d..8a858441e 100644 --- a/internal/utils/api_test.go +++ b/internal/utils/api_test.go @@ -10,8 +10,8 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils/cloudflare" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils/cloudflare" ) const host = "api.supabase.io" diff --git a/internal/utils/cloudflare/api.go b/internal/utils/cloudflare/api.go index 7c7cf10a2..eeadef033 100644 --- a/internal/utils/cloudflare/api.go +++ b/internal/utils/cloudflare/api.go @@ -4,7 +4,7 @@ import ( "net/http" "time" - "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/fetcher" ) type CloudflareAPI struct { diff --git a/internal/utils/cloudflare/dns.go b/internal/utils/cloudflare/dns.go index f8a06367c..739968ef9 100644 --- a/internal/utils/cloudflare/dns.go +++ b/internal/utils/cloudflare/dns.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/google/go-querystring/query" - "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/fetcher" ) type DNSType uint16 diff --git a/internal/utils/config.go b/internal/utils/config.go index 3f89dc75c..13af5cd34 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -12,7 +12,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/v2/pkg/config" ) var ( diff --git a/internal/utils/connect.go b/internal/utils/connect.go index 9479d4e4f..c4f20df56 100644 --- a/internal/utils/connect.go +++ b/internal/utils/connect.go @@ -13,8 +13,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/viper" - "github.com/supabase/cli/internal/debug" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/internal/debug" + "github.com/supabase/cli/v2/pkg/pgxv5" ) func ToPostgresURL(config pgconn.Config) string { diff --git a/internal/utils/connect_test.go b/internal/utils/connect_test.go index 4ea76c126..f66b66659 100644 --- a/internal/utils/connect_test.go +++ b/internal/utils/connect_test.go @@ -12,9 +12,9 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/utils/cloudflare" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/utils/cloudflare" + "github.com/supabase/cli/v2/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/utils/console.go b/internal/utils/console.go index 85bebdc1e..54c36b968 100644 --- a/internal/utils/console.go +++ b/internal/utils/console.go @@ -10,7 +10,7 @@ import ( "time" "github.com/go-errors/errors" - "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/v2/pkg/cast" "golang.org/x/term" ) diff --git a/internal/utils/console_test.go b/internal/utils/console_test.go index 19857ee11..5fbd53db5 100644 --- a/internal/utils/console_test.go +++ b/internal/utils/console_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/testing/fstest" ) func TestPromptYesNo(t *testing.T) { diff --git a/internal/utils/docker_test.go b/internal/utils/docker_test.go index 6a0cdf034..ef166611b 100644 --- a/internal/utils/docker_test.go +++ b/internal/utils/docker_test.go @@ -16,7 +16,7 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/testing/apitest" ) const ( diff --git a/internal/utils/flags/db_url.go b/internal/utils/flags/db_url.go index 013453b86..a08c6f0ba 100644 --- a/internal/utils/flags/db_url.go +++ b/internal/utils/flags/db_url.go @@ -12,9 +12,9 @@ import ( "github.com/spf13/afero" "github.com/spf13/pflag" "github.com/spf13/viper" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/credentials" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/internal/utils/credentials" + "github.com/supabase/cli/v2/pkg/api" ) type connection int diff --git a/internal/utils/flags/project_ref.go b/internal/utils/flags/project_ref.go index 73df72353..e8f675a16 100644 --- a/internal/utils/flags/project_ref.go +++ b/internal/utils/flags/project_ref.go @@ -9,7 +9,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" "golang.org/x/term" ) diff --git a/internal/utils/flags/project_ref_test.go b/internal/utils/flags/project_ref_test.go index 9932d6176..ca910e23d 100644 --- a/internal/utils/flags/project_ref_test.go +++ b/internal/utils/flags/project_ref_test.go @@ -11,10 +11,10 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/internal/testing/fstest" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func TestProjectRef(t *testing.T) { diff --git a/internal/utils/release_test.go b/internal/utils/release_test.go index 25aa920e8..c5f413274 100644 --- a/internal/utils/release_test.go +++ b/internal/utils/release_test.go @@ -9,8 +9,8 @@ import ( "github.com/google/go-github/v62/github" "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/internal/testing/apitest" - "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/v2/pkg/cast" ) func TestLatestRelease(t *testing.T) { diff --git a/internal/utils/tenant/client.go b/internal/utils/tenant/client.go index ad0ef6aa7..f932a5310 100644 --- a/internal/utils/tenant/client.go +++ b/internal/utils/tenant/client.go @@ -6,9 +6,9 @@ import ( "time" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/fetcher" ) var ( diff --git a/internal/utils/tenant/database.go b/internal/utils/tenant/database.go index 1ae1ee6a7..4f733e29c 100644 --- a/internal/utils/tenant/database.go +++ b/internal/utils/tenant/database.go @@ -4,7 +4,7 @@ import ( "context" "github.com/go-errors/errors" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) var errDatabaseVersion = errors.New("Database version not found.") diff --git a/internal/utils/tenant/gotrue.go b/internal/utils/tenant/gotrue.go index 507a63af5..64269b276 100644 --- a/internal/utils/tenant/gotrue.go +++ b/internal/utils/tenant/gotrue.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/go-errors/errors" - "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/fetcher" ) var errGotrueVersion = errors.New("GoTrue version not found.") diff --git a/internal/utils/tenant/gotrue_test.go b/internal/utils/tenant/gotrue_test.go index fcc646e0d..8c08d486f 100644 --- a/internal/utils/tenant/gotrue_test.go +++ b/internal/utils/tenant/gotrue_test.go @@ -8,7 +8,7 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/fetcher" ) var mockApi = TenantAPI{Fetcher: fetcher.NewFetcher( diff --git a/internal/utils/tenant/postgrest.go b/internal/utils/tenant/postgrest.go index cb8c96d28..00293b4cf 100644 --- a/internal/utils/tenant/postgrest.go +++ b/internal/utils/tenant/postgrest.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/go-errors/errors" - "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/fetcher" ) var errPostgrestVersion = errors.New("PostgREST version not found.") diff --git a/internal/vanity_subdomains/activate/activate.go b/internal/vanity_subdomains/activate/activate.go index 133ec7edd..2a968d88c 100644 --- a/internal/vanity_subdomains/activate/activate.go +++ b/internal/vanity_subdomains/activate/activate.go @@ -7,8 +7,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, projectRef string, desiredSubdomain string, fsys afero.Fs) error { diff --git a/internal/vanity_subdomains/check/check.go b/internal/vanity_subdomains/check/check.go index 390122707..6a8bf9ddd 100644 --- a/internal/vanity_subdomains/check/check.go +++ b/internal/vanity_subdomains/check/check.go @@ -7,8 +7,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/api" ) func Run(ctx context.Context, projectRef string, desiredSubdomain string, fsys afero.Fs) error { diff --git a/internal/vanity_subdomains/delete/delete.go b/internal/vanity_subdomains/delete/delete.go index 3ee24d473..592e2880f 100644 --- a/internal/vanity_subdomains/delete/delete.go +++ b/internal/vanity_subdomains/delete/delete.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/vanity_subdomains/get/get.go b/internal/vanity_subdomains/get/get.go index b466f1895..450b54f4b 100644 --- a/internal/vanity_subdomains/get/get.go +++ b/internal/vanity_subdomains/get/get.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/main.go b/main.go index 9b54f5ec4..be8d4dc88 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/supabase/cli/cmd" + "github.com/supabase/cli/v2/cmd" ) //go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen --config=pkg/api/types.cfg.yaml api/beta.yaml diff --git a/pkg/config/api.go b/pkg/config/api.go index ec7c4f86d..509e61e56 100644 --- a/pkg/config/api.go +++ b/pkg/config/api.go @@ -3,9 +3,9 @@ package config import ( "strings" - v1API "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" - "github.com/supabase/cli/pkg/diff" + v1API "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/v2/pkg/diff" ) type ( diff --git a/pkg/config/api_test.go b/pkg/config/api_test.go index 92859c671..951ea3c7c 100644 --- a/pkg/config/api_test.go +++ b/pkg/config/api_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - v1API "github.com/supabase/cli/pkg/api" + v1API "github.com/supabase/cli/v2/pkg/api" ) func TestApiToUpdatePostgrestConfigBody(t *testing.T) { diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 5cb551cd1..c02923df7 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -5,9 +5,9 @@ import ( "strings" "time" - v1API "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" - "github.com/supabase/cli/pkg/diff" + v1API "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/v2/pkg/diff" ) type PasswordRequirements string diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index 057c5ccdd..428a6d055 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -8,8 +8,8 @@ import ( "github.com/go-errors/errors" "github.com/stretchr/testify/assert" - v1API "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" + v1API "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" ) func newWithDefaults() auth { diff --git a/pkg/config/config.go b/pkg/config/config.go index 938016e83..425e02c12 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -30,8 +30,8 @@ import ( "github.com/joho/godotenv" "github.com/mitchellh/mapstructure" "github.com/spf13/viper" - "github.com/supabase/cli/pkg/cast" - "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/v2/pkg/fetcher" "golang.org/x/mod/semver" ) diff --git a/pkg/config/db.go b/pkg/config/db.go index 2a1d31cad..e08176587 100644 --- a/pkg/config/db.go +++ b/pkg/config/db.go @@ -3,9 +3,9 @@ package config import ( "bytes" - v1API "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" - "github.com/supabase/cli/pkg/diff" + v1API "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/v2/pkg/diff" ) type PoolMode string diff --git a/pkg/config/db_test.go b/pkg/config/db_test.go index 575fd202d..8e7006d14 100644 --- a/pkg/config/db_test.go +++ b/pkg/config/db_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - v1API "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" + v1API "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" ) func TestDbSettingsToUpdatePostgresConfigBody(t *testing.T) { diff --git a/pkg/config/storage.go b/pkg/config/storage.go index b11b28a10..b56907895 100644 --- a/pkg/config/storage.go +++ b/pkg/config/storage.go @@ -1,9 +1,9 @@ package config import ( - v1API "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" - "github.com/supabase/cli/pkg/diff" + v1API "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/v2/pkg/diff" ) type ( diff --git a/pkg/config/updater.go b/pkg/config/updater.go index 445000d0b..7a6d08d08 100644 --- a/pkg/config/updater.go +++ b/pkg/config/updater.go @@ -6,7 +6,7 @@ import ( "os" "github.com/go-errors/errors" - v1API "github.com/supabase/cli/pkg/api" + v1API "github.com/supabase/cli/v2/pkg/api" ) type ConfigUpdater struct { diff --git a/pkg/config/updater_test.go b/pkg/config/updater_test.go index 471e84963..d595d60b6 100644 --- a/pkg/config/updater_test.go +++ b/pkg/config/updater_test.go @@ -8,8 +8,8 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - v1API "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/cast" + v1API "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/cast" ) func TestUpdateApi(t *testing.T) { diff --git a/pkg/function/api.go b/pkg/function/api.go index e3f641dee..622786dc4 100644 --- a/pkg/function/api.go +++ b/pkg/function/api.go @@ -4,7 +4,7 @@ import ( "context" "io" - "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/v2/pkg/api" ) type EdgeRuntimeAPI struct { diff --git a/pkg/function/batch.go b/pkg/function/batch.go index 43f837fc4..0b61375c9 100644 --- a/pkg/function/batch.go +++ b/pkg/function/batch.go @@ -12,8 +12,8 @@ import ( "github.com/cenkalti/backoff/v4" "github.com/docker/go-units" "github.com/go-errors/errors" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/config" ) const ( diff --git a/pkg/function/batch_test.go b/pkg/function/batch_test.go index 1489cd329..dfba2f4af 100644 --- a/pkg/function/batch_test.go +++ b/pkg/function/batch_test.go @@ -10,8 +10,8 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/pkg/api" - "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/v2/pkg/config" ) type MockBundler struct { diff --git a/pkg/migration/apply_test.go b/pkg/migration/apply_test.go index 65a75028a..060702f11 100644 --- a/pkg/migration/apply_test.go +++ b/pkg/migration/apply_test.go @@ -9,7 +9,7 @@ import ( "github.com/jackc/pgerrcode" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/pgtest" ) func TestPendingMigrations(t *testing.T) { diff --git a/pkg/migration/drop.go b/pkg/migration/drop.go index 362f2a9d2..68677ac26 100644 --- a/pkg/migration/drop.go +++ b/pkg/migration/drop.go @@ -7,7 +7,7 @@ import ( "github.com/go-errors/errors" "github.com/jackc/pgx/v4" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/pkg/pgxv5" ) var ( diff --git a/pkg/migration/drop_test.go b/pkg/migration/drop_test.go index d2c25ed56..a218d883f 100644 --- a/pkg/migration/drop_test.go +++ b/pkg/migration/drop_test.go @@ -6,7 +6,7 @@ import ( "github.com/jackc/pgerrcode" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/pgtest" ) var escapedSchemas = append(ManagedSchemas, "extensions", "public") diff --git a/pkg/migration/file.go b/pkg/migration/file.go index 79da1c86a..d0bed5ad7 100644 --- a/pkg/migration/file.go +++ b/pkg/migration/file.go @@ -14,7 +14,7 @@ import ( "github.com/jackc/pgtype" "github.com/jackc/pgx/v4" "github.com/spf13/viper" - "github.com/supabase/cli/pkg/parser" + "github.com/supabase/cli/v2/pkg/parser" ) type MigrationFile struct { diff --git a/pkg/migration/file_test.go b/pkg/migration/file_test.go index a38238f8d..3b2877c52 100644 --- a/pkg/migration/file_test.go +++ b/pkg/migration/file_test.go @@ -10,8 +10,8 @@ import ( "github.com/jackc/pgerrcode" "github.com/spf13/viper" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/pkg/parser" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/parser" + "github.com/supabase/cli/v2/pkg/pgtest" ) func TestMigrationFile(t *testing.T) { diff --git a/pkg/migration/history.go b/pkg/migration/history.go index 2ca14167b..3e6f8a362 100644 --- a/pkg/migration/history.go +++ b/pkg/migration/history.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/pkg/pgxv5" ) const ( diff --git a/pkg/migration/list.go b/pkg/migration/list.go index ec8bf2ac8..dfe9837bf 100644 --- a/pkg/migration/list.go +++ b/pkg/migration/list.go @@ -13,7 +13,7 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgerrcode" "github.com/jackc/pgx/v4" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/pkg/pgxv5" ) func ListRemoteMigrations(ctx context.Context, conn *pgx.Conn) ([]string, error) { diff --git a/pkg/migration/list_test.go b/pkg/migration/list_test.go index 80d09fd40..40a193489 100644 --- a/pkg/migration/list_test.go +++ b/pkg/migration/list_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgerrcode" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/pgtest" ) func TestRemoteMigrations(t *testing.T) { diff --git a/pkg/migration/seed_test.go b/pkg/migration/seed_test.go index 7e9cd4aca..1d228e531 100644 --- a/pkg/migration/seed_test.go +++ b/pkg/migration/seed_test.go @@ -11,7 +11,7 @@ import ( "github.com/jackc/pgx/v4" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/v2/pkg/pgtest" ) //go:embed testdata/seed.sql diff --git a/pkg/parser/token.go b/pkg/parser/token.go index db0084342..b939ae6cb 100644 --- a/pkg/parser/token.go +++ b/pkg/parser/token.go @@ -8,7 +8,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/viper" - "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/v2/pkg/cast" ) // Equal to `startBufSize` from `bufio/scan.go` diff --git a/pkg/pgtest/mock.go b/pkg/pgtest/mock.go index 0f5e9bb84..daa1dbd2a 100644 --- a/pkg/pgtest/mock.go +++ b/pkg/pgtest/mock.go @@ -12,7 +12,7 @@ import ( "github.com/jackc/pgproto3/v2" "github.com/jackc/pgtype" "github.com/jackc/pgx/v4" - "github.com/supabase/cli/pkg/pgxv5" + "github.com/supabase/cli/v2/pkg/pgxv5" "google.golang.org/grpc/test/bufconn" ) diff --git a/pkg/storage/api.go b/pkg/storage/api.go index e7765eb9f..3904b52e8 100644 --- a/pkg/storage/api.go +++ b/pkg/storage/api.go @@ -1,6 +1,6 @@ package storage -import "github.com/supabase/cli/pkg/fetcher" +import "github.com/supabase/cli/v2/pkg/fetcher" type StorageAPI struct { *fetcher.Fetcher diff --git a/pkg/storage/batch.go b/pkg/storage/batch.go index 8a681242d..dc54515b5 100644 --- a/pkg/storage/batch.go +++ b/pkg/storage/batch.go @@ -9,8 +9,8 @@ import ( "path/filepath" "github.com/go-errors/errors" - "github.com/supabase/cli/pkg/config" - "github.com/supabase/cli/pkg/queue" + "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/v2/pkg/queue" ) func (s *StorageAPI) UpsertBuckets(ctx context.Context, bucketConfig config.BucketConfig, filter ...func(string) bool) error { diff --git a/pkg/storage/buckets.go b/pkg/storage/buckets.go index 1f4bf9cc8..b2d4fc255 100644 --- a/pkg/storage/buckets.go +++ b/pkg/storage/buckets.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/fetcher" ) type BucketResponse struct { diff --git a/pkg/storage/objects.go b/pkg/storage/objects.go index f048cecf6..3a5633cf0 100644 --- a/pkg/storage/objects.go +++ b/pkg/storage/objects.go @@ -11,7 +11,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/v2/pkg/fetcher" ) type ListObjectsQuery struct { diff --git a/tools/bumpdoc/main.go b/tools/bumpdoc/main.go index 55d9de344..10a86772e 100644 --- a/tools/bumpdoc/main.go +++ b/tools/bumpdoc/main.go @@ -12,8 +12,8 @@ import ( "regexp" "github.com/google/go-github/v62/github" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/tools/shared" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/tools/shared" ) const ( diff --git a/tools/changelog/main.go b/tools/changelog/main.go index 97b587ed4..84ce70eca 100644 --- a/tools/changelog/main.go +++ b/tools/changelog/main.go @@ -14,7 +14,7 @@ import ( "github.com/google/go-github/v62/github" "github.com/slack-go/slack" - "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/v2/internal/utils" ) func main() { diff --git a/tools/listdep/main.go b/tools/listdep/main.go index bf3c88985..6d28db52c 100644 --- a/tools/listdep/main.go +++ b/tools/listdep/main.go @@ -6,7 +6,7 @@ import ( "os" "strings" - "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/v2/pkg/config" ) func main() { diff --git a/tools/publish/main.go b/tools/publish/main.go index be2474edb..c9944a293 100644 --- a/tools/publish/main.go +++ b/tools/publish/main.go @@ -16,9 +16,9 @@ import ( "text/template" "github.com/google/go-github/v62/github" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/fetcher" - "github.com/supabase/cli/tools/shared" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/v2/tools/shared" ) const ( diff --git a/tools/selfhost/main.go b/tools/selfhost/main.go index cb9ada3a0..145c53801 100644 --- a/tools/selfhost/main.go +++ b/tools/selfhost/main.go @@ -11,9 +11,9 @@ import ( "strings" "github.com/google/go-github/v62/github" - "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/pkg/config" - "github.com/supabase/cli/tools/shared" + "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/v2/tools/shared" "gopkg.in/yaml.v3" ) From bd0d25023ed2315b2a8048bbd5de60e619dbc6c4 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sat, 7 Dec 2024 23:29:25 +0800 Subject: [PATCH 213/305] chore: update test coverage --- .github/workflows/ci.yml | 9 +++++---- internal/utils/console_test.go | 12 +----------- internal/utils/flags/project_ref.go | 5 +++-- internal/utils/flags/project_ref_test.go | 7 +++++-- internal/utils/prompt.go | 4 ++-- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f4078158..ce32d176b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,12 +21,13 @@ jobs: # Required by: internal/utils/credentials/keyring_test.go - uses: t1m0thyj/unlock-keyring@v1 - run: | - go run gotest.tools/gotestsum -- ./... -race -v -count=1 \ - -coverpkg ./cmd/...,./internal/... -coverprofile=coverage.out + go run gotest.tools/gotestsum -- -race -v -count=1 -coverprofile=coverage.out \ + `go list ./... | grep -Ev 'cmd|docs|examples|pkg/api|tools'` - - uses: shogo82148/actions-goveralls@v1 + - uses: coverallsapp/github-action@v2 with: - path-to-profile: coverage.out + file: coverage.out + format: golang lint: name: Lint diff --git a/internal/utils/console_test.go b/internal/utils/console_test.go index 5fbd53db5..f7662d2d1 100644 --- a/internal/utils/console_test.go +++ b/internal/utils/console_test.go @@ -2,11 +2,9 @@ package utils import ( "context" - "os" "testing" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "github.com/supabase/cli/v2/internal/testing/fstest" ) @@ -34,15 +32,7 @@ func TestPromptYesNo(t *testing.T) { func TestPromptText(t *testing.T) { t.Run("defaults on timeout", func(t *testing.T) { - // Setup stdin - r, _, err := os.Pipe() - require.NoError(t, err) - // Replace stdin - oldStdin := os.Stdin - defer func() { - os.Stdin = oldStdin - }() - os.Stdin = r + t.Cleanup(fstest.MockStdin(t, "")) c := NewConsole() // Run test val, err := c.PromptText(context.Background(), "test") diff --git a/internal/utils/flags/project_ref.go b/internal/utils/flags/project_ref.go index e8f675a16..6b39b02ac 100644 --- a/internal/utils/flags/project_ref.go +++ b/internal/utils/flags/project_ref.go @@ -6,6 +6,7 @@ import ( "fmt" "os" + tea "github.com/charmbracelet/bubbletea" "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/viper" @@ -26,7 +27,7 @@ func ParseProjectRef(ctx context.Context, fsys afero.Fs) error { return errors.New(utils.ErrNotLinked) } -func PromptProjectRef(ctx context.Context, title string) error { +func PromptProjectRef(ctx context.Context, title string, opts ...tea.ProgramOption) error { resp, err := utils.GetSupabase().V1ListAllProjectsWithResponse(ctx) if err != nil { return errors.Errorf("failed to retrieve projects: %w", err) @@ -41,7 +42,7 @@ func PromptProjectRef(ctx context.Context, title string) error { Details: fmt.Sprintf("name: %s, org: %s, region: %s", project.Name, project.OrganizationId, project.Region), } } - choice, err := utils.PromptChoice(ctx, title, items) + choice, err := utils.PromptChoice(ctx, title, items, opts...) if err != nil { return err } diff --git a/internal/utils/flags/project_ref_test.go b/internal/utils/flags/project_ref_test.go index ca910e23d..ee12de886 100644 --- a/internal/utils/flags/project_ref_test.go +++ b/internal/utils/flags/project_ref_test.go @@ -4,8 +4,10 @@ import ( "context" "net/http" "os" + "strings" "testing" + tea "github.com/charmbracelet/bubbletea" "github.com/go-errors/errors" "github.com/h2non/gock" "github.com/spf13/afero" @@ -69,6 +71,7 @@ func TestProjectPrompt(t *testing.T) { t.Setenv("SUPABASE_ACCESS_TOKEN", string(token)) t.Run("validates prompt input", func(t *testing.T) { + input := tea.WithInput(strings.NewReader("\r")) // Setup mock api defer gock.OffAll() gock.New(utils.DefaultApiHost). @@ -80,9 +83,9 @@ func TestProjectPrompt(t *testing.T) { OrganizationId: "test-org", }}) // Run test - err := PromptProjectRef(context.Background(), "") + err := PromptProjectRef(context.Background(), "", input) // Check error - assert.ErrorContains(t, err, "failed to prompt choice:") + assert.NoError(t, err) assert.Empty(t, apitest.ListUnmatchedRequests()) }) diff --git a/internal/utils/prompt.go b/internal/utils/prompt.go index 8ff67d97e..5589f49d6 100644 --- a/internal/utils/prompt.go +++ b/internal/utils/prompt.go @@ -103,7 +103,7 @@ func (m model) View() string { } // Prompt user to choose from a list of items, returns the chosen index. -func PromptChoice(ctx context.Context, title string, items []PromptItem) (PromptItem, error) { +func PromptChoice(ctx context.Context, title string, items []PromptItem, opts ...tea.ProgramOption) (PromptItem, error) { // Create list items var listItems []list.Item for _, v := range items { @@ -126,7 +126,7 @@ func PromptChoice(ctx context.Context, title string, items []PromptItem) (Prompt // Create our model ctx, cancel := context.WithCancel(ctx) initial := model{cancel: cancel, list: l} - prog := tea.NewProgram(initial) + prog := tea.NewProgram(initial, opts...) state, err := prog.Run() if err != nil { return initial.choice, errors.Errorf("failed to prompt choice: %w", err) From 0e8d7c49fa3997fefc2f142075b7a6bdd2b0f6f1 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Sun, 8 Dec 2024 00:23:48 +0800 Subject: [PATCH 214/305] Revert "chore: bump cli module to v2" This reverts commit e4c39e6ab3401bce21b9b6fd53ceedc29f5c993a. --- cmd/bans.go | 6 +-- cmd/bootstrap.go | 4 +- cmd/branches.go | 20 ++++---- cmd/config.go | 4 +- cmd/db.go | 32 ++++++------- cmd/domains.go | 12 ++--- cmd/encryption.go | 6 +-- cmd/functions.go | 18 ++++---- cmd/gen.go | 8 ++-- cmd/init.go | 4 +- cmd/inspect.go | 46 +++++++++---------- cmd/link.go | 6 +-- cmd/login.go | 4 +- cmd/logout.go | 2 +- cmd/migration.go | 16 +++---- cmd/orgs.go | 4 +- cmd/postgres.go | 6 +-- cmd/projects.go | 14 +++--- cmd/restrictions.go | 6 +-- cmd/root.go | 4 +- cmd/secrets.go | 8 ++-- cmd/seed.go | 6 +-- cmd/services.go | 2 +- cmd/snippets.go | 6 +-- cmd/sslEnforcement.go | 6 +-- cmd/sso.go | 16 +++---- cmd/start.go | 4 +- cmd/status.go | 4 +- cmd/stop.go | 2 +- cmd/storage.go | 12 ++--- cmd/test.go | 4 +- cmd/unlink.go | 2 +- cmd/vanitySubdomains.go | 10 ++-- docs/main.go | 4 +- examples/functions-deploy/main.go | 6 +-- examples/migrations-up/main.go | 4 +- examples/seed-buckets/main.go | 6 +-- go.mod | 21 ++++++++- go.sum | 42 +++++++++++++++++ internal/bans/get/get.go | 2 +- internal/bans/update/update.go | 4 +- internal/bootstrap/bootstrap.go | 24 +++++----- internal/bootstrap/bootstrap_test.go | 4 +- internal/branches/create/create.go | 8 ++-- internal/branches/create/create_test.go | 10 ++-- internal/branches/delete/delete.go | 2 +- internal/branches/disable/disable.go | 4 +- internal/branches/get/get.go | 4 +- internal/branches/list/list.go | 6 +-- internal/branches/update/update.go | 4 +- internal/config/push/push.go | 4 +- internal/db/branch/create/create.go | 2 +- internal/db/branch/create/create_test.go | 4 +- internal/db/branch/delete/delete.go | 2 +- internal/db/branch/delete/delete_test.go | 4 +- internal/db/branch/list/list.go | 2 +- internal/db/branch/list/list_test.go | 2 +- internal/db/branch/switch_/switch_.go | 4 +- internal/db/branch/switch_/switch__test.go | 8 ++-- internal/db/diff/diff.go | 10 ++-- internal/db/diff/diff_test.go | 16 +++---- internal/db/diff/migra.go | 4 +- internal/db/diff/pgadmin.go | 8 ++-- internal/db/dump/dump.go | 4 +- internal/db/dump/dump_test.go | 4 +- internal/db/lint/lint.go | 4 +- internal/db/lint/lint_test.go | 6 +-- internal/db/pull/pull.go | 14 +++--- internal/db/pull/pull_test.go | 10 ++-- internal/db/push/push.go | 8 ++-- internal/db/push/push_test.go | 10 ++-- internal/db/remote/changes/changes.go | 6 +-- internal/db/remote/commit/commit.go | 12 ++--- internal/db/reset/reset.go | 18 ++++---- internal/db/reset/reset_test.go | 16 +++---- internal/db/start/start.go | 8 ++-- internal/db/start/start_test.go | 10 ++-- internal/db/test/test.go | 4 +- internal/db/test/test_test.go | 8 ++-- internal/debug/postgres_test.go | 2 +- internal/encryption/get/get.go | 2 +- internal/encryption/get/get_test.go | 6 +-- internal/encryption/update/update.go | 6 +-- internal/encryption/update/update_test.go | 6 +-- internal/functions/delete/delete.go | 2 +- internal/functions/delete/delete_test.go | 4 +- internal/functions/deploy/bundle.go | 4 +- internal/functions/deploy/bundle_test.go | 4 +- internal/functions/deploy/deploy.go | 10 ++-- internal/functions/deploy/deploy_test.go | 10 ++-- internal/functions/download/download.go | 4 +- internal/functions/download/download_test.go | 6 +-- internal/functions/list/list.go | 4 +- internal/functions/list/list_test.go | 6 +-- internal/functions/new/new.go | 2 +- internal/functions/new/new_test.go | 2 +- internal/functions/serve/serve.go | 6 +-- internal/functions/serve/serve_test.go | 6 +-- internal/gen/keys/keys.go | 4 +- internal/gen/types/types.go | 4 +- internal/gen/types/types_test.go | 8 ++-- internal/hostnames/activate/activate.go | 4 +- internal/hostnames/common.go | 4 +- internal/hostnames/create/create.go | 6 +-- internal/hostnames/delete/delete.go | 2 +- internal/hostnames/get/get.go | 2 +- internal/hostnames/reverify/reverify.go | 4 +- internal/init/init.go | 2 +- internal/init/init_test.go | 6 +-- internal/inspect/bloat/bloat.go | 8 ++-- internal/inspect/bloat/bloat_test.go | 6 +-- internal/inspect/blocking/blocking.go | 6 +-- internal/inspect/blocking/blocking_test.go | 2 +- internal/inspect/cache/cache.go | 6 +-- internal/inspect/cache/cache_test.go | 2 +- internal/inspect/calls/calls.go | 6 +-- internal/inspect/calls/calls_test.go | 2 +- internal/inspect/index_sizes/index_sizes.go | 8 ++-- .../inspect/index_sizes/index_sizes_test.go | 6 +-- internal/inspect/index_usage/index_usage.go | 8 ++-- .../inspect/index_usage/index_usage_test.go | 6 +-- internal/inspect/locks/locks.go | 6 +-- internal/inspect/locks/locks_test.go | 2 +- .../long_running_queries.go | 6 +-- .../long_running_queries_test.go | 2 +- internal/inspect/outliers/outliers.go | 6 +-- internal/inspect/outliers/outliers_test.go | 2 +- .../replication_slots/replication_slots.go | 6 +-- .../replication_slots_test.go | 2 +- internal/inspect/report.go | 4 +- internal/inspect/report_test.go | 42 ++++++++--------- internal/inspect/role_configs/role_configs.go | 6 +-- .../inspect/role_configs/role_configs_test.go | 2 +- .../role_connections/role_connections.go | 6 +-- .../role_connections/role_connections_test.go | 2 +- internal/inspect/seq_scans/seq_scans.go | 8 ++-- internal/inspect/seq_scans/seq_scans_test.go | 6 +-- .../table_index_sizes/table_index_sizes.go | 8 ++-- .../table_index_sizes_test.go | 6 +-- .../table_record_counts.go | 8 ++-- .../table_record_counts_test.go | 6 +-- internal/inspect/table_sizes/table_sizes.go | 8 ++-- .../inspect/table_sizes/table_sizes_test.go | 6 +-- .../total_index_size/total_index_size.go | 8 ++-- .../total_index_size/total_index_size_test.go | 6 +-- .../total_table_sizes/total_table_sizes.go | 8 ++-- .../total_table_sizes_test.go | 6 +-- .../inspect/unused_indexes/unused_indexes.go | 8 ++-- .../unused_indexes/unused_indexes_test.go | 6 +-- internal/inspect/vacuum_stats/vacuum_stats.go | 8 ++-- .../inspect/vacuum_stats/vacuum_stats_test.go | 6 +-- internal/link/link.go | 18 ++++---- internal/link/link_test.go | 16 +++---- internal/login/login.go | 6 +-- internal/login/login_test.go | 6 +-- internal/logout/logout.go | 4 +- internal/logout/logout_test.go | 8 ++-- internal/migration/apply/apply.go | 6 +-- internal/migration/apply/apply_test.go | 10 ++-- internal/migration/fetch/fetch.go | 4 +- internal/migration/list/list.go | 4 +- internal/migration/list/list_test.go | 8 ++-- internal/migration/new/new.go | 2 +- internal/migration/new/new_test.go | 2 +- internal/migration/repair/repair.go | 6 +-- internal/migration/repair/repair_test.go | 10 ++-- internal/migration/squash/squash.go | 14 +++--- internal/migration/squash/squash_test.go | 16 +++---- internal/migration/up/up.go | 4 +- internal/migration/up/up_test.go | 8 ++-- internal/orgs/create/create.go | 4 +- internal/orgs/create/create_test.go | 6 +-- internal/orgs/list/list.go | 4 +- internal/orgs/list/list_test.go | 6 +-- internal/postgresConfig/get/get.go | 4 +- internal/postgresConfig/update/update.go | 4 +- internal/projects/apiKeys/api_keys.go | 6 +-- internal/projects/apiKeys/api_keys_test.go | 6 +-- internal/projects/create/create.go | 8 ++-- internal/projects/create/create_test.go | 6 +-- internal/projects/delete/delete.go | 6 +-- internal/projects/delete/delete_test.go | 6 +-- internal/projects/list/list.go | 8 ++-- internal/projects/list/list_test.go | 6 +-- internal/restrictions/get/get.go | 2 +- internal/restrictions/update/update.go | 4 +- internal/restrictions/update/update_test.go | 6 +-- internal/secrets/list/list.go | 6 +-- internal/secrets/list/list_test.go | 6 +-- internal/secrets/set/set.go | 4 +- internal/secrets/set/set_test.go | 6 +-- internal/secrets/unset/unset.go | 4 +- internal/secrets/unset/unset_test.go | 6 +-- internal/seed/buckets/buckets.go | 4 +- internal/seed/buckets/buckets_test.go | 6 +-- internal/services/services.go | 8 ++-- internal/snippets/download/download.go | 2 +- internal/snippets/list/list.go | 8 ++-- internal/ssl_enforcement/get/get.go | 2 +- internal/ssl_enforcement/update/update.go | 4 +- internal/sso/create/create.go | 8 ++-- internal/sso/get/get.go | 6 +-- internal/sso/get/get_test.go | 4 +- internal/sso/info/info.go | 4 +- internal/sso/internal/render/render.go | 6 +-- internal/sso/internal/saml/files.go | 4 +- internal/sso/list/list.go | 4 +- internal/sso/list/list_test.go | 4 +- internal/sso/remove/remove.go | 6 +-- internal/sso/remove/remove_test.go | 4 +- internal/sso/update/update.go | 8 ++-- internal/sso/update/update_test.go | 6 +-- internal/start/start.go | 16 +++---- internal/start/start_test.go | 10 ++-- internal/status/status.go | 4 +- internal/status/status_test.go | 4 +- internal/stop/stop.go | 2 +- internal/stop/stop_test.go | 4 +- internal/storage/client/api.go | 10 ++-- internal/storage/cp/cp.go | 12 ++--- internal/storage/cp/cp_test.go | 14 +++--- internal/storage/ls/ls.go | 6 +-- internal/storage/ls/ls_test.go | 16 +++---- internal/storage/mv/mv.go | 8 ++-- internal/storage/mv/mv_test.go | 14 +++--- internal/storage/rm/rm.go | 12 ++--- internal/storage/rm/rm_test.go | 16 +++---- internal/test/new/new.go | 2 +- internal/test/new/new_test.go | 2 +- internal/testing/helper/history.go | 4 +- internal/unlink/unlink.go | 4 +- internal/unlink/unlink_test.go | 6 +-- internal/utils/access_token.go | 2 +- internal/utils/access_token_test.go | 6 +-- internal/utils/api.go | 6 +-- internal/utils/api_test.go | 4 +- internal/utils/cloudflare/api.go | 2 +- internal/utils/cloudflare/dns.go | 2 +- internal/utils/config.go | 2 +- internal/utils/connect.go | 4 +- internal/utils/connect_test.go | 6 +-- internal/utils/console.go | 2 +- internal/utils/console_test.go | 2 +- internal/utils/docker_test.go | 2 +- internal/utils/flags/db_url.go | 6 +-- internal/utils/flags/project_ref.go | 2 +- internal/utils/flags/project_ref_test.go | 8 ++-- internal/utils/release_test.go | 4 +- internal/utils/tenant/client.go | 6 +-- internal/utils/tenant/database.go | 2 +- internal/utils/tenant/gotrue.go | 2 +- internal/utils/tenant/gotrue_test.go | 2 +- internal/utils/tenant/postgrest.go | 2 +- .../vanity_subdomains/activate/activate.go | 4 +- internal/vanity_subdomains/check/check.go | 4 +- internal/vanity_subdomains/delete/delete.go | 2 +- internal/vanity_subdomains/get/get.go | 2 +- main.go | 2 +- pkg/config/api.go | 6 +-- pkg/config/api_test.go | 2 +- pkg/config/auth.go | 6 +-- pkg/config/auth_test.go | 4 +- pkg/config/config.go | 4 +- pkg/config/db.go | 6 +-- pkg/config/db_test.go | 4 +- pkg/config/storage.go | 6 +-- pkg/config/updater.go | 2 +- pkg/config/updater_test.go | 4 +- pkg/function/api.go | 2 +- pkg/function/batch.go | 4 +- pkg/function/batch_test.go | 4 +- pkg/migration/apply_test.go | 2 +- pkg/migration/drop.go | 2 +- pkg/migration/drop_test.go | 2 +- pkg/migration/file.go | 2 +- pkg/migration/file_test.go | 4 +- pkg/migration/history.go | 2 +- pkg/migration/list.go | 2 +- pkg/migration/list_test.go | 2 +- pkg/migration/seed_test.go | 2 +- pkg/parser/token.go | 2 +- pkg/pgtest/mock.go | 2 +- pkg/storage/api.go | 2 +- pkg/storage/batch.go | 4 +- pkg/storage/buckets.go | 2 +- pkg/storage/objects.go | 2 +- tools/bumpdoc/main.go | 4 +- tools/changelog/main.go | 2 +- tools/listdep/main.go | 2 +- tools/publish/main.go | 6 +-- tools/selfhost/main.go | 6 +-- 291 files changed, 939 insertions(+), 878 deletions(-) diff --git a/cmd/bans.go b/cmd/bans.go index 6f930c042..603e2dd4d 100644 --- a/cmd/bans.go +++ b/cmd/bans.go @@ -3,9 +3,9 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/bans/get" - "github.com/supabase/cli/v2/internal/bans/update" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/bans/get" + "github.com/supabase/cli/internal/bans/update" + "github.com/supabase/cli/internal/utils/flags" ) var ( diff --git a/cmd/bootstrap.go b/cmd/bootstrap.go index 21d24fb1f..fd9f74912 100644 --- a/cmd/bootstrap.go +++ b/cmd/bootstrap.go @@ -11,8 +11,8 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/bootstrap" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/bootstrap" + "github.com/supabase/cli/internal/utils" ) var ( diff --git a/cmd/branches.go b/cmd/branches.go index dd0897d9f..0248e7f31 100644 --- a/cmd/branches.go +++ b/cmd/branches.go @@ -8,16 +8,16 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/branches/create" - "github.com/supabase/cli/v2/internal/branches/delete" - "github.com/supabase/cli/v2/internal/branches/disable" - "github.com/supabase/cli/v2/internal/branches/get" - "github.com/supabase/cli/v2/internal/branches/list" - "github.com/supabase/cli/v2/internal/branches/update" - "github.com/supabase/cli/v2/internal/gen/keys" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/branches/create" + "github.com/supabase/cli/internal/branches/delete" + "github.com/supabase/cli/internal/branches/disable" + "github.com/supabase/cli/internal/branches/get" + "github.com/supabase/cli/internal/branches/list" + "github.com/supabase/cli/internal/branches/update" + "github.com/supabase/cli/internal/gen/keys" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/api" ) var ( diff --git a/cmd/config.go b/cmd/config.go index 0b0657506..1d0f60733 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -3,8 +3,8 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/config/push" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/config/push" + "github.com/supabase/cli/internal/utils/flags" ) var ( diff --git a/cmd/db.go b/cmd/db.go index 6737f543e..2d64edd74 100644 --- a/cmd/db.go +++ b/cmd/db.go @@ -8,22 +8,22 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/db/branch/create" - "github.com/supabase/cli/v2/internal/db/branch/delete" - "github.com/supabase/cli/v2/internal/db/branch/list" - "github.com/supabase/cli/v2/internal/db/branch/switch_" - "github.com/supabase/cli/v2/internal/db/diff" - "github.com/supabase/cli/v2/internal/db/dump" - "github.com/supabase/cli/v2/internal/db/lint" - "github.com/supabase/cli/v2/internal/db/pull" - "github.com/supabase/cli/v2/internal/db/push" - "github.com/supabase/cli/v2/internal/db/remote/changes" - "github.com/supabase/cli/v2/internal/db/remote/commit" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/db/start" - "github.com/supabase/cli/v2/internal/db/test" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/db/branch/create" + "github.com/supabase/cli/internal/db/branch/delete" + "github.com/supabase/cli/internal/db/branch/list" + "github.com/supabase/cli/internal/db/branch/switch_" + "github.com/supabase/cli/internal/db/diff" + "github.com/supabase/cli/internal/db/dump" + "github.com/supabase/cli/internal/db/lint" + "github.com/supabase/cli/internal/db/pull" + "github.com/supabase/cli/internal/db/push" + "github.com/supabase/cli/internal/db/remote/changes" + "github.com/supabase/cli/internal/db/remote/commit" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/db/start" + "github.com/supabase/cli/internal/db/test" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" ) var ( diff --git a/cmd/domains.go b/cmd/domains.go index cbc9ecb6e..9ec4a097d 100644 --- a/cmd/domains.go +++ b/cmd/domains.go @@ -3,12 +3,12 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/hostnames/activate" - "github.com/supabase/cli/v2/internal/hostnames/create" - "github.com/supabase/cli/v2/internal/hostnames/delete" - "github.com/supabase/cli/v2/internal/hostnames/get" - "github.com/supabase/cli/v2/internal/hostnames/reverify" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/hostnames/activate" + "github.com/supabase/cli/internal/hostnames/create" + "github.com/supabase/cli/internal/hostnames/delete" + "github.com/supabase/cli/internal/hostnames/get" + "github.com/supabase/cli/internal/hostnames/reverify" + "github.com/supabase/cli/internal/utils/flags" ) var ( diff --git a/cmd/encryption.go b/cmd/encryption.go index 5e93d432a..d3b654afc 100644 --- a/cmd/encryption.go +++ b/cmd/encryption.go @@ -4,9 +4,9 @@ import ( "os" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/encryption/get" - "github.com/supabase/cli/v2/internal/encryption/update" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/encryption/get" + "github.com/supabase/cli/internal/encryption/update" + "github.com/supabase/cli/internal/utils/flags" ) var ( diff --git a/cmd/functions.go b/cmd/functions.go index b765a41ed..36dc47f94 100644 --- a/cmd/functions.go +++ b/cmd/functions.go @@ -5,15 +5,15 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/functions/delete" - "github.com/supabase/cli/v2/internal/functions/deploy" - "github.com/supabase/cli/v2/internal/functions/download" - "github.com/supabase/cli/v2/internal/functions/list" - new_ "github.com/supabase/cli/v2/internal/functions/new" - "github.com/supabase/cli/v2/internal/functions/serve" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/internal/functions/delete" + "github.com/supabase/cli/internal/functions/deploy" + "github.com/supabase/cli/internal/functions/download" + "github.com/supabase/cli/internal/functions/list" + new_ "github.com/supabase/cli/internal/functions/new" + "github.com/supabase/cli/internal/functions/serve" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/cast" ) var ( diff --git a/cmd/gen.go b/cmd/gen.go index 9c6e66129..1789e29ca 100644 --- a/cmd/gen.go +++ b/cmd/gen.go @@ -8,10 +8,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/gen/keys" - "github.com/supabase/cli/v2/internal/gen/types" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/gen/keys" + "github.com/supabase/cli/internal/gen/types" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" ) var ( diff --git a/cmd/init.go b/cmd/init.go index ed9684c23..a9d2d90a8 100644 --- a/cmd/init.go +++ b/cmd/init.go @@ -8,8 +8,8 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - _init "github.com/supabase/cli/v2/internal/init" - "github.com/supabase/cli/v2/internal/utils" + _init "github.com/supabase/cli/internal/init" + "github.com/supabase/cli/internal/utils" ) var ( diff --git a/cmd/inspect.go b/cmd/inspect.go index 29b69795a..2b55c3876 100644 --- a/cmd/inspect.go +++ b/cmd/inspect.go @@ -8,30 +8,30 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/inspect/bloat" - "github.com/supabase/cli/v2/internal/inspect/blocking" - "github.com/supabase/cli/v2/internal/inspect/cache" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/inspect/bloat" + "github.com/supabase/cli/internal/inspect/blocking" + "github.com/supabase/cli/internal/inspect/cache" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" - "github.com/supabase/cli/v2/internal/inspect" - "github.com/supabase/cli/v2/internal/inspect/calls" - "github.com/supabase/cli/v2/internal/inspect/index_sizes" - "github.com/supabase/cli/v2/internal/inspect/index_usage" - "github.com/supabase/cli/v2/internal/inspect/locks" - "github.com/supabase/cli/v2/internal/inspect/long_running_queries" - "github.com/supabase/cli/v2/internal/inspect/outliers" - "github.com/supabase/cli/v2/internal/inspect/replication_slots" - "github.com/supabase/cli/v2/internal/inspect/role_configs" - "github.com/supabase/cli/v2/internal/inspect/role_connections" - "github.com/supabase/cli/v2/internal/inspect/seq_scans" - "github.com/supabase/cli/v2/internal/inspect/table_index_sizes" - "github.com/supabase/cli/v2/internal/inspect/table_record_counts" - "github.com/supabase/cli/v2/internal/inspect/table_sizes" - "github.com/supabase/cli/v2/internal/inspect/total_index_size" - "github.com/supabase/cli/v2/internal/inspect/total_table_sizes" - "github.com/supabase/cli/v2/internal/inspect/unused_indexes" - "github.com/supabase/cli/v2/internal/inspect/vacuum_stats" + "github.com/supabase/cli/internal/inspect" + "github.com/supabase/cli/internal/inspect/calls" + "github.com/supabase/cli/internal/inspect/index_sizes" + "github.com/supabase/cli/internal/inspect/index_usage" + "github.com/supabase/cli/internal/inspect/locks" + "github.com/supabase/cli/internal/inspect/long_running_queries" + "github.com/supabase/cli/internal/inspect/outliers" + "github.com/supabase/cli/internal/inspect/replication_slots" + "github.com/supabase/cli/internal/inspect/role_configs" + "github.com/supabase/cli/internal/inspect/role_connections" + "github.com/supabase/cli/internal/inspect/seq_scans" + "github.com/supabase/cli/internal/inspect/table_index_sizes" + "github.com/supabase/cli/internal/inspect/table_record_counts" + "github.com/supabase/cli/internal/inspect/table_sizes" + "github.com/supabase/cli/internal/inspect/total_index_size" + "github.com/supabase/cli/internal/inspect/total_table_sizes" + "github.com/supabase/cli/internal/inspect/unused_indexes" + "github.com/supabase/cli/internal/inspect/vacuum_stats" ) var ( diff --git a/cmd/link.go b/cmd/link.go index ee947c060..b1aec1d7a 100644 --- a/cmd/link.go +++ b/cmd/link.go @@ -7,9 +7,9 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/link" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/link" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "golang.org/x/term" ) diff --git a/cmd/login.go b/cmd/login.go index e186d0d04..ca9aea666 100644 --- a/cmd/login.go +++ b/cmd/login.go @@ -6,8 +6,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/login" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/login" + "github.com/supabase/cli/internal/utils" "golang.org/x/term" ) diff --git a/cmd/logout.go b/cmd/logout.go index 52559d204..dda3dd4cc 100644 --- a/cmd/logout.go +++ b/cmd/logout.go @@ -5,7 +5,7 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/logout" + "github.com/supabase/cli/internal/logout" ) var ( diff --git a/cmd/migration.go b/cmd/migration.go index 1224c6659..30b7716ac 100644 --- a/cmd/migration.go +++ b/cmd/migration.go @@ -8,14 +8,14 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/migration/fetch" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/migration/new" - "github.com/supabase/cli/v2/internal/migration/repair" - "github.com/supabase/cli/v2/internal/migration/squash" - "github.com/supabase/cli/v2/internal/migration/up" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/migration/fetch" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/migration/new" + "github.com/supabase/cli/internal/migration/repair" + "github.com/supabase/cli/internal/migration/squash" + "github.com/supabase/cli/internal/migration/up" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" ) var ( diff --git a/cmd/orgs.go b/cmd/orgs.go index ace1cd960..5d0750dbb 100644 --- a/cmd/orgs.go +++ b/cmd/orgs.go @@ -2,8 +2,8 @@ package cmd import ( "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/orgs/create" - "github.com/supabase/cli/v2/internal/orgs/list" + "github.com/supabase/cli/internal/orgs/create" + "github.com/supabase/cli/internal/orgs/list" ) var ( diff --git a/cmd/postgres.go b/cmd/postgres.go index c1e84ca72..1c2e0e127 100644 --- a/cmd/postgres.go +++ b/cmd/postgres.go @@ -3,9 +3,9 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/postgresConfig/get" - "github.com/supabase/cli/v2/internal/postgresConfig/update" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/postgresConfig/get" + "github.com/supabase/cli/internal/postgresConfig/update" + "github.com/supabase/cli/internal/utils/flags" ) var ( diff --git a/cmd/projects.go b/cmd/projects.go index 4b214c517..c119e7171 100644 --- a/cmd/projects.go +++ b/cmd/projects.go @@ -7,13 +7,13 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/projects/apiKeys" - "github.com/supabase/cli/v2/internal/projects/create" - "github.com/supabase/cli/v2/internal/projects/delete" - "github.com/supabase/cli/v2/internal/projects/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/projects/apiKeys" + "github.com/supabase/cli/internal/projects/create" + "github.com/supabase/cli/internal/projects/delete" + "github.com/supabase/cli/internal/projects/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/api" "golang.org/x/term" ) diff --git a/cmd/restrictions.go b/cmd/restrictions.go index beb1bbf7d..4358d6132 100644 --- a/cmd/restrictions.go +++ b/cmd/restrictions.go @@ -2,9 +2,9 @@ package cmd import ( "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/restrictions/get" - "github.com/supabase/cli/v2/internal/restrictions/update" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/restrictions/get" + "github.com/supabase/cli/internal/restrictions/update" + "github.com/supabase/cli/internal/utils/flags" ) var ( diff --git a/cmd/root.go b/cmd/root.go index 8906ef32e..35540a897 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -15,8 +15,8 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "golang.org/x/mod/semver" ) diff --git a/cmd/secrets.go b/cmd/secrets.go index f4ee8d09e..df4084e46 100644 --- a/cmd/secrets.go +++ b/cmd/secrets.go @@ -3,10 +3,10 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/secrets/list" - "github.com/supabase/cli/v2/internal/secrets/set" - "github.com/supabase/cli/v2/internal/secrets/unset" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/secrets/list" + "github.com/supabase/cli/internal/secrets/set" + "github.com/supabase/cli/internal/secrets/unset" + "github.com/supabase/cli/internal/utils/flags" ) var ( diff --git a/cmd/seed.go b/cmd/seed.go index 7cac7c325..c36b70741 100644 --- a/cmd/seed.go +++ b/cmd/seed.go @@ -6,9 +6,9 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/seed/buckets" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/seed/buckets" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" ) var ( diff --git a/cmd/services.go b/cmd/services.go index 2fc80e6b0..fe298cb43 100644 --- a/cmd/services.go +++ b/cmd/services.go @@ -3,7 +3,7 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/services" + "github.com/supabase/cli/internal/services" ) var ( diff --git a/cmd/snippets.go b/cmd/snippets.go index 848e9b7d9..f69b232af 100644 --- a/cmd/snippets.go +++ b/cmd/snippets.go @@ -3,9 +3,9 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/snippets/download" - "github.com/supabase/cli/v2/internal/snippets/list" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/snippets/download" + "github.com/supabase/cli/internal/snippets/list" + "github.com/supabase/cli/internal/utils/flags" ) var ( diff --git a/cmd/sslEnforcement.go b/cmd/sslEnforcement.go index 3a7351484..7b44d6ddb 100644 --- a/cmd/sslEnforcement.go +++ b/cmd/sslEnforcement.go @@ -4,9 +4,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/ssl_enforcement/get" - "github.com/supabase/cli/v2/internal/ssl_enforcement/update" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/ssl_enforcement/get" + "github.com/supabase/cli/internal/ssl_enforcement/update" + "github.com/supabase/cli/internal/utils/flags" ) var ( diff --git a/cmd/sso.go b/cmd/sso.go index 8c7f3109f..a9b4db7d3 100644 --- a/cmd/sso.go +++ b/cmd/sso.go @@ -4,14 +4,14 @@ import ( "github.com/go-errors/errors" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/sso/create" - "github.com/supabase/cli/v2/internal/sso/get" - "github.com/supabase/cli/v2/internal/sso/info" - "github.com/supabase/cli/v2/internal/sso/list" - "github.com/supabase/cli/v2/internal/sso/remove" - "github.com/supabase/cli/v2/internal/sso/update" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/sso/create" + "github.com/supabase/cli/internal/sso/get" + "github.com/supabase/cli/internal/sso/info" + "github.com/supabase/cli/internal/sso/list" + "github.com/supabase/cli/internal/sso/remove" + "github.com/supabase/cli/internal/sso/update" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" ) var ( diff --git a/cmd/start.go b/cmd/start.go index bbdf54d0f..a7af80e0c 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -8,8 +8,8 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/start" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/start" + "github.com/supabase/cli/internal/utils" ) func validateExcludedContainers(excludedContainers []string) { diff --git a/cmd/status.go b/cmd/status.go index f082a432e..13540bfb1 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -7,8 +7,8 @@ import ( env "github.com/Netflix/go-env" "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/status" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/status" + "github.com/supabase/cli/internal/utils" ) var ( diff --git a/cmd/stop.go b/cmd/stop.go index 797651107..6a6f4aa55 100644 --- a/cmd/stop.go +++ b/cmd/stop.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/stop" + "github.com/supabase/cli/internal/stop" ) var ( diff --git a/cmd/storage.go b/cmd/storage.go index 8269baac0..3e6eb8fea 100644 --- a/cmd/storage.go +++ b/cmd/storage.go @@ -3,12 +3,12 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/storage/client" - "github.com/supabase/cli/v2/internal/storage/cp" - "github.com/supabase/cli/v2/internal/storage/ls" - "github.com/supabase/cli/v2/internal/storage/mv" - "github.com/supabase/cli/v2/internal/storage/rm" - "github.com/supabase/cli/v2/pkg/storage" + "github.com/supabase/cli/internal/storage/client" + "github.com/supabase/cli/internal/storage/cp" + "github.com/supabase/cli/internal/storage/ls" + "github.com/supabase/cli/internal/storage/mv" + "github.com/supabase/cli/internal/storage/rm" + "github.com/supabase/cli/pkg/storage" ) var ( diff --git a/cmd/test.go b/cmd/test.go index 91ac6def8..06fb77730 100644 --- a/cmd/test.go +++ b/cmd/test.go @@ -6,8 +6,8 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/test/new" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/test/new" + "github.com/supabase/cli/internal/utils" ) var ( diff --git a/cmd/unlink.go b/cmd/unlink.go index 8b0f726f7..e017e75ed 100644 --- a/cmd/unlink.go +++ b/cmd/unlink.go @@ -6,7 +6,7 @@ import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/unlink" + "github.com/supabase/cli/internal/unlink" ) var ( diff --git a/cmd/vanitySubdomains.go b/cmd/vanitySubdomains.go index 47f3de7b7..dd3608c53 100644 --- a/cmd/vanitySubdomains.go +++ b/cmd/vanitySubdomains.go @@ -3,11 +3,11 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/internal/vanity_subdomains/activate" - "github.com/supabase/cli/v2/internal/vanity_subdomains/check" - "github.com/supabase/cli/v2/internal/vanity_subdomains/delete" - "github.com/supabase/cli/v2/internal/vanity_subdomains/get" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/internal/vanity_subdomains/activate" + "github.com/supabase/cli/internal/vanity_subdomains/check" + "github.com/supabase/cli/internal/vanity_subdomains/delete" + "github.com/supabase/cli/internal/vanity_subdomains/get" ) var ( diff --git a/docs/main.go b/docs/main.go index c7cacc82b..bfacba311 100644 --- a/docs/main.go +++ b/docs/main.go @@ -11,8 +11,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" - cli "github.com/supabase/cli/v2/cmd" - "github.com/supabase/cli/v2/internal/utils" + cli "github.com/supabase/cli/cmd" + "github.com/supabase/cli/internal/utils" "gopkg.in/yaml.v3" ) diff --git a/examples/functions-deploy/main.go b/examples/functions-deploy/main.go index e3f7b0469..716ef1462 100644 --- a/examples/functions-deploy/main.go +++ b/examples/functions-deploy/main.go @@ -8,9 +8,9 @@ import ( "os" "time" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/config" - "github.com/supabase/cli/v2/pkg/function" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/pkg/function" ) func main() { diff --git a/examples/migrations-up/main.go b/examples/migrations-up/main.go index 4ff759e95..3ef03242b 100644 --- a/examples/migrations-up/main.go +++ b/examples/migrations-up/main.go @@ -6,8 +6,8 @@ import ( "log" "os" - "github.com/supabase/cli/v2/pkg/migration" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/pgxv5" ) func main() { diff --git a/examples/seed-buckets/main.go b/examples/seed-buckets/main.go index 8cd8f69e1..2c62b1084 100644 --- a/examples/seed-buckets/main.go +++ b/examples/seed-buckets/main.go @@ -8,9 +8,9 @@ import ( "os" "time" - "github.com/supabase/cli/v2/pkg/config" - "github.com/supabase/cli/v2/pkg/fetcher" - "github.com/supabase/cli/v2/pkg/storage" + "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/pkg/storage" ) func main() { diff --git a/go.mod b/go.mod index c33559c93..1c55174b8 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/supabase/cli/v2 +module github.com/supabase/cli go 1.23.2 @@ -18,6 +18,7 @@ require ( github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 github.com/getsentry/sentry-go v0.30.0 + github.com/gin-gonic/gin v1.10.0 github.com/go-errors/errors v1.5.1 github.com/go-git/go-git/v5 v5.12.0 github.com/go-xmlfmt/xmlfmt v1.1.3 @@ -34,6 +35,7 @@ require ( github.com/jackc/pgtype v1.14.4 github.com/jackc/pgx/v4 v4.18.3 github.com/joho/godotenv v1.5.1 + github.com/matoous/go-nanoid/v2 v2.1.0 github.com/mitchellh/mapstructure v1.5.0 github.com/muesli/reflow v0.3.0 github.com/oapi-codegen/runtime v1.1.1 @@ -93,6 +95,8 @@ require ( github.com/breml/errchkjson v0.4.0 // indirect github.com/butuzov/ireturn v0.3.0 // indirect github.com/butuzov/mirror v1.2.0 // indirect + github.com/bytedance/sonic v1.11.6 // indirect + github.com/bytedance/sonic/loader v0.1.1 // indirect github.com/catenacyber/perfsprint v0.7.1 // indirect github.com/ccojocar/zxcvbn-go v1.0.2 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect @@ -102,6 +106,8 @@ require ( github.com/chavacava/garif v0.1.0 // indirect github.com/ckaznocha/intrange v0.2.1 // indirect github.com/cloudflare/circl v1.3.7 // indirect + github.com/cloudwego/base64x v0.1.4 // indirect + github.com/cloudwego/iasm v0.2.0 // indirect github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect github.com/containerd/log v0.1.0 // indirect github.com/containers/storage v1.56.0 // indirect @@ -127,8 +133,10 @@ require ( github.com/fsnotify/fsnotify v1.8.0 // indirect github.com/fvbommel/sortorder v1.1.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/getkin/kin-openapi v0.124.0 // indirect github.com/ghostiam/protogetter v0.3.8 // indirect + github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-critic/go-critic v0.11.5 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect @@ -136,6 +144,9 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.20.0 // indirect github.com/go-toolsmith/astcast v1.1.0 // indirect github.com/go-toolsmith/astcopy v1.1.0 // indirect github.com/go-toolsmith/astequal v1.2.0 // indirect @@ -145,6 +156,7 @@ require ( github.com/go-toolsmith/typep v1.1.0 // indirect github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/gobwas/glob v0.2.3 // indirect + github.com/goccy/go-json v0.10.2 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/gofrs/flock v0.12.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -184,11 +196,13 @@ require ( github.com/jingyugao/rowserrcheck v1.1.1 // indirect github.com/jjti/go-spancheck v0.6.2 // indirect github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/julz/importas v0.1.0 // indirect github.com/karamaru-alpha/copyloopvar v1.1.0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/kisielk/errcheck v1.8.0 // indirect github.com/kkHAIKE/contextcheck v1.1.5 // indirect + github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/kulti/thelper v0.6.3 // indirect @@ -197,6 +211,7 @@ require ( github.com/lasiar/canonicalheader v1.1.2 // indirect github.com/ldez/gomoddirectives v0.2.4 // indirect github.com/ldez/tagliatelle v0.5.0 // indirect + github.com/leodido/go-urn v1.4.0 // indirect github.com/leonklingele/grouper v1.1.2 // indirect github.com/lib/pq v1.10.9 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect @@ -219,6 +234,8 @@ require ( github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/sys/sequential v0.6.0 // indirect github.com/moby/term v0.5.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/moricho/tparallel v0.3.2 // indirect github.com/morikuni/aec v1.0.0 // indirect @@ -281,6 +298,7 @@ require ( github.com/timonwong/loggercheck v0.10.1 // indirect github.com/tomarrell/wrapcheck/v2 v2.9.0 // indirect github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect github.com/ultraware/funlen v0.1.0 // indirect github.com/ultraware/whitespace v0.1.1 // indirect @@ -313,6 +331,7 @@ require ( go.uber.org/automaxprocs v1.6.0 // indirect go.uber.org/multierr v1.9.0 // indirect go.uber.org/zap v1.24.0 // indirect + golang.org/x/arch v0.8.0 // indirect golang.org/x/crypto v0.29.0 // indirect golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect diff --git a/go.sum b/go.sum index 29f788f41..9313587d7 100644 --- a/go.sum +++ b/go.sum @@ -147,6 +147,10 @@ github.com/butuzov/ireturn v0.3.0/go.mod h1:A09nIiwiqzN/IoVo9ogpa0Hzi9fex1kd9PSD github.com/butuzov/mirror v1.2.0 h1:9YVK1qIjNspaqWutSv8gsge2e/Xpq1eqEkslEUHy5cs= github.com/butuzov/mirror v1.2.0/go.mod h1:DqZZDtzm42wIAIyHXeN8W/qb1EPlb9Qn/if9icBOpdQ= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= +github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= +github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= +github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= +github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/catenacyber/perfsprint v0.7.1 h1:PGW5G/Kxn+YrN04cRAZKC+ZuvlVwolYMrIyyTJ/rMmc= github.com/catenacyber/perfsprint v0.7.1/go.mod h1:/wclWYompEyjUD2FuIIDVKNkqz7IgBIWXIH3V0Zol50= github.com/ccojocar/zxcvbn-go v1.0.2 h1:na/czXU8RrhXO4EZme6eQJLR4PzcGsahsBOAwU6I3Vg= @@ -185,6 +189,10 @@ github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= +github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= +github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= +github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= +github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= @@ -279,12 +287,18 @@ github.com/fvbommel/sortorder v1.1.0 h1:fUmoe+HLsBTctBDoaBwpQo5N+nrCp8g/BjKb/6ZQ github.com/fvbommel/sortorder v1.1.0/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0= github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= +github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= +github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj9kz/M= github.com/getkin/kin-openapi v0.124.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM= github.com/getsentry/sentry-go v0.30.0 h1:lWUwDnY7sKHaVIoZ9wYqRHJ5iEmoc0pqcRqFkosKzBo= github.com/getsentry/sentry-go v0.30.0/go.mod h1:WU9B9/1/sHDqeV8T+3VwwbjeR5MSXs/6aqG3mqZrezA= github.com/ghostiam/protogetter v0.3.8 h1:LYcXbYvybUyTIxN2Mj9h6rHrDZBDwZloPoKctWrFyJY= github.com/ghostiam/protogetter v0.3.8/go.mod h1:WZ0nw9pfzsgxuRsPOFQomgDVSWtDLJRfQJEhsGbmQMA= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= +github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= github.com/go-critic/go-critic v0.11.5 h1:TkDTOn5v7EEngMxu8KbuFqFR43USaaH8XRJLz1jhVYA= @@ -317,6 +331,14 @@ github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1 github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= +github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= +github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= +github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= +github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= github.com/go-sql-driver/mysql v1.3.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= @@ -353,6 +375,8 @@ github.com/go-xmlfmt/xmlfmt v1.1.3 h1:t8Ey3Uy7jDSEisW2K3somuMKIpzktkWptA0iFCnRUW github.com/go-xmlfmt/xmlfmt v1.1.3/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= +github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= @@ -578,6 +602,7 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= @@ -597,6 +622,10 @@ github.com/kisielk/errcheck v1.8.0/go.mod h1:1kLL+jV4e+CFfueBmI1dSK2ADDyQnlrnrY/ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkHAIKE/contextcheck v1.1.5 h1:CdnJh63tcDe53vG+RebdpdXJTc9atMgGqdx8LXxiilg= github.com/kkHAIKE/contextcheck v1.1.5/go.mod h1:O930cpht4xb1YQpK+1+AgoM3mFsvxr7uyFptcnWTYUA= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= +github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -623,6 +652,8 @@ github.com/ldez/gomoddirectives v0.2.4 h1:j3YjBIjEBbqZ0NKtBNzr8rtMHTOrLPeiwTkfUJ github.com/ldez/gomoddirectives v0.2.4/go.mod h1:oWu9i62VcQDYp9EQ0ONTfqLNh+mDLWWDO+SO0qSQw5g= github.com/ldez/tagliatelle v0.5.0 h1:epgfuYt9v0CG3fms0pEgIMNPuFf/LpPIfjk4kyqSioo= github.com/ldez/tagliatelle v0.5.0/go.mod h1:rj1HmWiL1MiKQuOONhd09iySTEkUuE/8+5jtPYz9xa4= +github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= +github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/leonklingele/grouper v1.1.2 h1:o1ARBDLOmmasUaNDesWqWCIFH3u7hoFlM84YrjT3mIY= github.com/leonklingele/grouper v1.1.2/go.mod h1:6D0M/HVkhs2yRKRFZUoGjeDy7EZTfFBE9gl4kjmIGkA= github.com/lib/pq v0.0.0-20150723085316-0dad96c0b94f/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -645,6 +676,8 @@ github.com/maratori/testableexamples v1.0.0 h1:dU5alXRrD8WKSjOUnmJZuzdxWOEQ57+7s github.com/maratori/testableexamples v1.0.0/go.mod h1:4rhjL1n20TUTT4vdh3RDqSizKLyXp7K2u6HgraZCGzE= github.com/maratori/testpackage v1.1.1 h1:S58XVV5AD7HADMmD0fNnziNHqKvSdDuEKdPD1rNTU04= github.com/maratori/testpackage v1.1.1/go.mod h1:s4gRK/ym6AMrqpOa/kEbQTV4Q4jb7WeLZzVhVVVOQMc= +github.com/matoous/go-nanoid/v2 v2.1.0 h1:P64+dmq21hhWdtvZfEAofnvJULaRR1Yib0+PnU669bE= +github.com/matoous/go-nanoid/v2 v2.1.0/go.mod h1:KlbGNQ+FhrUNIHUxZdL63t7tl4LaPkZNpUULS8H4uVM= github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26 h1:gWg6ZQ4JhDfJPqlo2srm/LN17lpybq15AryXIRcWYLE= github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s= github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= @@ -691,9 +724,11 @@ github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiT github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= @@ -936,6 +971,8 @@ github.com/tomarrell/wrapcheck/v2 v2.9.0 h1:801U2YCAjLhdN8zhZ/7tdjB3EnAoRlJHt/s+ github.com/tomarrell/wrapcheck/v2 v2.9.0/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo= github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ultraware/funlen v0.1.0 h1:BuqclbkY6pO+cvxoq7OsktIXZpgBSkYTQtmwhAK81vI= @@ -1037,6 +1074,9 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= +golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -1508,6 +1548,8 @@ mvdan.cc/gofumpt v0.7.0 h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU= mvdan.cc/gofumpt v0.7.0/go.mod h1:txVFJy/Sc/mvaycET54pV8SW8gWxTlUuGHVEcncmNUo= mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f h1:lMpcwN6GxNbWtbpI1+xzFLSW8XzX0u72NttUGVFjO3U= mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f/go.mod h1:RSLa7mKKCNeTTMHBw5Hsy2rfJmd6O2ivt9Dw9ZqCQpQ= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/internal/bans/get/get.go b/internal/bans/get/get.go index f6f63c401..a9e52901d 100644 --- a/internal/bans/get/get.go +++ b/internal/bans/get/get.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/bans/update/update.go b/internal/bans/update/update.go index 496f187ed..dfb31d8cf 100644 --- a/internal/bans/update/update.go +++ b/internal/bans/update/update.go @@ -7,8 +7,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func validateIps(ips []string) error { diff --git a/internal/bootstrap/bootstrap.go b/internal/bootstrap/bootstrap.go index aecbdd6e1..677ef1530 100644 --- a/internal/bootstrap/bootstrap.go +++ b/internal/bootstrap/bootstrap.go @@ -19,18 +19,18 @@ import ( "github.com/joho/godotenv" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/db/push" - initBlank "github.com/supabase/cli/v2/internal/init" - "github.com/supabase/cli/v2/internal/link" - "github.com/supabase/cli/v2/internal/login" - "github.com/supabase/cli/v2/internal/projects/apiKeys" - "github.com/supabase/cli/v2/internal/projects/create" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/internal/utils/tenant" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/fetcher" - "github.com/supabase/cli/v2/pkg/queue" + "github.com/supabase/cli/internal/db/push" + initBlank "github.com/supabase/cli/internal/init" + "github.com/supabase/cli/internal/link" + "github.com/supabase/cli/internal/login" + "github.com/supabase/cli/internal/projects/apiKeys" + "github.com/supabase/cli/internal/projects/create" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/internal/utils/tenant" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/pkg/queue" "golang.org/x/term" ) diff --git a/internal/bootstrap/bootstrap_test.go b/internal/bootstrap/bootstrap_test.go index 8dd89d46d..6cf6eb6e4 100644 --- a/internal/bootstrap/bootstrap_test.go +++ b/internal/bootstrap/bootstrap_test.go @@ -10,8 +10,8 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/api" ) func TestSuggestAppStart(t *testing.T) { diff --git a/internal/branches/create/create.go b/internal/branches/create/create.go index 63dbaad6f..bf2931b68 100644 --- a/internal/branches/create/create.go +++ b/internal/branches/create/create.go @@ -6,10 +6,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/gen/keys" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/gen/keys" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, body api.CreateBranchBody, fsys afero.Fs) error { diff --git a/internal/branches/create/create_test.go b/internal/branches/create/create_test.go index d58ed55ad..e07e10387 100644 --- a/internal/branches/create/create_test.go +++ b/internal/branches/create/create_test.go @@ -10,11 +10,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" ) func TestCreateCommand(t *testing.T) { diff --git a/internal/branches/delete/delete.go b/internal/branches/delete/delete.go index 568fd56c0..b7fdd6671 100644 --- a/internal/branches/delete/delete.go +++ b/internal/branches/delete/delete.go @@ -6,7 +6,7 @@ import ( "net/http" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, branchId string) error { diff --git a/internal/branches/disable/disable.go b/internal/branches/disable/disable.go index b7d54f293..d94c1e6c5 100644 --- a/internal/branches/disable/disable.go +++ b/internal/branches/disable/disable.go @@ -7,8 +7,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" ) func Run(ctx context.Context, fsys afero.Fs) error { diff --git a/internal/branches/get/get.go b/internal/branches/get/get.go index 19f04a58e..ee5bc332c 100644 --- a/internal/branches/get/get.go +++ b/internal/branches/get/get.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, branchId string) error { diff --git a/internal/branches/list/list.go b/internal/branches/list/list.go index d40b3824a..7a153138f 100644 --- a/internal/branches/list/list.go +++ b/internal/branches/list/list.go @@ -7,9 +7,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" ) func Run(ctx context.Context, fsys afero.Fs) error { diff --git a/internal/branches/update/update.go b/internal/branches/update/update.go index 2ddb03f19..6c0f5fc4a 100644 --- a/internal/branches/update/update.go +++ b/internal/branches/update/update.go @@ -6,8 +6,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, branchId string, body api.UpdateBranchBody, fsys afero.Fs) error { diff --git a/internal/config/push/push.go b/internal/config/push/push.go index 5ddc9070c..a4c901473 100644 --- a/internal/config/push/push.go +++ b/internal/config/push/push.go @@ -6,8 +6,8 @@ import ( "os" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/config" ) func Run(ctx context.Context, ref string, fsys afero.Fs) error { diff --git a/internal/db/branch/create/create.go b/internal/db/branch/create/create.go index 66635bad1..085e10f9d 100644 --- a/internal/db/branch/create/create.go +++ b/internal/db/branch/create/create.go @@ -13,7 +13,7 @@ import ( "github.com/docker/docker/pkg/stdcopy" "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) var ( diff --git a/internal/db/branch/create/create_test.go b/internal/db/branch/create/create_test.go index 20bfd4ac3..8e3842345 100644 --- a/internal/db/branch/create/create_test.go +++ b/internal/db/branch/create/create_test.go @@ -10,8 +10,8 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" ) func TestBranchValidation(t *testing.T) { diff --git a/internal/db/branch/delete/delete.go b/internal/db/branch/delete/delete.go index 9655cd793..f59f5e51c 100644 --- a/internal/db/branch/delete/delete.go +++ b/internal/db/branch/delete/delete.go @@ -11,7 +11,7 @@ import ( "github.com/docker/docker/pkg/stdcopy" "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func Run(branch string, fsys afero.Fs) error { diff --git a/internal/db/branch/delete/delete_test.go b/internal/db/branch/delete/delete_test.go index 709a3a520..76957e246 100644 --- a/internal/db/branch/delete/delete_test.go +++ b/internal/db/branch/delete/delete_test.go @@ -9,8 +9,8 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" ) func TestBranchDir(t *testing.T) { diff --git a/internal/db/branch/list/list.go b/internal/db/branch/list/list.go index f88104229..b1037ac1b 100644 --- a/internal/db/branch/list/list.go +++ b/internal/db/branch/list/list.go @@ -8,7 +8,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func Run(fsys afero.Fs, out io.Writer) error { diff --git a/internal/db/branch/list/list_test.go b/internal/db/branch/list/list_test.go index fa16586a5..24e34d5e5 100644 --- a/internal/db/branch/list/list_test.go +++ b/internal/db/branch/list/list_test.go @@ -10,7 +10,7 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func TestListCommand(t *testing.T) { diff --git a/internal/db/branch/switch_/switch_.go b/internal/db/branch/switch_/switch_.go index b1255ea63..462b26c69 100644 --- a/internal/db/branch/switch_/switch_.go +++ b/internal/db/branch/switch_/switch_.go @@ -10,8 +10,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, target string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/db/branch/switch_/switch__test.go b/internal/db/branch/switch_/switch__test.go index 8f22f3214..7c70959ce 100644 --- a/internal/db/branch/switch_/switch__test.go +++ b/internal/db/branch/switch_/switch__test.go @@ -13,10 +13,10 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgtest" ) func TestSwitchCommand(t *testing.T) { diff --git a/internal/db/diff/diff.go b/internal/db/diff/diff.go index 05da60459..6c5faa892 100644 --- a/internal/db/diff/diff.go +++ b/internal/db/diff/diff.go @@ -21,11 +21,11 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/start" - "github.com/supabase/cli/v2/internal/gen/keys" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" - "github.com/supabase/cli/v2/pkg/parser" + "github.com/supabase/cli/internal/db/start" + "github.com/supabase/cli/internal/gen/keys" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/parser" ) type DiffFunc func(context.Context, string, string, []string) (string, error) diff --git a/internal/db/diff/diff_test.go b/internal/db/diff/diff_test.go index 3db4d954a..6ada103c7 100644 --- a/internal/db/diff/diff_test.go +++ b/internal/db/diff/diff_test.go @@ -17,14 +17,14 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/db/start" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/testing/helper" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/config" - "github.com/supabase/cli/v2/pkg/migration" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/db/start" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/testing/helper" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/db/diff/migra.go b/internal/db/diff/migra.go index 47f8ba1bf..4e7842693 100644 --- a/internal/db/diff/migra.go +++ b/internal/db/diff/migra.go @@ -9,8 +9,8 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/config" ) //go:embed templates/migra.sh diff --git a/internal/db/diff/pgadmin.go b/internal/db/diff/pgadmin.go index baa984849..298023580 100644 --- a/internal/db/diff/pgadmin.go +++ b/internal/db/diff/pgadmin.go @@ -8,10 +8,10 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/start" - "github.com/supabase/cli/v2/internal/migration/new" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/internal/db/start" + "github.com/supabase/cli/internal/migration/new" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/config" ) var warnDiff = `WARNING: The diff tool is not foolproof, so you may need to manually rearrange and modify the generated migration. diff --git a/internal/db/dump/dump.go b/internal/db/dump/dump.go index bef685fe9..94e2ba7af 100644 --- a/internal/db/dump/dump.go +++ b/internal/db/dump/dump.go @@ -13,8 +13,8 @@ import ( "github.com/go-errors/errors" "github.com/jackc/pgconn" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - cliConfig "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/internal/utils" + cliConfig "github.com/supabase/cli/pkg/config" ) var ( diff --git a/internal/db/dump/dump_test.go b/internal/db/dump/dump_test.go index 62c1240a3..3a7c3cc65 100644 --- a/internal/db/dump/dump_test.go +++ b/internal/db/dump/dump_test.go @@ -10,8 +10,8 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" ) var dbConfig = pgconn.Config{ diff --git a/internal/db/lint/lint.go b/internal/db/lint/lint.go index 5fe21d182..5701d89be 100644 --- a/internal/db/lint/lint.go +++ b/internal/db/lint/lint.go @@ -13,8 +13,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" ) const ENABLE_PGSQL_CHECK = "CREATE EXTENSION IF NOT EXISTS plpgsql_check" diff --git a/internal/db/lint/lint_test.go b/internal/db/lint/lint_test.go index 807540a44..8d7abef8f 100644 --- a/internal/db/lint/lint_test.go +++ b/internal/db/lint/lint_test.go @@ -14,9 +14,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/db/pull/pull.go b/internal/db/pull/pull.go index ad5e07103..f6a235e11 100644 --- a/internal/db/pull/pull.go +++ b/internal/db/pull/pull.go @@ -12,13 +12,13 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/diff" - "github.com/supabase/cli/v2/internal/db/dump" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/migration/new" - "github.com/supabase/cli/v2/internal/migration/repair" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/internal/db/diff" + "github.com/supabase/cli/internal/db/dump" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/migration/new" + "github.com/supabase/cli/internal/migration/repair" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" ) var ( diff --git a/internal/db/pull/pull_test.go b/internal/db/pull/pull_test.go index f6248fe9d..2e55fcfed 100644 --- a/internal/db/pull/pull_test.go +++ b/internal/db/pull/pull_test.go @@ -13,11 +13,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/db/push/push.go b/internal/db/push/push.go index 29555b5be..2141255ae 100644 --- a/internal/db/push/push.go +++ b/internal/db/push/push.go @@ -10,10 +10,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/up" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/internal/migration/up" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/migration" ) func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, includeSeed bool, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/db/push/push_test.go b/internal/db/push/push_test.go index dad8f2e49..3a3ff3cda 100644 --- a/internal/db/push/push_test.go +++ b/internal/db/push/push_test.go @@ -13,11 +13,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/testing/helper" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/testing/helper" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/db/remote/changes/changes.go b/internal/db/remote/changes/changes.go index c711470c8..c735b5984 100644 --- a/internal/db/remote/changes/changes.go +++ b/internal/db/remote/changes/changes.go @@ -6,9 +6,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/diff" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/internal/db/diff" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" ) var output string diff --git a/internal/db/remote/commit/commit.go b/internal/db/remote/commit/commit.go index 75b9232d8..f9062d492 100644 --- a/internal/db/remote/commit/commit.go +++ b/internal/db/remote/commit/commit.go @@ -10,12 +10,12 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/diff" - "github.com/supabase/cli/v2/internal/db/dump" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/migration/repair" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/internal/db/diff" + "github.com/supabase/cli/internal/db/dump" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/migration/repair" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" ) func Run(ctx context.Context, schema []string, config pgconn.Config, fsys afero.Fs) error { diff --git a/internal/db/reset/reset.go b/internal/db/reset/reset.go index 81b8e1457..3830a019d 100644 --- a/internal/db/reset/reset.go +++ b/internal/db/reset/reset.go @@ -20,15 +20,15 @@ import ( "github.com/jackc/pgerrcode" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/start" - "github.com/supabase/cli/v2/internal/gen/keys" - "github.com/supabase/cli/v2/internal/migration/apply" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/migration/repair" - "github.com/supabase/cli/v2/internal/seed/buckets" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/internal/db/start" + "github.com/supabase/cli/internal/gen/keys" + "github.com/supabase/cli/internal/migration/apply" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/migration/repair" + "github.com/supabase/cli/internal/seed/buckets" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/migration" ) func Run(ctx context.Context, version string, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/db/reset/reset_test.go b/internal/db/reset/reset_test.go index 3693ac8b5..4e3558be3 100644 --- a/internal/db/reset/reset_test.go +++ b/internal/db/reset/reset_test.go @@ -16,14 +16,14 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/db/start" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/testing/helper" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" - "github.com/supabase/cli/v2/pkg/pgtest" - "github.com/supabase/cli/v2/pkg/storage" + "github.com/supabase/cli/internal/db/start" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/testing/helper" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/pkg/storage" ) func TestResetCommand(t *testing.T) { diff --git a/internal/db/start/start.go b/internal/db/start/start.go index f286b1fcb..c4722f22f 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -19,10 +19,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/apply" - "github.com/supabase/cli/v2/internal/status" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/internal/migration/apply" + "github.com/supabase/cli/internal/status" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" ) var ( diff --git a/internal/db/start/start_test.go b/internal/db/start/start_test.go index e52ecbbbd..475562f2f 100644 --- a/internal/db/start/start_test.go +++ b/internal/db/start/start_test.go @@ -14,11 +14,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/cast" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/pgtest" ) func TestInitBranch(t *testing.T) { diff --git a/internal/db/test/test.go b/internal/db/test/test.go index 4374e7c98..263305736 100644 --- a/internal/db/test/test.go +++ b/internal/db/test/test.go @@ -15,8 +15,8 @@ import ( "github.com/jackc/pgx/v4" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/utils" - cliConfig "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/internal/utils" + cliConfig "github.com/supabase/cli/pkg/config" ) const ( diff --git a/internal/db/test/test_test.go b/internal/db/test/test_test.go index 30f781fdf..7c9310991 100644 --- a/internal/db/test/test_test.go +++ b/internal/db/test/test_test.go @@ -11,10 +11,10 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/config" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/debug/postgres_test.go b/internal/debug/postgres_test.go index 4d836ce7d..9f46fd6b8 100644 --- a/internal/debug/postgres_test.go +++ b/internal/debug/postgres_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgx/v4" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/pgtest" ) func TestPostgresProxy(t *testing.T) { diff --git a/internal/encryption/get/get.go b/internal/encryption/get/get.go index 22b827860..93c698635 100644 --- a/internal/encryption/get/get.go +++ b/internal/encryption/get/get.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, projectRef string) error { diff --git a/internal/encryption/get/get_test.go b/internal/encryption/get/get_test.go index a3656dc0b..8f280189b 100644 --- a/internal/encryption/get/get_test.go +++ b/internal/encryption/get/get_test.go @@ -7,9 +7,9 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func TestGetRootKey(t *testing.T) { diff --git a/internal/encryption/update/update.go b/internal/encryption/update/update.go index 172c6429e..ed576823f 100644 --- a/internal/encryption/update/update.go +++ b/internal/encryption/update/update.go @@ -7,9 +7,9 @@ import ( "strings" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/credentials" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/credentials" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, projectRef string, stdin *os.File) error { diff --git a/internal/encryption/update/update_test.go b/internal/encryption/update/update_test.go index 5e8bf3434..8a6f60930 100644 --- a/internal/encryption/update/update_test.go +++ b/internal/encryption/update/update_test.go @@ -9,9 +9,9 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func TestUpdateRootKey(t *testing.T) { diff --git a/internal/functions/delete/delete.go b/internal/functions/delete/delete.go index 0242d5a7a..47d5957ef 100644 --- a/internal/functions/delete/delete.go +++ b/internal/functions/delete/delete.go @@ -7,7 +7,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, slug string, projectRef string, fsys afero.Fs) error { diff --git a/internal/functions/delete/delete_test.go b/internal/functions/delete/delete_test.go index ac39d5ce2..110208ea9 100644 --- a/internal/functions/delete/delete_test.go +++ b/internal/functions/delete/delete_test.go @@ -9,8 +9,8 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" ) func TestDeleteCommand(t *testing.T) { diff --git a/internal/functions/deploy/bundle.go b/internal/functions/deploy/bundle.go index 4a75e82e4..0119a559c 100644 --- a/internal/functions/deploy/bundle.go +++ b/internal/functions/deploy/bundle.go @@ -13,8 +13,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/function" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/function" ) type dockerBundler struct { diff --git a/internal/functions/deploy/bundle_test.go b/internal/functions/deploy/bundle_test.go index bb286cc21..f8a68f439 100644 --- a/internal/functions/deploy/bundle_test.go +++ b/internal/functions/deploy/bundle_test.go @@ -11,8 +11,8 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" ) func TestDockerBundle(t *testing.T) { diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index 2c97931c8..529b78976 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -9,11 +9,11 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/cast" - "github.com/supabase/cli/v2/pkg/config" - "github.com/supabase/cli/v2/pkg/function" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/pkg/function" ) func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bool, importMapPath string, fsys afero.Fs) error { diff --git a/internal/functions/deploy/deploy_test.go b/internal/functions/deploy/deploy_test.go index 542094f1a..558a33f32 100644 --- a/internal/functions/deploy/deploy_test.go +++ b/internal/functions/deploy/deploy_test.go @@ -12,11 +12,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" - "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/config" ) func TestDeployCommand(t *testing.T) { diff --git a/internal/functions/download/download.go b/internal/functions/download/download.go index 169df9d8b..e3b68cae9 100644 --- a/internal/functions/download/download.go +++ b/internal/functions/download/download.go @@ -15,8 +15,8 @@ import ( "github.com/docker/docker/api/types/network" "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) var ( diff --git a/internal/functions/download/download_test.go b/internal/functions/download/download_test.go index 73c8afd80..b727f95c3 100644 --- a/internal/functions/download/download_test.go +++ b/internal/functions/download/download_test.go @@ -13,9 +13,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func TestMain(m *testing.M) { diff --git a/internal/functions/list/list.go b/internal/functions/list/list.go index 603de90aa..d0d2d9ecc 100644 --- a/internal/functions/list/list.go +++ b/internal/functions/list/list.go @@ -7,8 +7,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/functions/list/list_test.go b/internal/functions/list/list_test.go index 8f9d26174..e9c7f26b7 100644 --- a/internal/functions/list/list_test.go +++ b/internal/functions/list/list_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func TestFunctionsListCommand(t *testing.T) { diff --git a/internal/functions/new/new.go b/internal/functions/new/new.go index d876a9916..3656e9b5f 100644 --- a/internal/functions/new/new.go +++ b/internal/functions/new/new.go @@ -10,7 +10,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) var ( diff --git a/internal/functions/new/new_test.go b/internal/functions/new/new_test.go index fbb5f5e2d..d5e9c2fc8 100644 --- a/internal/functions/new/new_test.go +++ b/internal/functions/new/new_test.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func TestNewCommand(t *testing.T) { diff --git a/internal/functions/serve/serve.go b/internal/functions/serve/serve.go index 1d9b28258..62811d769 100644 --- a/internal/functions/serve/serve.go +++ b/internal/functions/serve/serve.go @@ -16,9 +16,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/functions/deploy" - "github.com/supabase/cli/v2/internal/secrets/set" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/functions/deploy" + "github.com/supabase/cli/internal/secrets/set" + "github.com/supabase/cli/internal/utils" ) type InspectMode string diff --git a/internal/functions/serve/serve_test.go b/internal/functions/serve/serve_test.go index dbc14852a..570c4b927 100644 --- a/internal/functions/serve/serve_test.go +++ b/internal/functions/serve/serve_test.go @@ -12,9 +12,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/cast" ) func TestServeCommand(t *testing.T) { diff --git a/internal/gen/keys/keys.go b/internal/gen/keys/keys.go index a1079e627..81ed52988 100644 --- a/internal/gen/keys/keys.go +++ b/internal/gen/keys/keys.go @@ -11,8 +11,8 @@ import ( "github.com/go-errors/errors" "github.com/go-git/go-git/v5" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/config" ) type CustomName struct { diff --git a/internal/gen/types/types.go b/internal/gen/types/types.go index 1e158dd10..b399cfb5c 100644 --- a/internal/gen/types/types.go +++ b/internal/gen/types/types.go @@ -12,8 +12,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) const ( diff --git a/internal/gen/types/types_test.go b/internal/gen/types/types_test.go index 07ed9e02f..811ae061d 100644 --- a/internal/gen/types/types_test.go +++ b/internal/gen/types/types_test.go @@ -12,10 +12,10 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/pgtest" ) func TestGenLocalCommand(t *testing.T) { diff --git a/internal/hostnames/activate/activate.go b/internal/hostnames/activate/activate.go index 1b951085e..3cc01c206 100644 --- a/internal/hostnames/activate/activate.go +++ b/internal/hostnames/activate/activate.go @@ -6,8 +6,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/hostnames" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/hostnames" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, projectRef string, includeRawOutput bool, fsys afero.Fs) error { diff --git a/internal/hostnames/common.go b/internal/hostnames/common.go index b1f55e241..c01e6a0da 100644 --- a/internal/hostnames/common.go +++ b/internal/hostnames/common.go @@ -7,8 +7,8 @@ import ( "strings" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func GetCustomHostnameConfig(ctx context.Context, projectRef string) (*api.V1GetHostnameConfigResponse, error) { diff --git a/internal/hostnames/create/create.go b/internal/hostnames/create/create.go index 4f3e7c3e0..563b524bc 100644 --- a/internal/hostnames/create/create.go +++ b/internal/hostnames/create/create.go @@ -7,9 +7,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/hostnames" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/hostnames" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, projectRef string, customHostname string, includeRawOutput bool, fsys afero.Fs) error { diff --git a/internal/hostnames/delete/delete.go b/internal/hostnames/delete/delete.go index 6e472bc6c..3b9f3653c 100644 --- a/internal/hostnames/delete/delete.go +++ b/internal/hostnames/delete/delete.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/hostnames/get/get.go b/internal/hostnames/get/get.go index def0af734..9e17c19f2 100644 --- a/internal/hostnames/get/get.go +++ b/internal/hostnames/get/get.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/hostnames" + "github.com/supabase/cli/internal/hostnames" ) func Run(ctx context.Context, projectRef string, includeRawOutput bool, fsys afero.Fs) error { diff --git a/internal/hostnames/reverify/reverify.go b/internal/hostnames/reverify/reverify.go index c7abe8217..7f4329903 100644 --- a/internal/hostnames/reverify/reverify.go +++ b/internal/hostnames/reverify/reverify.go @@ -6,8 +6,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/hostnames" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/hostnames" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, projectRef string, includeRawOutput bool, fsys afero.Fs) error { diff --git a/internal/init/init.go b/internal/init/init.go index ed99ecb9c..f4e470b02 100644 --- a/internal/init/init.go +++ b/internal/init/init.go @@ -11,7 +11,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) var ( diff --git a/internal/init/init_test.go b/internal/init/init_test.go index b47c2f0f4..99a96dce5 100644 --- a/internal/init/init_test.go +++ b/internal/init/init_test.go @@ -9,9 +9,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/cast" ) func TestInitCommand(t *testing.T) { diff --git a/internal/inspect/bloat/bloat.go b/internal/inspect/bloat/bloat.go index ed680d005..6a97e41c8 100644 --- a/internal/inspect/bloat/bloat.go +++ b/internal/inspect/bloat/bloat.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed bloat.sql diff --git a/internal/inspect/bloat/bloat_test.go b/internal/inspect/bloat/bloat_test.go index e5b75d799..8646565ce 100644 --- a/internal/inspect/bloat/bloat_test.go +++ b/internal/inspect/bloat/bloat_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/blocking/blocking.go b/internal/inspect/blocking/blocking.go index 9aa6baba2..37baed1f9 100644 --- a/internal/inspect/blocking/blocking.go +++ b/internal/inspect/blocking/blocking.go @@ -10,9 +10,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed blocking.sql diff --git a/internal/inspect/blocking/blocking_test.go b/internal/inspect/blocking/blocking_test.go index 15bd69712..46b63441f 100644 --- a/internal/inspect/blocking/blocking_test.go +++ b/internal/inspect/blocking/blocking_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/cache/cache.go b/internal/inspect/cache/cache.go index c36339a66..ce30c1f4a 100644 --- a/internal/inspect/cache/cache.go +++ b/internal/inspect/cache/cache.go @@ -9,9 +9,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed cache.sql diff --git a/internal/inspect/cache/cache_test.go b/internal/inspect/cache/cache_test.go index cc332c857..28fa1cb73 100644 --- a/internal/inspect/cache/cache_test.go +++ b/internal/inspect/cache/cache_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/calls/calls.go b/internal/inspect/calls/calls.go index a1fe4d9e2..2fd0c8df8 100644 --- a/internal/inspect/calls/calls.go +++ b/internal/inspect/calls/calls.go @@ -10,9 +10,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed calls.sql diff --git a/internal/inspect/calls/calls_test.go b/internal/inspect/calls/calls_test.go index 3d5a8408b..ded271009 100644 --- a/internal/inspect/calls/calls_test.go +++ b/internal/inspect/calls/calls_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/index_sizes/index_sizes.go b/internal/inspect/index_sizes/index_sizes.go index 56467f381..2cfc06e8d 100644 --- a/internal/inspect/index_sizes/index_sizes.go +++ b/internal/inspect/index_sizes/index_sizes.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed index_sizes.sql diff --git a/internal/inspect/index_sizes/index_sizes_test.go b/internal/inspect/index_sizes/index_sizes_test.go index fe3cf71ed..9071c5710 100644 --- a/internal/inspect/index_sizes/index_sizes_test.go +++ b/internal/inspect/index_sizes/index_sizes_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/index_usage/index_usage.go b/internal/inspect/index_usage/index_usage.go index 76019e5cf..cd8875f79 100644 --- a/internal/inspect/index_usage/index_usage.go +++ b/internal/inspect/index_usage/index_usage.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed index_usage.sql diff --git a/internal/inspect/index_usage/index_usage_test.go b/internal/inspect/index_usage/index_usage_test.go index be965bf39..5b735bb60 100644 --- a/internal/inspect/index_usage/index_usage_test.go +++ b/internal/inspect/index_usage/index_usage_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/locks/locks.go b/internal/inspect/locks/locks.go index 57aa8ed67..0b2db71c6 100644 --- a/internal/inspect/locks/locks.go +++ b/internal/inspect/locks/locks.go @@ -10,9 +10,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed locks.sql diff --git a/internal/inspect/locks/locks_test.go b/internal/inspect/locks/locks_test.go index 398c9dce9..e4c55c6bd 100644 --- a/internal/inspect/locks/locks_test.go +++ b/internal/inspect/locks/locks_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/long_running_queries/long_running_queries.go b/internal/inspect/long_running_queries/long_running_queries.go index 31b0095a0..acf4be456 100644 --- a/internal/inspect/long_running_queries/long_running_queries.go +++ b/internal/inspect/long_running_queries/long_running_queries.go @@ -9,9 +9,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed long_running_queries.sql diff --git a/internal/inspect/long_running_queries/long_running_queries_test.go b/internal/inspect/long_running_queries/long_running_queries_test.go index afb2e249f..d936c61a3 100644 --- a/internal/inspect/long_running_queries/long_running_queries_test.go +++ b/internal/inspect/long_running_queries/long_running_queries_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/outliers/outliers.go b/internal/inspect/outliers/outliers.go index 2e5c849d8..06f015c18 100644 --- a/internal/inspect/outliers/outliers.go +++ b/internal/inspect/outliers/outliers.go @@ -10,9 +10,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed outliers.sql diff --git a/internal/inspect/outliers/outliers_test.go b/internal/inspect/outliers/outliers_test.go index f6f83cf34..e5d46432a 100644 --- a/internal/inspect/outliers/outliers_test.go +++ b/internal/inspect/outliers/outliers_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/replication_slots/replication_slots.go b/internal/inspect/replication_slots/replication_slots.go index e0ef52ee2..927ad052a 100644 --- a/internal/inspect/replication_slots/replication_slots.go +++ b/internal/inspect/replication_slots/replication_slots.go @@ -9,9 +9,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed replication_slots.sql diff --git a/internal/inspect/replication_slots/replication_slots_test.go b/internal/inspect/replication_slots/replication_slots_test.go index a7891b4c8..d9e9b3225 100644 --- a/internal/inspect/replication_slots/replication_slots_test.go +++ b/internal/inspect/replication_slots/replication_slots_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/report.go b/internal/inspect/report.go index 718ea5344..de721d954 100644 --- a/internal/inspect/report.go +++ b/internal/inspect/report.go @@ -14,8 +14,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/utils" ) //go:embed **/*.sql diff --git a/internal/inspect/report_test.go b/internal/inspect/report_test.go index 898734c69..6b4220451 100644 --- a/internal/inspect/report_test.go +++ b/internal/inspect/report_test.go @@ -8,27 +8,27 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/inspect/bloat" - "github.com/supabase/cli/v2/internal/inspect/blocking" - "github.com/supabase/cli/v2/internal/inspect/cache" - "github.com/supabase/cli/v2/internal/inspect/calls" - "github.com/supabase/cli/v2/internal/inspect/index_sizes" - "github.com/supabase/cli/v2/internal/inspect/index_usage" - "github.com/supabase/cli/v2/internal/inspect/locks" - "github.com/supabase/cli/v2/internal/inspect/long_running_queries" - "github.com/supabase/cli/v2/internal/inspect/outliers" - "github.com/supabase/cli/v2/internal/inspect/replication_slots" - "github.com/supabase/cli/v2/internal/inspect/role_configs" - "github.com/supabase/cli/v2/internal/inspect/role_connections" - "github.com/supabase/cli/v2/internal/inspect/seq_scans" - "github.com/supabase/cli/v2/internal/inspect/table_index_sizes" - "github.com/supabase/cli/v2/internal/inspect/table_record_counts" - "github.com/supabase/cli/v2/internal/inspect/table_sizes" - "github.com/supabase/cli/v2/internal/inspect/total_index_size" - "github.com/supabase/cli/v2/internal/inspect/total_table_sizes" - "github.com/supabase/cli/v2/internal/inspect/unused_indexes" - "github.com/supabase/cli/v2/internal/inspect/vacuum_stats" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/inspect/bloat" + "github.com/supabase/cli/internal/inspect/blocking" + "github.com/supabase/cli/internal/inspect/cache" + "github.com/supabase/cli/internal/inspect/calls" + "github.com/supabase/cli/internal/inspect/index_sizes" + "github.com/supabase/cli/internal/inspect/index_usage" + "github.com/supabase/cli/internal/inspect/locks" + "github.com/supabase/cli/internal/inspect/long_running_queries" + "github.com/supabase/cli/internal/inspect/outliers" + "github.com/supabase/cli/internal/inspect/replication_slots" + "github.com/supabase/cli/internal/inspect/role_configs" + "github.com/supabase/cli/internal/inspect/role_connections" + "github.com/supabase/cli/internal/inspect/seq_scans" + "github.com/supabase/cli/internal/inspect/table_index_sizes" + "github.com/supabase/cli/internal/inspect/table_record_counts" + "github.com/supabase/cli/internal/inspect/table_sizes" + "github.com/supabase/cli/internal/inspect/total_index_size" + "github.com/supabase/cli/internal/inspect/total_table_sizes" + "github.com/supabase/cli/internal/inspect/unused_indexes" + "github.com/supabase/cli/internal/inspect/vacuum_stats" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/role_configs/role_configs.go b/internal/inspect/role_configs/role_configs.go index 9f605419f..f4fb79382 100644 --- a/internal/inspect/role_configs/role_configs.go +++ b/internal/inspect/role_configs/role_configs.go @@ -9,9 +9,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed role_configs.sql diff --git a/internal/inspect/role_configs/role_configs_test.go b/internal/inspect/role_configs/role_configs_test.go index 67d734301..554a12526 100644 --- a/internal/inspect/role_configs/role_configs_test.go +++ b/internal/inspect/role_configs/role_configs_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/role_connections/role_connections.go b/internal/inspect/role_connections/role_connections.go index e5bec0934..5b0a56539 100644 --- a/internal/inspect/role_connections/role_connections.go +++ b/internal/inspect/role_connections/role_connections.go @@ -9,9 +9,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed role_connections.sql diff --git a/internal/inspect/role_connections/role_connections_test.go b/internal/inspect/role_connections/role_connections_test.go index b7d1ec884..32ecab768 100644 --- a/internal/inspect/role_connections/role_connections_test.go +++ b/internal/inspect/role_connections/role_connections_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/seq_scans/seq_scans.go b/internal/inspect/seq_scans/seq_scans.go index 240112d5b..6b52538ee 100644 --- a/internal/inspect/seq_scans/seq_scans.go +++ b/internal/inspect/seq_scans/seq_scans.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed seq_scans.sql diff --git a/internal/inspect/seq_scans/seq_scans_test.go b/internal/inspect/seq_scans/seq_scans_test.go index 0e2bdfb42..3db6caee5 100644 --- a/internal/inspect/seq_scans/seq_scans_test.go +++ b/internal/inspect/seq_scans/seq_scans_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/table_index_sizes/table_index_sizes.go b/internal/inspect/table_index_sizes/table_index_sizes.go index 8a5b3a096..e61f23361 100644 --- a/internal/inspect/table_index_sizes/table_index_sizes.go +++ b/internal/inspect/table_index_sizes/table_index_sizes.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed table_index_sizes.sql diff --git a/internal/inspect/table_index_sizes/table_index_sizes_test.go b/internal/inspect/table_index_sizes/table_index_sizes_test.go index 92e58ef56..20ad80fc9 100644 --- a/internal/inspect/table_index_sizes/table_index_sizes_test.go +++ b/internal/inspect/table_index_sizes/table_index_sizes_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/table_record_counts/table_record_counts.go b/internal/inspect/table_record_counts/table_record_counts.go index 19e32a5b3..e0b394374 100644 --- a/internal/inspect/table_record_counts/table_record_counts.go +++ b/internal/inspect/table_record_counts/table_record_counts.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed table_record_counts.sql diff --git a/internal/inspect/table_record_counts/table_record_counts_test.go b/internal/inspect/table_record_counts/table_record_counts_test.go index 753074e77..a03714d97 100644 --- a/internal/inspect/table_record_counts/table_record_counts_test.go +++ b/internal/inspect/table_record_counts/table_record_counts_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/table_sizes/table_sizes.go b/internal/inspect/table_sizes/table_sizes.go index 7ce49e225..7741f0119 100644 --- a/internal/inspect/table_sizes/table_sizes.go +++ b/internal/inspect/table_sizes/table_sizes.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed table_sizes.sql diff --git a/internal/inspect/table_sizes/table_sizes_test.go b/internal/inspect/table_sizes/table_sizes_test.go index 057f32d14..5cc6426ad 100644 --- a/internal/inspect/table_sizes/table_sizes_test.go +++ b/internal/inspect/table_sizes/table_sizes_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/total_index_size/total_index_size.go b/internal/inspect/total_index_size/total_index_size.go index bd6a13fd9..fbc66b259 100644 --- a/internal/inspect/total_index_size/total_index_size.go +++ b/internal/inspect/total_index_size/total_index_size.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed total_index_size.sql diff --git a/internal/inspect/total_index_size/total_index_size_test.go b/internal/inspect/total_index_size/total_index_size_test.go index c59401469..8eb0e0aa9 100644 --- a/internal/inspect/total_index_size/total_index_size_test.go +++ b/internal/inspect/total_index_size/total_index_size_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/total_table_sizes/total_table_sizes.go b/internal/inspect/total_table_sizes/total_table_sizes.go index 3b96dcadd..80b1c89a8 100644 --- a/internal/inspect/total_table_sizes/total_table_sizes.go +++ b/internal/inspect/total_table_sizes/total_table_sizes.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed total_table_sizes.sql diff --git a/internal/inspect/total_table_sizes/total_table_sizes_test.go b/internal/inspect/total_table_sizes/total_table_sizes_test.go index 3419fc762..bc548af60 100644 --- a/internal/inspect/total_table_sizes/total_table_sizes_test.go +++ b/internal/inspect/total_table_sizes/total_table_sizes_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/unused_indexes/unused_indexes.go b/internal/inspect/unused_indexes/unused_indexes.go index d7589888d..2a30a46d7 100644 --- a/internal/inspect/unused_indexes/unused_indexes.go +++ b/internal/inspect/unused_indexes/unused_indexes.go @@ -9,10 +9,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed unused_indexes.sql diff --git a/internal/inspect/unused_indexes/unused_indexes_test.go b/internal/inspect/unused_indexes/unused_indexes_test.go index af3936166..ee4182094 100644 --- a/internal/inspect/unused_indexes/unused_indexes_test.go +++ b/internal/inspect/unused_indexes/unused_indexes_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/inspect/vacuum_stats/vacuum_stats.go b/internal/inspect/vacuum_stats/vacuum_stats.go index 950956503..dc9326d79 100644 --- a/internal/inspect/vacuum_stats/vacuum_stats.go +++ b/internal/inspect/vacuum_stats/vacuum_stats.go @@ -10,10 +10,10 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgxv5" ) //go:embed vacuum_stats.sql diff --git a/internal/inspect/vacuum_stats/vacuum_stats_test.go b/internal/inspect/vacuum_stats/vacuum_stats_test.go index fba1e9a47..0d3cbec10 100644 --- a/internal/inspect/vacuum_stats/vacuum_stats_test.go +++ b/internal/inspect/vacuum_stats/vacuum_stats_test.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgconn" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/db/reset" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/db/reset" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/link/link.go b/internal/link/link.go index 5f156b11b..e791271b8 100644 --- a/internal/link/link.go +++ b/internal/link/link.go @@ -13,15 +13,15 @@ import ( "github.com/jackc/pgx/v4" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/credentials" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/internal/utils/tenant" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" - cliConfig "github.com/supabase/cli/v2/pkg/config" - "github.com/supabase/cli/v2/pkg/diff" - "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/credentials" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/internal/utils/tenant" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + cliConfig "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/pkg/diff" + "github.com/supabase/cli/pkg/migration" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/link/link_test.go b/internal/link/link_test.go index 4f05a296e..18c090ad3 100644 --- a/internal/link/link_test.go +++ b/internal/link/link_test.go @@ -12,14 +12,14 @@ import ( "github.com/jackc/pgx/v4" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/testing/helper" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/tenant" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/migration" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/testing/helper" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/tenant" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/pgtest" "github.com/zalando/go-keyring" ) diff --git a/internal/login/login.go b/internal/login/login.go index be1265bec..6239b500a 100644 --- a/internal/login/login.go +++ b/internal/login/login.go @@ -20,9 +20,9 @@ import ( "github.com/go-errors/errors" "github.com/google/uuid" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/new" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/internal/migration/new" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/fetcher" ) type RunParams struct { diff --git a/internal/login/login_test.go b/internal/login/login_test.go index 8dd02deab..758fbc5c4 100644 --- a/internal/login/login_test.go +++ b/internal/login/login_test.go @@ -12,9 +12,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/credentials" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/credentials" "github.com/zalando/go-keyring" ) diff --git a/internal/logout/logout.go b/internal/logout/logout.go index ae71bf00b..abbd191b8 100644 --- a/internal/logout/logout.go +++ b/internal/logout/logout.go @@ -7,8 +7,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/credentials" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/credentials" ) func Run(ctx context.Context, stdout *os.File, fsys afero.Fs) error { diff --git a/internal/logout/logout_test.go b/internal/logout/logout_test.go index 5a7835824..42f9f8ead 100644 --- a/internal/logout/logout_test.go +++ b/internal/logout/logout_test.go @@ -8,10 +8,10 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/credentials" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/credentials" "github.com/zalando/go-keyring" ) diff --git a/internal/migration/apply/apply.go b/internal/migration/apply/apply.go index ea7f6cb8b..224b342f7 100644 --- a/internal/migration/apply/apply.go +++ b/internal/migration/apply/apply.go @@ -5,9 +5,9 @@ import ( "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" ) func MigrateAndSeed(ctx context.Context, version string, conn *pgx.Conn, fsys afero.Fs) error { diff --git a/internal/migration/apply/apply_test.go b/internal/migration/apply/apply_test.go index 49165f275..286093743 100644 --- a/internal/migration/apply/apply_test.go +++ b/internal/migration/apply/apply_test.go @@ -9,11 +9,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/testing/helper" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/testing/helper" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/pgtest" ) func TestMigrateDatabase(t *testing.T) { diff --git a/internal/migration/fetch/fetch.go b/internal/migration/fetch/fetch.go index fac525787..cb78c70d8 100644 --- a/internal/migration/fetch/fetch.go +++ b/internal/migration/fetch/fetch.go @@ -10,8 +10,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" ) func Run(ctx context.Context, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/migration/list/list.go b/internal/migration/list/list.go index d1202d068..3107d4ec6 100644 --- a/internal/migration/list/list.go +++ b/internal/migration/list/list.go @@ -11,8 +11,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" ) func Run(ctx context.Context, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/migration/list/list_test.go b/internal/migration/list/list_test.go index c68ade375..b23fa4a2d 100644 --- a/internal/migration/list/list_test.go +++ b/internal/migration/list/list_test.go @@ -12,10 +12,10 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/migration/new/new.go b/internal/migration/new/new.go index 026c54c7b..be232b591 100644 --- a/internal/migration/new/new.go +++ b/internal/migration/new/new.go @@ -8,7 +8,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func Run(migrationName string, stdin afero.File, fsys afero.Fs) error { diff --git a/internal/migration/new/new_test.go b/internal/migration/new/new_test.go index 232623cb1..39e2fe115 100644 --- a/internal/migration/new/new_test.go +++ b/internal/migration/new/new_test.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func TestNewCommand(t *testing.T) { diff --git a/internal/migration/repair/repair.go b/internal/migration/repair/repair.go index b43779aa6..c0670000a 100644 --- a/internal/migration/repair/repair.go +++ b/internal/migration/repair/repair.go @@ -11,9 +11,9 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" ) const ( diff --git a/internal/migration/repair/repair_test.go b/internal/migration/repair/repair_test.go index cb035c489..4dea63279 100644 --- a/internal/migration/repair/repair_test.go +++ b/internal/migration/repair/repair_test.go @@ -12,11 +12,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/testing/helper" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/testing/helper" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/migration/squash/squash.go b/internal/migration/squash/squash.go index 64429d260..2ed9e6252 100644 --- a/internal/migration/squash/squash.go +++ b/internal/migration/squash/squash.go @@ -14,13 +14,13 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/diff" - "github.com/supabase/cli/v2/internal/db/dump" - "github.com/supabase/cli/v2/internal/db/start" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/migration/repair" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/internal/db/diff" + "github.com/supabase/cli/internal/db/dump" + "github.com/supabase/cli/internal/db/start" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/migration/repair" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" ) var ErrMissingVersion = errors.New("version not found") diff --git a/internal/migration/squash/squash_test.go b/internal/migration/squash/squash_test.go index 1cbd85849..cc0461f3b 100644 --- a/internal/migration/squash/squash_test.go +++ b/internal/migration/squash/squash_test.go @@ -21,14 +21,14 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/db/start" - "github.com/supabase/cli/v2/internal/migration/repair" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/testing/helper" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/db/start" + "github.com/supabase/cli/internal/migration/repair" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/testing/helper" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/migration/up/up.go b/internal/migration/up/up.go index 8229fd6ed..d33117f33 100644 --- a/internal/migration/up/up.go +++ b/internal/migration/up/up.go @@ -9,8 +9,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" ) func Run(ctx context.Context, includeAll bool, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { diff --git a/internal/migration/up/up_test.go b/internal/migration/up/up_test.go index 69e9c5ecd..ea41680bc 100644 --- a/internal/migration/up/up_test.go +++ b/internal/migration/up/up_test.go @@ -9,10 +9,10 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/migration" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/pgtest" ) func TestPendingMigrations(t *testing.T) { diff --git a/internal/orgs/create/create.go b/internal/orgs/create/create.go index df7c1eec5..ed6008ab3 100644 --- a/internal/orgs/create/create.go +++ b/internal/orgs/create/create.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, name string) error { diff --git a/internal/orgs/create/create_test.go b/internal/orgs/create/create_test.go index 8792188f6..f491bdc31 100644 --- a/internal/orgs/create/create_test.go +++ b/internal/orgs/create/create_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func TestOrganizationCreateCommand(t *testing.T) { diff --git a/internal/orgs/list/list.go b/internal/orgs/list/list.go index 4eb7487f0..abd6c08df 100644 --- a/internal/orgs/list/list.go +++ b/internal/orgs/list/list.go @@ -6,8 +6,8 @@ import ( "strings" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context) error { diff --git a/internal/orgs/list/list_test.go b/internal/orgs/list/list_test.go index d538f5fea..00030dbd2 100644 --- a/internal/orgs/list/list_test.go +++ b/internal/orgs/list/list_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func TestOrganizationListCommand(t *testing.T) { diff --git a/internal/postgresConfig/get/get.go b/internal/postgresConfig/get/get.go index 535f0f171..ad311b396 100644 --- a/internal/postgresConfig/get/get.go +++ b/internal/postgresConfig/get/get.go @@ -9,8 +9,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/postgresConfig/update/update.go b/internal/postgresConfig/update/update.go index 9c8bec823..94632d486 100644 --- a/internal/postgresConfig/update/update.go +++ b/internal/postgresConfig/update/update.go @@ -9,8 +9,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/postgresConfig/get" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/postgresConfig/get" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, projectRef string, values []string, replaceOverrides, noRestart bool, fsys afero.Fs) error { diff --git a/internal/projects/apiKeys/api_keys.go b/internal/projects/apiKeys/api_keys.go index be5035a5b..7daddce21 100644 --- a/internal/projects/apiKeys/api_keys.go +++ b/internal/projects/apiKeys/api_keys.go @@ -8,9 +8,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/projects/apiKeys/api_keys_test.go b/internal/projects/apiKeys/api_keys_test.go index e94a999ce..57130f158 100644 --- a/internal/projects/apiKeys/api_keys_test.go +++ b/internal/projects/apiKeys/api_keys_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func TestProjectApiKeysCommand(t *testing.T) { diff --git a/internal/projects/create/create.go b/internal/projects/create/create.go index 671020f1f..ddbd46b47 100644 --- a/internal/projects/create/create.go +++ b/internal/projects/create/create.go @@ -9,10 +9,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/credentials" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/credentials" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, params api.V1CreateProjectBodyDto, fsys afero.Fs) error { diff --git a/internal/projects/create/create_test.go b/internal/projects/create/create_test.go index 8db8ef3da..879421d72 100644 --- a/internal/projects/create/create_test.go +++ b/internal/projects/create/create_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func TestProjectCreateCommand(t *testing.T) { diff --git a/internal/projects/delete/delete.go b/internal/projects/delete/delete.go index dda1dd297..f042f62e1 100644 --- a/internal/projects/delete/delete.go +++ b/internal/projects/delete/delete.go @@ -8,9 +8,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/unlink" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/credentials" + "github.com/supabase/cli/internal/unlink" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/credentials" "github.com/zalando/go-keyring" ) diff --git a/internal/projects/delete/delete_test.go b/internal/projects/delete/delete_test.go index aaa441229..b83d4cf8c 100644 --- a/internal/projects/delete/delete_test.go +++ b/internal/projects/delete/delete_test.go @@ -10,9 +10,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" "github.com/zalando/go-keyring" ) diff --git a/internal/projects/list/list.go b/internal/projects/list/list.go index 23dae8f07..ef356dfcf 100644 --- a/internal/projects/list/list.go +++ b/internal/projects/list/list.go @@ -8,10 +8,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/api" ) type linkedProject struct { diff --git a/internal/projects/list/list_test.go b/internal/projects/list/list_test.go index 31a1bc716..d5450bfb4 100644 --- a/internal/projects/list/list_test.go +++ b/internal/projects/list/list_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func TestProjectListCommand(t *testing.T) { diff --git a/internal/restrictions/get/get.go b/internal/restrictions/get/get.go index ffd4d8fb0..f8e27342d 100644 --- a/internal/restrictions/get/get.go +++ b/internal/restrictions/get/get.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, projectRef string) error { diff --git a/internal/restrictions/update/update.go b/internal/restrictions/update/update.go index 8b5718a76..98a70da98 100644 --- a/internal/restrictions/update/update.go +++ b/internal/restrictions/update/update.go @@ -6,8 +6,8 @@ import ( "net" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, projectRef string, dbCidrsToAllow []string, bypassCidrChecks bool) error { diff --git a/internal/restrictions/update/update_test.go b/internal/restrictions/update/update_test.go index e23a3101e..5a6583ea8 100644 --- a/internal/restrictions/update/update_test.go +++ b/internal/restrictions/update/update_test.go @@ -8,9 +8,9 @@ import ( "github.com/go-errors/errors" "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func TestUpdateRestrictionsCommand(t *testing.T) { diff --git a/internal/secrets/list/list.go b/internal/secrets/list/list.go index 9cf4efa6a..e5b4d4538 100644 --- a/internal/secrets/list/list.go +++ b/internal/secrets/list/list.go @@ -8,9 +8,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/secrets/list/list_test.go b/internal/secrets/list/list_test.go index 4e831d38c..4e0da98b6 100644 --- a/internal/secrets/list/list_test.go +++ b/internal/secrets/list/list_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func TestSecretListCommand(t *testing.T) { diff --git a/internal/secrets/set/set.go b/internal/secrets/set/set.go index 14e715c7a..d2877c314 100644 --- a/internal/secrets/set/set.go +++ b/internal/secrets/set/set.go @@ -12,8 +12,8 @@ import ( "github.com/go-errors/errors" "github.com/joho/godotenv" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, projectRef, envFilePath string, args []string, fsys afero.Fs) error { diff --git a/internal/secrets/set/set_test.go b/internal/secrets/set/set_test.go index beb15c7fd..6021804c1 100644 --- a/internal/secrets/set/set_test.go +++ b/internal/secrets/set/set_test.go @@ -10,9 +10,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func TestSecretSetCommand(t *testing.T) { diff --git a/internal/secrets/unset/unset.go b/internal/secrets/unset/unset.go index e9f680d14..f6bbca8cf 100644 --- a/internal/secrets/unset/unset.go +++ b/internal/secrets/unset/unset.go @@ -9,8 +9,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/secrets/list" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/secrets/list" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, projectRef string, args []string, fsys afero.Fs) error { diff --git a/internal/secrets/unset/unset_test.go b/internal/secrets/unset/unset_test.go index e3f6d9dff..3207f8df7 100644 --- a/internal/secrets/unset/unset_test.go +++ b/internal/secrets/unset/unset_test.go @@ -8,9 +8,9 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func TestSecretUnsetCommand(t *testing.T) { diff --git a/internal/seed/buckets/buckets.go b/internal/seed/buckets/buckets.go index f68344828..b460fdc79 100644 --- a/internal/seed/buckets/buckets.go +++ b/internal/seed/buckets/buckets.go @@ -5,8 +5,8 @@ import ( "fmt" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/storage/client" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/storage/client" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, projectRef string, interactive bool, fsys afero.Fs) error { diff --git a/internal/seed/buckets/buckets_test.go b/internal/seed/buckets/buckets_test.go index 9e9c7b1a5..e14a40e74 100644 --- a/internal/seed/buckets/buckets_test.go +++ b/internal/seed/buckets/buckets_test.go @@ -11,9 +11,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/storage" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/storage" ) func TestSeedBuckets(t *testing.T) { diff --git a/internal/services/services.go b/internal/services/services.go index e32a3ad57..ebc08efca 100644 --- a/internal/services/services.go +++ b/internal/services/services.go @@ -9,10 +9,10 @@ import ( "sync" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/internal/utils/tenant" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/internal/utils/tenant" ) func Run(ctx context.Context, fsys afero.Fs) error { diff --git a/internal/snippets/download/download.go b/internal/snippets/download/download.go index f983d2101..7f1f3a463 100644 --- a/internal/snippets/download/download.go +++ b/internal/snippets/download/download.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, snippetId string, fsys afero.Fs) error { diff --git a/internal/snippets/list/list.go b/internal/snippets/list/list.go index c3c651f7b..f54325eaa 100644 --- a/internal/snippets/list/list.go +++ b/internal/snippets/list/list.go @@ -7,10 +7,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, fsys afero.Fs) error { diff --git a/internal/ssl_enforcement/get/get.go b/internal/ssl_enforcement/get/get.go index 50673d9c9..e6d58693e 100644 --- a/internal/ssl_enforcement/get/get.go +++ b/internal/ssl_enforcement/get/get.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/ssl_enforcement/update/update.go b/internal/ssl_enforcement/update/update.go index f5805d108..51b0b6725 100644 --- a/internal/ssl_enforcement/update/update.go +++ b/internal/ssl_enforcement/update/update.go @@ -6,8 +6,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, projectRef string, enforceDbSsl bool, fsys afero.Fs) error { diff --git a/internal/sso/create/create.go b/internal/sso/create/create.go index 1b24e12a9..a33b6e7e7 100644 --- a/internal/sso/create/create.go +++ b/internal/sso/create/create.go @@ -7,10 +7,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/sso/internal/render" - "github.com/supabase/cli/v2/internal/sso/internal/saml" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/sso/internal/render" + "github.com/supabase/cli/internal/sso/internal/saml" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) var Fs = afero.NewOsFs() diff --git a/internal/sso/get/get.go b/internal/sso/get/get.go index 43a8e206e..34370523e 100644 --- a/internal/sso/get/get.go +++ b/internal/sso/get/get.go @@ -7,9 +7,9 @@ import ( "os" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/sso/internal/render" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/sso/internal/render" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, ref, providerId, format string) error { diff --git a/internal/sso/get/get_test.go b/internal/sso/get/get_test.go index 3c506ce78..bd6fd0ef3 100644 --- a/internal/sso/get/get_test.go +++ b/internal/sso/get/get_test.go @@ -7,8 +7,8 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" ) func TestSSOProvidersShowCommand(t *testing.T) { diff --git a/internal/sso/info/info.go b/internal/sso/info/info.go index ffe51b8b0..c8a25805f 100644 --- a/internal/sso/info/info.go +++ b/internal/sso/info/info.go @@ -5,8 +5,8 @@ import ( "fmt" "os" - "github.com/supabase/cli/v2/internal/sso/internal/render" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/sso/internal/render" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, ref string, format string) error { diff --git a/internal/sso/internal/render/render.go b/internal/sso/internal/render/render.go index 3e45b2e01..3f3a03db1 100644 --- a/internal/sso/internal/render/render.go +++ b/internal/sso/internal/render/render.go @@ -7,9 +7,9 @@ import ( "github.com/go-errors/errors" "github.com/go-xmlfmt/xmlfmt" - "github.com/supabase/cli/v2/internal/migration/list" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/migration/list" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func formatProtocol(provider api.Provider) string { diff --git a/internal/sso/internal/saml/files.go b/internal/sso/internal/saml/files.go index 3b47dbe9d..62e0846e3 100644 --- a/internal/sso/internal/saml/files.go +++ b/internal/sso/internal/saml/files.go @@ -12,8 +12,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/fetcher" ) var DefaultClient = http.DefaultClient diff --git a/internal/sso/list/list.go b/internal/sso/list/list.go index 181a86aff..efacb1a04 100644 --- a/internal/sso/list/list.go +++ b/internal/sso/list/list.go @@ -6,8 +6,8 @@ import ( "os" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/sso/internal/render" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/sso/internal/render" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, ref, format string) error { diff --git a/internal/sso/list/list_test.go b/internal/sso/list/list_test.go index 50ab8d745..333ffd4a3 100644 --- a/internal/sso/list/list_test.go +++ b/internal/sso/list/list_test.go @@ -6,8 +6,8 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" ) func TestSSOProvidersListCommand(t *testing.T) { diff --git a/internal/sso/remove/remove.go b/internal/sso/remove/remove.go index a8b5b1ccf..1514314da 100644 --- a/internal/sso/remove/remove.go +++ b/internal/sso/remove/remove.go @@ -6,9 +6,9 @@ import ( "os" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/sso/internal/render" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/sso/internal/render" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, ref, providerId, format string) error { diff --git a/internal/sso/remove/remove_test.go b/internal/sso/remove/remove_test.go index c606c8628..f284f7e06 100644 --- a/internal/sso/remove/remove_test.go +++ b/internal/sso/remove/remove_test.go @@ -7,8 +7,8 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" ) func TestSSOProvidersRemoveCommand(t *testing.T) { diff --git a/internal/sso/update/update.go b/internal/sso/update/update.go index 5a412fed7..e8a745dc3 100644 --- a/internal/sso/update/update.go +++ b/internal/sso/update/update.go @@ -7,10 +7,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/sso/internal/render" - "github.com/supabase/cli/v2/internal/sso/internal/saml" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/sso/internal/render" + "github.com/supabase/cli/internal/sso/internal/saml" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) var Fs = afero.NewOsFs() diff --git a/internal/sso/update/update_test.go b/internal/sso/update/update_test.go index dd423dadd..6754fd487 100644 --- a/internal/sso/update/update_test.go +++ b/internal/sso/update/update_test.go @@ -10,9 +10,9 @@ import ( "github.com/google/uuid" "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func response(providerId string, domains []string) map[string]any { diff --git a/internal/start/start.go b/internal/start/start.go index c74f6287f..4315d31b7 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -23,14 +23,14 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/db/start" - "github.com/supabase/cli/v2/internal/functions/serve" - "github.com/supabase/cli/v2/internal/seed/buckets" - "github.com/supabase/cli/v2/internal/services" - "github.com/supabase/cli/v2/internal/status" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/internal/db/start" + "github.com/supabase/cli/internal/functions/serve" + "github.com/supabase/cli/internal/seed/buckets" + "github.com/supabase/cli/internal/services" + "github.com/supabase/cli/internal/status" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/config" "golang.org/x/mod/semver" ) diff --git a/internal/start/start_test.go b/internal/start/start_test.go index 93af236d9..079eb3c79 100644 --- a/internal/start/start_test.go +++ b/internal/start/start_test.go @@ -17,11 +17,11 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/config" - "github.com/supabase/cli/v2/pkg/pgtest" - "github.com/supabase/cli/v2/pkg/storage" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/pkg/pgtest" + "github.com/supabase/cli/pkg/storage" ) func TestStartCommand(t *testing.T) { diff --git a/internal/status/status.go b/internal/status/status.go index bcd8ff8bf..1b9d02f90 100644 --- a/internal/status/status.go +++ b/internal/status/status.go @@ -18,8 +18,8 @@ import ( "github.com/docker/docker/api/types/container" "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/fetcher" ) type CustomName struct { diff --git a/internal/status/status_test.go b/internal/status/status_test.go index 792b99c65..391a8c998 100644 --- a/internal/status/status_test.go +++ b/internal/status/status_test.go @@ -13,8 +13,8 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" ) func TestStatusCommand(t *testing.T) { diff --git a/internal/stop/stop.go b/internal/stop/stop.go index fc9dfebd5..39c5e00e5 100644 --- a/internal/stop/stop.go +++ b/internal/stop/stop.go @@ -8,7 +8,7 @@ import ( "github.com/docker/docker/api/types/volume" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, backup bool, projectId string, all bool, fsys afero.Fs) error { diff --git a/internal/stop/stop_test.go b/internal/stop/stop_test.go index cc287cb9e..b607d87d7 100644 --- a/internal/stop/stop_test.go +++ b/internal/stop/stop_test.go @@ -18,8 +18,8 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" ) func TestStopCommand(t *testing.T) { diff --git a/internal/storage/client/api.go b/internal/storage/client/api.go index ea44f3c7b..c8c2a02ef 100644 --- a/internal/storage/client/api.go +++ b/internal/storage/client/api.go @@ -5,11 +5,11 @@ import ( "net/http" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/status" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/tenant" - "github.com/supabase/cli/v2/pkg/fetcher" - "github.com/supabase/cli/v2/pkg/storage" + "github.com/supabase/cli/internal/status" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/tenant" + "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/pkg/storage" ) func NewStorageAPI(ctx context.Context, projectRef string) (storage.StorageAPI, error) { diff --git a/internal/storage/cp/cp.go b/internal/storage/cp/cp.go index 6c5df9f31..e55120a1c 100644 --- a/internal/storage/cp/cp.go +++ b/internal/storage/cp/cp.go @@ -12,12 +12,12 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/storage/client" - "github.com/supabase/cli/v2/internal/storage/ls" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/queue" - "github.com/supabase/cli/v2/pkg/storage" + "github.com/supabase/cli/internal/storage/client" + "github.com/supabase/cli/internal/storage/ls" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/queue" + "github.com/supabase/cli/pkg/storage" ) var errUnsupportedOperation = errors.New("Unsupported operation") diff --git a/internal/storage/cp/cp_test.go b/internal/storage/cp/cp_test.go index 83e787692..75a0cf3cd 100644 --- a/internal/storage/cp/cp_test.go +++ b/internal/storage/cp/cp_test.go @@ -10,13 +10,13 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" - "github.com/supabase/cli/v2/pkg/fetcher" - "github.com/supabase/cli/v2/pkg/storage" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/pkg/storage" ) var mockFile = storage.ObjectResponse{ diff --git a/internal/storage/ls/ls.go b/internal/storage/ls/ls.go index 0f521ce97..396dc9b7c 100644 --- a/internal/storage/ls/ls.go +++ b/internal/storage/ls/ls.go @@ -8,9 +8,9 @@ import ( "strings" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/storage/client" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/storage" + "github.com/supabase/cli/internal/storage/client" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/storage" ) func Run(ctx context.Context, objectPath string, recursive bool, fsys afero.Fs) error { diff --git a/internal/storage/ls/ls_test.go b/internal/storage/ls/ls_test.go index bef37987d..e0e2cd207 100644 --- a/internal/storage/ls/ls_test.go +++ b/internal/storage/ls/ls_test.go @@ -9,14 +9,14 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/storage/client" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" - "github.com/supabase/cli/v2/pkg/fetcher" - "github.com/supabase/cli/v2/pkg/storage" + "github.com/supabase/cli/internal/storage/client" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/pkg/storage" ) var mockFile = storage.ObjectResponse{ diff --git a/internal/storage/mv/mv.go b/internal/storage/mv/mv.go index 91f0ef3b2..a6dc8773c 100644 --- a/internal/storage/mv/mv.go +++ b/internal/storage/mv/mv.go @@ -9,10 +9,10 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/storage/client" - "github.com/supabase/cli/v2/internal/storage/ls" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/storage" + "github.com/supabase/cli/internal/storage/client" + "github.com/supabase/cli/internal/storage/ls" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/storage" ) var ( diff --git a/internal/storage/mv/mv_test.go b/internal/storage/mv/mv_test.go index 65164cc46..fd8ecfbcc 100644 --- a/internal/storage/mv/mv_test.go +++ b/internal/storage/mv/mv_test.go @@ -8,13 +8,13 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" - "github.com/supabase/cli/v2/pkg/fetcher" - "github.com/supabase/cli/v2/pkg/storage" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/pkg/storage" ) var mockFile = storage.ObjectResponse{ diff --git a/internal/storage/rm/rm.go b/internal/storage/rm/rm.go index 8734cc8ca..720bbce02 100644 --- a/internal/storage/rm/rm.go +++ b/internal/storage/rm/rm.go @@ -8,12 +8,12 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/storage/client" - "github.com/supabase/cli/v2/internal/storage/cp" - "github.com/supabase/cli/v2/internal/storage/ls" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/storage" + "github.com/supabase/cli/internal/storage/client" + "github.com/supabase/cli/internal/storage/cp" + "github.com/supabase/cli/internal/storage/ls" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/storage" ) var ( diff --git a/internal/storage/rm/rm_test.go b/internal/storage/rm/rm_test.go index c04a79a6a..46d204cf0 100644 --- a/internal/storage/rm/rm_test.go +++ b/internal/storage/rm/rm_test.go @@ -8,14 +8,14 @@ import ( "github.com/h2non/gock" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/flags" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" - "github.com/supabase/cli/v2/pkg/fetcher" - "github.com/supabase/cli/v2/pkg/storage" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/pkg/storage" ) var mockFile = storage.ObjectResponse{ diff --git a/internal/test/new/new.go b/internal/test/new/new.go index babe62194..506a9e02e 100644 --- a/internal/test/new/new.go +++ b/internal/test/new/new.go @@ -8,7 +8,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) const ( diff --git a/internal/test/new/new_test.go b/internal/test/new/new_test.go index a03e63dbf..d3f980157 100644 --- a/internal/test/new/new_test.go +++ b/internal/test/new/new_test.go @@ -8,7 +8,7 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func TestCreatePgTAP(t *testing.T) { diff --git a/internal/testing/helper/history.go b/internal/testing/helper/history.go index 7c5436dc4..95c846b7a 100644 --- a/internal/testing/helper/history.go +++ b/internal/testing/helper/history.go @@ -1,8 +1,8 @@ package helper import ( - "github.com/supabase/cli/v2/pkg/migration" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/pgtest" ) func MockMigrationHistory(conn *pgtest.MockConn) *pgtest.MockConn { diff --git a/internal/unlink/unlink.go b/internal/unlink/unlink.go index 5750f647d..b59f4d1f0 100644 --- a/internal/unlink/unlink.go +++ b/internal/unlink/unlink.go @@ -7,8 +7,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/credentials" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/credentials" "github.com/zalando/go-keyring" ) diff --git a/internal/unlink/unlink_test.go b/internal/unlink/unlink_test.go index e5967005a..9b526e109 100644 --- a/internal/unlink/unlink_test.go +++ b/internal/unlink/unlink_test.go @@ -8,9 +8,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/credentials" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/credentials" "github.com/zalando/go-keyring" ) diff --git a/internal/utils/access_token.go b/internal/utils/access_token.go index bd48823cb..f7ef90a01 100644 --- a/internal/utils/access_token.go +++ b/internal/utils/access_token.go @@ -7,7 +7,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils/credentials" + "github.com/supabase/cli/internal/utils/credentials" "github.com/zalando/go-keyring" ) diff --git a/internal/utils/access_token_test.go b/internal/utils/access_token_test.go index d05e5f3cd..f31988876 100644 --- a/internal/utils/access_token_test.go +++ b/internal/utils/access_token_test.go @@ -7,9 +7,9 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/utils/credentials" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/utils/credentials" "github.com/zalando/go-keyring" ) diff --git a/internal/utils/api.go b/internal/utils/api.go index 271d8cebf..32b199b69 100644 --- a/internal/utils/api.go +++ b/internal/utils/api.go @@ -14,9 +14,9 @@ import ( "github.com/go-errors/errors" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/utils/cloudflare" - supabase "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/internal/utils/cloudflare" + supabase "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" ) const ( diff --git a/internal/utils/api_test.go b/internal/utils/api_test.go index 8a858441e..09365897d 100644 --- a/internal/utils/api_test.go +++ b/internal/utils/api_test.go @@ -10,8 +10,8 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils/cloudflare" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils/cloudflare" ) const host = "api.supabase.io" diff --git a/internal/utils/cloudflare/api.go b/internal/utils/cloudflare/api.go index eeadef033..7c7cf10a2 100644 --- a/internal/utils/cloudflare/api.go +++ b/internal/utils/cloudflare/api.go @@ -4,7 +4,7 @@ import ( "net/http" "time" - "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/pkg/fetcher" ) type CloudflareAPI struct { diff --git a/internal/utils/cloudflare/dns.go b/internal/utils/cloudflare/dns.go index 739968ef9..f8a06367c 100644 --- a/internal/utils/cloudflare/dns.go +++ b/internal/utils/cloudflare/dns.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/google/go-querystring/query" - "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/pkg/fetcher" ) type DNSType uint16 diff --git a/internal/utils/config.go b/internal/utils/config.go index 13af5cd34..3f89dc75c 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -12,7 +12,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/pkg/config" ) var ( diff --git a/internal/utils/connect.go b/internal/utils/connect.go index c4f20df56..9479d4e4f 100644 --- a/internal/utils/connect.go +++ b/internal/utils/connect.go @@ -13,8 +13,8 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/debug" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/internal/debug" + "github.com/supabase/cli/pkg/pgxv5" ) func ToPostgresURL(config pgconn.Config) string { diff --git a/internal/utils/connect_test.go b/internal/utils/connect_test.go index f66b66659..4ea76c126 100644 --- a/internal/utils/connect_test.go +++ b/internal/utils/connect_test.go @@ -12,9 +12,9 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/utils/cloudflare" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/utils/cloudflare" + "github.com/supabase/cli/pkg/pgtest" ) var dbConfig = pgconn.Config{ diff --git a/internal/utils/console.go b/internal/utils/console.go index 54c36b968..85bebdc1e 100644 --- a/internal/utils/console.go +++ b/internal/utils/console.go @@ -10,7 +10,7 @@ import ( "time" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/pkg/cast" "golang.org/x/term" ) diff --git a/internal/utils/console_test.go b/internal/utils/console_test.go index f7662d2d1..ffc9532e7 100644 --- a/internal/utils/console_test.go +++ b/internal/utils/console_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/fstest" + "github.com/supabase/cli/internal/testing/fstest" ) func TestPromptYesNo(t *testing.T) { diff --git a/internal/utils/docker_test.go b/internal/utils/docker_test.go index ef166611b..6a0cdf034 100644 --- a/internal/utils/docker_test.go +++ b/internal/utils/docker_test.go @@ -16,7 +16,7 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" + "github.com/supabase/cli/internal/testing/apitest" ) const ( diff --git a/internal/utils/flags/db_url.go b/internal/utils/flags/db_url.go index a08c6f0ba..013453b86 100644 --- a/internal/utils/flags/db_url.go +++ b/internal/utils/flags/db_url.go @@ -12,9 +12,9 @@ import ( "github.com/spf13/afero" "github.com/spf13/pflag" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/internal/utils/credentials" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/credentials" + "github.com/supabase/cli/pkg/api" ) type connection int diff --git a/internal/utils/flags/project_ref.go b/internal/utils/flags/project_ref.go index 6b39b02ac..c1629c0fa 100644 --- a/internal/utils/flags/project_ref.go +++ b/internal/utils/flags/project_ref.go @@ -10,7 +10,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/spf13/viper" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" "golang.org/x/term" ) diff --git a/internal/utils/flags/project_ref_test.go b/internal/utils/flags/project_ref_test.go index ee12de886..ee6a5374a 100644 --- a/internal/utils/flags/project_ref_test.go +++ b/internal/utils/flags/project_ref_test.go @@ -13,10 +13,10 @@ import ( "github.com/spf13/afero" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/internal/testing/fstest" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/internal/testing/fstest" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func TestProjectRef(t *testing.T) { diff --git a/internal/utils/release_test.go b/internal/utils/release_test.go index c5f413274..25aa920e8 100644 --- a/internal/utils/release_test.go +++ b/internal/utils/release_test.go @@ -9,8 +9,8 @@ import ( "github.com/google/go-github/v62/github" "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/internal/testing/apitest" - "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/pkg/cast" ) func TestLatestRelease(t *testing.T) { diff --git a/internal/utils/tenant/client.go b/internal/utils/tenant/client.go index f932a5310..ad0ef6aa7 100644 --- a/internal/utils/tenant/client.go +++ b/internal/utils/tenant/client.go @@ -6,9 +6,9 @@ import ( "time" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/fetcher" ) var ( diff --git a/internal/utils/tenant/database.go b/internal/utils/tenant/database.go index 4f733e29c..1ae1ee6a7 100644 --- a/internal/utils/tenant/database.go +++ b/internal/utils/tenant/database.go @@ -4,7 +4,7 @@ import ( "context" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) var errDatabaseVersion = errors.New("Database version not found.") diff --git a/internal/utils/tenant/gotrue.go b/internal/utils/tenant/gotrue.go index 64269b276..507a63af5 100644 --- a/internal/utils/tenant/gotrue.go +++ b/internal/utils/tenant/gotrue.go @@ -5,7 +5,7 @@ import ( "net/http" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/pkg/fetcher" ) var errGotrueVersion = errors.New("GoTrue version not found.") diff --git a/internal/utils/tenant/gotrue_test.go b/internal/utils/tenant/gotrue_test.go index 8c08d486f..fcc646e0d 100644 --- a/internal/utils/tenant/gotrue_test.go +++ b/internal/utils/tenant/gotrue_test.go @@ -8,7 +8,7 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/pkg/fetcher" ) var mockApi = TenantAPI{Fetcher: fetcher.NewFetcher( diff --git a/internal/utils/tenant/postgrest.go b/internal/utils/tenant/postgrest.go index 00293b4cf..cb8c96d28 100644 --- a/internal/utils/tenant/postgrest.go +++ b/internal/utils/tenant/postgrest.go @@ -6,7 +6,7 @@ import ( "strings" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/pkg/fetcher" ) var errPostgrestVersion = errors.New("PostgREST version not found.") diff --git a/internal/vanity_subdomains/activate/activate.go b/internal/vanity_subdomains/activate/activate.go index 2a968d88c..133ec7edd 100644 --- a/internal/vanity_subdomains/activate/activate.go +++ b/internal/vanity_subdomains/activate/activate.go @@ -7,8 +7,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, projectRef string, desiredSubdomain string, fsys afero.Fs) error { diff --git a/internal/vanity_subdomains/check/check.go b/internal/vanity_subdomains/check/check.go index 6a8bf9ddd..390122707 100644 --- a/internal/vanity_subdomains/check/check.go +++ b/internal/vanity_subdomains/check/check.go @@ -7,8 +7,8 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/api" ) func Run(ctx context.Context, projectRef string, desiredSubdomain string, fsys afero.Fs) error { diff --git a/internal/vanity_subdomains/delete/delete.go b/internal/vanity_subdomains/delete/delete.go index 592e2880f..3ee24d473 100644 --- a/internal/vanity_subdomains/delete/delete.go +++ b/internal/vanity_subdomains/delete/delete.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/internal/vanity_subdomains/get/get.go b/internal/vanity_subdomains/get/get.go index 450b54f4b..b466f1895 100644 --- a/internal/vanity_subdomains/get/get.go +++ b/internal/vanity_subdomains/get/get.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, projectRef string, fsys afero.Fs) error { diff --git a/main.go b/main.go index be8d4dc88..9b54f5ec4 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/supabase/cli/v2/cmd" + "github.com/supabase/cli/cmd" ) //go:generate go run github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen --config=pkg/api/types.cfg.yaml api/beta.yaml diff --git a/pkg/config/api.go b/pkg/config/api.go index 509e61e56..ec7c4f86d 100644 --- a/pkg/config/api.go +++ b/pkg/config/api.go @@ -3,9 +3,9 @@ package config import ( "strings" - v1API "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" - "github.com/supabase/cli/v2/pkg/diff" + v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/diff" ) type ( diff --git a/pkg/config/api_test.go b/pkg/config/api_test.go index 951ea3c7c..92859c671 100644 --- a/pkg/config/api_test.go +++ b/pkg/config/api_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - v1API "github.com/supabase/cli/v2/pkg/api" + v1API "github.com/supabase/cli/pkg/api" ) func TestApiToUpdatePostgrestConfigBody(t *testing.T) { diff --git a/pkg/config/auth.go b/pkg/config/auth.go index c02923df7..5cb551cd1 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -5,9 +5,9 @@ import ( "strings" "time" - v1API "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" - "github.com/supabase/cli/v2/pkg/diff" + v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/diff" ) type PasswordRequirements string diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index 428a6d055..057c5ccdd 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -8,8 +8,8 @@ import ( "github.com/go-errors/errors" "github.com/stretchr/testify/assert" - v1API "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" + v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" ) func newWithDefaults() auth { diff --git a/pkg/config/config.go b/pkg/config/config.go index 425e02c12..938016e83 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -30,8 +30,8 @@ import ( "github.com/joho/godotenv" "github.com/mitchellh/mapstructure" "github.com/spf13/viper" - "github.com/supabase/cli/v2/pkg/cast" - "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/fetcher" "golang.org/x/mod/semver" ) diff --git a/pkg/config/db.go b/pkg/config/db.go index e08176587..2a1d31cad 100644 --- a/pkg/config/db.go +++ b/pkg/config/db.go @@ -3,9 +3,9 @@ package config import ( "bytes" - v1API "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" - "github.com/supabase/cli/v2/pkg/diff" + v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/diff" ) type PoolMode string diff --git a/pkg/config/db_test.go b/pkg/config/db_test.go index 8e7006d14..575fd202d 100644 --- a/pkg/config/db_test.go +++ b/pkg/config/db_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/stretchr/testify/assert" - v1API "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" + v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" ) func TestDbSettingsToUpdatePostgresConfigBody(t *testing.T) { diff --git a/pkg/config/storage.go b/pkg/config/storage.go index b56907895..b11b28a10 100644 --- a/pkg/config/storage.go +++ b/pkg/config/storage.go @@ -1,9 +1,9 @@ package config import ( - v1API "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" - "github.com/supabase/cli/v2/pkg/diff" + v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" + "github.com/supabase/cli/pkg/diff" ) type ( diff --git a/pkg/config/updater.go b/pkg/config/updater.go index 7a6d08d08..445000d0b 100644 --- a/pkg/config/updater.go +++ b/pkg/config/updater.go @@ -6,7 +6,7 @@ import ( "os" "github.com/go-errors/errors" - v1API "github.com/supabase/cli/v2/pkg/api" + v1API "github.com/supabase/cli/pkg/api" ) type ConfigUpdater struct { diff --git a/pkg/config/updater_test.go b/pkg/config/updater_test.go index d595d60b6..471e84963 100644 --- a/pkg/config/updater_test.go +++ b/pkg/config/updater_test.go @@ -8,8 +8,8 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - v1API "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/cast" + v1API "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/cast" ) func TestUpdateApi(t *testing.T) { diff --git a/pkg/function/api.go b/pkg/function/api.go index 622786dc4..e3f641dee 100644 --- a/pkg/function/api.go +++ b/pkg/function/api.go @@ -4,7 +4,7 @@ import ( "context" "io" - "github.com/supabase/cli/v2/pkg/api" + "github.com/supabase/cli/pkg/api" ) type EdgeRuntimeAPI struct { diff --git a/pkg/function/batch.go b/pkg/function/batch.go index 0b61375c9..43f837fc4 100644 --- a/pkg/function/batch.go +++ b/pkg/function/batch.go @@ -12,8 +12,8 @@ import ( "github.com/cenkalti/backoff/v4" "github.com/docker/go-units" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/config" ) const ( diff --git a/pkg/function/batch_test.go b/pkg/function/batch_test.go index dfba2f4af..1489cd329 100644 --- a/pkg/function/batch_test.go +++ b/pkg/function/batch_test.go @@ -10,8 +10,8 @@ import ( "github.com/h2non/gock" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/pkg/api" - "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/pkg/api" + "github.com/supabase/cli/pkg/config" ) type MockBundler struct { diff --git a/pkg/migration/apply_test.go b/pkg/migration/apply_test.go index 060702f11..65a75028a 100644 --- a/pkg/migration/apply_test.go +++ b/pkg/migration/apply_test.go @@ -9,7 +9,7 @@ import ( "github.com/jackc/pgerrcode" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/pgtest" ) func TestPendingMigrations(t *testing.T) { diff --git a/pkg/migration/drop.go b/pkg/migration/drop.go index 68677ac26..362f2a9d2 100644 --- a/pkg/migration/drop.go +++ b/pkg/migration/drop.go @@ -7,7 +7,7 @@ import ( "github.com/go-errors/errors" "github.com/jackc/pgx/v4" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/pkg/pgxv5" ) var ( diff --git a/pkg/migration/drop_test.go b/pkg/migration/drop_test.go index a218d883f..d2c25ed56 100644 --- a/pkg/migration/drop_test.go +++ b/pkg/migration/drop_test.go @@ -6,7 +6,7 @@ import ( "github.com/jackc/pgerrcode" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/pgtest" ) var escapedSchemas = append(ManagedSchemas, "extensions", "public") diff --git a/pkg/migration/file.go b/pkg/migration/file.go index d0bed5ad7..79da1c86a 100644 --- a/pkg/migration/file.go +++ b/pkg/migration/file.go @@ -14,7 +14,7 @@ import ( "github.com/jackc/pgtype" "github.com/jackc/pgx/v4" "github.com/spf13/viper" - "github.com/supabase/cli/v2/pkg/parser" + "github.com/supabase/cli/pkg/parser" ) type MigrationFile struct { diff --git a/pkg/migration/file_test.go b/pkg/migration/file_test.go index 3b2877c52..a38238f8d 100644 --- a/pkg/migration/file_test.go +++ b/pkg/migration/file_test.go @@ -10,8 +10,8 @@ import ( "github.com/jackc/pgerrcode" "github.com/spf13/viper" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/pkg/parser" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/parser" + "github.com/supabase/cli/pkg/pgtest" ) func TestMigrationFile(t *testing.T) { diff --git a/pkg/migration/history.go b/pkg/migration/history.go index 3e6f8a362..2ca14167b 100644 --- a/pkg/migration/history.go +++ b/pkg/migration/history.go @@ -6,7 +6,7 @@ import ( "github.com/go-errors/errors" "github.com/jackc/pgconn" "github.com/jackc/pgx/v4" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/pkg/pgxv5" ) const ( diff --git a/pkg/migration/list.go b/pkg/migration/list.go index dfe9837bf..ec8bf2ac8 100644 --- a/pkg/migration/list.go +++ b/pkg/migration/list.go @@ -13,7 +13,7 @@ import ( "github.com/jackc/pgconn" "github.com/jackc/pgerrcode" "github.com/jackc/pgx/v4" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/pkg/pgxv5" ) func ListRemoteMigrations(ctx context.Context, conn *pgx.Conn) ([]string, error) { diff --git a/pkg/migration/list_test.go b/pkg/migration/list_test.go index 40a193489..80d09fd40 100644 --- a/pkg/migration/list_test.go +++ b/pkg/migration/list_test.go @@ -7,7 +7,7 @@ import ( "github.com/jackc/pgerrcode" "github.com/stretchr/testify/assert" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/pgtest" ) func TestRemoteMigrations(t *testing.T) { diff --git a/pkg/migration/seed_test.go b/pkg/migration/seed_test.go index 1d228e531..7e9cd4aca 100644 --- a/pkg/migration/seed_test.go +++ b/pkg/migration/seed_test.go @@ -11,7 +11,7 @@ import ( "github.com/jackc/pgx/v4" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/supabase/cli/v2/pkg/pgtest" + "github.com/supabase/cli/pkg/pgtest" ) //go:embed testdata/seed.sql diff --git a/pkg/parser/token.go b/pkg/parser/token.go index b939ae6cb..db0084342 100644 --- a/pkg/parser/token.go +++ b/pkg/parser/token.go @@ -8,7 +8,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/viper" - "github.com/supabase/cli/v2/pkg/cast" + "github.com/supabase/cli/pkg/cast" ) // Equal to `startBufSize` from `bufio/scan.go` diff --git a/pkg/pgtest/mock.go b/pkg/pgtest/mock.go index daa1dbd2a..0f5e9bb84 100644 --- a/pkg/pgtest/mock.go +++ b/pkg/pgtest/mock.go @@ -12,7 +12,7 @@ import ( "github.com/jackc/pgproto3/v2" "github.com/jackc/pgtype" "github.com/jackc/pgx/v4" - "github.com/supabase/cli/v2/pkg/pgxv5" + "github.com/supabase/cli/pkg/pgxv5" "google.golang.org/grpc/test/bufconn" ) diff --git a/pkg/storage/api.go b/pkg/storage/api.go index 3904b52e8..e7765eb9f 100644 --- a/pkg/storage/api.go +++ b/pkg/storage/api.go @@ -1,6 +1,6 @@ package storage -import "github.com/supabase/cli/v2/pkg/fetcher" +import "github.com/supabase/cli/pkg/fetcher" type StorageAPI struct { *fetcher.Fetcher diff --git a/pkg/storage/batch.go b/pkg/storage/batch.go index dc54515b5..8a681242d 100644 --- a/pkg/storage/batch.go +++ b/pkg/storage/batch.go @@ -9,8 +9,8 @@ import ( "path/filepath" "github.com/go-errors/errors" - "github.com/supabase/cli/v2/pkg/config" - "github.com/supabase/cli/v2/pkg/queue" + "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/pkg/queue" ) func (s *StorageAPI) UpsertBuckets(ctx context.Context, bucketConfig config.BucketConfig, filter ...func(string) bool) error { diff --git a/pkg/storage/buckets.go b/pkg/storage/buckets.go index b2d4fc255..1f4bf9cc8 100644 --- a/pkg/storage/buckets.go +++ b/pkg/storage/buckets.go @@ -4,7 +4,7 @@ import ( "context" "net/http" - "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/pkg/fetcher" ) type BucketResponse struct { diff --git a/pkg/storage/objects.go b/pkg/storage/objects.go index 3a5633cf0..f048cecf6 100644 --- a/pkg/storage/objects.go +++ b/pkg/storage/objects.go @@ -11,7 +11,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" - "github.com/supabase/cli/v2/pkg/fetcher" + "github.com/supabase/cli/pkg/fetcher" ) type ListObjectsQuery struct { diff --git a/tools/bumpdoc/main.go b/tools/bumpdoc/main.go index 10a86772e..55d9de344 100644 --- a/tools/bumpdoc/main.go +++ b/tools/bumpdoc/main.go @@ -12,8 +12,8 @@ import ( "regexp" "github.com/google/go-github/v62/github" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/tools/shared" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/tools/shared" ) const ( diff --git a/tools/changelog/main.go b/tools/changelog/main.go index 84ce70eca..97b587ed4 100644 --- a/tools/changelog/main.go +++ b/tools/changelog/main.go @@ -14,7 +14,7 @@ import ( "github.com/google/go-github/v62/github" "github.com/slack-go/slack" - "github.com/supabase/cli/v2/internal/utils" + "github.com/supabase/cli/internal/utils" ) func main() { diff --git a/tools/listdep/main.go b/tools/listdep/main.go index 6d28db52c..bf3c88985 100644 --- a/tools/listdep/main.go +++ b/tools/listdep/main.go @@ -6,7 +6,7 @@ import ( "os" "strings" - "github.com/supabase/cli/v2/pkg/config" + "github.com/supabase/cli/pkg/config" ) func main() { diff --git a/tools/publish/main.go b/tools/publish/main.go index c9944a293..be2474edb 100644 --- a/tools/publish/main.go +++ b/tools/publish/main.go @@ -16,9 +16,9 @@ import ( "text/template" "github.com/google/go-github/v62/github" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/fetcher" - "github.com/supabase/cli/v2/tools/shared" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/fetcher" + "github.com/supabase/cli/tools/shared" ) const ( diff --git a/tools/selfhost/main.go b/tools/selfhost/main.go index 145c53801..cb9ada3a0 100644 --- a/tools/selfhost/main.go +++ b/tools/selfhost/main.go @@ -11,9 +11,9 @@ import ( "strings" "github.com/google/go-github/v62/github" - "github.com/supabase/cli/v2/internal/utils" - "github.com/supabase/cli/v2/pkg/config" - "github.com/supabase/cli/v2/tools/shared" + "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/tools/shared" "gopkg.in/yaml.v3" ) From ac76d14c59f60385271b283b0999ec7d67ce7ff3 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Sun, 8 Dec 2024 03:41:42 +0800 Subject: [PATCH 215/305] fix: optional smtp block should not override remote (#2954) --- internal/start/start.go | 2 +- pkg/config/auth.go | 70 ++++++++++++------- pkg/config/auth_test.go | 10 +++ pkg/config/config.go | 2 +- pkg/config/templates/config.toml | 1 + .../local_disabled_remote_enabled.diff | 14 ---- .../local_enabled_remote_disabled.diff | 13 ++-- 7 files changed, 67 insertions(+), 45 deletions(-) diff --git a/internal/start/start.go b/internal/start/start.go index 4315d31b7..2483b6aed 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -500,7 +500,7 @@ EOF fmt.Sprintf("GOTRUE_MFA_MAX_ENROLLED_FACTORS=%v", utils.Config.Auth.MFA.MaxEnrolledFactors), } - if utils.Config.Auth.Email.Smtp != nil { + if utils.Config.Auth.Email.Smtp != nil && utils.Config.Auth.Email.Smtp.IsEnabled() { env = append(env, fmt.Sprintf("GOTRUE_SMTP_HOST=%s", utils.Config.Auth.Email.Smtp.Host), fmt.Sprintf("GOTRUE_SMTP_PORT=%d", utils.Config.Auth.Email.Smtp.Port), diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 5cb551cd1..2341b9b4b 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -115,6 +115,7 @@ type ( } smtp struct { + Enabled *bool `toml:"enabled"` Host string `toml:"host"` Port uint16 `toml:"port"` User string `toml:"user"` @@ -380,16 +381,9 @@ func (e email) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { body.MailerOtpExp = cast.UintToIntPtr(&e.OtpExpiry) body.SecurityUpdatePasswordRequireReauthentication = &e.SecurePasswordChange body.SmtpMaxFrequency = cast.Ptr(int(e.MaxFrequency.Seconds())) + // When local config is not set, we assume platform defaults should not change if e.Smtp != nil { - body.SmtpHost = &e.Smtp.Host - body.SmtpPort = cast.Ptr(strconv.Itoa(int(e.Smtp.Port))) - body.SmtpUser = &e.Smtp.User - body.SmtpPass = &e.Smtp.Pass - body.SmtpAdminEmail = &e.Smtp.AdminEmail - body.SmtpSenderName = &e.Smtp.SenderName - } else { - // Setting a single empty string disables SMTP - body.SmtpHost = cast.Ptr("") + e.Smtp.toAuthConfigBody(body) } if len(e.Template) == 0 { return @@ -423,27 +417,14 @@ func (e *email) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { e.OtpExpiry = cast.IntToUint(remoteConfig.MailerOtpExp) e.SecurePasswordChange = cast.Val(remoteConfig.SecurityUpdatePasswordRequireReauthentication, false) e.MaxFrequency = time.Duration(cast.Val(remoteConfig.SmtpMaxFrequency, 0)) * time.Second - // Api resets all values when SMTP is disabled - if remoteConfig.SmtpHost != nil { - e.Smtp = &smtp{ - Host: *remoteConfig.SmtpHost, - User: cast.Val(remoteConfig.SmtpUser, ""), - Pass: hashPrefix + cast.Val(remoteConfig.SmtpPass, ""), - AdminEmail: cast.Val(remoteConfig.SmtpAdminEmail, ""), - SenderName: cast.Val(remoteConfig.SmtpSenderName, ""), - } - portStr := cast.Val(remoteConfig.SmtpPort, "") - if port, err := strconv.ParseUint(portStr, 10, 16); err == nil { - e.Smtp.Port = uint16(port) - } - } else { - e.Smtp = nil + // When local config is not set, we assume platform defaults should not change + if e.Smtp != nil { + e.Smtp.fromAuthConfig(remoteConfig) } if len(e.Template) == 0 { return } var tmpl emailTemplate - // When local config is not set, we assume platform defaults should not change tmpl = e.Template["invite"] if tmpl.Subject != nil { tmpl.Subject = remoteConfig.MailerSubjectsInvite @@ -499,6 +480,45 @@ func (e *email) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { e.Template["reauthentication"] = tmpl } +func (s smtp) IsEnabled() bool { + // If Enabled is not defined, or defined and set to true + return cast.Val(s.Enabled, true) +} + +func (s smtp) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { + if !s.IsEnabled() { + // Setting a single empty string disables SMTP + body.SmtpHost = cast.Ptr("") + return + } + body.SmtpHost = &s.Host + body.SmtpPort = cast.Ptr(strconv.Itoa(int(s.Port))) + body.SmtpUser = &s.User + body.SmtpPass = &s.Pass + body.SmtpAdminEmail = &s.AdminEmail + body.SmtpSenderName = &s.SenderName +} + +func (s *smtp) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { + showDiff := s.IsEnabled() + // Api resets all values when SMTP is disabled + if enabled := remoteConfig.SmtpHost != nil; s.Enabled != nil { + *s.Enabled = enabled + } + if !showDiff { + return + } + s.Host = cast.Val(remoteConfig.SmtpHost, "") + s.User = cast.Val(remoteConfig.SmtpUser, "") + s.Pass = hashPrefix + cast.Val(remoteConfig.SmtpPass, "") + s.AdminEmail = cast.Val(remoteConfig.SmtpAdminEmail, "") + s.SenderName = cast.Val(remoteConfig.SmtpSenderName, "") + portStr := cast.Val(remoteConfig.SmtpPort, "0") + if port, err := strconv.ParseUint(portStr, 10, 16); err == nil { + s.Port = uint16(port) + } +} + func (s sms) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { body.ExternalPhoneEnabled = &s.EnableSignup body.SmsMaxFrequency = cast.Ptr(int(s.MaxFrequency.Seconds())) diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index 057c5ccdd..aa35bcf9f 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -365,6 +365,7 @@ func TestEmailDiff(t *testing.T) { }, }, Smtp: &smtp{ + Enabled: cast.Ptr(true), Host: "smtp.sendgrid.net", Port: 587, User: "apikey", @@ -535,6 +536,15 @@ func TestEmailDiff(t *testing.T) { "email_change": {}, "reauthentication": {}, }, + Smtp: &smtp{ + Enabled: cast.Ptr(false), + Host: "smtp.sendgrid.net", + Port: 587, + User: "apikey", + Pass: "test-key", + AdminEmail: "admin@email.com", + SenderName: "Admin", + }, MaxFrequency: time.Minute, OtpLength: 6, OtpExpiry: 3600, diff --git a/pkg/config/config.go b/pkg/config/config.go index 938016e83..fcc2d3710 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -843,7 +843,7 @@ func (e *email) validate(fsys fs.FS) (err error) { } e.Template[name] = tmpl } - if e.Smtp != nil { + if e.Smtp != nil && e.Smtp.IsEnabled() { if len(e.Smtp.Host) == 0 { return errors.New("Missing required field in config: auth.email.smtp.host") } diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index f59dab08b..26c480c33 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -137,6 +137,7 @@ otp_expiry = 3600 # Use a production-ready SMTP server # [auth.email.smtp] +# enabled = true # host = "smtp.sendgrid.net" # port = 587 # user = "apikey" diff --git a/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff b/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff index 3123336fa..3308fd0a4 100644 --- a/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff +++ b/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff @@ -22,17 +22,3 @@ diff remote[auth] local[auth] [email.template] [email.template.confirmation] content_path = "" -@@ -71,13 +71,6 @@ - content_path = "" - [email.template.recovery] - content_path = "" --[email.smtp] --host = "smtp.sendgrid.net" --port = 587 --user = "apikey" --pass = "hash:ed64b7695a606bc6ab4fcb41fe815b5ddf1063ccbc87afe1fa89756635db520e" --admin_email = "admin@email.com" --sender_name = "Admin" - - [sms] - enable_signup = false diff --git a/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff index 24386ae91..d42967e05 100644 --- a/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff +++ b/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -51,28 +51,43 @@ +@@ -51,35 +51,43 @@ inactivity_timeout = "0s" [email] @@ -40,10 +40,15 @@ diff remote[auth] local[auth] +content = "" content_path = "" [email.template.recovery] --content_path = "" +content = "recovery-content" -+content_path = "" -+[email.smtp] + content_path = "" + [email.smtp] +-host = "" +-port = 0 +-user = "" +-pass = "hash:" +-admin_email = "" +-sender_name = "" +host = "smtp.sendgrid.net" +port = 587 +user = "apikey" From 11a9f429ac2ae2aa0f4ebbe038c1947baeb6ad9c Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Mon, 9 Dec 2024 15:10:42 +0800 Subject: [PATCH 216/305] fix: ignore undefined external auth provider (#2955) chore: ignore undefined external auth provider --- pkg/config/auth.go | 469 ++++++++++-------- pkg/config/auth_test.go | 30 +- pkg/config/config.go | 24 +- .../local_enabled_and_disabled.diff | 17 +- 4 files changed, 299 insertions(+), 241 deletions(-) diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 2341b9b4b..6c14cf649 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -601,107 +601,125 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if len(e) == 0 { return } - var p *provider // Ignore configs of disabled providers because their envs are not loaded - p = cast.Ptr(e["apple"]) - if body.ExternalAppleEnabled = &p.Enabled; *body.ExternalAppleEnabled { - body.ExternalAppleClientId = &p.ClientId - body.ExternalAppleSecret = &p.Secret - } - p = cast.Ptr(e["azure"]) - if body.ExternalAzureEnabled = &p.Enabled; *body.ExternalAzureEnabled { - body.ExternalAzureClientId = &p.ClientId - body.ExternalAzureSecret = &p.Secret - body.ExternalAzureUrl = &p.Url - } - p = cast.Ptr(e["bitbucket"]) - if body.ExternalBitbucketEnabled = &p.Enabled; *body.ExternalBitbucketEnabled { - body.ExternalBitbucketClientId = &p.ClientId - body.ExternalBitbucketSecret = &p.Secret - } - p = cast.Ptr(e["discord"]) - if body.ExternalDiscordEnabled = &p.Enabled; *body.ExternalDiscordEnabled { - body.ExternalDiscordClientId = &p.ClientId - body.ExternalDiscordSecret = &p.Secret - } - p = cast.Ptr(e["facebook"]) - if body.ExternalFacebookEnabled = &p.Enabled; *body.ExternalFacebookEnabled { - body.ExternalFacebookClientId = &p.ClientId - body.ExternalFacebookSecret = &p.Secret - } - p = cast.Ptr(e["figma"]) - if body.ExternalFigmaEnabled = &p.Enabled; *body.ExternalFigmaEnabled { - body.ExternalFigmaClientId = &p.ClientId - body.ExternalFigmaSecret = &p.Secret - } - p = cast.Ptr(e["github"]) - if body.ExternalGithubEnabled = &p.Enabled; *body.ExternalGithubEnabled { - body.ExternalGithubClientId = &p.ClientId - body.ExternalGithubSecret = &p.Secret - } - p = cast.Ptr(e["gitlab"]) - if body.ExternalGitlabEnabled = &p.Enabled; *body.ExternalGitlabEnabled { - body.ExternalGitlabClientId = &p.ClientId - body.ExternalGitlabSecret = &p.Secret - body.ExternalGitlabUrl = &p.Url - } - p = cast.Ptr(e["google"]) - if body.ExternalGoogleEnabled = &p.Enabled; *body.ExternalGoogleEnabled { - body.ExternalGoogleClientId = &p.ClientId - body.ExternalGoogleSecret = &p.Secret - body.ExternalGoogleSkipNonceCheck = &p.SkipNonceCheck - } - p = cast.Ptr(e["kakao"]) - if body.ExternalKakaoEnabled = &p.Enabled; *body.ExternalKakaoEnabled { - body.ExternalKakaoClientId = &p.ClientId - body.ExternalKakaoSecret = &p.Secret - } - p = cast.Ptr(e["keycloak"]) - if body.ExternalKeycloakEnabled = &p.Enabled; *body.ExternalKeycloakEnabled { - body.ExternalKeycloakClientId = &p.ClientId - body.ExternalKeycloakSecret = &p.Secret - body.ExternalKeycloakUrl = &p.Url - } - p = cast.Ptr(e["linkedin_oidc"]) - if body.ExternalLinkedinOidcEnabled = &p.Enabled; *body.ExternalLinkedinOidcEnabled { - body.ExternalLinkedinOidcClientId = &p.ClientId - body.ExternalLinkedinOidcSecret = &p.Secret - } - p = cast.Ptr(e["notion"]) - if body.ExternalNotionEnabled = &p.Enabled; *body.ExternalNotionEnabled { - body.ExternalNotionClientId = &p.ClientId - body.ExternalNotionSecret = &p.Secret - } - p = cast.Ptr(e["slack_oidc"]) - if body.ExternalSlackOidcEnabled = &p.Enabled; *body.ExternalSlackOidcEnabled { - body.ExternalSlackOidcClientId = &p.ClientId - body.ExternalSlackOidcSecret = &p.Secret - } - p = cast.Ptr(e["spotify"]) - if body.ExternalSpotifyEnabled = &p.Enabled; *body.ExternalSpotifyEnabled { - body.ExternalSpotifyClientId = &p.ClientId - body.ExternalSpotifySecret = &p.Secret - } - p = cast.Ptr(e["twitch"]) - if body.ExternalTwitchEnabled = &p.Enabled; *body.ExternalTwitchEnabled { - body.ExternalTwitchClientId = &p.ClientId - body.ExternalTwitchSecret = &p.Secret - } - p = cast.Ptr(e["twitter"]) - if body.ExternalTwitterEnabled = &p.Enabled; *body.ExternalTwitterEnabled { - body.ExternalTwitterClientId = &p.ClientId - body.ExternalTwitterSecret = &p.Secret - } - p = cast.Ptr(e["workos"]) - if body.ExternalWorkosEnabled = &p.Enabled; *body.ExternalWorkosEnabled { - body.ExternalWorkosClientId = &p.ClientId - body.ExternalWorkosSecret = &p.Secret - body.ExternalWorkosUrl = &p.Url - } - p = cast.Ptr(e["zoom"]) - if body.ExternalZoomEnabled = &p.Enabled; *body.ExternalZoomEnabled { - body.ExternalZoomClientId = &p.ClientId - body.ExternalZoomSecret = &p.Secret + if p, ok := e["apple"]; ok { + if body.ExternalAppleEnabled = &p.Enabled; *body.ExternalAppleEnabled { + body.ExternalAppleClientId = &p.ClientId + body.ExternalAppleSecret = &p.Secret + } + } + if p, ok := e["azure"]; ok { + if body.ExternalAzureEnabled = &p.Enabled; *body.ExternalAzureEnabled { + body.ExternalAzureClientId = &p.ClientId + body.ExternalAzureSecret = &p.Secret + body.ExternalAzureUrl = &p.Url + } + } + if p, ok := e["bitbucket"]; ok { + if body.ExternalBitbucketEnabled = &p.Enabled; *body.ExternalBitbucketEnabled { + body.ExternalBitbucketClientId = &p.ClientId + body.ExternalBitbucketSecret = &p.Secret + } + } + if p, ok := e["discord"]; ok { + if body.ExternalDiscordEnabled = &p.Enabled; *body.ExternalDiscordEnabled { + body.ExternalDiscordClientId = &p.ClientId + body.ExternalDiscordSecret = &p.Secret + } + } + if p, ok := e["facebook"]; ok { + if body.ExternalFacebookEnabled = &p.Enabled; *body.ExternalFacebookEnabled { + body.ExternalFacebookClientId = &p.ClientId + body.ExternalFacebookSecret = &p.Secret + } + } + if p, ok := e["figma"]; ok { + if body.ExternalFigmaEnabled = &p.Enabled; *body.ExternalFigmaEnabled { + body.ExternalFigmaClientId = &p.ClientId + body.ExternalFigmaSecret = &p.Secret + } + } + if p, ok := e["github"]; ok { + if body.ExternalGithubEnabled = &p.Enabled; *body.ExternalGithubEnabled { + body.ExternalGithubClientId = &p.ClientId + body.ExternalGithubSecret = &p.Secret + } + } + if p, ok := e["gitlab"]; ok { + if body.ExternalGitlabEnabled = &p.Enabled; *body.ExternalGitlabEnabled { + body.ExternalGitlabClientId = &p.ClientId + body.ExternalGitlabSecret = &p.Secret + body.ExternalGitlabUrl = &p.Url + } + } + if p, ok := e["google"]; ok { + if body.ExternalGoogleEnabled = &p.Enabled; *body.ExternalGoogleEnabled { + body.ExternalGoogleClientId = &p.ClientId + body.ExternalGoogleSecret = &p.Secret + body.ExternalGoogleSkipNonceCheck = &p.SkipNonceCheck + } + } + if p, ok := e["kakao"]; ok { + if body.ExternalKakaoEnabled = &p.Enabled; *body.ExternalKakaoEnabled { + body.ExternalKakaoClientId = &p.ClientId + body.ExternalKakaoSecret = &p.Secret + } + } + if p, ok := e["keycloak"]; ok { + if body.ExternalKeycloakEnabled = &p.Enabled; *body.ExternalKeycloakEnabled { + body.ExternalKeycloakClientId = &p.ClientId + body.ExternalKeycloakSecret = &p.Secret + body.ExternalKeycloakUrl = &p.Url + } + } + if p, ok := e["linkedin_oidc"]; ok { + if body.ExternalLinkedinOidcEnabled = &p.Enabled; *body.ExternalLinkedinOidcEnabled { + body.ExternalLinkedinOidcClientId = &p.ClientId + body.ExternalLinkedinOidcSecret = &p.Secret + } + } + if p, ok := e["notion"]; ok { + if body.ExternalNotionEnabled = &p.Enabled; *body.ExternalNotionEnabled { + body.ExternalNotionClientId = &p.ClientId + body.ExternalNotionSecret = &p.Secret + } + } + if p, ok := e["slack_oidc"]; ok { + if body.ExternalSlackOidcEnabled = &p.Enabled; *body.ExternalSlackOidcEnabled { + body.ExternalSlackOidcClientId = &p.ClientId + body.ExternalSlackOidcSecret = &p.Secret + } + } + if p, ok := e["spotify"]; ok { + if body.ExternalSpotifyEnabled = &p.Enabled; *body.ExternalSpotifyEnabled { + body.ExternalSpotifyClientId = &p.ClientId + body.ExternalSpotifySecret = &p.Secret + } + } + if p, ok := e["twitch"]; ok { + if body.ExternalTwitchEnabled = &p.Enabled; *body.ExternalTwitchEnabled { + body.ExternalTwitchClientId = &p.ClientId + body.ExternalTwitchSecret = &p.Secret + } + } + if p, ok := e["twitter"]; ok { + if body.ExternalTwitterEnabled = &p.Enabled; *body.ExternalTwitterEnabled { + body.ExternalTwitterClientId = &p.ClientId + body.ExternalTwitterSecret = &p.Secret + } + } + if p, ok := e["workos"]; ok { + if body.ExternalWorkosEnabled = &p.Enabled; *body.ExternalWorkosEnabled { + body.ExternalWorkosClientId = &p.ClientId + body.ExternalWorkosSecret = &p.Secret + body.ExternalWorkosUrl = &p.Url + } + } + if p, ok := e["zoom"]; ok { + if body.ExternalZoomEnabled = &p.Enabled; *body.ExternalZoomEnabled { + body.ExternalZoomClientId = &p.ClientId + body.ExternalZoomSecret = &p.Secret + } } } @@ -709,151 +727,188 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if len(e) == 0 { return } - var p provider // Ignore configs of disabled providers because their envs are not loaded - if p = e["apple"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalAppleClientId, "") - if ids := cast.Val(remoteConfig.ExternalAppleAdditionalClientIds, ""); len(ids) > 0 { - p.ClientId += "," + ids + if p, ok := e["apple"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalAppleClientId, "") + if ids := cast.Val(remoteConfig.ExternalAppleAdditionalClientIds, ""); len(ids) > 0 { + p.ClientId += "," + ids + } + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalAppleSecret, "") } - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalAppleSecret, "") - } - p.Enabled = cast.Val(remoteConfig.ExternalAppleEnabled, false) - e["apple"] = p - - if p = e["azure"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalAzureClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalAzureSecret, "") - p.Url = cast.Val(remoteConfig.ExternalAzureUrl, "") + p.Enabled = cast.Val(remoteConfig.ExternalAppleEnabled, false) + e["apple"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalAzureEnabled, false) - e["azure"] = p - if p = e["bitbucket"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalBitbucketClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalBitbucketSecret, "") + if p, ok := e["azure"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalAzureClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalAzureSecret, "") + p.Url = cast.Val(remoteConfig.ExternalAzureUrl, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalAzureEnabled, false) + e["azure"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalBitbucketEnabled, false) - e["bitbucket"] = p - if p = e["discord"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalDiscordClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalDiscordSecret, "") + if p, ok := e["bitbucket"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalBitbucketClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalBitbucketSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalBitbucketEnabled, false) + e["bitbucket"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalDiscordEnabled, false) - e["discord"] = p - if p = e["facebook"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalFacebookClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalFacebookSecret, "") + if p, ok := e["discord"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalDiscordClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalDiscordSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalDiscordEnabled, false) + e["discord"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalFacebookEnabled, false) - e["facebook"] = p - if p = e["figma"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalFigmaClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalFigmaSecret, "") + if p, ok := e["facebook"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalFacebookClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalFacebookSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalFacebookEnabled, false) + e["facebook"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalFigmaEnabled, false) - e["figma"] = p - if p = e["github"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalGithubClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalGithubSecret, "") + if p, ok := e["figma"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalFigmaClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalFigmaSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalFigmaEnabled, false) + e["figma"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalGithubEnabled, false) - e["github"] = p - if p = e["gitlab"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalGitlabClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalGitlabSecret, "") - p.Url = cast.Val(remoteConfig.ExternalGitlabUrl, "") + if p, ok := e["github"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalGithubClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalGithubSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalGithubEnabled, false) + e["github"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalGitlabEnabled, false) - e["gitlab"] = p - if p = e["google"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalGoogleClientId, "") - if ids := cast.Val(remoteConfig.ExternalGoogleAdditionalClientIds, ""); len(ids) > 0 { - p.ClientId += "," + ids + if p, ok := e["gitlab"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalGitlabClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalGitlabSecret, "") + p.Url = cast.Val(remoteConfig.ExternalGitlabUrl, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalGitlabEnabled, false) + e["gitlab"] = p + } + + if p, ok := e["google"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalGoogleClientId, "") + if ids := cast.Val(remoteConfig.ExternalGoogleAdditionalClientIds, ""); len(ids) > 0 { + p.ClientId += "," + ids + } + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalGoogleSecret, "") + p.SkipNonceCheck = cast.Val(remoteConfig.ExternalGoogleSkipNonceCheck, false) } - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalGoogleSecret, "") - p.SkipNonceCheck = cast.Val(remoteConfig.ExternalGoogleSkipNonceCheck, false) + p.Enabled = cast.Val(remoteConfig.ExternalGoogleEnabled, false) + e["google"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalGoogleEnabled, false) - e["google"] = p - if p = e["kakao"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalKakaoClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalKakaoSecret, "") + if p, ok := e["kakao"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalKakaoClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalKakaoSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalKakaoEnabled, false) + e["kakao"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalKakaoEnabled, false) - e["kakao"] = p - if p = e["keycloak"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalKeycloakClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalKeycloakSecret, "") - p.Url = cast.Val(remoteConfig.ExternalKeycloakUrl, "") + if p, ok := e["keycloak"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalKeycloakClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalKeycloakSecret, "") + p.Url = cast.Val(remoteConfig.ExternalKeycloakUrl, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalKeycloakEnabled, false) + e["keycloak"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalKeycloakEnabled, false) - e["keycloak"] = p - if p = e["linkedin_oidc"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalLinkedinOidcClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalLinkedinOidcSecret, "") + if p, ok := e["linkedin_oidc"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalLinkedinOidcClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalLinkedinOidcSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalLinkedinOidcEnabled, false) + e["linkedin_oidc"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalLinkedinOidcEnabled, false) - e["linkedin_oidc"] = p - if p = e["notion"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalNotionClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalNotionSecret, "") + if p, ok := e["notion"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalNotionClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalNotionSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalNotionEnabled, false) + e["notion"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalNotionEnabled, false) - e["notion"] = p - if p = e["slack_oidc"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalSlackOidcClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalSlackOidcSecret, "") + if p, ok := e["slack_oidc"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalSlackOidcClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalSlackOidcSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalSlackOidcEnabled, false) + e["slack_oidc"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalSlackOidcEnabled, false) - e["slack_oidc"] = p - if p = e["spotify"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalSpotifyClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalSpotifySecret, "") + if p, ok := e["spotify"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalSpotifyClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalSpotifySecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalSpotifyEnabled, false) + e["spotify"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalSpotifyEnabled, false) - e["spotify"] = p - if p = e["twitch"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalTwitchClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalTwitchSecret, "") + if p, ok := e["twitch"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalTwitchClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalTwitchSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalTwitchEnabled, false) + e["twitch"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalTwitchEnabled, false) - e["twitch"] = p - if p = e["twitter"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalTwitterClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalTwitterSecret, "") + if p, ok := e["twitter"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalTwitterClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalTwitterSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalTwitterEnabled, false) + e["twitter"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalTwitterEnabled, false) - e["twitter"] = p - if p = e["workos"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalWorkosClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalWorkosSecret, "") - p.Url = cast.Val(remoteConfig.ExternalWorkosUrl, "") + if p, ok := e["workos"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalWorkosClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalWorkosSecret, "") + p.Url = cast.Val(remoteConfig.ExternalWorkosUrl, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalWorkosEnabled, false) + e["workos"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalWorkosEnabled, false) - e["workos"] = p - if p = e["zoom"]; p.Enabled { - p.ClientId = cast.Val(remoteConfig.ExternalZoomClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalZoomSecret, "") + if p, ok := e["zoom"]; ok { + if p.Enabled { + p.ClientId = cast.Val(remoteConfig.ExternalZoomClientId, "") + p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalZoomSecret, "") + } + p.Enabled = cast.Val(remoteConfig.ExternalZoomEnabled, false) + e["zoom"] = p } - p.Enabled = cast.Val(remoteConfig.ExternalZoomEnabled, false) - e["zoom"] = p } func (a *auth) DiffWithRemote(projectRef string, remoteConfig v1API.AuthConfigResponse) ([]byte, error) { diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index aa35bcf9f..404f1cbb6 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -835,15 +835,24 @@ func TestExternalDiff(t *testing.T) { ClientId: "test-client-1,test-client-2", Secret: "test-secret", }, - "azure": {}, - "bitbucket": {}, - "discord": {}, - "facebook": {}, - "figma": {}, - "github": {}, - "gitlab": {}, - "google": {}, - "kakao": {}, + "azure": { + Enabled: true, + ClientId: "test-client-1", + Secret: "test-secret", + }, + "bitbucket": {}, + "discord": {}, + "facebook": {}, + "figma": {}, + "github": {}, + "gitlab": {}, + "google": { + Enabled: false, + ClientId: "test-client-2", + Secret: "env(test_secret)", + SkipNonceCheck: false, + }, + // "kakao": {}, "keycloak": {}, "linkedin_oidc": {}, "notion": {}, @@ -865,6 +874,9 @@ func TestExternalDiff(t *testing.T) { ExternalGoogleEnabled: cast.Ptr(true), ExternalGoogleSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), ExternalGoogleSkipNonceCheck: cast.Ptr(true), + ExternalKakaoClientId: cast.Ptr("test-client-2"), + ExternalKakaoEnabled: cast.Ptr(true), + ExternalKakaoSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), }) // Check error assert.NoError(t, err) diff --git a/pkg/config/config.go b/pkg/config/config.go index fcc2d3710..6b8306ba5 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -306,29 +306,7 @@ func NewConfig(editors ...ConfigEditor) config { Sms: sms{ TestOTP: map[string]string{}, }, - External: map[string]provider{ - "apple": {}, - "azure": {}, - "bitbucket": {}, - "discord": {}, - "facebook": {}, - "figma": {}, - "github": {}, - "gitlab": {}, - "google": {}, - "kakao": {}, - "keycloak": {}, - "linkedin": {}, // TODO: remove this field in v2 - "linkedin_oidc": {}, - "notion": {}, - "twitch": {}, - "twitter": {}, - "slack": {}, // TODO: remove this field in v2 - "slack_oidc": {}, - "spotify": {}, - "workos": {}, - "zoom": {}, - }, + External: map[string]provider{}, JwtSecret: defaultJwtSecret, }, Inbucket: inbucket{ diff --git a/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff index 234e422f4..37ab653dd 100644 --- a/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff +++ b/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff @@ -10,12 +10,25 @@ diff remote[auth] local[auth] client_id = "test-client-1,test-client-2" secret = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" url = "" +@@ -98,9 +98,9 @@ + redirect_uri = "" + skip_nonce_check = false + [external.azure] +-enabled = false +-client_id = "" +-secret = "hash:" ++enabled = true ++client_id = "test-client-1" ++secret = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" + url = "" + redirect_uri = "" + skip_nonce_check = false @@ -147,7 +147,7 @@ redirect_uri = "" skip_nonce_check = false [external.google] -enabled = true +enabled = false - client_id = "" - secret = "" + client_id = "test-client-2" + secret = "env(test_secret)" url = "" From 8627a1632f8079840cd71021e5bc827426deb692 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 04:08:00 +0000 Subject: [PATCH 217/305] chore(deps): bump github.com/docker/cli from 27.3.1+incompatible to 27.4.0+incompatible (#2959) chore(deps): bump github.com/docker/cli Bumps [github.com/docker/cli](https://github.com/docker/cli) from 27.3.1+incompatible to 27.4.0+incompatible. - [Commits](https://github.com/docker/cli/compare/v27.3.1...v27.4.0) --- updated-dependencies: - dependency-name: github.com/docker/cli dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 21 +-------------------- go.sum | 46 ++-------------------------------------------- 2 files changed, 3 insertions(+), 64 deletions(-) diff --git a/go.mod b/go.mod index 1c55174b8..7d1632a6a 100644 --- a/go.mod +++ b/go.mod @@ -13,12 +13,11 @@ require ( github.com/charmbracelet/lipgloss v0.12.1 github.com/containers/common v0.61.0 github.com/deepmap/oapi-codegen/v2 v2.2.0 - github.com/docker/cli v27.3.1+incompatible + github.com/docker/cli v27.4.0+incompatible github.com/docker/docker v27.3.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 github.com/getsentry/sentry-go v0.30.0 - github.com/gin-gonic/gin v1.10.0 github.com/go-errors/errors v1.5.1 github.com/go-git/go-git/v5 v5.12.0 github.com/go-xmlfmt/xmlfmt v1.1.3 @@ -35,7 +34,6 @@ require ( github.com/jackc/pgtype v1.14.4 github.com/jackc/pgx/v4 v4.18.3 github.com/joho/godotenv v1.5.1 - github.com/matoous/go-nanoid/v2 v2.1.0 github.com/mitchellh/mapstructure v1.5.0 github.com/muesli/reflow v0.3.0 github.com/oapi-codegen/runtime v1.1.1 @@ -95,8 +93,6 @@ require ( github.com/breml/errchkjson v0.4.0 // indirect github.com/butuzov/ireturn v0.3.0 // indirect github.com/butuzov/mirror v1.2.0 // indirect - github.com/bytedance/sonic v1.11.6 // indirect - github.com/bytedance/sonic/loader v0.1.1 // indirect github.com/catenacyber/perfsprint v0.7.1 // indirect github.com/ccojocar/zxcvbn-go v1.0.2 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect @@ -106,8 +102,6 @@ require ( github.com/chavacava/garif v0.1.0 // indirect github.com/ckaznocha/intrange v0.2.1 // indirect github.com/cloudflare/circl v1.3.7 // indirect - github.com/cloudwego/base64x v0.1.4 // indirect - github.com/cloudwego/iasm v0.2.0 // indirect github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect github.com/containerd/log v0.1.0 // indirect github.com/containers/storage v1.56.0 // indirect @@ -133,10 +127,8 @@ require ( github.com/fsnotify/fsnotify v1.8.0 // indirect github.com/fvbommel/sortorder v1.1.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/getkin/kin-openapi v0.124.0 // indirect github.com/ghostiam/protogetter v0.3.8 // indirect - github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-critic/go-critic v0.11.5 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect @@ -144,9 +136,6 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect - github.com/go-playground/locales v0.14.1 // indirect - github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.20.0 // indirect github.com/go-toolsmith/astcast v1.1.0 // indirect github.com/go-toolsmith/astcopy v1.1.0 // indirect github.com/go-toolsmith/astequal v1.2.0 // indirect @@ -156,7 +145,6 @@ require ( github.com/go-toolsmith/typep v1.1.0 // indirect github.com/go-viper/mapstructure/v2 v2.2.1 // indirect github.com/gobwas/glob v0.2.3 // indirect - github.com/goccy/go-json v0.10.2 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/gofrs/flock v0.12.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -196,13 +184,11 @@ require ( github.com/jingyugao/rowserrcheck v1.1.1 // indirect github.com/jjti/go-spancheck v0.6.2 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect github.com/julz/importas v0.1.0 // indirect github.com/karamaru-alpha/copyloopvar v1.1.0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/kisielk/errcheck v1.8.0 // indirect github.com/kkHAIKE/contextcheck v1.1.5 // indirect - github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/kr/text v0.2.0 // indirect github.com/kulti/thelper v0.6.3 // indirect @@ -211,7 +197,6 @@ require ( github.com/lasiar/canonicalheader v1.1.2 // indirect github.com/ldez/gomoddirectives v0.2.4 // indirect github.com/ldez/tagliatelle v0.5.0 // indirect - github.com/leodido/go-urn v1.4.0 // indirect github.com/leonklingele/grouper v1.1.2 // indirect github.com/lib/pq v1.10.9 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect @@ -234,8 +219,6 @@ require ( github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/sys/sequential v0.6.0 // indirect github.com/moby/term v0.5.0 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/moricho/tparallel v0.3.2 // indirect github.com/morikuni/aec v1.0.0 // indirect @@ -298,7 +281,6 @@ require ( github.com/timonwong/loggercheck v0.10.1 // indirect github.com/tomarrell/wrapcheck/v2 v2.9.0 // indirect github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect - github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect github.com/ultraware/funlen v0.1.0 // indirect github.com/ultraware/whitespace v0.1.1 // indirect @@ -331,7 +313,6 @@ require ( go.uber.org/automaxprocs v1.6.0 // indirect go.uber.org/multierr v1.9.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/arch v0.8.0 // indirect golang.org/x/crypto v0.29.0 // indirect golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect diff --git a/go.sum b/go.sum index 9313587d7..2e82216da 100644 --- a/go.sum +++ b/go.sum @@ -147,10 +147,6 @@ github.com/butuzov/ireturn v0.3.0/go.mod h1:A09nIiwiqzN/IoVo9ogpa0Hzi9fex1kd9PSD github.com/butuzov/mirror v1.2.0 h1:9YVK1qIjNspaqWutSv8gsge2e/Xpq1eqEkslEUHy5cs= github.com/butuzov/mirror v1.2.0/go.mod h1:DqZZDtzm42wIAIyHXeN8W/qb1EPlb9Qn/if9icBOpdQ= github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= -github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= -github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= -github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/catenacyber/perfsprint v0.7.1 h1:PGW5G/Kxn+YrN04cRAZKC+ZuvlVwolYMrIyyTJ/rMmc= github.com/catenacyber/perfsprint v0.7.1/go.mod h1:/wclWYompEyjUD2FuIIDVKNkqz7IgBIWXIH3V0Zol50= github.com/ccojocar/zxcvbn-go v1.0.2 h1:na/czXU8RrhXO4EZme6eQJLR4PzcGsahsBOAwU6I3Vg= @@ -189,10 +185,6 @@ github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= -github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y= -github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w= -github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg= -github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= @@ -234,8 +226,8 @@ github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk= github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE= -github.com/docker/cli v27.3.1+incompatible h1:qEGdFBF3Xu6SCvCYhc7CzaQTlBmqDuzxPDpigSyeKQQ= -github.com/docker/cli v27.3.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v27.4.0+incompatible h1:/nJzWkcI1MDMN+U+px/YXnQWJqnu4J+QKGTfD6ptiTc= +github.com/docker/cli v27.4.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= @@ -287,18 +279,12 @@ github.com/fvbommel/sortorder v1.1.0 h1:fUmoe+HLsBTctBDoaBwpQo5N+nrCp8g/BjKb/6ZQ github.com/fvbommel/sortorder v1.1.0/go.mod h1:uk88iVf1ovNn1iLfgUVU2F9o5eO30ui720w+kxuqRs0= github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= -github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= -github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj9kz/M= github.com/getkin/kin-openapi v0.124.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM= github.com/getsentry/sentry-go v0.30.0 h1:lWUwDnY7sKHaVIoZ9wYqRHJ5iEmoc0pqcRqFkosKzBo= github.com/getsentry/sentry-go v0.30.0/go.mod h1:WU9B9/1/sHDqeV8T+3VwwbjeR5MSXs/6aqG3mqZrezA= github.com/ghostiam/protogetter v0.3.8 h1:LYcXbYvybUyTIxN2Mj9h6rHrDZBDwZloPoKctWrFyJY= github.com/ghostiam/protogetter v0.3.8/go.mod h1:WZ0nw9pfzsgxuRsPOFQomgDVSWtDLJRfQJEhsGbmQMA= -github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= -github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= -github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU= -github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= github.com/go-critic/go-critic v0.11.5 h1:TkDTOn5v7EEngMxu8KbuFqFR43USaaH8XRJLz1jhVYA= @@ -331,14 +317,6 @@ github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1 github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= -github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= -github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= -github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= -github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= -github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8= -github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow= github.com/go-sql-driver/mysql v1.3.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= @@ -375,8 +353,6 @@ github.com/go-xmlfmt/xmlfmt v1.1.3 h1:t8Ey3Uy7jDSEisW2K3somuMKIpzktkWptA0iFCnRUW github.com/go-xmlfmt/xmlfmt v1.1.3/go.mod h1:aUCEOzzezBEjDBbFBoSiya/gduyIiWYRP6CnSFIV8AM= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= -github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= -github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= github.com/godbus/dbus/v5 v5.1.0/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E= @@ -602,7 +578,6 @@ github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCV github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= @@ -622,10 +597,6 @@ github.com/kisielk/errcheck v1.8.0/go.mod h1:1kLL+jV4e+CFfueBmI1dSK2ADDyQnlrnrY/ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkHAIKE/contextcheck v1.1.5 h1:CdnJh63tcDe53vG+RebdpdXJTc9atMgGqdx8LXxiilg= github.com/kkHAIKE/contextcheck v1.1.5/go.mod h1:O930cpht4xb1YQpK+1+AgoM3mFsvxr7uyFptcnWTYUA= -github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= -github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= -github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= -github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -652,8 +623,6 @@ github.com/ldez/gomoddirectives v0.2.4 h1:j3YjBIjEBbqZ0NKtBNzr8rtMHTOrLPeiwTkfUJ github.com/ldez/gomoddirectives v0.2.4/go.mod h1:oWu9i62VcQDYp9EQ0ONTfqLNh+mDLWWDO+SO0qSQw5g= github.com/ldez/tagliatelle v0.5.0 h1:epgfuYt9v0CG3fms0pEgIMNPuFf/LpPIfjk4kyqSioo= github.com/ldez/tagliatelle v0.5.0/go.mod h1:rj1HmWiL1MiKQuOONhd09iySTEkUuE/8+5jtPYz9xa4= -github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= -github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/leonklingele/grouper v1.1.2 h1:o1ARBDLOmmasUaNDesWqWCIFH3u7hoFlM84YrjT3mIY= github.com/leonklingele/grouper v1.1.2/go.mod h1:6D0M/HVkhs2yRKRFZUoGjeDy7EZTfFBE9gl4kjmIGkA= github.com/lib/pq v0.0.0-20150723085316-0dad96c0b94f/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -676,8 +645,6 @@ github.com/maratori/testableexamples v1.0.0 h1:dU5alXRrD8WKSjOUnmJZuzdxWOEQ57+7s github.com/maratori/testableexamples v1.0.0/go.mod h1:4rhjL1n20TUTT4vdh3RDqSizKLyXp7K2u6HgraZCGzE= github.com/maratori/testpackage v1.1.1 h1:S58XVV5AD7HADMmD0fNnziNHqKvSdDuEKdPD1rNTU04= github.com/maratori/testpackage v1.1.1/go.mod h1:s4gRK/ym6AMrqpOa/kEbQTV4Q4jb7WeLZzVhVVVOQMc= -github.com/matoous/go-nanoid/v2 v2.1.0 h1:P64+dmq21hhWdtvZfEAofnvJULaRR1Yib0+PnU669bE= -github.com/matoous/go-nanoid/v2 v2.1.0/go.mod h1:KlbGNQ+FhrUNIHUxZdL63t7tl4LaPkZNpUULS8H4uVM= github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26 h1:gWg6ZQ4JhDfJPqlo2srm/LN17lpybq15AryXIRcWYLE= github.com/matoous/godox v0.0.0-20230222163458-006bad1f9d26/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s= github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= @@ -724,11 +691,9 @@ github.com/moby/sys/sequential v0.6.0/go.mod h1:uyv8EUTrca5PnDsdMGXhZe6CCe8U/UiT github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= @@ -971,8 +936,6 @@ github.com/tomarrell/wrapcheck/v2 v2.9.0 h1:801U2YCAjLhdN8zhZ/7tdjB3EnAoRlJHt/s+ github.com/tomarrell/wrapcheck/v2 v2.9.0/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo= github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= -github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= -github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/ultraware/funlen v0.1.0 h1:BuqclbkY6pO+cvxoq7OsktIXZpgBSkYTQtmwhAK81vI= @@ -1074,9 +1037,6 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= -golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= -golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -1548,8 +1508,6 @@ mvdan.cc/gofumpt v0.7.0 h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU= mvdan.cc/gofumpt v0.7.0/go.mod h1:txVFJy/Sc/mvaycET54pV8SW8gWxTlUuGHVEcncmNUo= mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f h1:lMpcwN6GxNbWtbpI1+xzFLSW8XzX0u72NttUGVFjO3U= mvdan.cc/unparam v0.0.0-20240528143540-8a5130ca722f/go.mod h1:RSLa7mKKCNeTTMHBw5Hsy2rfJmd6O2ivt9Dw9ZqCQpQ= -nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= From 89357663cc1dd3b6506a62faec1df97e27d1d000 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Tue, 10 Dec 2024 18:26:29 +0800 Subject: [PATCH 218/305] fix: enforce auth hook secrets conform to standard webhooks (#2961) * fix: enforce auth hook secrets conform to standard webhooks * fix: skip hashing empty secrets * chore: mark all hook configs as optional * chore: update unit tests --- internal/start/start.go | 30 ++-- pkg/config/auth.go | 133 ++++++++-------- pkg/config/auth_test.go | 142 ++++++++++++------ pkg/config/config.go | 40 +++-- pkg/config/config_test.go | 10 +- .../local_enabled_and_disabled.diff | 2 +- .../local_disabled_remote_enabled.diff | 2 +- .../local_enabled_remote_disabled.diff | 2 +- .../local_enabled_and_disabled.diff | 6 +- .../local_disabled_remote_enabled.diff | 27 ++++ .../local_enabled_and_disabled.diff | 36 ----- .../local_enabled_remote_disabled.diff | 33 ++++ .../local_enabled_and_disabled.diff | 4 +- .../enable_sign_up_without_provider.diff | 2 +- .../local_disabled_remote_enabled.diff | 4 +- .../local_enabled_remote_disabled.diff | 6 +- 16 files changed, 290 insertions(+), 189 deletions(-) create mode 100644 pkg/config/testdata/TestHookDiff/local_disabled_remote_enabled.diff delete mode 100644 pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff create mode 100644 pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff diff --git a/internal/start/start.go b/internal/start/start.go index 2483b6aed..9096f381d 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -583,44 +583,44 @@ EOF ) } - if utils.Config.Auth.Hook.MFAVerificationAttempt.Enabled { + if hook := utils.Config.Auth.Hook.MFAVerificationAttempt; hook != nil && hook.Enabled { env = append( env, "GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_ENABLED=true", - "GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_URI="+utils.Config.Auth.Hook.MFAVerificationAttempt.URI, - "GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_SECRETS="+utils.Config.Auth.Hook.MFAVerificationAttempt.Secrets, + "GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_URI="+hook.URI, + "GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_SECRETS="+hook.Secrets, ) } - if utils.Config.Auth.Hook.PasswordVerificationAttempt.Enabled { + if hook := utils.Config.Auth.Hook.PasswordVerificationAttempt; hook != nil && hook.Enabled { env = append( env, "GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_ENABLED=true", - "GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_URI="+utils.Config.Auth.Hook.PasswordVerificationAttempt.URI, - "GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_SECRETS="+utils.Config.Auth.Hook.PasswordVerificationAttempt.Secrets, + "GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_URI="+hook.URI, + "GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_SECRETS="+hook.Secrets, ) } - if utils.Config.Auth.Hook.CustomAccessToken.Enabled { + if hook := utils.Config.Auth.Hook.CustomAccessToken; hook != nil && hook.Enabled { env = append( env, "GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_ENABLED=true", - "GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_URI="+utils.Config.Auth.Hook.CustomAccessToken.URI, - "GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_SECRETS="+utils.Config.Auth.Hook.CustomAccessToken.Secrets, + "GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_URI="+hook.URI, + "GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_SECRETS="+hook.Secrets, ) } - if utils.Config.Auth.Hook.SendSMS.Enabled { + if hook := utils.Config.Auth.Hook.SendSMS; hook != nil && hook.Enabled { env = append( env, "GOTRUE_HOOK_SEND_SMS_ENABLED=true", - "GOTRUE_HOOK_SEND_SMS_URI="+utils.Config.Auth.Hook.SendSMS.URI, - "GOTRUE_HOOK_SEND_SMS_SECRETS="+utils.Config.Auth.Hook.SendSMS.Secrets, + "GOTRUE_HOOK_SEND_SMS_URI="+hook.URI, + "GOTRUE_HOOK_SEND_SMS_SECRETS="+hook.Secrets, ) } - if utils.Config.Auth.Hook.SendEmail.Enabled { + if hook := utils.Config.Auth.Hook.SendEmail; hook != nil && hook.Enabled { env = append( env, "GOTRUE_HOOK_SEND_EMAIL_ENABLED=true", - "GOTRUE_HOOK_SEND_EMAIL_URI="+utils.Config.Auth.Hook.SendEmail.URI, - "GOTRUE_HOOK_SEND_EMAIL_SECRETS="+utils.Config.Auth.Hook.SendEmail.Secrets, + "GOTRUE_HOOK_SEND_EMAIL_URI="+hook.URI, + "GOTRUE_HOOK_SEND_EMAIL_SECRETS="+hook.Secrets, ) } diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 6c14cf649..b2e6b0fa6 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -145,11 +145,11 @@ type ( } hook struct { - MFAVerificationAttempt hookConfig `toml:"mfa_verification_attempt"` - PasswordVerificationAttempt hookConfig `toml:"password_verification_attempt"` - CustomAccessToken hookConfig `toml:"custom_access_token"` - SendSMS hookConfig `toml:"send_sms"` - SendEmail hookConfig `toml:"send_email"` + MFAVerificationAttempt *hookConfig `toml:"mfa_verification_attempt"` + PasswordVerificationAttempt *hookConfig `toml:"password_verification_attempt"` + CustomAccessToken *hookConfig `toml:"custom_access_token"` + SendSMS *hookConfig `toml:"send_sms"` + SendEmail *hookConfig `toml:"send_email"` } factorTypeConfiguration struct { @@ -261,80 +261,88 @@ func (a *auth) FromRemoteAuthConfig(remoteConfig v1API.AuthConfigResponse) { } func (h hook) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { - if body.HookCustomAccessTokenEnabled = &h.CustomAccessToken.Enabled; *body.HookCustomAccessTokenEnabled { - body.HookCustomAccessTokenUri = &h.CustomAccessToken.URI - if len(h.CustomAccessToken.Secrets) > 0 { - body.HookCustomAccessTokenSecrets = &h.CustomAccessToken.Secrets + // When local config is not set, we assume platform defaults should not change + if hook := h.CustomAccessToken; hook != nil { + if body.HookCustomAccessTokenEnabled = &hook.Enabled; hook.Enabled { + body.HookCustomAccessTokenUri = &hook.URI + if len(hook.Secrets) > 0 { + body.HookCustomAccessTokenSecrets = &hook.Secrets + } } } - if body.HookSendEmailEnabled = &h.SendEmail.Enabled; *body.HookSendEmailEnabled { - body.HookSendEmailUri = &h.SendEmail.URI - if len(h.SendEmail.Secrets) > 0 { - body.HookSendEmailSecrets = &h.SendEmail.Secrets + if hook := h.SendEmail; hook != nil { + if body.HookSendEmailEnabled = &hook.Enabled; hook.Enabled { + body.HookSendEmailUri = &hook.URI + if len(hook.Secrets) > 0 { + body.HookSendEmailSecrets = &hook.Secrets + } } } - if body.HookSendSmsEnabled = &h.SendSMS.Enabled; *body.HookSendSmsEnabled { - body.HookSendSmsUri = &h.SendSMS.URI - if len(h.SendSMS.Secrets) > 0 { - body.HookSendSmsSecrets = &h.SendSMS.Secrets + if hook := h.SendSMS; hook != nil { + if body.HookSendSmsEnabled = &hook.Enabled; hook.Enabled { + body.HookSendSmsUri = &hook.URI + if len(hook.Secrets) > 0 { + body.HookSendSmsSecrets = &hook.Secrets + } } } // Enterprise and team only features - if body.HookMfaVerificationAttemptEnabled = &h.MFAVerificationAttempt.Enabled; *body.HookMfaVerificationAttemptEnabled { - body.HookMfaVerificationAttemptUri = &h.MFAVerificationAttempt.URI - if len(h.MFAVerificationAttempt.Secrets) > 0 { - body.HookMfaVerificationAttemptSecrets = &h.MFAVerificationAttempt.Secrets + if hook := h.MFAVerificationAttempt; hook != nil { + if body.HookMfaVerificationAttemptEnabled = &hook.Enabled; hook.Enabled { + body.HookMfaVerificationAttemptUri = &hook.URI + if len(hook.Secrets) > 0 { + body.HookMfaVerificationAttemptSecrets = &hook.Secrets + } } } - if body.HookPasswordVerificationAttemptEnabled = &h.PasswordVerificationAttempt.Enabled; *body.HookPasswordVerificationAttemptEnabled { - body.HookPasswordVerificationAttemptUri = &h.PasswordVerificationAttempt.URI - if len(h.PasswordVerificationAttempt.Secrets) > 0 { - body.HookPasswordVerificationAttemptSecrets = &h.PasswordVerificationAttempt.Secrets + if hook := h.PasswordVerificationAttempt; hook != nil { + if body.HookPasswordVerificationAttemptEnabled = &hook.Enabled; hook.Enabled { + body.HookPasswordVerificationAttemptUri = &hook.URI + if len(hook.Secrets) > 0 { + body.HookPasswordVerificationAttemptSecrets = &hook.Secrets + } } } } func (h *hook) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { - // Ignore disabled hooks because their envs are not loaded - if h.CustomAccessToken.Enabled { - h.CustomAccessToken.URI = cast.Val(remoteConfig.HookCustomAccessTokenUri, "") - if remoteConfig.HookCustomAccessTokenSecrets != nil { - h.CustomAccessToken.Secrets = hashPrefix + cast.Val(remoteConfig.HookCustomAccessTokenSecrets, "") + // When local config is not set, we assume platform defaults should not change + if hook := h.CustomAccessToken; hook != nil { + // Ignore disabled hooks because their envs are not loaded + if hook.Enabled { + hook.URI = cast.Val(remoteConfig.HookCustomAccessTokenUri, "") + hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookCustomAccessTokenSecrets, "") } + hook.Enabled = cast.Val(remoteConfig.HookCustomAccessTokenEnabled, false) } - h.CustomAccessToken.Enabled = cast.Val(remoteConfig.HookCustomAccessTokenEnabled, false) - - if h.SendEmail.Enabled { - h.SendEmail.URI = cast.Val(remoteConfig.HookSendEmailUri, "") - if remoteConfig.HookSendEmailSecrets != nil { - h.SendEmail.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendEmailSecrets, "") + if hook := h.SendEmail; hook != nil { + if hook.Enabled { + hook.URI = cast.Val(remoteConfig.HookSendEmailUri, "") + hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendEmailSecrets, "") } + hook.Enabled = cast.Val(remoteConfig.HookSendEmailEnabled, false) } - h.SendEmail.Enabled = cast.Val(remoteConfig.HookSendEmailEnabled, false) - - if h.SendSMS.Enabled { - h.SendSMS.URI = cast.Val(remoteConfig.HookSendSmsUri, "") - if remoteConfig.HookSendSmsSecrets != nil { - h.SendSMS.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendSmsSecrets, "") + if hook := h.SendSMS; hook != nil { + if hook.Enabled { + hook.URI = cast.Val(remoteConfig.HookSendSmsUri, "") + hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendSmsSecrets, "") } + hook.Enabled = cast.Val(remoteConfig.HookSendSmsEnabled, false) } - h.SendSMS.Enabled = cast.Val(remoteConfig.HookSendSmsEnabled, false) - // Enterprise and team only features - if h.MFAVerificationAttempt.Enabled { - h.MFAVerificationAttempt.URI = cast.Val(remoteConfig.HookMfaVerificationAttemptUri, "") - if remoteConfig.HookMfaVerificationAttemptSecrets != nil { - h.MFAVerificationAttempt.Secrets = hashPrefix + cast.Val(remoteConfig.HookMfaVerificationAttemptSecrets, "") + if hook := h.MFAVerificationAttempt; hook != nil { + if hook.Enabled { + hook.URI = cast.Val(remoteConfig.HookMfaVerificationAttemptUri, "") + hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookMfaVerificationAttemptSecrets, "") } + hook.Enabled = cast.Val(remoteConfig.HookMfaVerificationAttemptEnabled, false) } - h.MFAVerificationAttempt.Enabled = cast.Val(remoteConfig.HookMfaVerificationAttemptEnabled, false) - - if h.PasswordVerificationAttempt.Enabled { - h.PasswordVerificationAttempt.URI = cast.Val(remoteConfig.HookPasswordVerificationAttemptUri, "") - if remoteConfig.HookPasswordVerificationAttemptSecrets != nil { - h.PasswordVerificationAttempt.Secrets = hashPrefix + cast.Val(remoteConfig.HookPasswordVerificationAttemptSecrets, "") + if hook := h.PasswordVerificationAttempt; hook != nil { + if hook.Enabled { + hook.URI = cast.Val(remoteConfig.HookPasswordVerificationAttemptUri, "") + hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookPasswordVerificationAttemptSecrets, "") } + hook.Enabled = cast.Val(remoteConfig.HookPasswordVerificationAttemptEnabled, false) } - h.PasswordVerificationAttempt.Enabled = cast.Val(remoteConfig.HookPasswordVerificationAttemptEnabled, false) } func (m mfa) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { @@ -931,9 +939,12 @@ const hashPrefix = "hash:" func (a *auth) HashSecrets(key string) { hash := func(v string) string { + if len(v) == 0 { + return hashPrefix + } return hashPrefix + sha256Hmac(key, v) } - if a.Email.Smtp != nil && len(a.Email.Smtp.Pass) > 0 { + if a.Email.Smtp != nil && a.Email.Smtp.IsEnabled() { a.Email.Smtp.Pass = hash(a.Email.Smtp.Pass) } // Only hash secrets for locally enabled providers because other envs won't be loaded @@ -949,19 +960,19 @@ func (a *auth) HashSecrets(key string) { case a.Sms.Vonage.Enabled: a.Sms.Vonage.ApiSecret = hash(a.Sms.Vonage.ApiSecret) } - if a.Hook.MFAVerificationAttempt.Enabled && len(a.Hook.MFAVerificationAttempt.Secrets) > 0 { + if a.Hook.MFAVerificationAttempt != nil && a.Hook.MFAVerificationAttempt.Enabled { a.Hook.MFAVerificationAttempt.Secrets = hash(a.Hook.MFAVerificationAttempt.Secrets) } - if a.Hook.PasswordVerificationAttempt.Enabled && len(a.Hook.PasswordVerificationAttempt.Secrets) > 0 { + if a.Hook.PasswordVerificationAttempt != nil && a.Hook.PasswordVerificationAttempt.Enabled { a.Hook.PasswordVerificationAttempt.Secrets = hash(a.Hook.PasswordVerificationAttempt.Secrets) } - if a.Hook.CustomAccessToken.Enabled && len(a.Hook.CustomAccessToken.Secrets) > 0 { + if a.Hook.CustomAccessToken != nil && a.Hook.CustomAccessToken.Enabled { a.Hook.CustomAccessToken.Secrets = hash(a.Hook.CustomAccessToken.Secrets) } - if a.Hook.SendSMS.Enabled && len(a.Hook.SendSMS.Secrets) > 0 { + if a.Hook.SendSMS != nil && a.Hook.SendSMS.Enabled { a.Hook.SendSMS.Secrets = hash(a.Hook.SendSMS.Secrets) } - if a.Hook.SendEmail.Enabled && len(a.Hook.SendEmail.Secrets) > 0 { + if a.Hook.SendEmail != nil && a.Hook.SendEmail.Enabled { a.Hook.SendEmail.Secrets = hash(a.Hook.SendEmail.Secrets) } for name, provider := range a.External { diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index 404f1cbb6..e659da166 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -121,27 +121,27 @@ func TestHookDiff(t *testing.T) { t.Run("local and remote enabled", func(t *testing.T) { c := newWithDefaults() c.Hook = hook{ - CustomAccessToken: hookConfig{ + CustomAccessToken: &hookConfig{ Enabled: true, URI: "http://example.com", Secrets: "test-secret", }, - SendSMS: hookConfig{ + SendSMS: &hookConfig{ Enabled: true, URI: "http://example.com", Secrets: "test-secret", }, - SendEmail: hookConfig{ + SendEmail: &hookConfig{ Enabled: true, URI: "https://example.com", Secrets: "test-secret", }, - MFAVerificationAttempt: hookConfig{ + MFAVerificationAttempt: &hookConfig{ Enabled: true, URI: "https://example.com", Secrets: "test-secret", }, - PasswordVerificationAttempt: hookConfig{ + PasswordVerificationAttempt: &hookConfig{ Enabled: true, URI: "pg-functions://verifyPassword", }, @@ -151,12 +151,12 @@ func TestHookDiff(t *testing.T) { HookCustomAccessTokenEnabled: cast.Ptr(true), HookCustomAccessTokenUri: cast.Ptr("http://example.com"), HookCustomAccessTokenSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), - HookSendEmailEnabled: cast.Ptr(true), - HookSendEmailUri: cast.Ptr("https://example.com"), - HookSendEmailSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), HookSendSmsEnabled: cast.Ptr(true), HookSendSmsUri: cast.Ptr("http://example.com"), HookSendSmsSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), + HookSendEmailEnabled: cast.Ptr(true), + HookSendEmailUri: cast.Ptr("https://example.com"), + HookSendEmailSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), HookMfaVerificationAttemptEnabled: cast.Ptr(true), HookMfaVerificationAttemptUri: cast.Ptr("https://example.com"), HookMfaVerificationAttemptSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), @@ -168,41 +168,38 @@ func TestHookDiff(t *testing.T) { assert.Empty(t, string(diff)) }) - t.Run("local enabled and disabled", func(t *testing.T) { + t.Run("local disabled remote enabled", func(t *testing.T) { c := newWithDefaults() c.Hook = hook{ - CustomAccessToken: hookConfig{ - Enabled: true, - URI: "http://example.com", - Secrets: "test-secret", + CustomAccessToken: &hookConfig{ + Enabled: false, }, - SendSMS: hookConfig{ + SendSMS: &hookConfig{ Enabled: false, URI: "https://example.com", Secrets: "test-secret", }, - SendEmail: hookConfig{ - Enabled: true, - URI: "pg-functions://sendEmail", + SendEmail: &hookConfig{ + Enabled: false, }, - MFAVerificationAttempt: hookConfig{ + MFAVerificationAttempt: &hookConfig{ Enabled: false, - URI: "pg-functions://verifyMFA", + URI: "pg-functions://postgres/public/verifyMFA", }, - PasswordVerificationAttempt: hookConfig{Enabled: false}, + PasswordVerificationAttempt: nil, } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ - HookCustomAccessTokenEnabled: cast.Ptr(false), - HookCustomAccessTokenUri: cast.Ptr(""), - HookCustomAccessTokenSecrets: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), - HookSendEmailEnabled: cast.Ptr(false), - HookSendEmailUri: cast.Ptr(""), + HookCustomAccessTokenEnabled: cast.Ptr(true), + HookCustomAccessTokenUri: cast.Ptr("http://example.com"), + HookCustomAccessTokenSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), HookSendSmsEnabled: cast.Ptr(true), - HookSendSmsUri: cast.Ptr("http://example.com"), + HookSendSmsUri: cast.Ptr("https://example.com"), HookSendSmsSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), + HookSendEmailEnabled: cast.Ptr(true), + HookSendEmailUri: cast.Ptr("pg-functions://postgres/public/sendEmail"), HookMfaVerificationAttemptEnabled: cast.Ptr(true), - HookMfaVerificationAttemptUri: cast.Ptr("pg-functions://verifyMFA"), + HookMfaVerificationAttemptUri: cast.Ptr("pg-functions://postgres/public/verifyMFA"), HookPasswordVerificationAttemptEnabled: cast.Ptr(true), HookPasswordVerificationAttemptUri: cast.Ptr("https://example.com"), HookPasswordVerificationAttemptSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), @@ -212,13 +209,62 @@ func TestHookDiff(t *testing.T) { assertSnapshotEqual(t, diff) }) - t.Run("local and remote disabled", func(t *testing.T) { + t.Run("local enabled remote disabled", func(t *testing.T) { c := newWithDefaults() + c.Hook = hook{ + CustomAccessToken: &hookConfig{ + Enabled: true, + URI: "http://example.com", + Secrets: "test-secret", + }, + SendSMS: &hookConfig{ + Enabled: true, + URI: "https://example.com", + Secrets: "test-secret", + }, + SendEmail: &hookConfig{ + Enabled: true, + URI: "pg-functions://postgres/public/sendEmail", + }, + MFAVerificationAttempt: &hookConfig{ + Enabled: true, + URI: "pg-functions://postgres/public/verifyMFA", + }, + PasswordVerificationAttempt: nil, + } // Run test diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ HookCustomAccessTokenEnabled: cast.Ptr(false), + HookCustomAccessTokenUri: cast.Ptr("pg-functions://postgres/public/customToken"), + HookSendSmsEnabled: cast.Ptr(false), + HookSendSmsUri: cast.Ptr("https://example.com"), + HookSendSmsSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), HookSendEmailEnabled: cast.Ptr(false), + HookSendEmailUri: cast.Ptr("https://example.com"), + HookSendEmailSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), + HookMfaVerificationAttemptEnabled: cast.Ptr(false), + HookMfaVerificationAttemptUri: cast.Ptr("pg-functions://postgres/public/verifyMFA"), + HookPasswordVerificationAttemptEnabled: cast.Ptr(false), + }) + // Check error + assert.NoError(t, err) + assertSnapshotEqual(t, diff) + }) + + t.Run("local and remote disabled", func(t *testing.T) { + c := newWithDefaults() + c.Hook = hook{ + CustomAccessToken: &hookConfig{Enabled: false}, + SendSMS: &hookConfig{Enabled: false}, + SendEmail: &hookConfig{Enabled: false}, + MFAVerificationAttempt: &hookConfig{Enabled: false}, + PasswordVerificationAttempt: &hookConfig{Enabled: false}, + } + // Run test + diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + HookCustomAccessTokenEnabled: cast.Ptr(false), HookSendSmsEnabled: cast.Ptr(false), + HookSendEmailEnabled: cast.Ptr(false), HookMfaVerificationAttemptEnabled: cast.Ptr(false), HookPasswordVerificationAttemptEnabled: cast.Ptr(false), }) @@ -719,7 +765,7 @@ func TestSmsDiff(t *testing.T) { diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(false), SmsProvider: cast.Ptr("messagebird"), - SmsMessagebirdAccessKey: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + SmsMessagebirdAccessKey: cast.Ptr(""), }) // Check error assert.NoError(t, err) @@ -756,67 +802,67 @@ func TestExternalDiff(t *testing.T) { ExternalAppleAdditionalClientIds: cast.Ptr(""), ExternalAppleClientId: cast.Ptr(""), ExternalAppleEnabled: cast.Ptr(true), - ExternalAppleSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalAppleSecret: cast.Ptr(""), ExternalAzureClientId: cast.Ptr(""), ExternalAzureEnabled: cast.Ptr(true), - ExternalAzureSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalAzureSecret: cast.Ptr(""), ExternalAzureUrl: cast.Ptr(""), ExternalBitbucketClientId: cast.Ptr(""), ExternalBitbucketEnabled: cast.Ptr(true), - ExternalBitbucketSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalBitbucketSecret: cast.Ptr(""), ExternalDiscordClientId: cast.Ptr(""), ExternalDiscordEnabled: cast.Ptr(true), - ExternalDiscordSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalDiscordSecret: cast.Ptr(""), ExternalFacebookClientId: cast.Ptr(""), ExternalFacebookEnabled: cast.Ptr(true), - ExternalFacebookSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalFacebookSecret: cast.Ptr(""), ExternalFigmaClientId: cast.Ptr(""), ExternalFigmaEnabled: cast.Ptr(true), - ExternalFigmaSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalFigmaSecret: cast.Ptr(""), ExternalGithubClientId: cast.Ptr(""), ExternalGithubEnabled: cast.Ptr(true), - ExternalGithubSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalGithubSecret: cast.Ptr(""), ExternalGitlabClientId: cast.Ptr(""), ExternalGitlabEnabled: cast.Ptr(true), - ExternalGitlabSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalGitlabSecret: cast.Ptr(""), ExternalGitlabUrl: cast.Ptr(""), ExternalGoogleAdditionalClientIds: cast.Ptr(""), ExternalGoogleClientId: cast.Ptr(""), ExternalGoogleEnabled: cast.Ptr(true), - ExternalGoogleSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalGoogleSecret: cast.Ptr(""), ExternalGoogleSkipNonceCheck: cast.Ptr(false), ExternalKakaoClientId: cast.Ptr(""), ExternalKakaoEnabled: cast.Ptr(true), - ExternalKakaoSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalKakaoSecret: cast.Ptr(""), ExternalKeycloakClientId: cast.Ptr(""), ExternalKeycloakEnabled: cast.Ptr(true), - ExternalKeycloakSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalKeycloakSecret: cast.Ptr(""), ExternalKeycloakUrl: cast.Ptr(""), ExternalLinkedinOidcClientId: cast.Ptr(""), ExternalLinkedinOidcEnabled: cast.Ptr(true), - ExternalLinkedinOidcSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalLinkedinOidcSecret: cast.Ptr(""), ExternalNotionClientId: cast.Ptr(""), ExternalNotionEnabled: cast.Ptr(true), - ExternalNotionSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalNotionSecret: cast.Ptr(""), ExternalSlackOidcClientId: cast.Ptr(""), ExternalSlackOidcEnabled: cast.Ptr(true), - ExternalSlackOidcSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalSlackOidcSecret: cast.Ptr(""), ExternalSpotifyClientId: cast.Ptr(""), ExternalSpotifyEnabled: cast.Ptr(true), - ExternalSpotifySecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalSpotifySecret: cast.Ptr(""), ExternalTwitchClientId: cast.Ptr(""), ExternalTwitchEnabled: cast.Ptr(true), - ExternalTwitchSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalTwitchSecret: cast.Ptr(""), ExternalTwitterClientId: cast.Ptr(""), ExternalTwitterEnabled: cast.Ptr(true), - ExternalTwitterSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalTwitterSecret: cast.Ptr(""), ExternalWorkosClientId: cast.Ptr(""), ExternalWorkosEnabled: cast.Ptr(true), - ExternalWorkosSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalWorkosSecret: cast.Ptr(""), ExternalWorkosUrl: cast.Ptr(""), ExternalZoomClientId: cast.Ptr(""), ExternalZoomEnabled: cast.Ptr(true), - ExternalZoomSecret: cast.Ptr("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"), + ExternalZoomSecret: cast.Ptr(""), // Deprecated fields should be ignored ExternalSlackClientId: cast.Ptr(""), ExternalSlackEnabled: cast.Ptr(true), diff --git a/pkg/config/config.go b/pkg/config/config.go index 6b8306ba5..0e3f00a84 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -950,21 +950,36 @@ func (e external) validate() (err error) { } func (h *hook) validate() error { - if err := h.MFAVerificationAttempt.validate("mfa_verification_attempt"); err != nil { - return err + if hook := h.MFAVerificationAttempt; hook != nil { + if err := hook.validate("mfa_verification_attempt"); err != nil { + return err + } } - if err := h.PasswordVerificationAttempt.validate("password_verification_attempt"); err != nil { - return err + if hook := h.PasswordVerificationAttempt; hook != nil { + if err := hook.validate("password_verification_attempt"); err != nil { + return err + } } - if err := h.CustomAccessToken.validate("custom_access_token"); err != nil { - return err + if hook := h.CustomAccessToken; hook != nil { + if err := hook.validate("custom_access_token"); err != nil { + return err + } } - if err := h.SendSMS.validate("send_sms"); err != nil { - return err + if hook := h.SendSMS; hook != nil { + if err := hook.validate("send_sms"); err != nil { + return err + } + } + if hook := h.SendEmail; hook != nil { + if err := h.SendEmail.validate("send_email"); err != nil { + return err + } } - return h.SendEmail.validate("send_email") + return nil } +var hookSecretPattern = regexp.MustCompile(`^v1,whsec_[A-Za-z0-9+/=]{32,88}$`) + func (h *hookConfig) validate(hookType string) (err error) { // If not enabled do nothing if !h.Enabled { @@ -984,12 +999,17 @@ func (h *hookConfig) validate(hookType string) (err error) { } else if h.Secrets, err = maybeLoadEnv(h.Secrets); err != nil { return err } + for _, secret := range strings.Split(h.Secrets, "|") { + if !hookSecretPattern.MatchString(secret) { + return errors.Errorf(`Invalid hook config: auth.hook.%s.secrets must be formatted as "v1,whsec_"`, hookType) + } + } case "pg-functions": if len(h.Secrets) > 0 { return errors.Errorf("Invalid hook config: auth.hook.%s.secrets is unsupported for pg-functions URI", hookType) } default: - return errors.Errorf("Invalid hook config: auth.hook.%v should be a HTTP, HTTPS, or pg-functions URI", hookType) + return errors.Errorf("Invalid hook config: auth.hook.%s.uri should be a HTTP, HTTPS, or pg-functions URI", hookType) } return nil } diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 4aa7ce243..e1678f2ed 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -214,7 +214,7 @@ func TestValidateHookURI(t *testing.T) { hookConfig: hookConfig{ Enabled: true, URI: "http://example.com", - Secrets: "test-secret", + Secrets: "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw==", }, }, { @@ -222,7 +222,7 @@ func TestValidateHookURI(t *testing.T) { hookConfig: hookConfig{ Enabled: true, URI: "https://example.com", - Secrets: "test-secret", + Secrets: "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw==", }, }, { @@ -237,16 +237,16 @@ func TestValidateHookURI(t *testing.T) { hookConfig: hookConfig{ Enabled: true, URI: "ftp://example.com", - Secrets: "test-secret", + Secrets: "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw==", }, - errorMsg: "Invalid hook config: auth.hook.invalid URI with unsupported scheme should be a HTTP, HTTPS, or pg-functions URI", + errorMsg: "Invalid hook config: auth.hook.invalid URI with unsupported scheme.uri should be a HTTP, HTTPS, or pg-functions URI", }, { name: "invalid URI with parsing error", hookConfig: hookConfig{ Enabled: true, URI: "http://a b.com", - Secrets: "test-secret", + Secrets: "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw==", }, errorMsg: "failed to parse template url: parse \"http://a b.com\": invalid character \" \" in host name", }, diff --git a/pkg/config/testdata/TestAuthDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestAuthDiff/local_enabled_and_disabled.diff index 3db4d5462..b4022569c 100644 --- a/pkg/config/testdata/TestAuthDiff/local_enabled_and_disabled.diff +++ b/pkg/config/testdata/TestAuthDiff/local_enabled_and_disabled.diff @@ -25,4 +25,4 @@ diff remote[auth] local[auth] +password_requirements = "lower_upper_letters_digits_symbols" [hook] - [hook.mfa_verification_attempt] + diff --git a/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff b/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff index 3308fd0a4..99a50071f 100644 --- a/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff +++ b/pkg/config/testdata/TestEmailDiff/local_disabled_remote_enabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -51,13 +51,13 @@ +@@ -31,13 +31,13 @@ inactivity_timeout = "0s" [email] diff --git a/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff index d42967e05..85d30362a 100644 --- a/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff +++ b/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -51,35 +51,43 @@ +@@ -31,35 +31,43 @@ inactivity_timeout = "0s" [email] diff --git a/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff index 37ab653dd..089d74eee 100644 --- a/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff +++ b/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -91,7 +91,7 @@ +@@ -71,7 +71,7 @@ [external] [external.apple] @@ -10,7 +10,7 @@ diff remote[auth] local[auth] client_id = "test-client-1,test-client-2" secret = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" url = "" -@@ -98,9 +98,9 @@ +@@ -78,9 +78,9 @@ redirect_uri = "" skip_nonce_check = false [external.azure] @@ -23,7 +23,7 @@ diff remote[auth] local[auth] url = "" redirect_uri = "" skip_nonce_check = false -@@ -147,7 +147,7 @@ +@@ -127,7 +127,7 @@ redirect_uri = "" skip_nonce_check = false [external.google] diff --git a/pkg/config/testdata/TestHookDiff/local_disabled_remote_enabled.diff b/pkg/config/testdata/TestHookDiff/local_disabled_remote_enabled.diff new file mode 100644 index 000000000..c8cf4c5f0 --- /dev/null +++ b/pkg/config/testdata/TestHookDiff/local_disabled_remote_enabled.diff @@ -0,0 +1,27 @@ +diff remote[auth] local[auth] +--- remote[auth] ++++ local[auth] +@@ -11,19 +11,19 @@ + + [hook] + [hook.mfa_verification_attempt] +-enabled = true ++enabled = false + uri = "pg-functions://postgres/public/verifyMFA" + secrets = "" + [hook.custom_access_token] +-enabled = true ++enabled = false + uri = "" + secrets = "" + [hook.send_sms] +-enabled = true ++enabled = false + uri = "https://example.com" + secrets = "test-secret" + [hook.send_email] +-enabled = true ++enabled = false + uri = "" + secrets = "" + diff --git a/pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff deleted file mode 100644 index e3afeb491..000000000 --- a/pkg/config/testdata/TestHookDiff/local_enabled_and_disabled.diff +++ /dev/null @@ -1,36 +0,0 @@ -diff remote[auth] local[auth] ---- remote[auth] -+++ local[auth] -@@ -11,24 +11,24 @@ - - [hook] - [hook.mfa_verification_attempt] --enabled = true -+enabled = false - uri = "pg-functions://verifyMFA" - secrets = "" - [hook.password_verification_attempt] --enabled = true -+enabled = false - uri = "" - secrets = "" - [hook.custom_access_token] --enabled = false --uri = "" --secrets = "hash:b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad" -+enabled = true -+uri = "http://example.com" -+secrets = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" - [hook.send_sms] --enabled = true -+enabled = false - uri = "https://example.com" - secrets = "test-secret" - [hook.send_email] --enabled = false --uri = "" -+enabled = true -+uri = "pg-functions://sendEmail" - secrets = "" - - [mfa] diff --git a/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff new file mode 100644 index 000000000..e5f26740e --- /dev/null +++ b/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff @@ -0,0 +1,33 @@ +diff remote[auth] local[auth] +--- remote[auth] ++++ local[auth] +@@ -11,21 +11,21 @@ + + [hook] + [hook.mfa_verification_attempt] +-enabled = false ++enabled = true + uri = "pg-functions://postgres/public/verifyMFA" + secrets = "hash:" + [hook.custom_access_token] +-enabled = false +-uri = "pg-functions://postgres/public/customToken" +-secrets = "hash:" ++enabled = true ++uri = "http://example.com" ++secrets = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" + [hook.send_sms] +-enabled = false ++enabled = true + uri = "https://example.com" + secrets = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" + [hook.send_email] +-enabled = false +-uri = "https://example.com" +-secrets = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" ++enabled = true ++uri = "pg-functions://postgres/public/sendEmail" ++secrets = "hash:" + + [mfa] + max_enrolled_factors = 0 diff --git a/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff index 866ce8fae..e5fa7c476 100644 --- a/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff +++ b/pkg/config/testdata/TestMfaDiff/local_enabled_and_disabled.diff @@ -1,8 +1,8 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -32,16 +32,16 @@ - secrets = "" +@@ -12,16 +12,16 @@ + [hook] [mfa] -max_enrolled_factors = 10 diff --git a/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff b/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff index 637a0206e..a7c312c91 100644 --- a/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff +++ b/pkg/config/testdata/TestSmsDiff/enable_sign_up_without_provider.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -60,7 +60,7 @@ +@@ -40,7 +40,7 @@ otp_expiry = 0 [sms] diff --git a/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff b/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff index 4348c80ba..1dd938cd7 100644 --- a/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff +++ b/pkg/config/testdata/TestSmsDiff/local_disabled_remote_enabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -60,12 +60,12 @@ +@@ -40,12 +40,12 @@ otp_expiry = 0 [sms] @@ -19,7 +19,7 @@ diff remote[auth] local[auth] account_sid = "" message_service_sid = "" auth_token = "" -@@ -88,8 +88,6 @@ +@@ -68,8 +68,6 @@ api_key = "" api_secret = "" [sms.test_otp] diff --git a/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff index e29c287ed..4418013bf 100644 --- a/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff +++ b/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -60,12 +60,12 @@ +@@ -40,12 +40,12 @@ otp_expiry = 0 [sms] @@ -19,7 +19,7 @@ diff remote[auth] local[auth] account_sid = "" message_service_sid = "" auth_token = "" -@@ -75,9 +75,9 @@ +@@ -55,9 +55,9 @@ message_service_sid = "" auth_token = "" [sms.messagebird] @@ -32,7 +32,7 @@ diff remote[auth] local[auth] [sms.textlocal] enabled = false sender = "" -@@ -88,6 +88,7 @@ +@@ -68,6 +68,7 @@ api_key = "" api_secret = "" [sms.test_otp] From 440764786fe117d0dddcb34c0a85e86ab3a5ce00 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Tue, 10 Dec 2024 19:09:53 +0800 Subject: [PATCH 219/305] fix: handle pointers when cloning auth hooks (#2962) --- pkg/config/config.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pkg/config/config.go b/pkg/config/config.go index 0e3f00a84..a9536f43e 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -224,6 +224,26 @@ func (a *auth) Clone() auth { mailer := *a.Email.Smtp copy.Email.Smtp = &mailer } + if a.Hook.MFAVerificationAttempt != nil { + hook := *a.Hook.MFAVerificationAttempt + copy.Hook.MFAVerificationAttempt = &hook + } + if a.Hook.PasswordVerificationAttempt != nil { + hook := *a.Hook.PasswordVerificationAttempt + copy.Hook.PasswordVerificationAttempt = &hook + } + if a.Hook.CustomAccessToken != nil { + hook := *a.Hook.CustomAccessToken + copy.Hook.CustomAccessToken = &hook + } + if a.Hook.SendSMS != nil { + hook := *a.Hook.SendSMS + copy.Hook.SendSMS = &hook + } + if a.Hook.SendEmail != nil { + hook := *a.Hook.SendEmail + copy.Hook.SendEmail = &hook + } copy.Email.Template = maps.Clone(a.Email.Template) copy.Sms.TestOTP = maps.Clone(a.Sms.TestOTP) return copy From 06044cea4bae549528ec61a8ff34c3f5ecbd4231 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 11 Dec 2024 11:41:14 +0800 Subject: [PATCH 220/305] chore: update CODEOWNERS --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index e58bd32eb..25b00f97a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @supabase/cli +* @supabase/dev-workflows From baa2c23fa2379f532ba38e9bbf7d9e69a41bcbe0 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 11 Dec 2024 15:20:43 +0800 Subject: [PATCH 221/305] fix: rewrite content template path in nested directory (#2965) * fix: rewrite content template path in nested directory * chore: remove unnecessary clean --- pkg/config/config.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index a9536f43e..fa8da8bf4 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -495,6 +495,15 @@ func (c *config) Load(path string, fsys fs.FS) error { if version, err := fs.ReadFile(fsys, builder.PgmetaVersionPath); err == nil && len(version) > 0 { c.Studio.PgmetaImage = replaceImageTag(pgmetaImage, string(version)) } + // Update content paths + for name, tmpl := range c.Auth.Email.Template { + // FIXME: only email template is relative to repo directory + cwd := filepath.Dir(builder.SupabaseDirPath) + if len(tmpl.ContentPath) > 0 && !filepath.IsAbs(tmpl.ContentPath) { + tmpl.ContentPath = filepath.Join(cwd, tmpl.ContentPath) + } + c.Auth.Email.Template[name] = tmpl + } // Update fallback configs for name, bucket := range c.Storage.Buckets { if bucket.FileSizeLimit == 0 { @@ -834,7 +843,7 @@ func (e *email) validate(fsys fs.FS) (err error) { } continue } - if content, err := fs.ReadFile(fsys, filepath.Clean(tmpl.ContentPath)); err != nil { + if content, err := fs.ReadFile(fsys, tmpl.ContentPath); err != nil { return errors.Errorf("Invalid config for auth.email.%s.content_path: %w", name, err) } else { tmpl.Content = cast.Ptr(string(content)) From 8cac0be02711cdd3bc08b56db4dfb256ea574423 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 11 Dec 2024 17:49:40 +0800 Subject: [PATCH 222/305] fix: disable image transformation and mfa by default (#2966) * fix: disable image transformation by default * fix: disable mfa totp by default * chore: update test config * chore: disable instead of commenting out * chore: add note about pro plan * fix: remove default value for image transformation config --- pkg/config/config.go | 3 +-- pkg/config/templates/config.toml | 14 ++++++++------ pkg/config/testdata/config.toml | 29 ++++++++++++++++++++--------- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index fa8da8bf4..410bd7aa3 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -307,8 +307,7 @@ func NewConfig(editors ...ConfigEditor) config { Region: "local", }, ImageTransformation: imageTransformation{ - Enabled: true, - Image: imageProxyImage, + Image: imageProxyImage, }, }, Auth: auth{ diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index 26c480c33..e3f55ae68 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -82,8 +82,9 @@ enabled = true # The maximum file size allowed (e.g. "5MB", "500KB"). file_size_limit = "50MiB" +# Image transformation API is available to Supabase Pro plan. [storage.image_transformation] -enabled = true +enabled = false # Uncomment to configure local storage buckets # [storage.buckets.images] @@ -184,16 +185,17 @@ message_service_sid = "" # DO NOT commit your Twilio auth token to git. Use environment variable substitution instead: auth_token = "env(SUPABASE_AUTH_SMS_TWILIO_AUTH_TOKEN)" +# Multi-factor-authentication is available to Supabase Pro plan. [auth.mfa] # Control how many MFA factors can be enrolled at once per user. max_enrolled_factors = 10 -# Control use of MFA via App Authenticator (TOTP) +# Control MFA via App Authenticator (TOTP) [auth.mfa.totp] -enroll_enabled = true -verify_enabled = true +enroll_enabled = false +verify_enabled = false -# Configure Multi-factor-authentication via Phone Messaging +# Configure MFA via Phone Messaging [auth.mfa.phone] enroll_enabled = false verify_enabled = false @@ -201,7 +203,7 @@ otp_length = 6 template = "Your code is {{ `{{ .Code }}` }}" max_frequency = "5s" -# Configure Multi-factor-authentication via WebAuthn +# Configure MFA via WebAuthn # [auth.mfa.web_authn] # enroll_enabled = true # verify_enabled = true diff --git a/pkg/config/testdata/config.toml b/pkg/config/testdata/config.toml index ce845743e..113626868 100644 --- a/pkg/config/testdata/config.toml +++ b/pkg/config/testdata/config.toml @@ -1,3 +1,5 @@ +# For detailed configuration reference documentation, visit: +# https://supabase.com/docs/guides/local-development/cli/config # A string used to distinguish different Supabase projects on the same host. Defaults to the # working directory name when running `supabase init`. project_id = "test" @@ -7,7 +9,7 @@ enabled = true # Port to use for the API URL. port = 54321 # Schemas to expose in your API. Tables, views and stored procedures in this schema will get API -# endpoints. public and storage are always included. +# endpoints. `public` and `graphql_public` schemas are included by default. schemas = ["public", "graphql_public"] # Extra schemas to add to the search_path of every request. public is always included. extra_search_path = ["public", "extensions"] @@ -16,6 +18,7 @@ extra_search_path = ["public", "extensions"] max_rows = 1000 [api.tls] +# Enable HTTPS endpoints locally using a self-signed certificate. enabled = true [db] @@ -43,8 +46,7 @@ max_client_conn = 100 # If enabled, seeds the database after migrations during a db reset. enabled = true # Specifies an ordered list of seed files to load during db reset. -# Supports glob patterns relative to supabase directory. For example: -# sql_paths = ['./seeds/*.sql', '../project-src/seeds/*-load-testing.sql'] +# Supports glob patterns relative to supabase directory: './seeds/*.sql' sql_paths = ['./seed.sql'] [realtime] @@ -72,14 +74,17 @@ port = 54324 # Uncomment to expose additional ports for testing user applications that send emails. # smtp_port = 54325 # pop3_port = 54326 +# admin_email = "admin@email.com" +# sender_name = "Admin" [storage] enabled = true # The maximum file size allowed (e.g. "5MB", "500KB"). file_size_limit = "50MiB" +# Image transformation API is available to Supabase Pro plan. [storage.image_transformation] -enabled = false +enabled = true # Uncomment to configure local storage buckets [storage.buckets.images] @@ -104,6 +109,8 @@ enable_refresh_token_rotation = true refresh_token_reuse_interval = 10 # Allow/disallow new user signups to your project. enable_signup = true +# Allow/disallow anonymous sign-ins to your project. +enable_anonymous_sign_ins = true # Allow/disallow testing manual linking of accounts enable_manual_linking = true # Passwords shorter than this value will be rejected as weak. Minimum 6, recommended 8 or more. @@ -120,15 +127,18 @@ enable_signup = true double_confirm_changes = true # If enabled, users need to confirm their email address before signing in. enable_confirmations = false +# If enabled, users will need to reauthenticate or have logged in recently to change their password. +secure_password_change = true # Controls the minimum amount of time that must pass before sending another signup confirmation or password reset email. max_frequency = "1s" # Number of characters used in the email OTP. otp_length = 6 -# Number of seconds before the email OTP expires. -otp_expiry = 300 +# Number of seconds before the email OTP expires (defaults to 1 hour). +otp_expiry = 3600 # Use a production-ready SMTP server [auth.email.smtp] +enabled = true host = "smtp.sendgrid.net" port = 587 user = "apikey" @@ -162,6 +172,7 @@ timebox = "24h" # Force log out if the user has been inactive longer than the specified duration. inactivity_timeout = "8h" +# This hook runs before a token is issued and allows you to add additional claims based on the authentication method used. [auth.hook.custom_access_token] enabled = true uri = "pg-functions://postgres/auth/custom-access-token-hook" @@ -171,7 +182,6 @@ enabled = true uri = "http://host.docker.internal/functions/v1/send_sms" secrets = "env(AUTH_SEND_SMS_SECRETS)" - # Configure one of the supported SMS providers: `twilio`, `twilio_verify`, `messagebird`, `textlocal`, `vonage`. [auth.sms.twilio] enabled = true @@ -180,6 +190,7 @@ message_service_sid = "message_service_sid" # DO NOT commit your Twilio auth token to git. Use environment variable substitution instead: auth_token = "env(TWILIO_AUTH_TOKEN)" +# Multi-factor-authentication is available to Supabase Pro plan. [auth.mfa] max_enrolled_factors = 10 @@ -188,7 +199,7 @@ max_enrolled_factors = 10 enroll_enabled = true verify_enabled = true -# Configure Multi-factor-authentication via Phone Messaging +# Configure MFA via Phone Messaging [auth.mfa.phone] enroll_enabled = true verify_enabled = true @@ -196,7 +207,7 @@ otp_length = 6 template = "Your code is {{ `{{ .Code }}` }}" max_frequency = "5s" -# Configure Multi-factor-authentication via Phone Messaging +# Configure MFA via Phone Messaging [auth.mfa.web_authn] enroll_enabled = true verify_enabled = true From f1b57bc32205965ad01d6e2267be752eb126eda3 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 11 Dec 2024 22:02:48 +0800 Subject: [PATCH 223/305] fix: make image transformation feature optional (#2967) --- internal/start/start.go | 8 +++++--- internal/start/start_test.go | 2 +- pkg/config/config.go | 6 ++---- pkg/config/storage.go | 25 ++++++++++++++++++------- pkg/config/templates/config.toml | 4 ++-- pkg/config/updater_test.go | 2 +- 6 files changed, 29 insertions(+), 18 deletions(-) diff --git a/internal/start/start.go b/internal/start/start.go index 9096f381d..f31a950cc 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -169,6 +169,8 @@ func run(p utils.Program, ctx context.Context, fsys afero.Fs, excludedContainers var started []string var isStorageEnabled = utils.Config.Storage.Enabled && !isContainerExcluded(utils.Config.Storage.Image, excluded) + var isImgProxyEnabled = utils.Config.Storage.ImageTransformation != nil && + utils.Config.Storage.ImageTransformation.Enabled && !isContainerExcluded(utils.Config.Storage.ImgProxyImage, excluded) p.Send(utils.StatusMsg("Starting containers...")) // Start Logflare @@ -833,7 +835,7 @@ EOF // TODO: https://github.com/supabase/storage-api/issues/55 "STORAGE_S3_REGION=" + utils.Config.Storage.S3Credentials.Region, "GLOBAL_S3_BUCKET=stub", - fmt.Sprintf("ENABLE_IMAGE_TRANSFORMATION=%t", utils.Config.Storage.ImageTransformation.Enabled), + fmt.Sprintf("ENABLE_IMAGE_TRANSFORMATION=%t", isImgProxyEnabled), fmt.Sprintf("IMGPROXY_URL=http://%s:5001", utils.ImgProxyId), "TUS_URL_PATH=/storage/v1/upload/resumable", "S3_PROTOCOL_ACCESS_KEY_ID=" + utils.Config.Storage.S3Credentials.AccessKeyId, @@ -872,11 +874,11 @@ EOF } // Start Storage ImgProxy. - if isStorageEnabled && utils.Config.Storage.ImageTransformation.Enabled && !isContainerExcluded(utils.Config.Storage.ImageTransformation.Image, excluded) { + if isStorageEnabled && isImgProxyEnabled { if _, err := utils.DockerStart( ctx, container.Config{ - Image: utils.Config.Storage.ImageTransformation.Image, + Image: utils.Config.Storage.ImgProxyImage, Env: []string{ "IMGPROXY_BIND=:5001", "IMGPROXY_LOCAL_FILESYSTEM_ROOT=/", diff --git a/internal/start/start_test.go b/internal/start/start_test.go index 079eb3c79..b61cb9cd4 100644 --- a/internal/start/start_test.go +++ b/internal/start/start_test.go @@ -133,7 +133,7 @@ func TestDatabaseStart(t *testing.T) { utils.StorageId = "test-storage" apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Storage.Image), utils.StorageId) utils.ImgProxyId = "test-imgproxy" - apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Storage.ImageTransformation.Image), utils.ImgProxyId) + apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.Storage.ImgProxyImage), utils.ImgProxyId) utils.EdgeRuntimeId = "test-edge-runtime" apitest.MockDockerStart(utils.Docker, utils.GetRegistryImageUrl(utils.Config.EdgeRuntime.Image), utils.EdgeRuntimeId) utils.PgmetaId = "test-pgmeta" diff --git a/pkg/config/config.go b/pkg/config/config.go index 410bd7aa3..5c7fc0946 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -300,15 +300,13 @@ func NewConfig(editors ...ConfigEditor) config { SecretKeyBase: "EAx3IQ/wRG1v47ZD4NE4/9RzBI8Jmil3x0yhcW4V2NHBP6c2iPIzwjofi2Ep4HIG", }, Storage: storage{ - Image: storageImage, + Image: storageImage, + ImgProxyImage: imageProxyImage, S3Credentials: storageS3Credentials{ AccessKeyId: "625729a08b95bf1b7ff351a663f3a23c", SecretAccessKey: "850181e4652dd023b7a98c58ae0d2d34bd487ee0cc3254aed6eda37307425907", Region: "local", }, - ImageTransformation: imageTransformation{ - Image: imageProxyImage, - }, }, Auth: auth{ Image: gotrueImage, diff --git a/pkg/config/storage.go b/pkg/config/storage.go index b11b28a10..3b5696738 100644 --- a/pkg/config/storage.go +++ b/pkg/config/storage.go @@ -10,15 +10,15 @@ type ( storage struct { Enabled bool `toml:"enabled"` Image string `toml:"-"` + ImgProxyImage string `toml:"-"` FileSizeLimit sizeInBytes `toml:"file_size_limit"` + ImageTransformation *imageTransformation `toml:"image_transformation"` S3Credentials storageS3Credentials `toml:"-"` - ImageTransformation imageTransformation `toml:"image_transformation"` Buckets BucketConfig `toml:"buckets"` } imageTransformation struct { - Enabled bool `toml:"enabled"` - Image string `toml:"-"` + Enabled bool `toml:"enabled"` } storageS3Credentials struct { @@ -38,15 +38,26 @@ type ( ) func (s *storage) ToUpdateStorageConfigBody() v1API.UpdateStorageConfigBody { - body := v1API.UpdateStorageConfigBody{Features: &v1API.StorageFeatures{}} - body.FileSizeLimit = cast.Ptr(int64(s.FileSizeLimit)) - body.Features.ImageTransformation.Enabled = s.ImageTransformation.Enabled + body := v1API.UpdateStorageConfigBody{ + FileSizeLimit: cast.Ptr(int64(s.FileSizeLimit)), + } + // When local config is not set, we assume platform defaults should not change + if s.ImageTransformation != nil { + body.Features = &v1API.StorageFeatures{ + ImageTransformation: v1API.StorageFeatureImageTransformation{ + Enabled: s.ImageTransformation.Enabled, + }, + } + } return body } func (s *storage) FromRemoteStorageConfig(remoteConfig v1API.StorageConfigResponse) { s.FileSizeLimit = sizeInBytes(remoteConfig.FileSizeLimit) - s.ImageTransformation.Enabled = remoteConfig.Features.ImageTransformation.Enabled + // When local config is not set, we assume platform defaults should not change + if s.ImageTransformation != nil { + s.ImageTransformation.Enabled = remoteConfig.Features.ImageTransformation.Enabled + } } func (s *storage) DiffWithRemote(remoteConfig v1API.StorageConfigResponse) ([]byte, error) { diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index e3f55ae68..5345f4d0d 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -83,8 +83,8 @@ enabled = true file_size_limit = "50MiB" # Image transformation API is available to Supabase Pro plan. -[storage.image_transformation] -enabled = false +# [storage.image_transformation] +# enabled = true # Uncomment to configure local storage buckets # [storage.buckets.images] diff --git a/pkg/config/updater_test.go b/pkg/config/updater_test.go index 471e84963..f3eb0bcb4 100644 --- a/pkg/config/updater_test.go +++ b/pkg/config/updater_test.go @@ -336,7 +336,7 @@ func TestUpdateRemoteConfig(t *testing.T) { Storage: storage{ Enabled: true, FileSizeLimit: 100, - ImageTransformation: imageTransformation{ + ImageTransformation: &imageTransformation{ Enabled: true, }, }, From c414ec87532a28920417833ba9d7255a84ca4f01 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 11 Dec 2024 22:58:13 +0800 Subject: [PATCH 224/305] fix: copy image transform by value (#2969) --- pkg/config/storage.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/config/storage.go b/pkg/config/storage.go index 3b5696738..b026d0cf6 100644 --- a/pkg/config/storage.go +++ b/pkg/config/storage.go @@ -62,6 +62,10 @@ func (s *storage) FromRemoteStorageConfig(remoteConfig v1API.StorageConfigRespon func (s *storage) DiffWithRemote(remoteConfig v1API.StorageConfigResponse) ([]byte, error) { copy := *s + if s.ImageTransformation != nil { + img := *s.ImageTransformation + copy.ImageTransformation = &img + } // Convert the config values into easily comparable remoteConfig values currentValue, err := ToTomlBytes(copy) if err != nil { From e0d03ec6a50074dc92c739745bff089531f7a12c Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Wed, 11 Dec 2024 18:21:52 +0100 Subject: [PATCH 225/305] feat(dump): print complete filedist path for dump (#2968) * choredump): print complete filedist path for dump * Update cmd/db.go Co-authored-by: Han Qiao --------- Co-authored-by: Han Qiao --- cmd/db.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/db.go b/cmd/db.go index 2d64edd74..13f29401f 100644 --- a/cmd/db.go +++ b/cmd/db.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "os/signal" + "path/filepath" "github.com/spf13/afero" "github.com/spf13/cobra" @@ -125,7 +126,11 @@ var ( }, PostRun: func(cmd *cobra.Command, args []string) { if len(file) > 0 { - fmt.Fprintln(os.Stderr, "Dumped schema to "+utils.Bold(file)+".") + if absPath, err := filepath.Abs(file); err != nil { + fmt.Fprintln(os.Stderr, "Dumped schema to "+utils.Bold(file)+".") + } else { + fmt.Fprintln(os.Stderr, "Dumped schema to "+utils.Bold(absPath)+".") + } } }, } From 3b0df03bda6e1bcf84ab68795807d182858e2a9f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 05:01:44 +0000 Subject: [PATCH 226/305] chore(deps): bump google.golang.org/grpc from 1.68.1 to 1.69.0 (#2973) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.68.1 to 1.69.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.68.1...v1.69.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 7d1632a6a..82190adb8 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( golang.org/x/mod v0.22.0 golang.org/x/oauth2 v0.24.0 golang.org/x/term v0.27.0 - google.golang.org/grpc v1.68.1 + google.golang.org/grpc v1.69.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.12.0 ) @@ -305,8 +305,8 @@ require ( go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect go.opentelemetry.io/otel/metric v1.32.0 // indirect - go.opentelemetry.io/otel/sdk v1.28.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.28.0 // indirect + go.opentelemetry.io/otel/sdk v1.31.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.31.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/atomic v1.9.0 // indirect @@ -321,8 +321,8 @@ require ( golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.20.0 // indirect golang.org/x/tools v0.27.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect google.golang.org/protobuf v1.35.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect diff --git a/go.sum b/go.sum index 2e82216da..8644ebb55 100644 --- a/go.sum +++ b/go.sum @@ -1008,10 +1008,10 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 h1:j9+03 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0/go.mod h1:Y5+XiUG4Emn1hTfciPzGPJaSI+RpDts6BnCIir0SLqk= go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= -go.opentelemetry.io/otel/sdk v1.28.0 h1:b9d7hIry8yZsgtbmM0DKyPWMMUMlK9NEKuIG4aBqWyE= -go.opentelemetry.io/otel/sdk v1.28.0/go.mod h1:oYj7ClPUA7Iw3m+r7GeEjz0qckQRJK2B8zjcZEfu7Pg= -go.opentelemetry.io/otel/sdk/metric v1.28.0 h1:OkuaKgKrgAbYrrY0t92c+cC+2F6hsFNnCQArXCKlg08= -go.opentelemetry.io/otel/sdk/metric v1.28.0/go.mod h1:cWPjykihLAPvXKi4iZc1dpER3Jdq2Z0YLse3moQUCpg= +go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk= +go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0= +go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc= +go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= @@ -1424,10 +1424,10 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 h1:hjSy6tcFQZ171igDaN5QHOw2n6vx40juYbC/x67CEhc= -google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:qpvKtACPCQhAdu3PyQgV4l3LMXZEtft7y8QcarRsp9I= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 h1:fVoAXEKA4+yufmbdVYv+SE73+cPZbbbe8paLsHfkK+U= +google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53/go.mod h1:riSXTwQ4+nqmPGtobMFyW5FqVAmIs0St6VPp4Ug7CE4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= google.golang.org/grpc v1.0.5/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -1441,8 +1441,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.68.1 h1:oI5oTa11+ng8r8XMMN7jAOmWfPZWbYpCFaMUTACxkM0= -google.golang.org/grpc v1.68.1/go.mod h1:+q1XYFJjShcqn0QZHvCyeR4CXPA+llXIeUIfIe00waw= +google.golang.org/grpc v1.69.0 h1:quSiOM1GJPmPH5XtU+BCoVXcDVJJAzNcoyfC2cCjGkI= +google.golang.org/grpc v1.69.0/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From 574b879f19d0da995e08121d01c13b7834e00b46 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 05:06:42 +0000 Subject: [PATCH 227/305] chore(deps): bump github.com/docker/docker from 27.3.1+incompatible to 27.4.0+incompatible (#2960) chore(deps): bump github.com/docker/docker Bumps [github.com/docker/docker](https://github.com/docker/docker) from 27.3.1+incompatible to 27.4.0+incompatible. - [Release notes](https://github.com/docker/docker/releases) - [Commits](https://github.com/docker/docker/compare/v27.3.1...v27.4.0) --- updated-dependencies: - dependency-name: github.com/docker/docker dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 82190adb8..61074c80d 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/containers/common v0.61.0 github.com/deepmap/oapi-codegen/v2 v2.2.0 github.com/docker/cli v27.4.0+incompatible - github.com/docker/docker v27.3.1+incompatible + github.com/docker/docker v27.4.0+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 github.com/getsentry/sentry-go v0.30.0 diff --git a/go.sum b/go.sum index 8644ebb55..1ccf6a50a 100644 --- a/go.sum +++ b/go.sum @@ -231,8 +231,8 @@ github.com/docker/cli v27.4.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvM github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v27.3.1+incompatible h1:KttF0XoteNTicmUtBO0L2tP+J7FGRFTjaEF4k6WdhfI= -github.com/docker/docker v27.3.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.4.0+incompatible h1:I9z7sQ5qyzO0BfAb9IMOawRkAGxhYsidKiTMcm0DU+A= +github.com/docker/docker v27.4.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo= github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0= From b6c230337a411f265260f76f12dee5d2c266d236 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 05:11:36 +0000 Subject: [PATCH 228/305] chore(deps): bump go.opentelemetry.io/otel from 1.32.0 to 1.33.0 (#2974) Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.32.0 to 1.33.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.32.0...v1.33.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/otel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 7 ++++--- go.sum | 14 ++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 61074c80d..09f10d325 100644 --- a/go.mod +++ b/go.mod @@ -46,7 +46,7 @@ require ( github.com/stripe/pg-schema-diff v0.8.0 github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 github.com/zalando/go-keyring v0.2.6 - go.opentelemetry.io/otel v1.32.0 + go.opentelemetry.io/otel v1.33.0 golang.org/x/mod v0.22.0 golang.org/x/oauth2 v0.24.0 golang.org/x/term v0.27.0 @@ -299,15 +299,16 @@ require ( gitlab.com/bosi/decorder v0.4.2 // indirect go-simpler.org/musttag v0.13.0 // indirect go-simpler.org/sloglint v0.7.2 // indirect + go.opentelemetry.io/auto/sdk v1.1.0 // indirect go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect - go.opentelemetry.io/otel/metric v1.32.0 // indirect + go.opentelemetry.io/otel/metric v1.33.0 // indirect go.opentelemetry.io/otel/sdk v1.31.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.31.0 // indirect - go.opentelemetry.io/otel/trace v1.32.0 // indirect + go.opentelemetry.io/otel/trace v1.33.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/automaxprocs v1.6.0 // indirect diff --git a/go.sum b/go.sum index 1ccf6a50a..804a4c0fd 100644 --- a/go.sum +++ b/go.sum @@ -994,10 +994,12 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8= -go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= -go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= +go.opentelemetry.io/otel v1.33.0 h1:/FerN9bax5LoK51X/sI0SVYrjSE0/yUL7DpxW4K3FWw= +go.opentelemetry.io/otel v1.33.0/go.mod h1:SUUkR6csvUQl+yjReHu5uM3EtVV7MBm5FHKRlNx4I8I= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 h1:U2guen0GhqH8o/G2un8f/aG/y++OuW6MyCo6hT9prXk= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0/go.mod h1:yeGZANgEcpdx/WK0IvvRFC+2oLiMS2u4L/0Rj2M2Qr0= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY= @@ -1006,14 +1008,14 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 h1:R3X6Z go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0/go.mod h1:QWFXnDavXWwMx2EEcZsf3yxgEKAqsxQ+Syjp+seyInw= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 h1:j9+03ymgYhPKmeXGk5Zu+cIZOlVzd9Zv7QIiyItjFBU= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0/go.mod h1:Y5+XiUG4Emn1hTfciPzGPJaSI+RpDts6BnCIir0SLqk= -go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= -go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= +go.opentelemetry.io/otel/metric v1.33.0 h1:r+JOocAyeRVXD8lZpjdQjzMadVZp2M4WmQ+5WtEnklQ= +go.opentelemetry.io/otel/metric v1.33.0/go.mod h1:L9+Fyctbp6HFTddIxClbQkjtubW6O9QS3Ann/M82u6M= go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk= go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0= go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc= go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8= -go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= -go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= +go.opentelemetry.io/otel/trace v1.33.0 h1:cCJuF7LRjUFso9LPnEAHJDB2pqzp+hbO8eu1qqW2d/s= +go.opentelemetry.io/otel/trace v1.33.0/go.mod h1:uIcdVUZMpTAmz0tI1z04GoVSezK37CbGV4fr1f2nBck= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= From 9432d4322faa48f2421c479bc861b03e825006d7 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Mon, 16 Dec 2024 16:19:20 +0100 Subject: [PATCH 229/305] fix: update storage image v1.14.5 (#2976) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 44b61997e..318052679 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -17,7 +17,7 @@ const ( supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.164.0" realtimeImage = "supabase/realtime:v2.33.58" - storageImage = "supabase/storage-api:v1.11.13" + storageImage = "supabase/storage-api:v1.14.5" logflareImage = "supabase/logflare:1.4.0" // Append to JobImages when adding new dependencies below DifferImage = "supabase/pgadmin-schema-diff:cli-0.0.5" From 1d230cc6b2a81027edb5edc8d58a552a54f8e09a Mon Sep 17 00:00:00 2001 From: avallete Date: Wed, 18 Dec 2024 11:13:56 +0900 Subject: [PATCH 230/305] fix: test --- internal/start/start_test.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/internal/start/start_test.go b/internal/start/start_test.go index b61cb9cd4..570d48110 100644 --- a/internal/start/start_test.go +++ b/internal/start/start_test.go @@ -57,7 +57,13 @@ func TestStartCommand(t *testing.T) { assert.Empty(t, apitest.ListUnmatchedRequests()) }) - t.Run("noop if database is already running", func(t *testing.T) { + t.Run("show status if database is already running", func(t *testing.T) { + var running []types.Container + for _, name := range utils.GetDockerIds() { + running = append(running, types.Container{ + Names: []string{name + "_test"}, + }) + } // Setup in-memory fs fsys := afero.NewMemMapFs() require.NoError(t, utils.WriteConfig(fsys, false)) @@ -68,6 +74,17 @@ func TestStartCommand(t *testing.T) { Get("/v" + utils.Docker.ClientVersion() + "/containers"). Reply(http.StatusOK). JSON(types.ContainerJSON{}) + + gock.New(utils.Docker.DaemonHost()). + Get("/v" + utils.Docker.ClientVersion() + "/containers/supabase_db_test/json"). + Reply(http.StatusOK). + JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ + State: &types.ContainerState{Running: true}, + }}) + gock.New(utils.Docker.DaemonHost()). + Get("/v" + utils.Docker.ClientVersion() + "/containers/json"). + Reply(http.StatusOK). + JSON(running) // Run test err := Run(context.Background(), fsys, []string{}, false) // Check error From b0f139950ff0961fca603aa254ba501def76c338 Mon Sep 17 00:00:00 2001 From: avallete Date: Wed, 18 Dec 2024 11:35:13 +0900 Subject: [PATCH 231/305] Revert "fix: test" This reverts commit 1d230cc6b2a81027edb5edc8d58a552a54f8e09a. --- internal/start/start_test.go | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/internal/start/start_test.go b/internal/start/start_test.go index 570d48110..b61cb9cd4 100644 --- a/internal/start/start_test.go +++ b/internal/start/start_test.go @@ -57,13 +57,7 @@ func TestStartCommand(t *testing.T) { assert.Empty(t, apitest.ListUnmatchedRequests()) }) - t.Run("show status if database is already running", func(t *testing.T) { - var running []types.Container - for _, name := range utils.GetDockerIds() { - running = append(running, types.Container{ - Names: []string{name + "_test"}, - }) - } + t.Run("noop if database is already running", func(t *testing.T) { // Setup in-memory fs fsys := afero.NewMemMapFs() require.NoError(t, utils.WriteConfig(fsys, false)) @@ -74,17 +68,6 @@ func TestStartCommand(t *testing.T) { Get("/v" + utils.Docker.ClientVersion() + "/containers"). Reply(http.StatusOK). JSON(types.ContainerJSON{}) - - gock.New(utils.Docker.DaemonHost()). - Get("/v" + utils.Docker.ClientVersion() + "/containers/supabase_db_test/json"). - Reply(http.StatusOK). - JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ - State: &types.ContainerState{Running: true}, - }}) - gock.New(utils.Docker.DaemonHost()). - Get("/v" + utils.Docker.ClientVersion() + "/containers/json"). - Reply(http.StatusOK). - JSON(running) // Run test err := Run(context.Background(), fsys, []string{}, false) // Check error From 6fd230ee43620d5bcad2011e257ab24a93ab3671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Caba=C3=A7o?= Date: Wed, 18 Dec 2024 14:21:49 +0000 Subject: [PATCH 232/305] fix: bump realtime image to 2.33.70 (#2982) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 318052679..67a09325f 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -16,7 +16,7 @@ const ( vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.164.0" - realtimeImage = "supabase/realtime:v2.33.58" + realtimeImage = "supabase/realtime:v2.33.70" storageImage = "supabase/storage-api:v1.14.5" logflareImage = "supabase/logflare:1.4.0" // Append to JobImages when adding new dependencies below From e22867205e730c7c7193707abfbfb11bcc4859e7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 04:40:56 +0000 Subject: [PATCH 233/305] chore(deps): bump github.com/docker/docker from 27.4.0+incompatible to 27.4.1+incompatible (#2987) chore(deps): bump github.com/docker/docker Bumps [github.com/docker/docker](https://github.com/docker/docker) from 27.4.0+incompatible to 27.4.1+incompatible. - [Release notes](https://github.com/docker/docker/releases) - [Commits](https://github.com/docker/docker/compare/v27.4.0...v27.4.1) --- updated-dependencies: - dependency-name: github.com/docker/docker dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 09f10d325..25c0c3a02 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/containers/common v0.61.0 github.com/deepmap/oapi-codegen/v2 v2.2.0 github.com/docker/cli v27.4.0+incompatible - github.com/docker/docker v27.4.0+incompatible + github.com/docker/docker v27.4.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 github.com/getsentry/sentry-go v0.30.0 diff --git a/go.sum b/go.sum index 804a4c0fd..4739c2dae 100644 --- a/go.sum +++ b/go.sum @@ -231,8 +231,8 @@ github.com/docker/cli v27.4.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvM github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v27.4.0+incompatible h1:I9z7sQ5qyzO0BfAb9IMOawRkAGxhYsidKiTMcm0DU+A= -github.com/docker/docker v27.4.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.4.1+incompatible h1:ZJvcY7gfwHn1JF48PfbyXg7Jyt9ZCWDW+GGXOIxEwp4= +github.com/docker/docker v27.4.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo= github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0= From dbcb1a8122b3e4320352e874f8fc6237107c5522 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 04:45:46 +0000 Subject: [PATCH 234/305] chore(deps): bump google.golang.org/grpc from 1.69.0 to 1.69.2 (#2986) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.69.0 to 1.69.2. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.69.0...v1.69.2) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 25c0c3a02..f00de0434 100644 --- a/go.mod +++ b/go.mod @@ -50,7 +50,7 @@ require ( golang.org/x/mod v0.22.0 golang.org/x/oauth2 v0.24.0 golang.org/x/term v0.27.0 - google.golang.org/grpc v1.69.0 + google.golang.org/grpc v1.69.2 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.12.0 ) diff --git a/go.sum b/go.sum index 4739c2dae..6022e8b9b 100644 --- a/go.sum +++ b/go.sum @@ -1443,8 +1443,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.69.0 h1:quSiOM1GJPmPH5XtU+BCoVXcDVJJAzNcoyfC2cCjGkI= -google.golang.org/grpc v1.69.0/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= +google.golang.org/grpc v1.69.2 h1:U3S9QEtbXC0bYNvRtcoklF3xGtLViumSYxWykJS+7AU= +google.golang.org/grpc v1.69.2/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From bbdbe3a1b03abbbf5000d3824ab518daf69c0891 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 04:50:29 +0000 Subject: [PATCH 235/305] chore(deps): bump github.com/docker/cli from 27.4.0+incompatible to 27.4.1+incompatible (#2988) chore(deps): bump github.com/docker/cli Bumps [github.com/docker/cli](https://github.com/docker/cli) from 27.4.0+incompatible to 27.4.1+incompatible. - [Commits](https://github.com/docker/cli/compare/v27.4.0...v27.4.1) --- updated-dependencies: - dependency-name: github.com/docker/cli dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f00de0434..886ac3858 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/charmbracelet/lipgloss v0.12.1 github.com/containers/common v0.61.0 github.com/deepmap/oapi-codegen/v2 v2.2.0 - github.com/docker/cli v27.4.0+incompatible + github.com/docker/cli v27.4.1+incompatible github.com/docker/docker v27.4.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 diff --git a/go.sum b/go.sum index 6022e8b9b..3ae3bcc30 100644 --- a/go.sum +++ b/go.sum @@ -226,8 +226,8 @@ github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk= github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE= -github.com/docker/cli v27.4.0+incompatible h1:/nJzWkcI1MDMN+U+px/YXnQWJqnu4J+QKGTfD6ptiTc= -github.com/docker/cli v27.4.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v27.4.1+incompatible h1:VzPiUlRJ/xh+otB75gva3r05isHMo5wXDfPRi5/b4hI= +github.com/docker/cli v27.4.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= From f81c17bbcecaae478e1c19d155dd6fef33f3d08d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Thu, 19 Dec 2024 14:35:45 +0900 Subject: [PATCH 236/305] fix: bump edge-runtime to 1.65.6 (#2985) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 67a09325f..1da92445d 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241202-71e5240" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.65.4" + edgeRuntimeImage = "supabase/edge-runtime:v1.65.6" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.164.0" From f5df11debc796d557f800c45e3a566f995c43f84 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Sun, 22 Dec 2024 01:32:29 +0900 Subject: [PATCH 237/305] fix(db): upgrade pg15 to 15.8.1.020 (#2978) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 1da92445d..a0fdddb8d 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -3,7 +3,7 @@ package config const ( pg13Image = "supabase/postgres:13.3.0" pg14Image = "supabase/postgres:14.1.0.89" - Pg15Image = "supabase/postgres:15.6.1.143" + Pg15Image = "supabase/postgres:15.8.1.020" // Append to ServiceImages when adding new dependencies below // TODO: try https://github.com/axllent/mailpit kongImage = "library/kong:2.8.1" From 3f5da996b9914cec808d059ece8ea8c8ea2d1d1b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 22 Dec 2024 00:32:54 +0800 Subject: [PATCH 238/305] chore(deps): bump golang.org/x/crypto from 0.29.0 to 0.31.0 (#2975) --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 886ac3858..79b137ea1 100644 --- a/go.mod +++ b/go.mod @@ -314,13 +314,13 @@ require ( go.uber.org/automaxprocs v1.6.0 // indirect go.uber.org/multierr v1.9.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.29.0 // indirect + golang.org/x/crypto v0.31.0 // indirect golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect golang.org/x/net v0.31.0 // indirect - golang.org/x/sync v0.9.0 // indirect + golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect - golang.org/x/text v0.20.0 // indirect + golang.org/x/text v0.21.0 // indirect golang.org/x/tools v0.27.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect diff --git a/go.sum b/go.sum index 3ae3bcc30..ed7084110 100644 --- a/go.sum +++ b/go.sum @@ -1063,8 +1063,8 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/crypto v0.29.0 h1:L5SG1JTTXupVV3n6sUqMTeWbjAyfPwoda2DLX8J8FrQ= -golang.org/x/crypto v0.29.0/go.mod h1:+F4F4N5hv6v38hfeYwTdx20oUvLLc+QfrE9Ax9HtgRg= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1187,8 +1187,8 @@ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= -golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1291,8 +1291,8 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug= -golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= From d3acc108e579a573f25fe078d7f961e666946f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Mon, 30 Dec 2024 12:21:27 +0900 Subject: [PATCH 239/305] fix: bump edge-runtime to 1.66.0 (#2997) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index a0fdddb8d..d8ddc3c59 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241202-71e5240" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.65.6" + edgeRuntimeImage = "supabase/edge-runtime:v1.66.0" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.164.0" From 9f6f2717ec0309534c00223e42e8a1b77d6f6c07 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Mon, 30 Dec 2024 12:26:41 +0900 Subject: [PATCH 240/305] feat(start): automatically run the status command if already started (#2980) * feat(start): automatically run the status command if already started Rather than asking the user to run the command to get the values Run the command for him so start command always return the infos of the running stack. * fix: test * fix: test --- internal/start/start.go | 4 ++-- internal/start/start_test.go | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/internal/start/start.go b/internal/start/start.go index f31a950cc..f5a24d8c4 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -42,8 +42,8 @@ func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string, ignore } if err := utils.AssertSupabaseDbIsRunning(); err == nil { fmt.Fprintln(os.Stderr, utils.Aqua("supabase start")+" is already running.") - utils.CmdSuggestion = fmt.Sprintf("Run %s to show status of local Supabase containers.", utils.Aqua("supabase status")) - return nil + names := status.CustomName{} + return status.Run(ctx, names, utils.OutputPretty, fsys) } else if !errors.Is(err, utils.ErrNotRunning) { return err } diff --git a/internal/start/start_test.go b/internal/start/start_test.go index b61cb9cd4..6d07eb364 100644 --- a/internal/start/start_test.go +++ b/internal/start/start_test.go @@ -57,7 +57,13 @@ func TestStartCommand(t *testing.T) { assert.Empty(t, apitest.ListUnmatchedRequests()) }) - t.Run("noop if database is already running", func(t *testing.T) { + t.Run("show status if database is already running", func(t *testing.T) { + var running []types.Container + for _, name := range utils.GetDockerIds() { + running = append(running, types.Container{ + Names: []string{name + "_test"}, + }) + } // Setup in-memory fs fsys := afero.NewMemMapFs() require.NoError(t, utils.WriteConfig(fsys, false)) @@ -68,6 +74,17 @@ func TestStartCommand(t *testing.T) { Get("/v" + utils.Docker.ClientVersion() + "/containers"). Reply(http.StatusOK). JSON(types.ContainerJSON{}) + + gock.New(utils.Docker.DaemonHost()). + Get("/v" + utils.Docker.ClientVersion() + "/containers/supabase_db_start/json"). + Reply(http.StatusOK). + JSON(types.ContainerJSON{ContainerJSONBase: &types.ContainerJSONBase{ + State: &types.ContainerState{Running: true}, + }}) + gock.New(utils.Docker.DaemonHost()). + Get("/v" + utils.Docker.ClientVersion() + "/containers/json"). + Reply(http.StatusOK). + JSON(running) // Run test err := Run(context.Background(), fsys, []string{}, false) // Check error From 8b2496c5e468d10c98e5ebc0ee598cee14df24d7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Dec 2024 04:54:52 +0000 Subject: [PATCH 241/305] chore(deps): bump github.com/go-git/go-git/v5 from 5.12.0 to 5.13.0 (#2999) Bumps [github.com/go-git/go-git/v5](https://github.com/go-git/go-git) from 5.12.0 to 5.13.0. - [Release notes](https://github.com/go-git/go-git/releases) - [Commits](https://github.com/go-git/go-git/compare/v5.12.0...v5.13.0) --- updated-dependencies: - dependency-name: github.com/go-git/go-git/v5 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 8 ++++---- go.sum | 32 ++++++++++++-------------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/go.mod b/go.mod index 79b137ea1..77f62b252 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/docker/go-units v0.5.0 github.com/getsentry/sentry-go v0.30.0 github.com/go-errors/errors v1.5.1 - github.com/go-git/go-git/v5 v5.12.0 + github.com/go-git/go-git/v5 v5.13.0 github.com/go-xmlfmt/xmlfmt v1.1.3 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/golangci/golangci-lint v1.62.2 @@ -72,7 +72,7 @@ require ( github.com/Masterminds/semver/v3 v3.3.0 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/OpenPeeDeeP/depguard/v2 v2.2.0 // indirect - github.com/ProtonMail/go-crypto v1.0.0 // indirect + github.com/ProtonMail/go-crypto v1.1.3 // indirect github.com/alecthomas/chroma/v2 v2.8.0 // indirect github.com/alecthomas/go-check-sumtype v0.2.0 // indirect github.com/alexkohler/nakedret/v2 v2.0.5 // indirect @@ -131,7 +131,7 @@ require ( github.com/ghostiam/protogetter v0.3.8 // indirect github.com/go-critic/go-critic v0.11.5 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.5.0 // indirect + github.com/go-git/go-billy/v5 v5.6.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect @@ -317,7 +317,7 @@ require ( golang.org/x/crypto v0.31.0 // indirect golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect - golang.org/x/net v0.31.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect diff --git a/go.sum b/go.sum index ed7084110..6195b3eac 100644 --- a/go.sum +++ b/go.sum @@ -71,8 +71,8 @@ github.com/Netflix/go-env v0.1.2 h1:0DRoLR9lECQ9Zqvkswuebm3jJ/2enaDX6Ei8/Z+EnK0= github.com/Netflix/go-env v0.1.2/go.mod h1:WlIhYi++8FlKNJtrop1mjXYAJMzv1f43K4MqCoh0yGE= github.com/OpenPeeDeeP/depguard/v2 v2.2.0 h1:vDfG60vDtIuf0MEOhmLlLLSzqaRM8EMcgJPdp74zmpA= github.com/OpenPeeDeeP/depguard/v2 v2.2.0/go.mod h1:CIzddKRvLBC4Au5aYP/i3nyaWQ+ClszLIuVocRiCYFQ= -github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= -github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/ProtonMail/go-crypto v1.1.3 h1:nRBOetoydLeUb4nHajyO2bKqMLfWQ/ZPwkXqXxPxCFk= +github.com/ProtonMail/go-crypto v1.1.3/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d h1:hi6J4K6DKrR4/ljxn6SF6nURyu785wKMuQcjt7H3VCQ= github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= @@ -146,7 +146,6 @@ github.com/butuzov/ireturn v0.3.0 h1:hTjMqWw3y5JC3kpnC5vXmFJAWI/m31jaCYQqzkS6PL0 github.com/butuzov/ireturn v0.3.0/go.mod h1:A09nIiwiqzN/IoVo9ogpa0Hzi9fex1kd9PSD6edP5ZA= github.com/butuzov/mirror v1.2.0 h1:9YVK1qIjNspaqWutSv8gsge2e/Xpq1eqEkslEUHy5cs= github.com/butuzov/mirror v1.2.0/go.mod h1:DqZZDtzm42wIAIyHXeN8W/qb1EPlb9Qn/if9icBOpdQ= -github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/catenacyber/perfsprint v0.7.1 h1:PGW5G/Kxn+YrN04cRAZKC+ZuvlVwolYMrIyyTJ/rMmc= github.com/catenacyber/perfsprint v0.7.1/go.mod h1:/wclWYompEyjUD2FuIIDVKNkqz7IgBIWXIH3V0Zol50= github.com/ccojocar/zxcvbn-go v1.0.2 h1:na/czXU8RrhXO4EZme6eQJLR4PzcGsahsBOAwU6I3Vg= @@ -182,7 +181,6 @@ github.com/ckaznocha/intrange v0.2.1/go.mod h1:7NEhVyf8fzZO5Ds7CRaqPEm52Ut83hsTi github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004 h1:lkAMpLVBDaj17e85keuznYcH5rqI438v41pKcBl4ZxQ= github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON2oQp+43nFtAV/uvKQIFpSPerB57DCt9t8sSA= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU= github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= @@ -248,8 +246,8 @@ github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/dvsekhvalnov/jose2go v0.0.0-20170216131308-f21a8cedbbae/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= -github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= -github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= +github.com/elazarl/goproxy v1.2.1 h1:njjgvO6cRG9rIqN2ebkqy6cQz2Njkx7Fsfv/zIZqgug= +github.com/elazarl/goproxy v1.2.1/go.mod h1:YfEbZtqP4AetfO6d40vWchF3znWX7C7Vd6ZMfdL8z64= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -285,20 +283,20 @@ github.com/getsentry/sentry-go v0.30.0 h1:lWUwDnY7sKHaVIoZ9wYqRHJ5iEmoc0pqcRqFko github.com/getsentry/sentry-go v0.30.0/go.mod h1:WU9B9/1/sHDqeV8T+3VwwbjeR5MSXs/6aqG3mqZrezA= github.com/ghostiam/protogetter v0.3.8 h1:LYcXbYvybUyTIxN2Mj9h6rHrDZBDwZloPoKctWrFyJY= github.com/ghostiam/protogetter v0.3.8/go.mod h1:WZ0nw9pfzsgxuRsPOFQomgDVSWtDLJRfQJEhsGbmQMA= -github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= -github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= +github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c= +github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU= github.com/go-critic/go-critic v0.11.5 h1:TkDTOn5v7EEngMxu8KbuFqFR43USaaH8XRJLz1jhVYA= github.com/go-critic/go-critic v0.11.5/go.mod h1:wu6U7ny9PiaHaZHcvMDmdysMqvDem162Rh3zWTrqk8M= github.com/go-errors/errors v1.5.1 h1:ZwEMSLRCapFLflTpT7NKaAc7ukJ8ZPEjzlxt8rPN8bk= github.com/go-errors/errors v1.5.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= -github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-billy/v5 v5.6.0 h1:w2hPNtoehvJIxR00Vb4xX94qHQi/ApZfX+nBE2Cjio8= +github.com/go-git/go-billy/v5 v5.6.0/go.mod h1:sFDq7xD3fn3E0GOwUSZqHo9lrkmx8xJhA0ZrfvjBRGM= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= -github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= -github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= +github.com/go-git/go-git/v5 v5.13.0 h1:vLn5wlGIh/X78El6r3Jr+30W16Blk0CTcxTYcYPWi5E= +github.com/go-git/go-git/v5 v5.13.0/go.mod h1:Wjo7/JyVKtQgUNdXYXIepzWfJQkUEIGvkvVkiXRR/zw= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -1056,8 +1054,6 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= -golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= @@ -1156,14 +1152,13 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/net v0.31.0 h1:68CPQngjLL0r2AlUKiSxtQFKvzRVbnzLwMUn5SzcLHo= -golang.org/x/net v0.31.0/go.mod h1:P4fl1q7dY2hnZFxEk4pPSkDHF+QqjitcnDjUQyMM+pM= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1247,7 +1242,6 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1267,7 +1261,6 @@ golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= @@ -1286,7 +1279,6 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= From 034a31c9a2d102a4e47852c85a677988b2932d57 Mon Sep 17 00:00:00 2001 From: Nyannyacha Date: Tue, 31 Dec 2024 06:45:23 +0900 Subject: [PATCH 242/305] fix: bump edge-runtime to 1.66.1 --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index d8ddc3c59..200c16da8 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241202-71e5240" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.66.0" + edgeRuntimeImage = "supabase/edge-runtime:v1.66.1" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.164.0" From 7a513e346ab55ad2e3a90a8675445121b66c3761 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 1 Jan 2025 21:10:01 +0800 Subject: [PATCH 243/305] fix: resolve file paths in remote config (#3002) * Update config.go * Update config.go * Update config.go * Update config.go * Update config.go * Update config.go * Update config.go --- pkg/config/config.go | 85 +++++++++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 37 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 5c7fc0946..6903b6b24 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -492,6 +492,53 @@ func (c *config) Load(path string, fsys fs.FS) error { if version, err := fs.ReadFile(fsys, builder.PgmetaVersionPath); err == nil && len(version) > 0 { c.Studio.PgmetaImage = replaceImageTag(pgmetaImage, string(version)) } + // Resolve remote config, then base config + idToName := map[string]string{} + c.Remotes = make(map[string]baseConfig, len(c.Overrides)) + for name, remote := range c.Overrides { + base := c.baseConfig.Clone() + // On remotes branches set seed as disabled by default + base.Db.Seed.Enabled = false + // Encode a toml file with only config overrides + var buf bytes.Buffer + if err := toml.NewEncoder(&buf).Encode(remote); err != nil { + return errors.Errorf("failed to encode map to TOML: %w", err) + } + // Decode overrides using base config as defaults + if metadata, err := toml.NewDecoder(&buf).Decode(&base); err != nil { + return errors.Errorf("failed to decode remote config: %w", err) + } else if undecoded := metadata.Undecoded(); len(undecoded) > 0 { + fmt.Fprintf(os.Stderr, "WARN: unknown config fields: %+v\n", undecoded) + } + // Cross validate remote project id + if base.ProjectId == c.baseConfig.ProjectId { + fmt.Fprintf(os.Stderr, "WARN: project_id is missing for [remotes.%s]\n", name) + } else if other, exists := idToName[base.ProjectId]; exists { + return errors.Errorf("duplicate project_id for [remotes.%s] and [remotes.%s]", other, name) + } else { + idToName[base.ProjectId] = name + } + if err := base.resolve(builder, fsys); err != nil { + return err + } + c.Remotes[name] = base + } + if err := c.baseConfig.resolve(builder, fsys); err != nil { + return err + } + // Validate base config, then remote config + if err := c.baseConfig.Validate(fsys); err != nil { + return err + } + for name, base := range c.Remotes { + if err := base.Validate(fsys); err != nil { + return errors.Errorf("invalid config for [remotes.%s]: %w", name, err) + } + } + return nil +} + +func (c *baseConfig) resolve(builder pathBuilder, fsys fs.FS) error { // Update content paths for name, tmpl := range c.Auth.Email.Template { // FIXME: only email template is relative to repo directory @@ -534,43 +581,7 @@ func (c *config) Load(path string, fsys fs.FS) error { } c.Functions[slug] = function } - if err := c.Db.Seed.loadSeedPaths(builder.SupabaseDirPath, fsys); err != nil { - return err - } - if err := c.baseConfig.Validate(fsys); err != nil { - return err - } - idToName := map[string]string{} - c.Remotes = make(map[string]baseConfig, len(c.Overrides)) - for name, remote := range c.Overrides { - base := c.baseConfig.Clone() - // On remotes branches set seed as disabled by default - base.Db.Seed.Enabled = false - // Encode a toml file with only config overrides - var buf bytes.Buffer - if err := toml.NewEncoder(&buf).Encode(remote); err != nil { - return errors.Errorf("failed to encode map to TOML: %w", err) - } - // Decode overrides using base config as defaults - if metadata, err := toml.NewDecoder(&buf).Decode(&base); err != nil { - return errors.Errorf("failed to decode remote config: %w", err) - } else if undecoded := metadata.Undecoded(); len(undecoded) > 0 { - fmt.Fprintf(os.Stderr, "WARN: unknown config fields: %+v\n", undecoded) - } - // Cross validate remote project id - if base.ProjectId == c.baseConfig.ProjectId { - fmt.Fprintf(os.Stderr, "WARN: project_id is missing for [remotes.%s]\n", name) - } else if other, exists := idToName[base.ProjectId]; exists { - return errors.Errorf("duplicate project_id for [remotes.%s] and [remotes.%s]", other, name) - } else { - idToName[base.ProjectId] = name - } - if err := base.Validate(fsys); err != nil { - return errors.Errorf("invalid config for [remotes.%s]: %w", name, err) - } - c.Remotes[name] = base - } - return nil + return c.Db.Seed.loadSeedPaths(builder.SupabaseDirPath, fsys) } func (c *baseConfig) Validate(fsys fs.FS) error { From d412bc065811ec6a61951063203b82b7fa73cafc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Jan 2025 04:09:20 +0000 Subject: [PATCH 244/305] chore(deps): bump github.com/golangci/golangci-lint from 1.62.2 to 1.63.1 (#3004) chore(deps): bump github.com/golangci/golangci-lint Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.62.2 to 1.63.1. - [Release notes](https://github.com/golangci/golangci-lint/releases) - [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md) - [Commits](https://github.com/golangci/golangci-lint/compare/v1.62.2...v1.63.1) --- updated-dependencies: - dependency-name: github.com/golangci/golangci-lint dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 69 +++++++++++++----------- go.sum | 167 ++++++++++++++++++++++++++++++++------------------------- 2 files changed, 130 insertions(+), 106 deletions(-) diff --git a/go.mod b/go.mod index 77f62b252..89f024e3c 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/go-git/go-git/v5 v5.13.0 github.com/go-xmlfmt/xmlfmt v1.1.3 github.com/golang-jwt/jwt/v5 v5.2.1 - github.com/golangci/golangci-lint v1.62.2 + github.com/golangci/golangci-lint v1.63.1 github.com/google/go-github/v62 v62.0.0 github.com/google/go-querystring v1.1.0 github.com/google/uuid v1.6.0 @@ -60,10 +60,10 @@ require ( 4d63.com/gochecknoglobals v0.2.1 // indirect al.essio.dev/pkg/shellescape v1.5.1 // indirect dario.cat/mergo v1.0.1 // indirect - github.com/4meepo/tagalign v1.3.4 // indirect + github.com/4meepo/tagalign v1.4.1 // indirect github.com/Abirdcfly/dupword v0.1.3 // indirect github.com/Antonboom/errname v1.0.0 // indirect - github.com/Antonboom/nilnil v1.0.0 // indirect + github.com/Antonboom/nilnil v1.0.1 // indirect github.com/Antonboom/testifylint v1.5.2 // indirect github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/Crocmagnon/fatcontext v0.5.3 // indirect @@ -74,13 +74,14 @@ require ( github.com/OpenPeeDeeP/depguard/v2 v2.2.0 // indirect github.com/ProtonMail/go-crypto v1.1.3 // indirect github.com/alecthomas/chroma/v2 v2.8.0 // indirect - github.com/alecthomas/go-check-sumtype v0.2.0 // indirect + github.com/alecthomas/go-check-sumtype v0.3.1 // indirect github.com/alexkohler/nakedret/v2 v2.0.5 // indirect github.com/alexkohler/prealloc v1.0.0 // indirect github.com/alingse/asasalint v0.0.11 // indirect + github.com/alingse/nilnesserr v0.1.1 // indirect github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect github.com/ashanbrown/forbidigo v1.6.0 // indirect - github.com/ashanbrown/makezero v1.1.1 // indirect + github.com/ashanbrown/makezero v1.2.0 // indirect github.com/atotto/clipboard v0.1.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/aymerick/douceur v0.2.0 // indirect @@ -88,11 +89,11 @@ require ( github.com/bitfield/gotestdox v0.2.2 // indirect github.com/bkielbasa/cyclop v1.2.3 // indirect github.com/blizzy78/varnamelen v0.8.0 // indirect - github.com/bombsimon/wsl/v4 v4.4.1 // indirect + github.com/bombsimon/wsl/v4 v4.5.0 // indirect github.com/breml/bidichk v0.3.2 // indirect github.com/breml/errchkjson v0.4.0 // indirect - github.com/butuzov/ireturn v0.3.0 // indirect - github.com/butuzov/mirror v1.2.0 // indirect + github.com/butuzov/ireturn v0.3.1 // indirect + github.com/butuzov/mirror v1.3.0 // indirect github.com/catenacyber/perfsprint v0.7.1 // indirect github.com/ccojocar/zxcvbn-go v1.0.2 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect @@ -100,19 +101,19 @@ require ( github.com/charmbracelet/harmonica v0.2.0 // indirect github.com/charmbracelet/x/ansi v0.1.4 // indirect github.com/chavacava/garif v0.1.0 // indirect - github.com/ckaznocha/intrange v0.2.1 // indirect + github.com/ckaznocha/intrange v0.3.0 // indirect github.com/cloudflare/circl v1.3.7 // indirect github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect github.com/containerd/log v0.1.0 // indirect github.com/containers/storage v1.56.0 // indirect - github.com/curioswitch/go-reassign v0.2.0 // indirect + github.com/curioswitch/go-reassign v0.3.0 // indirect github.com/cyphar/filepath-securejoin v0.3.4 // indirect github.com/daixiang0/gci v0.13.5 // indirect github.com/danieljoos/wincred v1.2.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/denis-tingaikin/go-header v0.5.0 // indirect github.com/distribution/reference v0.6.0 // indirect - github.com/dlclark/regexp2 v1.4.0 // indirect + github.com/dlclark/regexp2 v1.11.0 // indirect github.com/dnephin/pflag v1.0.7 // indirect github.com/docker/distribution v2.8.3+incompatible // indirect github.com/docker/docker-credential-helpers v0.8.2 // indirect @@ -152,9 +153,8 @@ require ( github.com/golang/protobuf v1.5.4 // indirect github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect github.com/golangci/go-printf-func-name v0.1.0 // indirect - github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9 // indirect + github.com/golangci/gofmt v0.0.0-20241223200906-057b0627d9b9 // indirect github.com/golangci/misspell v0.6.0 // indirect - github.com/golangci/modinfo v0.3.4 // indirect github.com/golangci/plugin-module-register v0.1.1 // indirect github.com/golangci/revgrep v0.5.3 // indirect github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect @@ -170,7 +170,9 @@ require ( github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 // indirect + github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hexops/gotextdiff v1.0.3 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -182,9 +184,9 @@ require ( github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jgautheron/goconst v1.7.1 // indirect github.com/jingyugao/rowserrcheck v1.1.1 // indirect - github.com/jjti/go-spancheck v0.6.2 // indirect + github.com/jjti/go-spancheck v0.6.4 // indirect github.com/josharian/intern v1.0.0 // indirect - github.com/julz/importas v0.1.0 // indirect + github.com/julz/importas v0.2.0 // indirect github.com/karamaru-alpha/copyloopvar v1.1.0 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/kisielk/errcheck v1.8.0 // indirect @@ -195,8 +197,11 @@ require ( github.com/kunwardeep/paralleltest v1.0.10 // indirect github.com/kyoh86/exportloopref v0.1.11 // indirect github.com/lasiar/canonicalheader v1.1.2 // indirect - github.com/ldez/gomoddirectives v0.2.4 // indirect - github.com/ldez/tagliatelle v0.5.0 // indirect + github.com/ldez/exptostd v0.3.0 // indirect + github.com/ldez/gomoddirectives v0.6.0 // indirect + github.com/ldez/grignotin v0.7.0 // indirect + github.com/ldez/tagliatelle v0.7.1 // indirect + github.com/ldez/usetesting v0.4.1 // indirect github.com/leonklingele/grouper v1.1.2 // indirect github.com/lib/pq v1.10.9 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect @@ -228,7 +233,7 @@ require ( github.com/nakabonne/nestif v0.3.1 // indirect github.com/nishanths/exhaustive v0.12.0 // indirect github.com/nishanths/predeclared v0.2.2 // indirect - github.com/nunnatsa/ginkgolinter v0.18.3 // indirect + github.com/nunnatsa/ginkgolinter v0.18.4 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect @@ -247,7 +252,7 @@ require ( github.com/quasilyte/gogrep v0.5.0 // indirect github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect - github.com/raeperd/recvcheck v0.1.2 // indirect + github.com/raeperd/recvcheck v0.2.0 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/rogpeppe/go-internal v1.13.1 // indirect github.com/ryancurrah/gomodguard v1.3.5 // indirect @@ -255,10 +260,10 @@ require ( github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f // indirect - github.com/sanposhiho/wastedassign/v2 v2.0.7 // indirect - github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect + github.com/sanposhiho/wastedassign/v2 v2.1.0 // indirect + github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect github.com/sashamelentyev/interfacebloat v1.1.0 // indirect - github.com/sashamelentyev/usestdlibvars v1.27.0 // indirect + github.com/sashamelentyev/usestdlibvars v1.28.0 // indirect github.com/securego/gosec/v2 v2.21.4 // indirect github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect @@ -271,21 +276,21 @@ require ( github.com/sourcegraph/go-diff v0.7.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect - github.com/stbenjam/no-sprintf-host-port v0.1.1 // indirect + github.com/stbenjam/no-sprintf-host-port v0.2.0 // indirect github.com/stretchr/objx v0.5.2 // indirect github.com/subosito/gotenv v1.6.0 // indirect - github.com/tdakkota/asciicheck v0.2.0 // indirect - github.com/tetafro/godot v1.4.18 // indirect + github.com/tdakkota/asciicheck v0.3.0 // indirect + github.com/tetafro/godot v1.4.20 // indirect github.com/theupdateframework/notary v0.7.0 // indirect - github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 // indirect + github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 // indirect github.com/timonwong/loggercheck v0.10.1 // indirect - github.com/tomarrell/wrapcheck/v2 v2.9.0 // indirect + github.com/tomarrell/wrapcheck/v2 v2.10.0 // indirect github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect - github.com/ultraware/funlen v0.1.0 // indirect - github.com/ultraware/whitespace v0.1.1 // indirect - github.com/uudashr/gocognit v1.1.3 // indirect - github.com/uudashr/iface v1.2.1 // indirect + github.com/ultraware/funlen v0.2.0 // indirect + github.com/ultraware/whitespace v0.2.0 // indirect + github.com/uudashr/gocognit v1.2.0 // indirect + github.com/uudashr/iface v1.3.0 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect @@ -321,7 +326,7 @@ require ( golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect - golang.org/x/tools v0.27.0 // indirect + golang.org/x/tools v0.28.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect google.golang.org/protobuf v1.35.1 // indirect diff --git a/go.sum b/go.sum index 6195b3eac..d71db5ed3 100644 --- a/go.sum +++ b/go.sum @@ -39,14 +39,14 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/4meepo/tagalign v1.3.4 h1:P51VcvBnf04YkHzjfclN6BbsopfJR5rxs1n+5zHt+w8= -github.com/4meepo/tagalign v1.3.4/go.mod h1:M+pnkHH2vG8+qhE5bVc/zeP7HS/j910Fwa9TUSyZVI0= +github.com/4meepo/tagalign v1.4.1 h1:GYTu2FaPGOGb/xJalcqHeD4il5BiCywyEYZOA55P6J4= +github.com/4meepo/tagalign v1.4.1/go.mod h1:2H9Yu6sZ67hmuraFgfZkNcg5Py9Ch/Om9l2K/2W1qS4= github.com/Abirdcfly/dupword v0.1.3 h1:9Pa1NuAsZvpFPi9Pqkd93I7LIYRURj+A//dFd5tgBeE= github.com/Abirdcfly/dupword v0.1.3/go.mod h1:8VbB2t7e10KRNdwTVoxdBaxla6avbhGzb8sCTygUMhw= github.com/Antonboom/errname v1.0.0 h1:oJOOWR07vS1kRusl6YRSlat7HFnb3mSfMl6sDMRoTBA= github.com/Antonboom/errname v1.0.0/go.mod h1:gMOBFzK/vrTiXN9Oh+HFs+e6Ndl0eTFbtsRTSRdXyGI= -github.com/Antonboom/nilnil v1.0.0 h1:n+v+B12dsE5tbAqRODXmEKfZv9j2KcTBrp+LkoM4HZk= -github.com/Antonboom/nilnil v1.0.0/go.mod h1:fDJ1FSFoLN6yoG65ANb1WihItf6qt9PJVTn/s2IrcII= +github.com/Antonboom/nilnil v1.0.1 h1:C3Tkm0KUxgfO4Duk3PM+ztPncTFlOf0b2qadmS0s4xs= +github.com/Antonboom/nilnil v1.0.1/go.mod h1:CH7pW2JsRNFgEh8B2UaPZTEPhCMuFowP/e8Udp9Nnb0= github.com/Antonboom/testifylint v1.5.2 h1:4s3Xhuv5AvdIgbd8wOOEeo0uZG7PbDKQyKY5lGoQazk= github.com/Antonboom/testifylint v1.5.2/go.mod h1:vxy8VJ0bc6NavlYqjZfmp6EfqXMtBgQ4+mhCojwC1P8= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= @@ -76,14 +76,14 @@ github.com/ProtonMail/go-crypto v1.1.3/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQA github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d h1:hi6J4K6DKrR4/ljxn6SF6nURyu785wKMuQcjt7H3VCQ= github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= -github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk= -github.com/alecthomas/assert/v2 v2.2.2/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= +github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0= +github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k= github.com/alecthomas/chroma/v2 v2.8.0 h1:w9WJUjFFmHHB2e8mRpL9jjy3alYDlU0QLDezj1xE264= github.com/alecthomas/chroma/v2 v2.8.0/go.mod h1:yrkMI9807G1ROx13fhe1v6PN2DDeaR73L3d+1nmYQtw= -github.com/alecthomas/go-check-sumtype v0.2.0 h1:Bo+e4DFf3rs7ME9w/0SU/g6nmzJaphduP8Cjiz0gbwY= -github.com/alecthomas/go-check-sumtype v0.2.0/go.mod h1:WyYPfhfkdhyrdaligV6svFopZV8Lqdzn5pyVBaV6jhQ= -github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk= -github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= +github.com/alecthomas/go-check-sumtype v0.3.1 h1:u9aUvbGINJxLVXiFvHUlPEaD7VDULsrxJb4Aq31NLkU= +github.com/alecthomas/go-check-sumtype v0.3.1/go.mod h1:A8TSiN3UPRw3laIgWEUOHHLPa6/r9MtoigdlP5h3K/E= +github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc= +github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -95,6 +95,8 @@ github.com/alexkohler/prealloc v1.0.0 h1:Hbq0/3fJPQhNkN0dR95AVrr6R7tou91y0uHG5pO github.com/alexkohler/prealloc v1.0.0/go.mod h1:VetnK3dIgFBBKmg0YnD9F9x6Icjd+9cvfHR56wJVlKE= github.com/alingse/asasalint v0.0.11 h1:SFwnQXJ49Kx/1GghOFz1XGqHYKp21Kq1nHad/0WQRnw= github.com/alingse/asasalint v0.0.11/go.mod h1:nCaoMhw7a9kSJObvQyVzNTPBDbNpdocqrSP7t/cW5+I= +github.com/alingse/nilnesserr v0.1.1 h1:7cYuJewpy9jFNMEA72Q1+3Nm3zKHzg+Q28D5f2bBFUA= +github.com/alingse/nilnesserr v0.1.1/go.mod h1:1xJPrXonEtX7wyTq8Dytns5P2hNzoWymVUIaKm4HNFg= github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8= @@ -105,8 +107,8 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/ashanbrown/forbidigo v1.6.0 h1:D3aewfM37Yb3pxHujIPSpTf6oQk9sc9WZi8gerOIVIY= github.com/ashanbrown/forbidigo v1.6.0/go.mod h1:Y8j9jy9ZYAEHXdu723cUlraTqbzjKF1MUyfOKL+AjcU= -github.com/ashanbrown/makezero v1.1.1 h1:iCQ87C0V0vSyO+M9E/FZYbu65auqH0lnsOkf5FcB28s= -github.com/ashanbrown/makezero v1.1.1/go.mod h1:i1bJLCRSCHOcOa9Y6MyF2FTfMZMFdHvxKHxgO5Z1axI= +github.com/ashanbrown/makezero v1.2.0 h1:/2Lp1bypdmK9wDIq7uWBlDF1iMUpIIS4A+pF6C9IEUU= +github.com/ashanbrown/makezero v1.2.0/go.mod h1:dxlPhHbDMC6N6xICzFBSK+4njQDdK8euNO0qjQMtGY4= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k= @@ -130,8 +132,8 @@ github.com/blizzy78/varnamelen v0.8.0 h1:oqSblyuQvFsW1hbBHh1zfwrKe3kcSj0rnXkKzsQ github.com/blizzy78/varnamelen v0.8.0/go.mod h1:V9TzQZ4fLJ1DSrjVDfl89H7aMnTvKkApdHeyESmyR7k= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= -github.com/bombsimon/wsl/v4 v4.4.1 h1:jfUaCkN+aUpobrMO24zwyAMwMAV5eSziCkOKEauOLdw= -github.com/bombsimon/wsl/v4 v4.4.1/go.mod h1:Xu/kDxGZTofQcDGCtQe9KCzhHphIe0fDuyWTxER9Feo= +github.com/bombsimon/wsl/v4 v4.5.0 h1:iZRsEvDdyhd2La0FVi5k6tYehpOR/R7qIUjmKk7N74A= +github.com/bombsimon/wsl/v4 v4.5.0/go.mod h1:NOQ3aLF4nD7N5YPXMruR6ZXDOAqLoM0GEpLwTdvmOSc= github.com/breml/bidichk v0.3.2 h1:xV4flJ9V5xWTqxL+/PMFF6dtJPvZLPsyixAoPe8BGJs= github.com/breml/bidichk v0.3.2/go.mod h1:VzFLBxuYtT23z5+iVkamXO386OB+/sVwZOpIj6zXGos= github.com/breml/errchkjson v0.4.0 h1:gftf6uWZMtIa/Is3XJgibewBm2ksAQSY/kABDNFTAdk= @@ -142,10 +144,10 @@ github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b h1:otBG+dV+YK+Soembj github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50= github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXer/kZD8Ri1aaunCxIEsOst1BVJswV0o= github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= -github.com/butuzov/ireturn v0.3.0 h1:hTjMqWw3y5JC3kpnC5vXmFJAWI/m31jaCYQqzkS6PL0= -github.com/butuzov/ireturn v0.3.0/go.mod h1:A09nIiwiqzN/IoVo9ogpa0Hzi9fex1kd9PSD6edP5ZA= -github.com/butuzov/mirror v1.2.0 h1:9YVK1qIjNspaqWutSv8gsge2e/Xpq1eqEkslEUHy5cs= -github.com/butuzov/mirror v1.2.0/go.mod h1:DqZZDtzm42wIAIyHXeN8W/qb1EPlb9Qn/if9icBOpdQ= +github.com/butuzov/ireturn v0.3.1 h1:mFgbEI6m+9W8oP/oDdfA34dLisRFCj2G6o/yiI1yZrY= +github.com/butuzov/ireturn v0.3.1/go.mod h1:ZfRp+E7eJLC0NQmk1Nrm1LOrn/gQlOykv+cVPdiXH5M= +github.com/butuzov/mirror v1.3.0 h1:HdWCXzmwlQHdVhwvsfBb2Au0r3HyINry3bDWLYXiKoc= +github.com/butuzov/mirror v1.3.0/go.mod h1:AEij0Z8YMALaq4yQj9CPPVYOyJQyiexpQEQgihajRfI= github.com/catenacyber/perfsprint v0.7.1 h1:PGW5G/Kxn+YrN04cRAZKC+ZuvlVwolYMrIyyTJ/rMmc= github.com/catenacyber/perfsprint v0.7.1/go.mod h1:/wclWYompEyjUD2FuIIDVKNkqz7IgBIWXIH3V0Zol50= github.com/ccojocar/zxcvbn-go v1.0.2 h1:na/czXU8RrhXO4EZme6eQJLR4PzcGsahsBOAwU6I3Vg= @@ -176,8 +178,8 @@ github.com/chavacava/garif v0.1.0/go.mod h1:XMyYCkEL58DF0oyW4qDjjnPWONs2HBqYKI+U github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/ckaznocha/intrange v0.2.1 h1:M07spnNEQoALOJhwrImSrJLaxwuiQK+hA2DeajBlwYk= -github.com/ckaznocha/intrange v0.2.1/go.mod h1:7NEhVyf8fzZO5Ds7CRaqPEm52Ut83hsTiL5zbER/HYk= +github.com/ckaznocha/intrange v0.3.0 h1:VqnxtK32pxgkhJgYQEeOArVidIPg+ahLP7WBOXZd5ZY= +github.com/ckaznocha/intrange v0.3.0/go.mod h1:+I/o2d2A1FBHgGELbGxzIcyd3/9l9DuwjM8FsbSS3Lo= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004 h1:lkAMpLVBDaj17e85keuznYcH5rqI438v41pKcBl4ZxQ= github.com/cloudflare/cfssl v0.0.0-20180223231731-4e2dcbde5004/go.mod h1:yMWuSON2oQp+43nFtAV/uvKQIFpSPerB57DCt9t8sSA= @@ -201,8 +203,8 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= -github.com/curioswitch/go-reassign v0.2.0 h1:G9UZyOcpk/d7Gd6mqYgd8XYWFMw/znxwGDUstnC9DIo= -github.com/curioswitch/go-reassign v0.2.0/go.mod h1:x6OpXuWvgfQaMGks2BZybTngWjT84hqJfKoO8Tt/Roc= +github.com/curioswitch/go-reassign v0.3.0 h1:dh3kpQHuADL3cobV/sSGETA8DOv457dwl+fbBAhrQPs= +github.com/curioswitch/go-reassign v0.3.0/go.mod h1:nApPCCTtqLJN/s8HfItCcKV0jIPwluBOvZP+dsJGA88= github.com/cyphar/filepath-securejoin v0.3.4 h1:VBWugsJh2ZxJmLFSM06/0qzQyiQX2Qs0ViKrUAcqdZ8= github.com/cyphar/filepath-securejoin v0.3.4/go.mod h1:8s/MCNJREmFK0H02MF6Ihv1nakJe4L/w3WZLHNkvlYM= github.com/daixiang0/gci v0.13.5 h1:kThgmH1yBmZSBCh1EJVxQ7JsHpm5Oms0AMed/0LaH4c= @@ -220,8 +222,8 @@ github.com/denis-tingaikin/go-header v0.5.0/go.mod h1:mMenU5bWrok6Wl2UsZjy+1okeg github.com/denisenkom/go-mssqldb v0.0.0-20191128021309-1d7a30a10f73/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E= -github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI= +github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk= github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE= github.com/docker/cli v27.4.1+incompatible h1:VzPiUlRJ/xh+otB75gva3r05isHMo5wXDfPRi5/b4hI= @@ -399,14 +401,12 @@ github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a h1:w8hkcTqaFpzKqonE9 github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk= github.com/golangci/go-printf-func-name v0.1.0 h1:dVokQP+NMTO7jwO4bwsRwLWeudOVUPPyAKJuzv8pEJU= github.com/golangci/go-printf-func-name v0.1.0/go.mod h1:wqhWFH5mUdJQhweRnldEywnR5021wTdZSNgwYceV14s= -github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9 h1:/1322Qns6BtQxUZDTAT4SdcoxknUki7IAoK4SAXr8ME= -github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9/go.mod h1:Oesb/0uFAyWoaw1U1qS5zyjCg5NP9C9iwjnI4tIsXEE= -github.com/golangci/golangci-lint v1.62.2 h1:b8K5K9PN+rZN1+mKLtsZHz2XXS9aYKzQ9i25x3Qnxxw= -github.com/golangci/golangci-lint v1.62.2/go.mod h1:ILWWyeFUrctpHVGMa1dg2xZPKoMUTc5OIMgW7HZr34g= +github.com/golangci/gofmt v0.0.0-20241223200906-057b0627d9b9 h1:t5wybL6RtO83VwoMOb7U/Peqe3gGKQlPIC66wXmnkvM= +github.com/golangci/gofmt v0.0.0-20241223200906-057b0627d9b9/go.mod h1:Ag3L7sh7E28qAp/5xnpMMTuGYqxLZoSaEHZDkZB1RgU= +github.com/golangci/golangci-lint v1.63.1 h1:fr7zu2W0qexDkTvYwtdrsYJwYIx+tS09ujM1CIjIpCQ= +github.com/golangci/golangci-lint v1.63.1/go.mod h1:O2+mo4qsJuG4cSXBzLbEV+5NAtntoNIbAv428zaEY/s= github.com/golangci/misspell v0.6.0 h1:JCle2HUTNWirNlDIAUO44hUsKhOFqGPoC4LZxlaSXDs= github.com/golangci/misspell v0.6.0/go.mod h1:keMNyY6R9isGaSAu+4Q8NMBwMPkh15Gtc8UCVoDtAWo= -github.com/golangci/modinfo v0.3.4 h1:oU5huX3fbxqQXdfspamej74DFX0kyGLkw1ppvXoJ8GA= -github.com/golangci/modinfo v0.3.4/go.mod h1:wytF1M5xl9u0ij8YSvhkEVPP3M5Mc7XLl1pxH3B2aUM= github.com/golangci/plugin-module-register v0.1.1 h1:TCmesur25LnyJkpsVrupv1Cdzo+2f7zX0H6Jkw1Ol6c= github.com/golangci/plugin-module-register v0.1.1/go.mod h1:TTpqoB6KkwOJMV8u7+NyXMrkwwESJLOkfl9TxR1DGFc= github.com/golangci/revgrep v0.5.3 h1:3tL7c1XBMtWHHqVpS5ChmiAAoe4PF/d5+ULzV9sLAzs= @@ -476,8 +476,8 @@ github.com/gostaticanalysis/forcetypeassert v0.1.0/go.mod h1:qZEedyP/sY1lTGV1uJ3 github.com/gostaticanalysis/nilerr v0.1.1 h1:ThE+hJP0fEp4zWLkWHWcRyI2Od0p7DlgYG3Uqrmrcpk= github.com/gostaticanalysis/nilerr v0.1.1/go.mod h1:wZYb6YI5YAxxq0i1+VJbY0s2YONW0HU0GPE3+5PWN4A= github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod h1:D+FIZ+7OahH3ePw/izIEeH5I06eKs1IKI4Xr64/Am3M= -github.com/gostaticanalysis/testutil v0.4.0 h1:nhdCmubdmDF6VEatUNjgUZBJKWRqugoISdUv3PPQgHY= -github.com/gostaticanalysis/testutil v0.4.0/go.mod h1:bLIoPefWXrRi/ssLFWX1dx7Repi5x3CuviD3dgAZaBU= +github.com/gostaticanalysis/testutil v0.5.0 h1:Dq4wT1DdTwTGCQQv3rl3IvD5Ld0E6HiY+3Zh0sUGqw8= +github.com/gostaticanalysis/testutil v0.5.0/go.mod h1:OLQSbuM6zw2EvCcXTz1lVq5unyoNft372msDY0nY5Hs= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= github.com/h2non/gock v1.2.0 h1:K6ol8rfrRkUOefooBC8elXoaNGYkpp7y2qcxGG6BzUE= @@ -486,11 +486,17 @@ github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslC github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed h1:5upAirOpQc1Q53c0bnx2ufif5kANL7bfZWcc6VJWJd8= github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed/go.mod h1:tMWxXQ9wFIaZeTI9F+hmhFiGpFmhOHzyShyFUhRm0H4= +github.com/hashicorp/go-immutable-radix/v2 v2.1.0 h1:CUW5RYIcysz+D3B+l1mDeXrQ7fUvGGCwJfdASSzbrfo= +github.com/hashicorp/go-immutable-radix/v2 v2.1.0/go.mod h1:hgdqLXA4f6NIjRVisM1TJ9aOJVNRqKZj+xDGF6m7PBw= +github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= +github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k= +github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= @@ -565,8 +571,8 @@ github.com/jinzhu/gorm v0.0.0-20170222002820-5409931a1bb8/go.mod h1:Vla75njaFJ8c github.com/jinzhu/inflection v0.0.0-20170102125226-1c35d901db3d h1:jRQLvyVGL+iVtDElaEIDdKwpPqUIZJfzkNLV34htpEc= github.com/jinzhu/inflection v0.0.0-20170102125226-1c35d901db3d/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/jjti/go-spancheck v0.6.2 h1:iYtoxqPMzHUPp7St+5yA8+cONdyXD3ug6KK15n7Pklk= -github.com/jjti/go-spancheck v0.6.2/go.mod h1:+X7lvIrR5ZdUTkxFYqzJ0abr8Sb5LOo80uOhWNqIrYA= +github.com/jjti/go-spancheck v0.6.4 h1:Tl7gQpYf4/TMU7AT84MN83/6PutY21Nb9fuQjFTpRRc= +github.com/jjti/go-spancheck v0.6.4/go.mod h1:yAEYdKJ2lRkDA8g7X+oKUHXOWVAXSBJRv04OhF+QUjk= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= @@ -583,8 +589,8 @@ github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPci github.com/juju/loggo v0.0.0-20190526231331-6e530bcce5d8/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/julz/importas v0.1.0 h1:F78HnrsjY3cR7j0etXy5+TU1Zuy7Xt08X/1aJnH5xXY= -github.com/julz/importas v0.1.0/go.mod h1:oSFU2R4XK/P7kNBrnL/FEQlDGN1/6WoxXEjSSXO0DV0= +github.com/julz/importas v0.2.0 h1:y+MJN/UdL63QbFJHws9BVC5RpA2iq0kpjrFajTGivjQ= +github.com/julz/importas v0.2.0/go.mod h1:pThlt589EnCYtMnmhmRYY/qn9lCf/frPOK+WMx3xiJY= github.com/karamaru-alpha/copyloopvar v1.1.0 h1:x7gNyKcC2vRBO1H2Mks5u1VxQtYvFiym7fCjIP8RPos= github.com/karamaru-alpha/copyloopvar v1.1.0/go.mod h1:u7CIfztblY0jZLOQZgH3oYsJzpC2A7S6u/lfgSXHy0k= github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4= @@ -617,10 +623,16 @@ github.com/kyoh86/exportloopref v0.1.11 h1:1Z0bcmTypkL3Q4k+IDHMWTcnCliEZcaPiIe0/ github.com/kyoh86/exportloopref v0.1.11/go.mod h1:qkV4UF1zGl6EkF1ox8L5t9SwyeBAZ3qLMd6up458uqA= github.com/lasiar/canonicalheader v1.1.2 h1:vZ5uqwvDbyJCnMhmFYimgMZnJMjwljN5VGY0VKbMXb4= github.com/lasiar/canonicalheader v1.1.2/go.mod h1:qJCeLFS0G/QlLQ506T+Fk/fWMa2VmBUiEI2cuMK4djI= -github.com/ldez/gomoddirectives v0.2.4 h1:j3YjBIjEBbqZ0NKtBNzr8rtMHTOrLPeiwTkfUJZ3alg= -github.com/ldez/gomoddirectives v0.2.4/go.mod h1:oWu9i62VcQDYp9EQ0ONTfqLNh+mDLWWDO+SO0qSQw5g= -github.com/ldez/tagliatelle v0.5.0 h1:epgfuYt9v0CG3fms0pEgIMNPuFf/LpPIfjk4kyqSioo= -github.com/ldez/tagliatelle v0.5.0/go.mod h1:rj1HmWiL1MiKQuOONhd09iySTEkUuE/8+5jtPYz9xa4= +github.com/ldez/exptostd v0.3.0 h1:iKdMtUedzov89jDvuwmo0qpo+ARpZJg9hMp3428WwNg= +github.com/ldez/exptostd v0.3.0/go.mod h1:iZBRYaUmcW5jwCR3KROEZ1KivQQp6PHXbDPk9hqJKCQ= +github.com/ldez/gomoddirectives v0.6.0 h1:Jyf1ZdTeiIB4dd+2n4qw+g4aI9IJ6JyfOZ8BityWvnA= +github.com/ldez/gomoddirectives v0.6.0/go.mod h1:TuwOGYoPAoENDWQpe8DMqEm5nIfjrxZXmxX/CExWyZ4= +github.com/ldez/grignotin v0.7.0 h1:vh0dI32WhHaq6LLPZ38g7WxXuZ1+RzyrJ7iPG9JMa8c= +github.com/ldez/grignotin v0.7.0/go.mod h1:uaVTr0SoZ1KBii33c47O1M8Jp3OP3YDwhZCmzT9GHEk= +github.com/ldez/tagliatelle v0.7.1 h1:bTgKjjc2sQcsgPiT902+aadvMjCeMHrY7ly2XKFORIk= +github.com/ldez/tagliatelle v0.7.1/go.mod h1:3zjxUpsNB2aEZScWiZTHrAXOl1x25t3cRmzfK1mlo2I= +github.com/ldez/usetesting v0.4.1 h1:T/4Bk3YDX6XUBtdNDDFymlr5GBekKA4j7HUtrv1YaaI= +github.com/ldez/usetesting v0.4.1/go.mod h1:eEs46T3PpQ+9RgN9VjpY6qWdiw2/QmfiDeWmdZdrjIQ= github.com/leonklingele/grouper v1.1.2 h1:o1ARBDLOmmasUaNDesWqWCIFH3u7hoFlM84YrjT3mIY= github.com/leonklingele/grouper v1.1.2/go.mod h1:6D0M/HVkhs2yRKRFZUoGjeDy7EZTfFBE9gl4kjmIGkA= github.com/lib/pq v0.0.0-20150723085316-0dad96c0b94f/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -718,8 +730,8 @@ github.com/nishanths/exhaustive v0.12.0 h1:vIY9sALmw6T/yxiASewa4TQcFsVYZQQRUQJhK github.com/nishanths/exhaustive v0.12.0/go.mod h1:mEZ95wPIZW+x8kC4TgC+9YCUgiST7ecevsVDTgc2obs= github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk= github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c= -github.com/nunnatsa/ginkgolinter v0.18.3 h1:WgS7X3zzmni3vwHSBhvSgqrRgUecN6PQUcfB0j1noDw= -github.com/nunnatsa/ginkgolinter v0.18.3/go.mod h1:BE1xyB/PNtXXG1azrvrqJW5eFH0hSRylNzFy8QHPwzs= +github.com/nunnatsa/ginkgolinter v0.18.4 h1:zmX4KUR+6fk/vhUFt8DOP6KwznekhkmVSzzVJve2vyM= +github.com/nunnatsa/ginkgolinter v0.18.4/go.mod h1:AMEane4QQ6JwFz5GgjI5xLUM9S/CylO+UyM97fN2iBI= github.com/oapi-codegen/runtime v1.1.1 h1:EXLHh0DXIJnWhdRPN2w4MXAzFyE4CskzhNLUmtpMYro= github.com/oapi-codegen/runtime v1.1.1/go.mod h1:SK9X900oXmPWilYR5/WKPzt3Kqxn/uS/+lbpREv+eCg= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= @@ -807,8 +819,8 @@ github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 h1:TCg2WBOl github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0= github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 h1:M8mH9eK4OUR4lu7Gd+PU1fV2/qnDNfzT635KRSObncs= github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ= -github.com/raeperd/recvcheck v0.1.2 h1:SjdquRsRXJc26eSonWIo8b7IMtKD3OAT2Lb5G3ZX1+4= -github.com/raeperd/recvcheck v0.1.2/go.mod h1:n04eYkwIR0JbgD73wT8wL4JjPC3wm0nFtzBnWNocnYU= +github.com/raeperd/recvcheck v0.2.0 h1:GnU+NsbiCqdC2XX5+vMZzP+jAJC5fht7rcVTAhX74UI= +github.com/raeperd/recvcheck v0.2.0/go.mod h1:n04eYkwIR0JbgD73wT8wL4JjPC3wm0nFtzBnWNocnYU= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= @@ -832,14 +844,14 @@ github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6g github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f h1:MvTmaQdww/z0Q4wrYjDSCcZ78NoftLQyHBSLW/Cx79Y= github.com/sahilm/fuzzy v0.1.1-0.20230530133925-c48e322e2a8f/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y= -github.com/sanposhiho/wastedassign/v2 v2.0.7 h1:J+6nrY4VW+gC9xFzUc+XjPD3g3wF3je/NsJFwFK7Uxc= -github.com/sanposhiho/wastedassign/v2 v2.0.7/go.mod h1:KyZ0MWTwxxBmfwn33zh3k1dmsbF2ud9pAAGfoLfjhtI= -github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 h1:lZUw3E0/J3roVtGQ+SCrUrg3ON6NgVqpn3+iol9aGu4= -github.com/santhosh-tekuri/jsonschema/v5 v5.3.1/go.mod h1:uToXkOrWAZ6/Oc07xWQrPOhJotwFIyu2bBVN41fcDUY= +github.com/sanposhiho/wastedassign/v2 v2.1.0 h1:crurBF7fJKIORrV85u9UUpePDYGWnwvv3+A96WvwXT0= +github.com/sanposhiho/wastedassign/v2 v2.1.0/go.mod h1:+oSmSC+9bQ+VUAxA66nBb0Z7N8CK7mscKTDYC6aIek4= +github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 h1:PKK9DyHxif4LZo+uQSgXNqs0jj5+xZwwfKHgph2lxBw= +github.com/santhosh-tekuri/jsonschema/v6 v6.0.1/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU= github.com/sashamelentyev/interfacebloat v1.1.0 h1:xdRdJp0irL086OyW1H/RTZTr1h/tMEOsumirXcOJqAw= github.com/sashamelentyev/interfacebloat v1.1.0/go.mod h1:+Y9yU5YdTkrNvoX0xHc84dxiN1iBi9+G8zZIhPVoNjQ= -github.com/sashamelentyev/usestdlibvars v1.27.0 h1:t/3jZpSXtRPRf2xr0m63i32ZrusyurIGT9E5wAvXQnI= -github.com/sashamelentyev/usestdlibvars v1.27.0/go.mod h1:9nl0jgOfHKWNFS43Ojw0i7aRoS4j6EBye3YBhmAIRF8= +github.com/sashamelentyev/usestdlibvars v1.28.0 h1:jZnudE2zKCtYlGzLVreNp5pmCdOxXUzwsMDBkR21cyQ= +github.com/sashamelentyev/usestdlibvars v1.28.0/go.mod h1:9nl0jgOfHKWNFS43Ojw0i7aRoS4j6EBye3YBhmAIRF8= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/securego/gosec/v2 v2.21.4 h1:Le8MSj0PDmOnHJgUATjD96PaXRvCpKC+DGJvwyy0Mlk= github.com/securego/gosec/v2 v2.21.4/go.mod h1:Jtb/MwRQfRxCXyCm1rfM1BEiiiTfUOdyzzAhlr6lUTA= @@ -892,8 +904,8 @@ github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+ github.com/spkg/bom v0.0.0-20160624110644-59b7046e48ad/go.mod h1:qLr4V1qq6nMqFKkMo8ZTx3f+BZEkzsRUY10Xsm2mwU0= github.com/ssgreg/nlreturn/v2 v2.2.1 h1:X4XDI7jstt3ySqGU86YGAURbxw3oTDPK9sPEi6YEwQ0= github.com/ssgreg/nlreturn/v2 v2.2.1/go.mod h1:E/iiPB78hV7Szg2YfRgyIrk1AD6JVMTRkkxBiELzh2I= -github.com/stbenjam/no-sprintf-host-port v0.1.1 h1:tYugd/yrm1O0dV+ThCbaKZh195Dfm07ysF0U6JQXczc= -github.com/stbenjam/no-sprintf-host-port v0.1.1/go.mod h1:TLhvtIvONRzdmkFiio4O8LHsN9N74I+PhRquPsxpL0I= +github.com/stbenjam/no-sprintf-host-port v0.2.0 h1:i8pxvGrt1+4G0czLr/WnmyH7zbZ8Bg8etvARQ1rpyl4= +github.com/stbenjam/no-sprintf-host-port v0.2.0/go.mod h1:eL0bQ9PasS0hsyTyfTjjG+E80QIyPnBVQbYZyv20Jfk= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= @@ -916,34 +928,34 @@ github.com/stripe/pg-schema-diff v0.8.0 h1:Ggm4yDbPtaflYQLV3auEMTLxQPaentV/wmDEo github.com/stripe/pg-schema-diff v0.8.0/go.mod h1:HuTBuWLuvnY9g9nptbSD58xugN19zSJNkF4w/sYRtdU= github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= -github.com/tdakkota/asciicheck v0.2.0 h1:o8jvnUANo0qXtnslk2d3nMKTFNlOnJjRrNcj0j9qkHM= -github.com/tdakkota/asciicheck v0.2.0/go.mod h1:Qb7Y9EgjCLJGup51gDHFzbI08/gbGhL/UVhYIPWG2rg= +github.com/tdakkota/asciicheck v0.3.0 h1:LqDGgZdholxZMaJgpM6b0U9CFIjDCbFdUF00bDnBKOQ= +github.com/tdakkota/asciicheck v0.3.0/go.mod h1:KoJKXuX/Z/lt6XzLo8WMBfQGzak0SrAKZlvRr4tg8Ac= github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA= github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= -github.com/tetafro/godot v1.4.18 h1:ouX3XGiziKDypbpXqShBfnNLTSjR8r3/HVzrtJ+bHlI= -github.com/tetafro/godot v1.4.18/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= +github.com/tetafro/godot v1.4.20 h1:z/p8Ek55UdNvzt4TFn2zx2KscpW4rWqcnUrdmvWJj7E= +github.com/tetafro/godot v1.4.20/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= github.com/theupdateframework/notary v0.7.0 h1:QyagRZ7wlSpjT5N2qQAh/pN+DVqgekv4DzbAiAiEL3c= github.com/theupdateframework/notary v0.7.0/go.mod h1:c9DRxcmhHmVLDay4/2fUYdISnHqbFDGRSlXPO0AhYWw= -github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 h1:quvGphlmUVU+nhpFa4gg4yJyTRJ13reZMDHrKwYw53M= -github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966/go.mod h1:27bSVNWSBOHm+qRp1T9qzaIpsWEP6TbUnei/43HK+PQ= +github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 h1:y4mJRFlM6fUyPhoXuFg/Yu02fg/nIPFMOY8tOqppoFg= +github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3/go.mod h1:mkjARE7Yr8qU23YcGMSALbIxTQ9r9QBVahQOBRfU460= github.com/timonwong/loggercheck v0.10.1 h1:uVZYClxQFpw55eh+PIoqM7uAOHMrhVcDoWDery9R8Lg= github.com/timonwong/loggercheck v0.10.1/go.mod h1:HEAWU8djynujaAVX7QI65Myb8qgfcZ1uKbdpg3ZzKl8= -github.com/tomarrell/wrapcheck/v2 v2.9.0 h1:801U2YCAjLhdN8zhZ/7tdjB3EnAoRlJHt/s+9hijLQ4= -github.com/tomarrell/wrapcheck/v2 v2.9.0/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo= +github.com/tomarrell/wrapcheck/v2 v2.10.0 h1:SzRCryzy4IrAH7bVGG4cK40tNUhmVmMDuJujy4XwYDg= +github.com/tomarrell/wrapcheck/v2 v2.10.0/go.mod h1:g9vNIyhb5/9TQgumxQyOEqDHsmGYcGsVMOx/xGkqdMo= github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= -github.com/ultraware/funlen v0.1.0 h1:BuqclbkY6pO+cvxoq7OsktIXZpgBSkYTQtmwhAK81vI= -github.com/ultraware/funlen v0.1.0/go.mod h1:XJqmOQja6DpxarLj6Jj1U7JuoS8PvL4nEqDaQhy22p4= -github.com/ultraware/whitespace v0.1.1 h1:bTPOGejYFulW3PkcrqkeQwOd6NKOOXvmGD9bo/Gk8VQ= -github.com/ultraware/whitespace v0.1.1/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= -github.com/uudashr/gocognit v1.1.3 h1:l+a111VcDbKfynh+airAy/DJQKaXh2m9vkoysMPSZyM= -github.com/uudashr/gocognit v1.1.3/go.mod h1:aKH8/e8xbTRBwjbCkwZ8qt4l2EpKXl31KMHgSS+lZ2U= -github.com/uudashr/iface v1.2.1 h1:vHHyzAUmWZ64Olq6NZT3vg/z1Ws56kyPdBOd5kTXDF8= -github.com/uudashr/iface v1.2.1/go.mod h1:4QvspiRd3JLPAEXBQ9AiZpLbJlrWWgRChOKDJEuQTdg= +github.com/ultraware/funlen v0.2.0 h1:gCHmCn+d2/1SemTdYMiKLAHFYxTYz7z9VIDRaTGyLkI= +github.com/ultraware/funlen v0.2.0/go.mod h1:ZE0q4TsJ8T1SQcjmkhN/w+MceuatI6pBFSxxyteHIJA= +github.com/ultraware/whitespace v0.2.0 h1:TYowo2m9Nfj1baEQBjuHzvMRbp19i+RCcRYrSWoFa+g= +github.com/ultraware/whitespace v0.2.0/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= +github.com/uudashr/gocognit v1.2.0 h1:3BU9aMr1xbhPlvJLSydKwdLN3tEUUrzPSSM8S4hDYRA= +github.com/uudashr/gocognit v1.2.0/go.mod h1:k/DdKPI6XBZO1q7HgoV2juESI2/Ofj9AcHPZhBBdrTU= +github.com/uudashr/iface v1.3.0 h1:zwPch0fs9tdh9BmL5kcgSpvnObV+yHjO4JjVBl8IA10= +github.com/uudashr/iface v1.3.0/go.mod h1:4QvspiRd3JLPAEXBQ9AiZpLbJlrWWgRChOKDJEuQTdg= github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 h1:MzD3XeOOSO3mAjOPpF07jFteSKZxsRHvlIcAR9RQzKM= github.com/withfig/autocomplete-tools/packages/cobra v1.2.0/go.mod h1:RoXh7+7qknOXL65uTzdzE1mPxqcPwS7FLCE9K5GfmKo= github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM= @@ -1056,6 +1068,7 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= @@ -1099,7 +1112,6 @@ golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= @@ -1107,6 +1119,7 @@ golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= @@ -1152,9 +1165,11 @@ golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= +golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= @@ -1181,6 +1196,7 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= @@ -1225,7 +1241,6 @@ golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1248,6 +1263,7 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= @@ -1261,9 +1277,11 @@ golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= @@ -1279,6 +1297,7 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= @@ -1344,23 +1363,23 @@ golang.org/x/tools v0.0.0-20200820010801-b793a1359eac/go.mod h1:njjCfa9FT2d7l9Bc golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20201023174141-c8cfbd0f21e6/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1-0.20210205202024-ef80cdb6ec6d/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU= golang.org/x/tools v0.1.1-0.20210302220138-2ac05c832e1a/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.9/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= +golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= -golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o= -golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q= +golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8= +golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 37438c4c291ef97ea49bd4569fa8b3d07857a81b Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Thu, 2 Jan 2025 13:18:28 +0800 Subject: [PATCH 245/305] fix: assume platform defaults when local sms keys are unset --- pkg/config/auth.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pkg/config/auth.go b/pkg/config/auth.go index b2e6b0fa6..d0d41aa43 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -542,25 +542,35 @@ func (s sms) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { switch { case s.Twilio.Enabled: body.SmsProvider = cast.Ptr("twilio") - body.SmsTwilioAuthToken = &s.Twilio.AuthToken + if len(s.Twilio.AuthToken) > 0 { + body.SmsTwilioAuthToken = &s.Twilio.AuthToken + } body.SmsTwilioAccountSid = &s.Twilio.AccountSid body.SmsTwilioMessageServiceSid = &s.Twilio.MessageServiceSid case s.TwilioVerify.Enabled: body.SmsProvider = cast.Ptr("twilio_verify") - body.SmsTwilioVerifyAuthToken = &s.TwilioVerify.AuthToken + if len(s.TwilioVerify.AuthToken) > 0 { + body.SmsTwilioVerifyAuthToken = &s.TwilioVerify.AuthToken + } body.SmsTwilioVerifyAccountSid = &s.TwilioVerify.AccountSid body.SmsTwilioVerifyMessageServiceSid = &s.TwilioVerify.MessageServiceSid case s.Messagebird.Enabled: body.SmsProvider = cast.Ptr("messagebird") - body.SmsMessagebirdAccessKey = &s.Messagebird.AccessKey + if len(s.Messagebird.AccessKey) > 0 { + body.SmsMessagebirdAccessKey = &s.Messagebird.AccessKey + } body.SmsMessagebirdOriginator = &s.Messagebird.Originator case s.Textlocal.Enabled: body.SmsProvider = cast.Ptr("textlocal") - body.SmsTextlocalApiKey = &s.Textlocal.ApiKey + if len(s.Textlocal.ApiKey) > 0 { + body.SmsTextlocalApiKey = &s.Textlocal.ApiKey + } body.SmsTextlocalSender = &s.Textlocal.Sender case s.Vonage.Enabled: body.SmsProvider = cast.Ptr("vonage") - body.SmsVonageApiSecret = &s.Vonage.ApiSecret + if len(s.Vonage.ApiSecret) > 0 { + body.SmsVonageApiSecret = &s.Vonage.ApiSecret + } body.SmsVonageApiKey = &s.Vonage.ApiKey body.SmsVonageFrom = &s.Vonage.From } From 185ec6e732490fcce5d30517aa6f469dd9401d91 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Thu, 2 Jan 2025 15:52:48 +0800 Subject: [PATCH 246/305] chore: use double quote consistently --- pkg/config/templates/config.toml | 4 ++-- pkg/config/testdata/config.toml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index 5345f4d0d..6c50b1447 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -46,8 +46,8 @@ max_client_conn = 100 # If enabled, seeds the database after migrations during a db reset. enabled = true # Specifies an ordered list of seed files to load during db reset. -# Supports glob patterns relative to supabase directory: './seeds/*.sql' -sql_paths = ['./seed.sql'] +# Supports glob patterns relative to supabase directory: "./seeds/*.sql" +sql_paths = ["./seed.sql"] [realtime] enabled = true diff --git a/pkg/config/testdata/config.toml b/pkg/config/testdata/config.toml index 113626868..e3093924a 100644 --- a/pkg/config/testdata/config.toml +++ b/pkg/config/testdata/config.toml @@ -46,8 +46,8 @@ max_client_conn = 100 # If enabled, seeds the database after migrations during a db reset. enabled = true # Specifies an ordered list of seed files to load during db reset. -# Supports glob patterns relative to supabase directory: './seeds/*.sql' -sql_paths = ['./seed.sql'] +# Supports glob patterns relative to supabase directory: "./seeds/*.sql" +sql_paths = ["./seed.sql"] [realtime] enabled = true From 0bf473b3695cc8f3d0db71ee19c26c0ca727b13f Mon Sep 17 00:00:00 2001 From: Monica Date: Thu, 2 Jan 2025 12:59:40 +0200 Subject: [PATCH 247/305] fix: bump gotrue to 2.166.0 --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 200c16da8..aedecd659 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -15,7 +15,7 @@ const ( edgeRuntimeImage = "supabase/edge-runtime:v1.66.1" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" - gotrueImage = "supabase/gotrue:v2.164.0" + gotrueImage = "supabase/gotrue:v2.166.0" realtimeImage = "supabase/realtime:v2.33.70" storageImage = "supabase/storage-api:v1.14.5" logflareImage = "supabase/logflare:1.4.0" From d10322d8144846dab2228375285e902434e2b23c Mon Sep 17 00:00:00 2001 From: Monica Date: Thu, 2 Jan 2025 13:22:49 +0200 Subject: [PATCH 248/305] bump to the latest version v2.167.0 --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index aedecd659..d86112ea4 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -15,7 +15,7 @@ const ( edgeRuntimeImage = "supabase/edge-runtime:v1.66.1" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" - gotrueImage = "supabase/gotrue:v2.166.0" + gotrueImage = "supabase/gotrue:v2.167.0" realtimeImage = "supabase/realtime:v2.33.70" storageImage = "supabase/storage-api:v1.14.5" logflareImage = "supabase/logflare:1.4.0" From b36952eecc90171a7c98980b21b12fea583e079c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 04:39:26 +0000 Subject: [PATCH 249/305] chore(deps): bump github.com/go-git/go-git/v5 from 5.13.0 to 5.13.1 (#3008) Bumps [github.com/go-git/go-git/v5](https://github.com/go-git/go-git) from 5.13.0 to 5.13.1. - [Release notes](https://github.com/go-git/go-git/releases) - [Commits](https://github.com/go-git/go-git/compare/v5.13.0...v5.13.1) --- updated-dependencies: - dependency-name: github.com/go-git/go-git/v5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index 89f024e3c..e129eb761 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/docker/go-units v0.5.0 github.com/getsentry/sentry-go v0.30.0 github.com/go-errors/errors v1.5.1 - github.com/go-git/go-git/v5 v5.13.0 + github.com/go-git/go-git/v5 v5.13.1 github.com/go-xmlfmt/xmlfmt v1.1.3 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/golangci/golangci-lint v1.63.1 @@ -107,7 +107,7 @@ require ( github.com/containerd/log v0.1.0 // indirect github.com/containers/storage v1.56.0 // indirect github.com/curioswitch/go-reassign v0.3.0 // indirect - github.com/cyphar/filepath-securejoin v0.3.4 // indirect + github.com/cyphar/filepath-securejoin v0.3.6 // indirect github.com/daixiang0/gci v0.13.5 // indirect github.com/danieljoos/wincred v1.2.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect @@ -132,7 +132,7 @@ require ( github.com/ghostiam/protogetter v0.3.8 // indirect github.com/go-critic/go-critic v0.11.5 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.6.0 // indirect + github.com/go-git/go-billy/v5 v5.6.1 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect diff --git a/go.sum b/go.sum index d71db5ed3..c71759c65 100644 --- a/go.sum +++ b/go.sum @@ -205,8 +205,8 @@ github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/curioswitch/go-reassign v0.3.0 h1:dh3kpQHuADL3cobV/sSGETA8DOv457dwl+fbBAhrQPs= github.com/curioswitch/go-reassign v0.3.0/go.mod h1:nApPCCTtqLJN/s8HfItCcKV0jIPwluBOvZP+dsJGA88= -github.com/cyphar/filepath-securejoin v0.3.4 h1:VBWugsJh2ZxJmLFSM06/0qzQyiQX2Qs0ViKrUAcqdZ8= -github.com/cyphar/filepath-securejoin v0.3.4/go.mod h1:8s/MCNJREmFK0H02MF6Ihv1nakJe4L/w3WZLHNkvlYM= +github.com/cyphar/filepath-securejoin v0.3.6 h1:4d9N5ykBnSp5Xn2JkhocYDkOpURL/18CYMpo6xB9uWM= +github.com/cyphar/filepath-securejoin v0.3.6/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= github.com/daixiang0/gci v0.13.5 h1:kThgmH1yBmZSBCh1EJVxQ7JsHpm5Oms0AMed/0LaH4c= github.com/daixiang0/gci v0.13.5/go.mod h1:12etP2OniiIdP4q+kjUGrC/rUagga7ODbqsom5Eo5Yk= github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0= @@ -248,8 +248,8 @@ github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/dvsekhvalnov/jose2go v0.0.0-20170216131308-f21a8cedbbae/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= -github.com/elazarl/goproxy v1.2.1 h1:njjgvO6cRG9rIqN2ebkqy6cQz2Njkx7Fsfv/zIZqgug= -github.com/elazarl/goproxy v1.2.1/go.mod h1:YfEbZtqP4AetfO6d40vWchF3znWX7C7Vd6ZMfdL8z64= +github.com/elazarl/goproxy v1.2.3 h1:xwIyKHbaP5yfT6O9KIeYJR5549MXRQkoQMRXGztz8YQ= +github.com/elazarl/goproxy v1.2.3/go.mod h1:YfEbZtqP4AetfO6d40vWchF3znWX7C7Vd6ZMfdL8z64= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -293,12 +293,12 @@ github.com/go-errors/errors v1.5.1 h1:ZwEMSLRCapFLflTpT7NKaAc7ukJ8ZPEjzlxt8rPN8b github.com/go-errors/errors v1.5.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.6.0 h1:w2hPNtoehvJIxR00Vb4xX94qHQi/ApZfX+nBE2Cjio8= -github.com/go-git/go-billy/v5 v5.6.0/go.mod h1:sFDq7xD3fn3E0GOwUSZqHo9lrkmx8xJhA0ZrfvjBRGM= +github.com/go-git/go-billy/v5 v5.6.1 h1:u+dcrgaguSSkbjzHwelEjc0Yj300NUevrrPphk/SoRA= +github.com/go-git/go-billy/v5 v5.6.1/go.mod h1:0AsLr1z2+Uksi4NlElmMblP5rPcDZNRCD8ujZCRR2BE= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= -github.com/go-git/go-git/v5 v5.13.0 h1:vLn5wlGIh/X78El6r3Jr+30W16Blk0CTcxTYcYPWi5E= -github.com/go-git/go-git/v5 v5.13.0/go.mod h1:Wjo7/JyVKtQgUNdXYXIepzWfJQkUEIGvkvVkiXRR/zw= +github.com/go-git/go-git/v5 v5.13.1 h1:DAQ9APonnlvSWpvolXWIuV6Q6zXy2wHbN4cVlNR5Q+M= +github.com/go-git/go-git/v5 v5.13.1/go.mod h1:qryJB4cSBoq3FRoBRf5A77joojuBcmPJ0qu3XXXVixc= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= From f4a59ab63974ddca1638556f2f9357b6204fe47b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 04:44:18 +0000 Subject: [PATCH 250/305] chore(deps): bump github.com/golangci/golangci-lint from 1.63.1 to 1.63.3 (#3009) chore(deps): bump github.com/golangci/golangci-lint Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.63.1 to 1.63.3. - [Release notes](https://github.com/golangci/golangci-lint/releases) - [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md) - [Commits](https://github.com/golangci/golangci-lint/compare/v1.63.1...v1.63.3) --- updated-dependencies: - dependency-name: github.com/golangci/golangci-lint dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index e129eb761..301390179 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/go-git/go-git/v5 v5.13.1 github.com/go-xmlfmt/xmlfmt v1.1.3 github.com/golang-jwt/jwt/v5 v5.2.1 - github.com/golangci/golangci-lint v1.63.1 + github.com/golangci/golangci-lint v1.63.3 github.com/google/go-github/v62 v62.0.0 github.com/google/go-querystring v1.1.0 github.com/google/uuid v1.6.0 @@ -197,11 +197,11 @@ require ( github.com/kunwardeep/paralleltest v1.0.10 // indirect github.com/kyoh86/exportloopref v0.1.11 // indirect github.com/lasiar/canonicalheader v1.1.2 // indirect - github.com/ldez/exptostd v0.3.0 // indirect + github.com/ldez/exptostd v0.3.1 // indirect github.com/ldez/gomoddirectives v0.6.0 // indirect github.com/ldez/grignotin v0.7.0 // indirect github.com/ldez/tagliatelle v0.7.1 // indirect - github.com/ldez/usetesting v0.4.1 // indirect + github.com/ldez/usetesting v0.4.2 // indirect github.com/leonklingele/grouper v1.1.2 // indirect github.com/lib/pq v1.10.9 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect diff --git a/go.sum b/go.sum index c71759c65..0cf38017a 100644 --- a/go.sum +++ b/go.sum @@ -403,8 +403,8 @@ github.com/golangci/go-printf-func-name v0.1.0 h1:dVokQP+NMTO7jwO4bwsRwLWeudOVUP github.com/golangci/go-printf-func-name v0.1.0/go.mod h1:wqhWFH5mUdJQhweRnldEywnR5021wTdZSNgwYceV14s= github.com/golangci/gofmt v0.0.0-20241223200906-057b0627d9b9 h1:t5wybL6RtO83VwoMOb7U/Peqe3gGKQlPIC66wXmnkvM= github.com/golangci/gofmt v0.0.0-20241223200906-057b0627d9b9/go.mod h1:Ag3L7sh7E28qAp/5xnpMMTuGYqxLZoSaEHZDkZB1RgU= -github.com/golangci/golangci-lint v1.63.1 h1:fr7zu2W0qexDkTvYwtdrsYJwYIx+tS09ujM1CIjIpCQ= -github.com/golangci/golangci-lint v1.63.1/go.mod h1:O2+mo4qsJuG4cSXBzLbEV+5NAtntoNIbAv428zaEY/s= +github.com/golangci/golangci-lint v1.63.3 h1:Q/UZqLRuqo3mmwA/EN2pq9y+JV4S2IqmqrS3t855ZMc= +github.com/golangci/golangci-lint v1.63.3/go.mod h1:Hx0B7Lg5/NXbaOHem8+KU+ZUIzMI6zNj/7tFwdnn10I= github.com/golangci/misspell v0.6.0 h1:JCle2HUTNWirNlDIAUO44hUsKhOFqGPoC4LZxlaSXDs= github.com/golangci/misspell v0.6.0/go.mod h1:keMNyY6R9isGaSAu+4Q8NMBwMPkh15Gtc8UCVoDtAWo= github.com/golangci/plugin-module-register v0.1.1 h1:TCmesur25LnyJkpsVrupv1Cdzo+2f7zX0H6Jkw1Ol6c= @@ -623,16 +623,16 @@ github.com/kyoh86/exportloopref v0.1.11 h1:1Z0bcmTypkL3Q4k+IDHMWTcnCliEZcaPiIe0/ github.com/kyoh86/exportloopref v0.1.11/go.mod h1:qkV4UF1zGl6EkF1ox8L5t9SwyeBAZ3qLMd6up458uqA= github.com/lasiar/canonicalheader v1.1.2 h1:vZ5uqwvDbyJCnMhmFYimgMZnJMjwljN5VGY0VKbMXb4= github.com/lasiar/canonicalheader v1.1.2/go.mod h1:qJCeLFS0G/QlLQ506T+Fk/fWMa2VmBUiEI2cuMK4djI= -github.com/ldez/exptostd v0.3.0 h1:iKdMtUedzov89jDvuwmo0qpo+ARpZJg9hMp3428WwNg= -github.com/ldez/exptostd v0.3.0/go.mod h1:iZBRYaUmcW5jwCR3KROEZ1KivQQp6PHXbDPk9hqJKCQ= +github.com/ldez/exptostd v0.3.1 h1:90yWWoAKMFHeovTK8uzBms9Ppp8Du/xQ20DRO26Ymrw= +github.com/ldez/exptostd v0.3.1/go.mod h1:iZBRYaUmcW5jwCR3KROEZ1KivQQp6PHXbDPk9hqJKCQ= github.com/ldez/gomoddirectives v0.6.0 h1:Jyf1ZdTeiIB4dd+2n4qw+g4aI9IJ6JyfOZ8BityWvnA= github.com/ldez/gomoddirectives v0.6.0/go.mod h1:TuwOGYoPAoENDWQpe8DMqEm5nIfjrxZXmxX/CExWyZ4= github.com/ldez/grignotin v0.7.0 h1:vh0dI32WhHaq6LLPZ38g7WxXuZ1+RzyrJ7iPG9JMa8c= github.com/ldez/grignotin v0.7.0/go.mod h1:uaVTr0SoZ1KBii33c47O1M8Jp3OP3YDwhZCmzT9GHEk= github.com/ldez/tagliatelle v0.7.1 h1:bTgKjjc2sQcsgPiT902+aadvMjCeMHrY7ly2XKFORIk= github.com/ldez/tagliatelle v0.7.1/go.mod h1:3zjxUpsNB2aEZScWiZTHrAXOl1x25t3cRmzfK1mlo2I= -github.com/ldez/usetesting v0.4.1 h1:T/4Bk3YDX6XUBtdNDDFymlr5GBekKA4j7HUtrv1YaaI= -github.com/ldez/usetesting v0.4.1/go.mod h1:eEs46T3PpQ+9RgN9VjpY6qWdiw2/QmfiDeWmdZdrjIQ= +github.com/ldez/usetesting v0.4.2 h1:J2WwbrFGk3wx4cZwSMiCQQ00kjGR0+tuuyW0Lqm4lwA= +github.com/ldez/usetesting v0.4.2/go.mod h1:eEs46T3PpQ+9RgN9VjpY6qWdiw2/QmfiDeWmdZdrjIQ= github.com/leonklingele/grouper v1.1.2 h1:o1ARBDLOmmasUaNDesWqWCIFH3u7hoFlM84YrjT3mIY= github.com/leonklingele/grouper v1.1.2/go.mod h1:6D0M/HVkhs2yRKRFZUoGjeDy7EZTfFBE9gl4kjmIGkA= github.com/lib/pq v0.0.0-20150723085316-0dad96c0b94f/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= From 8b8a876fd1c6ce22549b30859b129408b05d29c0 Mon Sep 17 00:00:00 2001 From: Nyannyacha Date: Fri, 3 Jan 2025 14:51:57 +0900 Subject: [PATCH 251/305] fix: bump edge-runtime to 1.66.2 --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index d86112ea4..fb6bdd51b 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241202-71e5240" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.66.1" + edgeRuntimeImage = "supabase/edge-runtime:v1.66.2" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.167.0" From 7c9f8c9a66781332544676c9c46d402941e629b6 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Fri, 3 Jan 2025 17:21:10 +0800 Subject: [PATCH 252/305] fix: ignore hash if local secret is unset (#3012) * fix: ignore hash if local secret is unset * chore: update unit tests --- pkg/config/auth.go | 40 ++++++++++++++----- .../local_enabled_remote_disabled.diff | 6 +-- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/pkg/config/auth.go b/pkg/config/auth.go index d0d41aa43..b93123bd2 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -310,21 +310,27 @@ func (h *hook) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { // Ignore disabled hooks because their envs are not loaded if hook.Enabled { hook.URI = cast.Val(remoteConfig.HookCustomAccessTokenUri, "") - hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookCustomAccessTokenSecrets, "") + if hook.Secrets != hashPrefix { + hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookCustomAccessTokenSecrets, "") + } } hook.Enabled = cast.Val(remoteConfig.HookCustomAccessTokenEnabled, false) } if hook := h.SendEmail; hook != nil { if hook.Enabled { hook.URI = cast.Val(remoteConfig.HookSendEmailUri, "") - hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendEmailSecrets, "") + if hook.Secrets != hashPrefix { + hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendEmailSecrets, "") + } } hook.Enabled = cast.Val(remoteConfig.HookSendEmailEnabled, false) } if hook := h.SendSMS; hook != nil { if hook.Enabled { hook.URI = cast.Val(remoteConfig.HookSendSmsUri, "") - hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendSmsSecrets, "") + if hook.Secrets != hashPrefix { + hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendSmsSecrets, "") + } } hook.Enabled = cast.Val(remoteConfig.HookSendSmsEnabled, false) } @@ -332,14 +338,18 @@ func (h *hook) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if hook := h.MFAVerificationAttempt; hook != nil { if hook.Enabled { hook.URI = cast.Val(remoteConfig.HookMfaVerificationAttemptUri, "") - hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookMfaVerificationAttemptSecrets, "") + if hook.Secrets != hashPrefix { + hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookMfaVerificationAttemptSecrets, "") + } } hook.Enabled = cast.Val(remoteConfig.HookMfaVerificationAttemptEnabled, false) } if hook := h.PasswordVerificationAttempt; hook != nil { if hook.Enabled { hook.URI = cast.Val(remoteConfig.HookPasswordVerificationAttemptUri, "") - hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookPasswordVerificationAttemptSecrets, "") + if hook.Secrets != hashPrefix { + hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookPasswordVerificationAttemptSecrets, "") + } } hook.Enabled = cast.Val(remoteConfig.HookPasswordVerificationAttemptEnabled, false) } @@ -585,21 +595,31 @@ func (s *sms) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { // We are only interested in the provider that's enabled locally switch { case s.Twilio.Enabled: - s.Twilio.AuthToken = hashPrefix + cast.Val(remoteConfig.SmsTwilioAuthToken, "") + if s.Twilio.AuthToken != hashPrefix { + s.Twilio.AuthToken = hashPrefix + cast.Val(remoteConfig.SmsTwilioAuthToken, "") + } s.Twilio.AccountSid = cast.Val(remoteConfig.SmsTwilioAccountSid, "") s.Twilio.MessageServiceSid = cast.Val(remoteConfig.SmsTwilioMessageServiceSid, "") case s.TwilioVerify.Enabled: - s.TwilioVerify.AuthToken = hashPrefix + cast.Val(remoteConfig.SmsTwilioVerifyAuthToken, "") + if s.TwilioVerify.AuthToken != hashPrefix { + s.TwilioVerify.AuthToken = hashPrefix + cast.Val(remoteConfig.SmsTwilioVerifyAuthToken, "") + } s.TwilioVerify.AccountSid = cast.Val(remoteConfig.SmsTwilioVerifyAccountSid, "") s.TwilioVerify.MessageServiceSid = cast.Val(remoteConfig.SmsTwilioVerifyMessageServiceSid, "") case s.Messagebird.Enabled: - s.Messagebird.AccessKey = hashPrefix + cast.Val(remoteConfig.SmsMessagebirdAccessKey, "") + if s.Messagebird.AccessKey != hashPrefix { + s.Messagebird.AccessKey = hashPrefix + cast.Val(remoteConfig.SmsMessagebirdAccessKey, "") + } s.Messagebird.Originator = cast.Val(remoteConfig.SmsMessagebirdOriginator, "") case s.Textlocal.Enabled: - s.Textlocal.ApiKey = hashPrefix + cast.Val(remoteConfig.SmsTextlocalApiKey, "") + if s.Textlocal.ApiKey != hashPrefix { + s.Textlocal.ApiKey = hashPrefix + cast.Val(remoteConfig.SmsTextlocalApiKey, "") + } s.Textlocal.Sender = cast.Val(remoteConfig.SmsTextlocalSender, "") case s.Vonage.Enabled: - s.Vonage.ApiSecret = hashPrefix + cast.Val(remoteConfig.SmsVonageApiSecret, "") + if s.Vonage.ApiSecret != hashPrefix { + s.Vonage.ApiSecret = hashPrefix + cast.Val(remoteConfig.SmsVonageApiSecret, "") + } s.Vonage.ApiKey = cast.Val(remoteConfig.SmsVonageApiKey, "") s.Vonage.From = cast.Val(remoteConfig.SmsVonageFrom, "") case !s.EnableSignup: diff --git a/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff index e5f26740e..dc80e57a3 100644 --- a/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff +++ b/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff @@ -1,7 +1,7 @@ diff remote[auth] local[auth] --- remote[auth] +++ local[auth] -@@ -11,21 +11,21 @@ +@@ -11,20 +11,20 @@ [hook] [hook.mfa_verification_attempt] @@ -24,10 +24,8 @@ diff remote[auth] local[auth] [hook.send_email] -enabled = false -uri = "https://example.com" --secrets = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" +enabled = true +uri = "pg-functions://postgres/public/sendEmail" -+secrets = "hash:" + secrets = "hash:" [mfa] - max_enrolled_factors = 0 From 2cca98ceed8e699a172e4cf5d54263141fb00654 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Jan 2025 17:52:40 +0800 Subject: [PATCH 253/305] chore(deps): bump github.com/getsentry/sentry-go from 0.30.0 to 0.31.1 (#3010) Bumps [github.com/getsentry/sentry-go](https://github.com/getsentry/sentry-go) from 0.30.0 to 0.31.1. - [Release notes](https://github.com/getsentry/sentry-go/releases) - [Changelog](https://github.com/getsentry/sentry-go/blob/master/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-go/compare/v0.30.0...v0.31.1) --- updated-dependencies: - dependency-name: github.com/getsentry/sentry-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Han Qiao --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 301390179..2a7b49ac3 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/docker/docker v27.4.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 - github.com/getsentry/sentry-go v0.30.0 + github.com/getsentry/sentry-go v0.31.1 github.com/go-errors/errors v1.5.1 github.com/go-git/go-git/v5 v5.13.1 github.com/go-xmlfmt/xmlfmt v1.1.3 diff --git a/go.sum b/go.sum index 0cf38017a..9b19db7e3 100644 --- a/go.sum +++ b/go.sum @@ -281,8 +281,8 @@ github.com/fzipp/gocyclo v0.6.0 h1:lsblElZG7d3ALtGMx9fmxeTKZaLLpU8mET09yN4BBLo= github.com/fzipp/gocyclo v0.6.0/go.mod h1:rXPyn8fnlpa0R2csP/31uerbiVBugk5whMdlyaLkLoA= github.com/getkin/kin-openapi v0.124.0 h1:VSFNMB9C9rTKBnQ/fpyDU8ytMTr4dWI9QovSKj9kz/M= github.com/getkin/kin-openapi v0.124.0/go.mod h1:wb1aSZA/iWmorQP9KTAS/phLj/t17B5jT7+fS8ed9NM= -github.com/getsentry/sentry-go v0.30.0 h1:lWUwDnY7sKHaVIoZ9wYqRHJ5iEmoc0pqcRqFkosKzBo= -github.com/getsentry/sentry-go v0.30.0/go.mod h1:WU9B9/1/sHDqeV8T+3VwwbjeR5MSXs/6aqG3mqZrezA= +github.com/getsentry/sentry-go v0.31.1 h1:ELVc0h7gwyhnXHDouXkhqTFSO5oslsRDk0++eyE0KJ4= +github.com/getsentry/sentry-go v0.31.1/go.mod h1:CYNcMMz73YigoHljQRG+qPF+eMq8gG72XcGN/p71BAY= github.com/ghostiam/protogetter v0.3.8 h1:LYcXbYvybUyTIxN2Mj9h6rHrDZBDwZloPoKctWrFyJY= github.com/ghostiam/protogetter v0.3.8/go.mod h1:WZ0nw9pfzsgxuRsPOFQomgDVSWtDLJRfQJEhsGbmQMA= github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c= From 1bdc4efa6789af5bbbf6b478ac59d066c1c42e2c Mon Sep 17 00:00:00 2001 From: Yaten Dhingra <129659514+yaten2302@users.noreply.github.com> Date: Sun, 5 Jan 2025 16:02:38 +0530 Subject: [PATCH 254/305] fix: obtain Postgres URL from branches get command (#2996) * fix:2964/obtain Postgres DB URL from ENV using branches get command Signed-off-by: Yaten Dhingra * added --output-env flag in branches get command Signed-off-by: Yaten Dhingra * fixed typo in internal/branches/get/get.go Signed-off-by: Yaten Dhingra * updated the output-env flag in branches.go Signed-off-by: Yaten Dhingra * changed output var to postgres_url var in branches.go Signed-off-by: Yaten Dhingra * changed postgres_url to output Signed-off-by: Yaten Dhingra * changed checks condition from env to utils.OutputEnv Signed-off-by: Yaten Dhingra * remove cmdFlags condition in cmd/branches.go Co-authored-by: Han Qiao * remove cmdFlags in cmd/branches.go Co-authored-by: Han Qiao * remove pgconn.Config{} param in get.Run() Co-authored-by: Han Qiao * remove unused import in cmd/branches.go Co-authored-by: Han Qiao * get DB URL from utils.GetSupabaseDbHost(...) Signed-off-by: Yaten Dhingra * revert to prev table render structure Signed-off-by: Yaten Dhingra * update get.go Signed-off-by: Yaten Dhingra * added postgres connection string Signed-off-by: Yaten Dhingra * removed GetPostgresURLNonPooling func from bootstrap.go Signed-off-by: Yaten Dhingra * remove vars which are not required Signed-off-by: Yaten Dhingra * minor changes in get.go & branches.go Signed-off-by: Yaten Dhingra * convert port from int to uint Signed-off-by: Yaten Dhingra * attempt to fix linter errors Signed-off-by: Yaten Dhingra * attempt to fix uint->uint16 linter error Signed-off-by: Yaten Dhingra * fixed uint->uint16 overflow error Signed-off-by: Yaten Dhingra --------- Signed-off-by: Yaten Dhingra Co-authored-by: Han Qiao --- cmd/branches.go | 4 +++- internal/branches/get/get.go | 29 +++++++++++++++++++++++++---- pkg/cast/cast.go | 8 ++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/cmd/branches.go b/cmd/branches.go index 0248e7f31..b541704bf 100644 --- a/cmd/branches.go +++ b/cmd/branches.go @@ -82,7 +82,7 @@ var ( } else { branchId = args[0] } - return get.Run(ctx, branchId) + return get.Run(ctx, branchId, afero.NewOsFs()) }, } @@ -165,6 +165,8 @@ func init() { createFlags.Var(&branchRegion, "region", "Select a region to deploy the branch database.") createFlags.Var(&size, "size", "Select a desired instance size for the branch database.") createFlags.BoolVar(&persistent, "persistent", false, "Whether to create a persistent branch.") + getFlags := branchGetCmd.Flags() + getFlags.VarP(&utils.OutputFormat, "output", "o", "Output format of branch details.") branchesCmd.AddCommand(branchCreateCmd) branchesCmd.AddCommand(branchListCmd) branchesCmd.AddCommand(branchGetCmd) diff --git a/internal/branches/get/get.go b/internal/branches/get/get.go index ee5bc332c..22f3274e7 100644 --- a/internal/branches/get/get.go +++ b/internal/branches/get/get.go @@ -3,13 +3,17 @@ package get import ( "context" "fmt" + "os" "github.com/go-errors/errors" + "github.com/jackc/pgconn" + "github.com/spf13/afero" "github.com/supabase/cli/internal/migration/list" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/pkg/cast" ) -func Run(ctx context.Context, branchId string) error { +func Run(ctx context.Context, branchId string, fsys afero.Fs) error { resp, err := utils.GetSupabase().V1GetABranchConfigWithResponse(ctx, branchId) if err != nil { return errors.Errorf("failed to retrieve preview branch: %w", err) @@ -29,10 +33,25 @@ func Run(ctx context.Context, branchId string) error { resp.JSON200.JwtSecret = &masked } - table := `|HOST|PORT|USER|PASSWORD|JWT SECRET|POSTGRES VERSION|STATUS| -|-|-|-|-|-|-|-| + config := pgconn.Config{ + Host: utils.GetSupabaseDbHost(resp.JSON200.DbHost), + Port: cast.UIntToUInt16(cast.IntToUint(resp.JSON200.DbPort)), + User: *resp.JSON200.DbUser, + Password: *resp.JSON200.DbPass, + } + + postgresConnectionString := utils.ToPostgresURL(config) + if utils.OutputFormat.Value != utils.OutputPretty { + envs := map[string]string{ + "POSTGRES_URL": postgresConnectionString, + } + return utils.EncodeOutput(utils.OutputFormat.Value, os.Stdout, envs) + } + + table := `|HOST|PORT|USER|PASSWORD|JWT SECRET|POSTGRES VERSION|STATUS|POSTGRES URL| +|-|-|-|-|-|-|-|-| ` + fmt.Sprintf( - "|`%s`|`%d`|`%s`|`%s`|`%s`|`%s`|`%s`|\n", + "|`%s`|`%d`|`%s`|`%s`|`%s`|`%s`|`%s`|`%s`|\n", resp.JSON200.DbHost, resp.JSON200.DbPort, *resp.JSON200.DbUser, @@ -40,6 +59,8 @@ func Run(ctx context.Context, branchId string) error { *resp.JSON200.JwtSecret, resp.JSON200.PostgresVersion, resp.JSON200.Status, + postgresConnectionString, ) + return list.RenderTable(table) } diff --git a/pkg/cast/cast.go b/pkg/cast/cast.go index 621ae9a61..89840c895 100644 --- a/pkg/cast/cast.go +++ b/pkg/cast/cast.go @@ -10,6 +10,14 @@ func UintToInt(value uint) int { return math.MaxInt } +// UIntToUInt16 converts a uint to an uint16, handling potential overflow +func UIntToUInt16(value uint) uint16 { + if value <= math.MaxUint16 { + return uint16(value) + } + return math.MaxUint16 +} + // IntToUint converts an int to a uint, handling negative values func IntToUint(value int) uint { if value < 0 { From e93f6fe66d39dda0c3176f909bd65d8aea7eb91a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 04:13:55 +0000 Subject: [PATCH 255/305] chore(deps): bump github.com/golangci/golangci-lint from 1.63.3 to 1.63.4 (#3018) chore(deps): bump github.com/golangci/golangci-lint Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.63.3 to 1.63.4. - [Release notes](https://github.com/golangci/golangci-lint/releases) - [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md) - [Commits](https://github.com/golangci/golangci-lint/compare/v1.63.3...v1.63.4) --- updated-dependencies: - dependency-name: github.com/golangci/golangci-lint dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 2a7b49ac3..8a039b40e 100644 --- a/go.mod +++ b/go.mod @@ -22,7 +22,7 @@ require ( github.com/go-git/go-git/v5 v5.13.1 github.com/go-xmlfmt/xmlfmt v1.1.3 github.com/golang-jwt/jwt/v5 v5.2.1 - github.com/golangci/golangci-lint v1.63.3 + github.com/golangci/golangci-lint v1.63.4 github.com/google/go-github/v62 v62.0.0 github.com/google/go-querystring v1.1.0 github.com/google/uuid v1.6.0 diff --git a/go.sum b/go.sum index 9b19db7e3..221a9a558 100644 --- a/go.sum +++ b/go.sum @@ -403,8 +403,8 @@ github.com/golangci/go-printf-func-name v0.1.0 h1:dVokQP+NMTO7jwO4bwsRwLWeudOVUP github.com/golangci/go-printf-func-name v0.1.0/go.mod h1:wqhWFH5mUdJQhweRnldEywnR5021wTdZSNgwYceV14s= github.com/golangci/gofmt v0.0.0-20241223200906-057b0627d9b9 h1:t5wybL6RtO83VwoMOb7U/Peqe3gGKQlPIC66wXmnkvM= github.com/golangci/gofmt v0.0.0-20241223200906-057b0627d9b9/go.mod h1:Ag3L7sh7E28qAp/5xnpMMTuGYqxLZoSaEHZDkZB1RgU= -github.com/golangci/golangci-lint v1.63.3 h1:Q/UZqLRuqo3mmwA/EN2pq9y+JV4S2IqmqrS3t855ZMc= -github.com/golangci/golangci-lint v1.63.3/go.mod h1:Hx0B7Lg5/NXbaOHem8+KU+ZUIzMI6zNj/7tFwdnn10I= +github.com/golangci/golangci-lint v1.63.4 h1:bJQFQ3hSfUto597dkL7ipDzOxsGEpiWdLiZ359OWOBI= +github.com/golangci/golangci-lint v1.63.4/go.mod h1:Hx0B7Lg5/NXbaOHem8+KU+ZUIzMI6zNj/7tFwdnn10I= github.com/golangci/misspell v0.6.0 h1:JCle2HUTNWirNlDIAUO44hUsKhOFqGPoC4LZxlaSXDs= github.com/golangci/misspell v0.6.0/go.mod h1:keMNyY6R9isGaSAu+4Q8NMBwMPkh15Gtc8UCVoDtAWo= github.com/golangci/plugin-module-register v0.1.1 h1:TCmesur25LnyJkpsVrupv1Cdzo+2f7zX0H6Jkw1Ol6c= From 7b4a96844cf6262c4f4f6d5240b0554f1e58643b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 12:43:29 +0800 Subject: [PATCH 256/305] chore(deps): bump golang.org/x/term from 0.27.0 to 0.28.0 (#3017) --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 8a039b40e..0e1a0ae0a 100644 --- a/go.mod +++ b/go.mod @@ -49,7 +49,7 @@ require ( go.opentelemetry.io/otel v1.33.0 golang.org/x/mod v0.22.0 golang.org/x/oauth2 v0.24.0 - golang.org/x/term v0.27.0 + golang.org/x/term v0.28.0 google.golang.org/grpc v1.69.2 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.12.0 @@ -324,7 +324,7 @@ require ( golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.10.0 // indirect - golang.org/x/sys v0.28.0 // indirect + golang.org/x/sys v0.29.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/tools v0.28.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 // indirect diff --git a/go.sum b/go.sum index 221a9a558..947e58501 100644 --- a/go.sum +++ b/go.sum @@ -1267,8 +1267,8 @@ golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= +golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1284,8 +1284,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= -golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= -golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= +golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= +golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= From 96de7636320be74c61b489c9112fc5b0ad655bff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 13:12:48 +0800 Subject: [PATCH 257/305] chore(deps): bump golang.org/x/oauth2 from 0.24.0 to 0.25.0 (#3016) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 0e1a0ae0a..62b544b34 100644 --- a/go.mod +++ b/go.mod @@ -48,7 +48,7 @@ require ( github.com/zalando/go-keyring v0.2.6 go.opentelemetry.io/otel v1.33.0 golang.org/x/mod v0.22.0 - golang.org/x/oauth2 v0.24.0 + golang.org/x/oauth2 v0.25.0 golang.org/x/term v0.28.0 google.golang.org/grpc v1.69.2 gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 947e58501..8b6bf5eda 100644 --- a/go.sum +++ b/go.sum @@ -1180,8 +1180,8 @@ golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4Iltr golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE= -golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.25.0 h1:CY4y7XT9v0cRI9oupztF8AgiIu99L/ksR/Xp/6jrZ70= +golang.org/x/oauth2 v0.25.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= From 8e17f033bc6bd7b5e0bf0dd3336affd87844a79f Mon Sep 17 00:00:00 2001 From: Lakshan Perera Date: Tue, 7 Jan 2025 10:50:46 +1100 Subject: [PATCH 258/305] fix: pass NPM_CONFIG_REGISTRY env variable when bundling functions --- internal/functions/deploy/bundle.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/functions/deploy/bundle.go b/internal/functions/deploy/bundle.go index 0119a559c..02f31863f 100644 --- a/internal/functions/deploy/bundle.go +++ b/internal/functions/deploy/bundle.go @@ -57,12 +57,16 @@ func (b *dockerBundler) Bundle(ctx context.Context, entrypoint string, importMap if viper.GetBool("DEBUG") { cmd = append(cmd, "--verbose") } + env := []string{} + if custom_registry := os.Getenv("NPM_CONFIG_REGISTRY"); custom_registry != "" { + env = append(env, "NPM_CONFIG_REGISTRY="+custom_registry) + } // Run bundle if err := utils.DockerRunOnceWithConfig( ctx, container.Config{ Image: utils.Config.EdgeRuntime.Image, - Env: []string{}, + Env: env, Cmd: cmd, WorkingDir: utils.ToDockerPath(cwd), }, From 805dcd08c6a7c95a2e6da96a6e4bf10f42a29dbd Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Tue, 7 Jan 2025 13:21:00 +0800 Subject: [PATCH 259/305] feat: support restoring local db from backup (#3015) --- cmd/db.go | 6 +- internal/db/start/start.go | 42 ++++- internal/db/start/start_test.go | 16 +- internal/db/start/templates/restore.sh | 41 +++++ internal/db/start/templates/schema.sql | 233 ------------------------ internal/db/start/templates/webhook.sql | 232 +++++++++++++++++++++++ internal/start/start.go | 2 +- 7 files changed, 325 insertions(+), 247 deletions(-) create mode 100755 internal/db/start/templates/restore.sh create mode 100644 internal/db/start/templates/webhook.sql diff --git a/cmd/db.go b/cmd/db.go index 13f29401f..bcc7ac5e7 100644 --- a/cmd/db.go +++ b/cmd/db.go @@ -219,11 +219,13 @@ var ( }, } + fromBackup string + dbStartCmd = &cobra.Command{ Use: "start", Short: "Starts local Postgres database", RunE: func(cmd *cobra.Command, args []string) error { - return start.Run(cmd.Context(), afero.NewOsFs()) + return start.Run(cmd.Context(), fromBackup, afero.NewOsFs()) }, } @@ -329,6 +331,8 @@ func init() { lintFlags.Var(&lintFailOn, "fail-on", "Error level to exit with non-zero status.") dbCmd.AddCommand(dbLintCmd) // Build start command + startFlags := dbStartCmd.Flags() + startFlags.StringVar(&fromBackup, "from-backup", "", "Path to a logical backup file.") dbCmd.AddCommand(dbStartCmd) // Build test command dbCmd.AddCommand(dbTestCmd) diff --git a/internal/db/start/start.go b/internal/db/start/start.go index c4722f22f..aa8b9cee5 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "os" + "path/filepath" "strconv" "strings" "time" @@ -29,11 +30,15 @@ var ( HealthTimeout = 120 * time.Second //go:embed templates/schema.sql initialSchema string + //go:embed templates/webhook.sql + webhookSchema string //go:embed templates/_supabase.sql _supabaseSchema string + //go:embed templates/restore.sh + restoreScript string ) -func Run(ctx context.Context, fsys afero.Fs) error { +func Run(ctx context.Context, fromBackup string, fsys afero.Fs) error { if err := utils.LoadConfigFS(fsys); err != nil { return err } @@ -43,7 +48,7 @@ func Run(ctx context.Context, fsys afero.Fs) error { } else if !errors.Is(err, utils.ErrNotRunning) { return err } - err := StartDatabase(ctx, fsys, os.Stderr) + err := StartDatabase(ctx, fromBackup, fsys, os.Stderr) if err != nil { if err := utils.DockerRemoveAll(context.Background(), os.Stderr, utils.Config.ProjectId); err != nil { fmt.Fprintln(os.Stderr, err) @@ -86,6 +91,7 @@ cat <<'EOF' > /etc/postgresql-custom/pgsodium_root.key && \ cat <<'EOF' >> /etc/postgresql/postgresql.conf && \ docker-entrypoint.sh postgres -D /etc/postgresql ` + initialSchema + ` +` + webhookSchema + ` ` + _supabaseSchema + ` EOF ` + utils.Config.Db.RootKey + ` @@ -116,7 +122,7 @@ func NewHostConfig() container.HostConfig { return hostConfig } -func StartDatabase(ctx context.Context, fsys afero.Fs, w io.Writer, options ...func(*pgx.ConnConfig)) error { +func StartDatabase(ctx context.Context, fromBackup string, fsys afero.Fs, w io.Writer, options ...func(*pgx.ConnConfig)) error { config := NewContainerConfig() hostConfig := NewHostConfig() networkingConfig := network.NetworkingConfig{ @@ -137,11 +143,35 @@ EOF EOF`} hostConfig.Tmpfs = map[string]string{"/docker-entrypoint-initdb.d": ""} } + if len(fromBackup) > 0 { + config.Entrypoint = []string{"sh", "-c", ` +cat <<'EOF' > /etc/postgresql.schema.sql && \ +cat <<'EOF' > /docker-entrypoint-initdb.d/migrate.sh && \ +cat <<'EOF' > /etc/postgresql-custom/pgsodium_root.key && \ +cat <<'EOF' >> /etc/postgresql/postgresql.conf && \ +docker-entrypoint.sh postgres -D /etc/postgresql +` + initialSchema + ` +` + _supabaseSchema + ` +EOF +` + restoreScript + ` +EOF +` + utils.Config.Db.RootKey + ` +EOF +` + utils.Config.Db.Settings.ToPostgresConfig() + ` +EOF`} + if !filepath.IsAbs(fromBackup) { + fromBackup = filepath.Join(utils.CurrentDirAbs, fromBackup) + } + hostConfig.Binds = append(hostConfig.Binds, utils.ToDockerPath(fromBackup)+":/etc/backup.sql:ro") + } // Creating volume will not override existing volume, so we must inspect explicitly _, err := utils.Docker.VolumeInspect(ctx, utils.DbId) utils.NoBackupVolume = client.IsErrNotFound(err) if utils.NoBackupVolume { fmt.Fprintln(w, "Starting database...") + } else if len(fromBackup) > 0 { + utils.CmdSuggestion = fmt.Sprintf("Run %s to remove existing docker volumes.", utils.Aqua("supabase stop --no-backup")) + return errors.Errorf("backup volume already exists") } else { fmt.Fprintln(w, "Starting database from backup...") } @@ -152,7 +182,11 @@ EOF`} return err } // Initialize if we are on PG14 and there's no existing db volume - if utils.NoBackupVolume { + if len(fromBackup) > 0 { + if err := initSchema15(ctx, utils.DbId); err != nil { + return err + } + } else if utils.NoBackupVolume { if err := SetupLocalDatabase(ctx, "", fsys, w, options...); err != nil { return err } diff --git a/internal/db/start/start_test.go b/internal/db/start/start_test.go index 475562f2f..afdb8e28b 100644 --- a/internal/db/start/start_test.go +++ b/internal/db/start/start_test.go @@ -89,7 +89,7 @@ func TestStartDatabase(t *testing.T) { conn.Query(roles). Reply("CREATE ROLE") // Run test - err := StartDatabase(context.Background(), fsys, io.Discard, conn.Intercept) + err := StartDatabase(context.Background(), "", fsys, io.Discard, conn.Intercept) // Check error assert.NoError(t, err) assert.Empty(t, apitest.ListUnmatchedRequests()) @@ -124,7 +124,7 @@ func TestStartDatabase(t *testing.T) { }, }}) // Run test - err := StartDatabase(context.Background(), fsys, io.Discard) + err := StartDatabase(context.Background(), "", fsys, io.Discard) // Check error assert.NoError(t, err) assert.Empty(t, apitest.ListUnmatchedRequests()) @@ -149,7 +149,7 @@ func TestStartDatabase(t *testing.T) { Get("/v" + utils.Docker.ClientVersion() + "/images/" + utils.GetRegistryImageUrl(utils.Config.Db.Image) + "/json"). Reply(http.StatusInternalServerError) // Run test - err := StartDatabase(context.Background(), fsys, io.Discard) + err := StartDatabase(context.Background(), "", fsys, io.Discard) // Check error assert.ErrorContains(t, err, "request returned Internal Server Error for API route and version") assert.Empty(t, apitest.ListUnmatchedRequests()) @@ -161,7 +161,7 @@ func TestStartCommand(t *testing.T) { // Setup in-memory fs fsys := afero.NewMemMapFs() // Run test - err := Run(context.Background(), fsys) + err := Run(context.Background(), "", fsys) // Check error assert.ErrorIs(t, err, os.ErrNotExist) }) @@ -177,7 +177,7 @@ func TestStartCommand(t *testing.T) { Get("/v" + utils.Docker.ClientVersion() + "/containers"). ReplyError(errors.New("network error")) // Run test - err := Run(context.Background(), fsys) + err := Run(context.Background(), "", fsys) // Check error assert.ErrorContains(t, err, "network error") assert.Empty(t, apitest.ListUnmatchedRequests()) @@ -195,7 +195,7 @@ func TestStartCommand(t *testing.T) { Reply(http.StatusOK). JSON(types.ContainerJSON{}) // Run test - err := Run(context.Background(), fsys) + err := Run(context.Background(), "", fsys) // Check error assert.NoError(t, err) assert.Empty(t, apitest.ListUnmatchedRequests()) @@ -221,7 +221,7 @@ func TestStartCommand(t *testing.T) { // Cleanup resources apitest.MockDockerStop(utils.Docker) // Run test - err := Run(context.Background(), fsys) + err := Run(context.Background(), "", fsys) // Check error assert.ErrorContains(t, err, "network error") assert.Empty(t, apitest.ListUnmatchedRequests()) @@ -350,7 +350,7 @@ func TestStartDatabaseWithCustomSettings(t *testing.T) { defer conn.Close(t) // Run test - err := StartDatabase(context.Background(), fsys, io.Discard, conn.Intercept) + err := StartDatabase(context.Background(), "", fsys, io.Discard, conn.Intercept) // Check error assert.NoError(t, err) diff --git a/internal/db/start/templates/restore.sh b/internal/db/start/templates/restore.sh new file mode 100755 index 000000000..26f6418e3 --- /dev/null +++ b/internal/db/start/templates/restore.sh @@ -0,0 +1,41 @@ +#!/bin/sh +set -eu + +####################################### +# Used by both ami and docker builds to initialise database schema. +# Env vars: +# POSTGRES_DB defaults to postgres +# POSTGRES_HOST defaults to localhost +# POSTGRES_PORT defaults to 5432 +# POSTGRES_PASSWORD defaults to "" +# USE_DBMATE defaults to "" +# Exit code: +# 0 if migration succeeds, non-zero on error. +####################################### + +export PGDATABASE="${POSTGRES_DB:-postgres}" +export PGHOST="${POSTGRES_HOST:-localhost}" +export PGPORT="${POSTGRES_PORT:-5432}" +export PGPASSWORD="${POSTGRES_PASSWORD:-}" + +echo "$0: restoring roles" +cat "/etc/backup.sql" \ +| grep 'CREATE ROLE' \ +| grep -v 'supabase_admin' \ +| psql -v ON_ERROR_STOP=1 --no-password --no-psqlrc -U supabase_admin + +echo "$0: restoring schema" +cat "/etc/backup.sql" \ +| sed -E 's/^CREATE VIEW /CREATE OR REPLACE VIEW /' \ +| sed -E 's/^CREATE FUNCTION /CREATE OR REPLACE FUNCTION /' \ +| sed -E 's/^CREATE TRIGGER /CREATE OR REPLACE TRIGGER /' \ +| sed -E 's/^GRANT ALL ON FUNCTION graphql_public\./-- &/' \ +| sed -E 's/^CREATE ROLE /-- &/' \ +| psql -v ON_ERROR_STOP=1 --no-password --no-psqlrc -U supabase_admin + +# run any post migration script to update role passwords +postinit="/etc/postgresql.schema.sql" +if [ -e "$postinit" ]; then + echo "$0: running $postinit" + psql -v ON_ERROR_STOP=1 --no-password --no-psqlrc -U supabase_admin -f "$postinit" +fi diff --git a/internal/db/start/templates/schema.sql b/internal/db/start/templates/schema.sql index 534dd1207..810d9506e 100644 --- a/internal/db/start/templates/schema.sql +++ b/internal/db/start/templates/schema.sql @@ -14,236 +14,3 @@ ALTER USER supabase_read_only_user WITH PASSWORD :'pgpass'; create schema if not exists _realtime; alter schema _realtime owner to postgres; - -BEGIN; - --- Create pg_net extension -CREATE EXTENSION IF NOT EXISTS pg_net SCHEMA extensions; - --- Create supabase_functions schema -CREATE SCHEMA supabase_functions AUTHORIZATION supabase_admin; - -GRANT USAGE ON SCHEMA supabase_functions TO postgres, anon, authenticated, service_role; -ALTER DEFAULT PRIVILEGES IN SCHEMA supabase_functions GRANT ALL ON TABLES TO postgres, anon, authenticated, service_role; -ALTER DEFAULT PRIVILEGES IN SCHEMA supabase_functions GRANT ALL ON FUNCTIONS TO postgres, anon, authenticated, service_role; -ALTER DEFAULT PRIVILEGES IN SCHEMA supabase_functions GRANT ALL ON SEQUENCES TO postgres, anon, authenticated, service_role; - --- supabase_functions.migrations definition -CREATE TABLE supabase_functions.migrations ( - version text PRIMARY KEY, - inserted_at timestamptz NOT NULL DEFAULT NOW() -); - --- Initial supabase_functions migration -INSERT INTO supabase_functions.migrations (version) VALUES ('initial'); - --- supabase_functions.hooks definition -CREATE TABLE supabase_functions.hooks ( - id bigserial PRIMARY KEY, - hook_table_id integer NOT NULL, - hook_name text NOT NULL, - created_at timestamptz NOT NULL DEFAULT NOW(), - request_id bigint -); -CREATE INDEX supabase_functions_hooks_request_id_idx ON supabase_functions.hooks USING btree (request_id); -CREATE INDEX supabase_functions_hooks_h_table_id_h_name_idx ON supabase_functions.hooks USING btree (hook_table_id, hook_name); -COMMENT ON TABLE supabase_functions.hooks IS 'Supabase Functions Hooks: Audit trail for triggered hooks.'; - -CREATE FUNCTION supabase_functions.http_request() - RETURNS trigger - LANGUAGE plpgsql - AS $function$ - DECLARE - request_id bigint; - payload jsonb; - url text := TG_ARGV[0]::text; - method text := TG_ARGV[1]::text; - headers jsonb DEFAULT '{}'::jsonb; - params jsonb DEFAULT '{}'::jsonb; - timeout_ms integer DEFAULT 1000; - BEGIN - IF url IS NULL OR url = 'null' THEN - RAISE EXCEPTION 'url argument is missing'; - END IF; - - IF method IS NULL OR method = 'null' THEN - RAISE EXCEPTION 'method argument is missing'; - END IF; - - IF TG_ARGV[2] IS NULL OR TG_ARGV[2] = 'null' THEN - headers = '{"Content-Type": "application/json"}'::jsonb; - ELSE - headers = TG_ARGV[2]::jsonb; - END IF; - - IF TG_ARGV[3] IS NULL OR TG_ARGV[3] = 'null' THEN - params = '{}'::jsonb; - ELSE - params = TG_ARGV[3]::jsonb; - END IF; - - IF TG_ARGV[4] IS NULL OR TG_ARGV[4] = 'null' THEN - timeout_ms = 1000; - ELSE - timeout_ms = TG_ARGV[4]::integer; - END IF; - - CASE - WHEN method = 'GET' THEN - SELECT http_get INTO request_id FROM net.http_get( - url, - params, - headers, - timeout_ms - ); - WHEN method = 'POST' THEN - payload = jsonb_build_object( - 'old_record', OLD, - 'record', NEW, - 'type', TG_OP, - 'table', TG_TABLE_NAME, - 'schema', TG_TABLE_SCHEMA - ); - - SELECT http_post INTO request_id FROM net.http_post( - url, - payload, - params, - headers, - timeout_ms - ); - ELSE - RAISE EXCEPTION 'method argument % is invalid', method; - END CASE; - - INSERT INTO supabase_functions.hooks - (hook_table_id, hook_name, request_id) - VALUES - (TG_RELID, TG_NAME, request_id); - - RETURN NEW; - END -$function$; - --- Supabase super admin -DO -$$ -BEGIN - IF NOT EXISTS ( - SELECT 1 - FROM pg_roles - WHERE rolname = 'supabase_functions_admin' - ) - THEN - CREATE USER supabase_functions_admin NOINHERIT CREATEROLE LOGIN NOREPLICATION; - END IF; -END -$$; - -GRANT ALL PRIVILEGES ON SCHEMA supabase_functions TO supabase_functions_admin; -GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA supabase_functions TO supabase_functions_admin; -GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA supabase_functions TO supabase_functions_admin; -ALTER USER supabase_functions_admin SET search_path = "supabase_functions"; -ALTER table "supabase_functions".migrations OWNER TO supabase_functions_admin; -ALTER table "supabase_functions".hooks OWNER TO supabase_functions_admin; -ALTER function "supabase_functions".http_request() OWNER TO supabase_functions_admin; -GRANT supabase_functions_admin TO postgres; - --- Remove unused supabase_pg_net_admin role -DO -$$ -BEGIN - IF EXISTS ( - SELECT 1 - FROM pg_roles - WHERE rolname = 'supabase_pg_net_admin' - ) - THEN - REASSIGN OWNED BY supabase_pg_net_admin TO supabase_admin; - DROP OWNED BY supabase_pg_net_admin; - DROP ROLE supabase_pg_net_admin; - END IF; -END -$$; - --- pg_net grants when extension is already enabled -DO -$$ -BEGIN - IF EXISTS ( - SELECT 1 - FROM pg_extension - WHERE extname = 'pg_net' - ) - THEN - GRANT USAGE ON SCHEMA net TO supabase_functions_admin, postgres, anon, authenticated, service_role; - - ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER; - ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER; - - ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net; - ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net; - - REVOKE ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC; - REVOKE ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC; - - GRANT EXECUTE ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role; - GRANT EXECUTE ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role; - END IF; -END -$$; - --- Event trigger for pg_net -CREATE OR REPLACE FUNCTION extensions.grant_pg_net_access() -RETURNS event_trigger -LANGUAGE plpgsql -AS $$ -BEGIN - IF EXISTS ( - SELECT 1 - FROM pg_event_trigger_ddl_commands() AS ev - JOIN pg_extension AS ext - ON ev.objid = ext.oid - WHERE ext.extname = 'pg_net' - ) - THEN - GRANT USAGE ON SCHEMA net TO supabase_functions_admin, postgres, anon, authenticated, service_role; - - ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER; - ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER; - - ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net; - ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net; - - REVOKE ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC; - REVOKE ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC; - - GRANT EXECUTE ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role; - GRANT EXECUTE ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role; - END IF; -END; -$$; -COMMENT ON FUNCTION extensions.grant_pg_net_access IS 'Grants access to pg_net'; - -DO -$$ -BEGIN - IF NOT EXISTS ( - SELECT 1 - FROM pg_event_trigger - WHERE evtname = 'issue_pg_net_access' - ) THEN - CREATE EVENT TRIGGER issue_pg_net_access ON ddl_command_end WHEN TAG IN ('CREATE EXTENSION') - EXECUTE PROCEDURE extensions.grant_pg_net_access(); - END IF; -END -$$; - -INSERT INTO supabase_functions.migrations (version) VALUES ('20210809183423_update_grants'); - -ALTER function supabase_functions.http_request() SECURITY DEFINER; -ALTER function supabase_functions.http_request() SET search_path = supabase_functions; -REVOKE ALL ON FUNCTION supabase_functions.http_request() FROM PUBLIC; -GRANT EXECUTE ON FUNCTION supabase_functions.http_request() TO postgres, anon, authenticated, service_role; - -COMMIT; diff --git a/internal/db/start/templates/webhook.sql b/internal/db/start/templates/webhook.sql new file mode 100644 index 000000000..52cd09747 --- /dev/null +++ b/internal/db/start/templates/webhook.sql @@ -0,0 +1,232 @@ +BEGIN; + +-- Create pg_net extension +CREATE EXTENSION IF NOT EXISTS pg_net SCHEMA extensions; + +-- Create supabase_functions schema +CREATE SCHEMA supabase_functions AUTHORIZATION supabase_admin; + +GRANT USAGE ON SCHEMA supabase_functions TO postgres, anon, authenticated, service_role; +ALTER DEFAULT PRIVILEGES IN SCHEMA supabase_functions GRANT ALL ON TABLES TO postgres, anon, authenticated, service_role; +ALTER DEFAULT PRIVILEGES IN SCHEMA supabase_functions GRANT ALL ON FUNCTIONS TO postgres, anon, authenticated, service_role; +ALTER DEFAULT PRIVILEGES IN SCHEMA supabase_functions GRANT ALL ON SEQUENCES TO postgres, anon, authenticated, service_role; + +-- supabase_functions.migrations definition +CREATE TABLE supabase_functions.migrations ( + version text PRIMARY KEY, + inserted_at timestamptz NOT NULL DEFAULT NOW() +); + +-- Initial supabase_functions migration +INSERT INTO supabase_functions.migrations (version) VALUES ('initial'); + +-- supabase_functions.hooks definition +CREATE TABLE supabase_functions.hooks ( + id bigserial PRIMARY KEY, + hook_table_id integer NOT NULL, + hook_name text NOT NULL, + created_at timestamptz NOT NULL DEFAULT NOW(), + request_id bigint +); +CREATE INDEX supabase_functions_hooks_request_id_idx ON supabase_functions.hooks USING btree (request_id); +CREATE INDEX supabase_functions_hooks_h_table_id_h_name_idx ON supabase_functions.hooks USING btree (hook_table_id, hook_name); +COMMENT ON TABLE supabase_functions.hooks IS 'Supabase Functions Hooks: Audit trail for triggered hooks.'; + +CREATE FUNCTION supabase_functions.http_request() + RETURNS trigger + LANGUAGE plpgsql + AS $function$ + DECLARE + request_id bigint; + payload jsonb; + url text := TG_ARGV[0]::text; + method text := TG_ARGV[1]::text; + headers jsonb DEFAULT '{}'::jsonb; + params jsonb DEFAULT '{}'::jsonb; + timeout_ms integer DEFAULT 1000; + BEGIN + IF url IS NULL OR url = 'null' THEN + RAISE EXCEPTION 'url argument is missing'; + END IF; + + IF method IS NULL OR method = 'null' THEN + RAISE EXCEPTION 'method argument is missing'; + END IF; + + IF TG_ARGV[2] IS NULL OR TG_ARGV[2] = 'null' THEN + headers = '{"Content-Type": "application/json"}'::jsonb; + ELSE + headers = TG_ARGV[2]::jsonb; + END IF; + + IF TG_ARGV[3] IS NULL OR TG_ARGV[3] = 'null' THEN + params = '{}'::jsonb; + ELSE + params = TG_ARGV[3]::jsonb; + END IF; + + IF TG_ARGV[4] IS NULL OR TG_ARGV[4] = 'null' THEN + timeout_ms = 1000; + ELSE + timeout_ms = TG_ARGV[4]::integer; + END IF; + + CASE + WHEN method = 'GET' THEN + SELECT http_get INTO request_id FROM net.http_get( + url, + params, + headers, + timeout_ms + ); + WHEN method = 'POST' THEN + payload = jsonb_build_object( + 'old_record', OLD, + 'record', NEW, + 'type', TG_OP, + 'table', TG_TABLE_NAME, + 'schema', TG_TABLE_SCHEMA + ); + + SELECT http_post INTO request_id FROM net.http_post( + url, + payload, + params, + headers, + timeout_ms + ); + ELSE + RAISE EXCEPTION 'method argument % is invalid', method; + END CASE; + + INSERT INTO supabase_functions.hooks + (hook_table_id, hook_name, request_id) + VALUES + (TG_RELID, TG_NAME, request_id); + + RETURN NEW; + END +$function$; + +-- Supabase super admin +DO +$$ +BEGIN + IF NOT EXISTS ( + SELECT 1 + FROM pg_roles + WHERE rolname = 'supabase_functions_admin' + ) + THEN + CREATE USER supabase_functions_admin NOINHERIT CREATEROLE LOGIN NOREPLICATION; + END IF; +END +$$; + +GRANT ALL PRIVILEGES ON SCHEMA supabase_functions TO supabase_functions_admin; +GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA supabase_functions TO supabase_functions_admin; +GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA supabase_functions TO supabase_functions_admin; +ALTER USER supabase_functions_admin SET search_path = "supabase_functions"; +ALTER table "supabase_functions".migrations OWNER TO supabase_functions_admin; +ALTER table "supabase_functions".hooks OWNER TO supabase_functions_admin; +ALTER function "supabase_functions".http_request() OWNER TO supabase_functions_admin; +GRANT supabase_functions_admin TO postgres; + +-- Remove unused supabase_pg_net_admin role +DO +$$ +BEGIN + IF EXISTS ( + SELECT 1 + FROM pg_roles + WHERE rolname = 'supabase_pg_net_admin' + ) + THEN + REASSIGN OWNED BY supabase_pg_net_admin TO supabase_admin; + DROP OWNED BY supabase_pg_net_admin; + DROP ROLE supabase_pg_net_admin; + END IF; +END +$$; + +-- pg_net grants when extension is already enabled +DO +$$ +BEGIN + IF EXISTS ( + SELECT 1 + FROM pg_extension + WHERE extname = 'pg_net' + ) + THEN + GRANT USAGE ON SCHEMA net TO supabase_functions_admin, postgres, anon, authenticated, service_role; + + ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER; + ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER; + + ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net; + ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net; + + REVOKE ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC; + REVOKE ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC; + + GRANT EXECUTE ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role; + GRANT EXECUTE ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role; + END IF; +END +$$; + +-- Event trigger for pg_net +CREATE OR REPLACE FUNCTION extensions.grant_pg_net_access() +RETURNS event_trigger +LANGUAGE plpgsql +AS $$ +BEGIN + IF EXISTS ( + SELECT 1 + FROM pg_event_trigger_ddl_commands() AS ev + JOIN pg_extension AS ext + ON ev.objid = ext.oid + WHERE ext.extname = 'pg_net' + ) + THEN + GRANT USAGE ON SCHEMA net TO supabase_functions_admin, postgres, anon, authenticated, service_role; + + ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER; + ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SECURITY DEFINER; + + ALTER function net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net; + ALTER function net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) SET search_path = net; + + REVOKE ALL ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC; + REVOKE ALL ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) FROM PUBLIC; + + GRANT EXECUTE ON FUNCTION net.http_get(url text, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role; + GRANT EXECUTE ON FUNCTION net.http_post(url text, body jsonb, params jsonb, headers jsonb, timeout_milliseconds integer) TO supabase_functions_admin, postgres, anon, authenticated, service_role; + END IF; +END; +$$; +COMMENT ON FUNCTION extensions.grant_pg_net_access IS 'Grants access to pg_net'; + +DO +$$ +BEGIN + IF NOT EXISTS ( + SELECT 1 + FROM pg_event_trigger + WHERE evtname = 'issue_pg_net_access' + ) THEN + CREATE EVENT TRIGGER issue_pg_net_access ON ddl_command_end WHEN TAG IN ('CREATE EXTENSION') + EXECUTE PROCEDURE extensions.grant_pg_net_access(); + END IF; +END +$$; + +INSERT INTO supabase_functions.migrations (version) VALUES ('20210809183423_update_grants'); + +ALTER function supabase_functions.http_request() SECURITY DEFINER; +ALTER function supabase_functions.http_request() SET search_path = supabase_functions; +REVOKE ALL ON FUNCTION supabase_functions.http_request() FROM PUBLIC; +GRANT EXECUTE ON FUNCTION supabase_functions.http_request() TO postgres, anon, authenticated, service_role; + +COMMIT; diff --git a/internal/start/start.go b/internal/start/start.go index f5a24d8c4..c3684c14b 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -162,7 +162,7 @@ func run(p utils.Program, ctx context.Context, fsys afero.Fs, excludedContainers // Start Postgres. w := utils.StatusWriter{Program: p} if dbConfig.Host == utils.DbId { - if err := start.StartDatabase(ctx, fsys, w, options...); err != nil { + if err := start.StartDatabase(ctx, "", fsys, w, options...); err != nil { return err } } From 1b58c87b51c3d1399ba6e0220eb59da3a067cbbf Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 8 Jan 2025 13:24:29 +0800 Subject: [PATCH 260/305] feat: support env loading for all string fields (#3019) * feat: support env loading for all string fields * chore: update unit tests * chore: assert env loaded for backwards compatibility --- internal/db/branch/switch_/switch__test.go | 2 +- internal/start/start_test.go | 2 +- internal/status/status_test.go | 2 +- pkg/config/config.go | 176 +++++++++++++-------- 4 files changed, 113 insertions(+), 69 deletions(-) diff --git a/internal/db/branch/switch_/switch__test.go b/internal/db/branch/switch_/switch__test.go index 7c70959ce..722229b79 100644 --- a/internal/db/branch/switch_/switch__test.go +++ b/internal/db/branch/switch_/switch__test.go @@ -79,7 +79,7 @@ func TestSwitchCommand(t *testing.T) { // Run test err := Run(context.Background(), "target", fsys) // Check error - assert.ErrorContains(t, err, "toml: line 0: unexpected EOF; expected key separator '='") + assert.ErrorContains(t, err, "toml: expected = after a key, but the document ends there") }) t.Run("throws error on missing database", func(t *testing.T) { diff --git a/internal/start/start_test.go b/internal/start/start_test.go index 6d07eb364..bbd73ab93 100644 --- a/internal/start/start_test.go +++ b/internal/start/start_test.go @@ -37,7 +37,7 @@ func TestStartCommand(t *testing.T) { // Run test err := Run(context.Background(), fsys, []string{}, false) // Check error - assert.ErrorContains(t, err, "toml: line 0: unexpected EOF; expected key separator '='") + assert.ErrorContains(t, err, "toml: expected = after a key, but the document ends there") }) t.Run("throws error on missing docker", func(t *testing.T) { diff --git a/internal/status/status_test.go b/internal/status/status_test.go index 391a8c998..175d28ca0 100644 --- a/internal/status/status_test.go +++ b/internal/status/status_test.go @@ -59,7 +59,7 @@ func TestStatusCommand(t *testing.T) { // Run test err := Run(context.Background(), CustomName{}, utils.OutputPretty, fsys) // Check error - assert.ErrorContains(t, err, "toml: line 0: unexpected EOF; expected key separator '='") + assert.ErrorContains(t, err, "toml: expected = after a key, but the document ends there") }) t.Run("throws error on missing docker", func(t *testing.T) { diff --git a/pkg/config/config.go b/pkg/config/config.go index 6903b6b24..35b84eb68 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -16,6 +16,7 @@ import ( "os" "path" "path/filepath" + "reflect" "regexp" "sort" "strconv" @@ -378,9 +379,64 @@ func (c *config) Eject(w io.Writer) error { return nil } +// Loads custom config file to struct fields tagged with toml. +func (c *config) loadFromFile(filename string, fsys fs.FS) error { + v := viper.New() + v.SetConfigType("toml") + // Load default values + var buf bytes.Buffer + if err := initConfigTemplate.Option("missingkey=zero").Execute(&buf, c); err != nil { + return errors.Errorf("failed to initialise template config: %w", err) + } else if err := c.loadFromReader(v, &buf); err != nil { + return err + } + // Load custom config + if ext := filepath.Ext(filename); len(ext) > 0 { + v.SetConfigType(ext[1:]) + } + f, err := fsys.Open(filename) + if err != nil { + return errors.Errorf("failed to read file config: %w", err) + } + defer f.Close() + return c.loadFromReader(v, f) +} + +func (c *config) loadFromReader(v *viper.Viper, r io.Reader) error { + if err := v.MergeConfig(r); err != nil { + return errors.Errorf("failed to merge config: %w", err) + } + // Manually parse [functions.*] to empty struct for backwards compatibility + for key, value := range v.GetStringMap("functions") { + if m, ok := value.(map[string]any); ok && len(m) == 0 { + v.Set("functions."+key, function{}) + } + } + if err := v.UnmarshalExact(c, viper.DecodeHook(mapstructure.ComposeDecodeHookFunc( + mapstructure.StringToTimeDurationHookFunc(), + mapstructure.StringToIPHookFunc(), + mapstructure.StringToSliceHookFunc(","), + mapstructure.TextUnmarshallerHookFunc(), + LoadEnvHook, + // TODO: include decrypt secret hook + )), func(dc *mapstructure.DecoderConfig) { + dc.TagName = "toml" + dc.Squash = true + }); err != nil { + return errors.Errorf("failed to parse config: %w", err) + } + return nil +} + +// Loads envs prefixed with supabase_ to struct fields tagged with mapstructure. func (c *config) loadFromEnv() error { - // Allow overriding base config object with automatic env - // Ref: https://github.com/spf13/viper/issues/761 + v := viper.New() + v.SetEnvPrefix("SUPABASE") + v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) + v.AutomaticEnv() + // Viper does not parse env vars automatically. Instead of calling viper.BindEnv + // per key, we decode all keys from an existing struct, and merge them to viper. + // Ref: https://github.com/spf13/viper/issues/761#issuecomment-859306364 envKeysMap := map[string]interface{}{} if dec, err := mapstructure.NewDecoder(&mapstructure.DecoderConfig{ Result: &envKeysMap, @@ -389,47 +445,32 @@ func (c *config) loadFromEnv() error { return errors.Errorf("failed to create decoder: %w", err) } else if err := dec.Decode(c.baseConfig); err != nil { return errors.Errorf("failed to decode env: %w", err) - } - v := viper.New() - v.SetEnvPrefix("SUPABASE") - v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) - v.AutomaticEnv() - if err := v.MergeConfigMap(envKeysMap); err != nil { - return errors.Errorf("failed to merge config: %w", err) - } else if err := v.Unmarshal(c); err != nil { - return errors.Errorf("failed to parse env to config: %w", err) + } else if err := v.MergeConfigMap(envKeysMap); err != nil { + return errors.Errorf("failed to merge env config: %w", err) + } + // Writes viper state back to config struct, with automatic env substitution + if err := v.UnmarshalExact(c, viper.DecodeHook(mapstructure.ComposeDecodeHookFunc( + mapstructure.StringToTimeDurationHookFunc(), + mapstructure.StringToIPHookFunc(), + mapstructure.StringToSliceHookFunc(","), + mapstructure.TextUnmarshallerHookFunc(), + // TODO: include decrypt secret hook + ))); err != nil { + return errors.Errorf("failed to parse env override: %w", err) } return nil } func (c *config) Load(path string, fsys fs.FS) error { builder := NewPathBuilder(path) - // Load default values - var buf bytes.Buffer - if err := initConfigTemplate.Option("missingkey=zero").Execute(&buf, c); err != nil { - return errors.Errorf("failed to initialise config template: %w", err) - } - dec := toml.NewDecoder(&buf) - if _, err := dec.Decode(c); err != nil { - return errors.Errorf("failed to decode config template: %w", err) - } - if metadata, err := toml.DecodeFS(fsys, builder.ConfigPath, c); err != nil { - cwd, osErr := os.Getwd() - if osErr != nil { - cwd = "current directory" - } - return errors.Errorf("cannot read config in %s: %w", cwd, err) - } else if undecoded := metadata.Undecoded(); len(undecoded) > 0 { - for _, key := range undecoded { - if key[0] != "remotes" { - fmt.Fprintf(os.Stderr, "Unknown config field: [%s]\n", key) - } - } - } // Load secrets from .env file if err := loadDefaultEnv(); err != nil { return err - } else if err := c.loadFromEnv(); err != nil { + } + if err := c.loadFromFile(builder.ConfigPath, fsys); err != nil { + return err + } + if err := c.loadFromEnv(); err != nil { return err } // Generate JWT tokens @@ -619,17 +660,16 @@ func (c *baseConfig) Validate(fsys fs.FS) error { case 15: if len(c.Experimental.OrioleDBVersion) > 0 { c.Db.Image = "supabase/postgres:orioledb-" + c.Experimental.OrioleDBVersion - var err error - if c.Experimental.S3Host, err = maybeLoadEnv(c.Experimental.S3Host); err != nil { + if err := assertEnvLoaded(c.Experimental.S3Host); err != nil { return err } - if c.Experimental.S3Region, err = maybeLoadEnv(c.Experimental.S3Region); err != nil { + if err := assertEnvLoaded(c.Experimental.S3Region); err != nil { return err } - if c.Experimental.S3AccessKey, err = maybeLoadEnv(c.Experimental.S3AccessKey); err != nil { + if err := assertEnvLoaded(c.Experimental.S3AccessKey); err != nil { return err } - if c.Experimental.S3SecretKey, err = maybeLoadEnv(c.Experimental.S3SecretKey); err != nil { + if err := assertEnvLoaded(c.Experimental.S3SecretKey); err != nil { return err } } @@ -666,7 +706,6 @@ func (c *baseConfig) Validate(fsys fs.FS) error { } else if parsed.Host == "" || parsed.Host == c.Hostname { c.Studio.ApiUrl = c.Api.ExternalUrl } - c.Studio.OpenaiApiKey, _ = maybeLoadEnv(c.Studio.OpenaiApiKey) } // Validate smtp config if c.Inbucket.Enabled { @@ -679,12 +718,11 @@ func (c *baseConfig) Validate(fsys fs.FS) error { if c.Auth.SiteUrl == "" { return errors.New("Missing required field in config: auth.site_url") } - var err error - if c.Auth.SiteUrl, err = maybeLoadEnv(c.Auth.SiteUrl); err != nil { + if err := assertEnvLoaded(c.Auth.SiteUrl); err != nil { return err } for i, url := range c.Auth.AdditionalRedirectUrls { - if c.Auth.AdditionalRedirectUrls[i], err = maybeLoadEnv(url); err != nil { + if err := assertEnvLoaded(url); err != nil { return errors.Errorf("Invalid config for auth.additional_redirect_urls[%d]: %v", i, err) } } @@ -749,18 +787,24 @@ func (c *baseConfig) Validate(fsys fs.FS) error { return nil } -func maybeLoadEnv(s string) (string, error) { - matches := envPattern.FindStringSubmatch(s) - if len(matches) == 0 { - return s, nil +func assertEnvLoaded(s string) error { + if matches := envPattern.FindStringSubmatch(s); len(matches) > 1 { + return errors.Errorf(`Error evaluating "%s": environment variable %s is unset.`, s, matches[1]) } + return nil +} - envName := matches[1] - if value := os.Getenv(envName); value != "" { - return value, nil +func LoadEnvHook(f reflect.Kind, t reflect.Kind, data interface{}) (interface{}, error) { + if f != reflect.String || t != reflect.String { + return data, nil } - - return "", errors.Errorf(`Error evaluating "%s": environment variable %s is unset.`, s, envName) + value := data.(string) + if matches := envPattern.FindStringSubmatch(value); len(matches) > 1 { + if v, exists := os.LookupEnv(matches[1]); exists { + value = v + } + } + return value, nil } func truncateText(text string, maxLen int) string { @@ -874,7 +918,7 @@ func (e *email) validate(fsys fs.FS) (err error) { if len(e.Smtp.AdminEmail) == 0 { return errors.New("Missing required field in config: auth.email.smtp.admin_email") } - if e.Smtp.Pass, err = maybeLoadEnv(e.Smtp.Pass); err != nil { + if err := assertEnvLoaded(e.Smtp.Pass); err != nil { return err } } @@ -893,7 +937,7 @@ func (s *sms) validate() (err error) { if len(s.Twilio.AuthToken) == 0 { return errors.New("Missing required field in config: auth.sms.twilio.auth_token") } - if s.Twilio.AuthToken, err = maybeLoadEnv(s.Twilio.AuthToken); err != nil { + if err := assertEnvLoaded(s.Twilio.AuthToken); err != nil { return err } case s.TwilioVerify.Enabled: @@ -906,7 +950,7 @@ func (s *sms) validate() (err error) { if len(s.TwilioVerify.AuthToken) == 0 { return errors.New("Missing required field in config: auth.sms.twilio_verify.auth_token") } - if s.TwilioVerify.AuthToken, err = maybeLoadEnv(s.TwilioVerify.AuthToken); err != nil { + if err := assertEnvLoaded(s.TwilioVerify.AuthToken); err != nil { return err } case s.Messagebird.Enabled: @@ -916,7 +960,7 @@ func (s *sms) validate() (err error) { if len(s.Messagebird.AccessKey) == 0 { return errors.New("Missing required field in config: auth.sms.messagebird.access_key") } - if s.Messagebird.AccessKey, err = maybeLoadEnv(s.Messagebird.AccessKey); err != nil { + if err := assertEnvLoaded(s.Messagebird.AccessKey); err != nil { return err } case s.Textlocal.Enabled: @@ -926,7 +970,7 @@ func (s *sms) validate() (err error) { if len(s.Textlocal.ApiKey) == 0 { return errors.New("Missing required field in config: auth.sms.textlocal.api_key") } - if s.Textlocal.ApiKey, err = maybeLoadEnv(s.Textlocal.ApiKey); err != nil { + if err := assertEnvLoaded(s.Textlocal.ApiKey); err != nil { return err } case s.Vonage.Enabled: @@ -939,10 +983,10 @@ func (s *sms) validate() (err error) { if len(s.Vonage.ApiSecret) == 0 { return errors.New("Missing required field in config: auth.sms.vonage.api_secret") } - if s.Vonage.ApiKey, err = maybeLoadEnv(s.Vonage.ApiKey); err != nil { + if err := assertEnvLoaded(s.Vonage.ApiKey); err != nil { return err } - if s.Vonage.ApiSecret, err = maybeLoadEnv(s.Vonage.ApiSecret); err != nil { + if err := assertEnvLoaded(s.Vonage.ApiSecret); err != nil { return err } case s.EnableSignup: @@ -969,16 +1013,16 @@ func (e external) validate() (err error) { if !sliceContains([]string{"apple", "google"}, ext) && provider.Secret == "" { return errors.Errorf("Missing required field in config: auth.external.%s.secret", ext) } - if provider.ClientId, err = maybeLoadEnv(provider.ClientId); err != nil { + if err := assertEnvLoaded(provider.ClientId); err != nil { return err } - if provider.Secret, err = maybeLoadEnv(provider.Secret); err != nil { + if err := assertEnvLoaded(provider.Secret); err != nil { return err } - if provider.RedirectUri, err = maybeLoadEnv(provider.RedirectUri); err != nil { + if err := assertEnvLoaded(provider.RedirectUri); err != nil { return err } - if provider.Url, err = maybeLoadEnv(provider.Url); err != nil { + if err := assertEnvLoaded(provider.Url); err != nil { return err } e[ext] = provider @@ -1033,7 +1077,7 @@ func (h *hookConfig) validate(hookType string) (err error) { case "http", "https": if len(h.Secrets) == 0 { return errors.Errorf("Missing required field in config: auth.hook.%s.secrets", hookType) - } else if h.Secrets, err = maybeLoadEnv(h.Secrets); err != nil { + } else if err := assertEnvLoaded(h.Secrets); err != nil { return err } for _, secret := range strings.Split(h.Secrets, "|") { @@ -1119,13 +1163,13 @@ func (c *tpaCognito) issuerURL() string { func (c *tpaCognito) validate() (err error) { if c.UserPoolID == "" { return errors.New("Invalid config: auth.third_party.cognito is enabled but without a user_pool_id.") - } else if c.UserPoolID, err = maybeLoadEnv(c.UserPoolID); err != nil { + } else if err := assertEnvLoaded(c.UserPoolID); err != nil { return err } if c.UserPoolRegion == "" { return errors.New("Invalid config: auth.third_party.cognito is enabled but without a user_pool_region.") - } else if c.UserPoolRegion, err = maybeLoadEnv(c.UserPoolRegion); err != nil { + } else if err := assertEnvLoaded(c.UserPoolRegion); err != nil { return err } From 89df6b9538d06f5fad6511c80d27e8d766015a3c Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Wed, 8 Jan 2025 18:26:26 +0900 Subject: [PATCH 261/305] fix(edge-functions): add warning for edge-functions configuration (#2984) * feat(functions): auto add deno.jsonc and .npmrc to new functions * feat(deploy): add warning for functions imports structure * Update internal/functions/new/templates/.npmrc Co-authored-by: Han Qiao * fix: function prototype --------- Co-authored-by: Han Qiao --- internal/functions/deploy/deploy.go | 14 +++++++ internal/functions/new/new.go | 41 +++++++++++++++------ internal/functions/new/new_test.go | 10 +++++ internal/functions/new/templates/.npmrc | 3 ++ internal/functions/new/templates/deno.jsonc | 6 +++ 5 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 internal/functions/new/templates/.npmrc create mode 100644 internal/functions/new/templates/deno.jsonc diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index 529b78976..5ee2ae845 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -71,6 +71,8 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, // Although some functions do not require import map, it's more convenient to setup // vscode deno extension with a single import map for all functions. fallbackExists := true + functionsUsingDeprecatedGlobalFallback := []string{} + functionsUsingDeprecatedImportMap := []string{} if _, err := fsys.Stat(utils.FallbackImportMapPath); errors.Is(err, os.ErrNotExist) { fallbackExists = false } else if err != nil { @@ -94,12 +96,17 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, } else if len(function.ImportMap) == 0 { denoJsonPath := filepath.Join(functionDir, "deno.json") denoJsoncPath := filepath.Join(functionDir, "deno.jsonc") + importMapPath := filepath.Join(functionDir, "import_map.json") if _, err := fsys.Stat(denoJsonPath); err == nil { function.ImportMap = denoJsonPath } else if _, err := fsys.Stat(denoJsoncPath); err == nil { function.ImportMap = denoJsoncPath + } else if _, err := fsys.Stat(importMapPath); err == nil { + function.ImportMap = importMapPath + functionsUsingDeprecatedImportMap = append(functionsUsingDeprecatedImportMap, name) } else if fallbackExists { function.ImportMap = utils.FallbackImportMapPath + functionsUsingDeprecatedGlobalFallback = append(functionsUsingDeprecatedGlobalFallback, name) } } if noVerifyJWT != nil { @@ -107,5 +114,12 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, } functionConfig[name] = function } + if len(functionsUsingDeprecatedImportMap) > 0 { + fmt.Fprintln(os.Stderr, utils.Yellow("WARNING:"), "Functions using deprecated import_map.json (please migrate to deno.jsonc):", utils.Aqua(strings.Join(functionsUsingDeprecatedImportMap, ", "))) + } + if len(functionsUsingDeprecatedGlobalFallback) > 0 { + fmt.Fprintln(os.Stderr, utils.Yellow("WARNING:"), "Functions using fallback import map:", utils.Aqua(strings.Join(functionsUsingDeprecatedGlobalFallback, ", "))) + fmt.Fprintln(os.Stderr, "Please use recommended per function dependency declaration ", utils.Aqua("https://supabase.com/docs/guides/functions/import-maps")) + } return functionConfig, nil } diff --git a/internal/functions/new/new.go b/internal/functions/new/new.go index 3656e9b5f..f787ce90c 100644 --- a/internal/functions/new/new.go +++ b/internal/functions/new/new.go @@ -15,8 +15,13 @@ import ( var ( //go:embed templates/index.ts - indexEmbed string - indexTemplate = template.Must(template.New("indexl").Parse(indexEmbed)) + indexEmbed string + //go:embed templates/deno.jsonc + denoEmbed string + //go:embed templates/.npmrc + npmrcEmbed string + + indexTemplate = template.Must(template.New("index").Parse(indexEmbed)) ) type indexConfig struct { @@ -38,25 +43,37 @@ func Run(ctx context.Context, slug string, fsys afero.Fs) error { if err := utils.MkdirIfNotExistFS(fsys, funcDir); err != nil { return err } - path := filepath.Join(funcDir, "index.ts") - f, err := fsys.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0644) - if err != nil { - return errors.Errorf("failed to create function entrypoint: %w", err) - } - defer f.Close() - // Templatize index.ts by config.toml if available + + // Load config if available if err := utils.LoadConfigFS(fsys); err != nil { utils.CmdSuggestion = "" } - config := indexConfig{ + + if err := createTemplateFile(fsys, filepath.Join(funcDir, "index.ts"), indexTemplate, indexConfig{ URL: utils.GetApiUrl("/functions/v1/" + slug), Token: utils.Config.Auth.AnonKey, + }); err != nil { + return errors.Errorf("failed to create function entrypoint: %w", err) } - if err := indexTemplate.Option("missingkey=error").Execute(f, config); err != nil { - return errors.Errorf("failed to initialise function entrypoint: %w", err) + + if err := afero.WriteFile(fsys, filepath.Join(funcDir, "deno.jsonc"), []byte(denoEmbed), 0644); err != nil { + return errors.Errorf("failed to create deno.jsonc config: %w", err) + } + + if err := afero.WriteFile(fsys, filepath.Join(funcDir, ".npmrc"), []byte(npmrcEmbed), 0644); err != nil { + return errors.Errorf("failed to create .npmrc config: %w", err) } } fmt.Println("Created new Function at " + utils.Bold(funcDir)) return nil } + +func createTemplateFile(fsys afero.Fs, path string, tmpl *template.Template, data interface{}) error { + f, err := fsys.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0644) + if err != nil { + return err + } + defer f.Close() + return tmpl.Option("missingkey=error").Execute(f, data) +} diff --git a/internal/functions/new/new_test.go b/internal/functions/new/new_test.go index d5e9c2fc8..56a24f705 100644 --- a/internal/functions/new/new_test.go +++ b/internal/functions/new/new_test.go @@ -24,6 +24,16 @@ func TestNewCommand(t *testing.T) { assert.Contains(t, string(content), "curl -i --location --request POST 'http://127.0.0.1:54321/functions/v1/test-func'", ) + + // Verify deno.jsonc exists + denoPath := filepath.Join(utils.FunctionsDir, "test-func", "deno.jsonc") + _, err = afero.ReadFile(fsys, denoPath) + assert.NoError(t, err, "deno.jsonc should be created") + + // Verify .npmrc exists + npmrcPath := filepath.Join(utils.FunctionsDir, "test-func", ".npmrc") + _, err = afero.ReadFile(fsys, npmrcPath) + assert.NoError(t, err, ".npmrc should be created") }) t.Run("throws error on malformed slug", func(t *testing.T) { diff --git a/internal/functions/new/templates/.npmrc b/internal/functions/new/templates/.npmrc new file mode 100644 index 000000000..48c638863 --- /dev/null +++ b/internal/functions/new/templates/.npmrc @@ -0,0 +1,3 @@ +# Configuration for private npm package dependencies +# For more information on using private registries with Edge Functions, see: +# https://supabase.com/docs/guides/functions/import-maps#importing-from-private-registries diff --git a/internal/functions/new/templates/deno.jsonc b/internal/functions/new/templates/deno.jsonc new file mode 100644 index 000000000..97275ba5e --- /dev/null +++ b/internal/functions/new/templates/deno.jsonc @@ -0,0 +1,6 @@ +{ + "imports": { + // Add your dependencies here + // See: https://supabase.com/docs/guides/functions/import-maps#using-denojson-recommended + } +} From b0c7523b455beae9f8503a7cd785824fccb49d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Thu, 9 Jan 2025 14:05:14 +0900 Subject: [PATCH 262/305] fix: bump edge-runtime to 1.66.3 (#3025) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index fb6bdd51b..e39d799a9 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241202-71e5240" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.66.2" + edgeRuntimeImage = "supabase/edge-runtime:v1.66.3" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.167.0" From 3429667d5775884831784cc7a510abd907d32d7c Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Thu, 9 Jan 2025 19:04:47 +0900 Subject: [PATCH 263/305] feat(storage): autodetect narrow down text/plain contentype (#3022) * feat(storage): autodetect narrow down text/plain contentype based on extension - Add content type detection for JavaScript (text/javascript) - Add content type detection for CSS (text/css) - Add content type detection for SQL (application/x-sql) - Default to text/plain for unrecognized text files like .go * fix: tests for cross platform run * chore: reuse upload object method --------- Co-authored-by: Qiao Han --- internal/storage/cp/cp.go | 6 +-- pkg/storage/batch.go | 14 ++---- pkg/storage/objects.go | 11 ++++- pkg/storage/objects_test.go | 92 +++++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 15 deletions(-) create mode 100644 pkg/storage/objects_test.go diff --git a/internal/storage/cp/cp.go b/internal/storage/cp/cp.go index e55120a1c..e2e304ced 100644 --- a/internal/storage/cp/cp.go +++ b/internal/storage/cp/cp.go @@ -52,7 +52,7 @@ func Run(ctx context.Context, src, dst string, recursive bool, maxJobs uint, fsy if recursive { return UploadStorageObjectAll(ctx, api, dstParsed.Path, localPath, maxJobs, fsys, opts...) } - return api.UploadObject(ctx, dstParsed.Path, src, fsys, opts...) + return api.UploadObject(ctx, dstParsed.Path, src, utils.NewRootFS(fsys), opts...) } else if strings.EqualFold(srcParsed.Scheme, client.STORAGE_SCHEME) && strings.EqualFold(dstParsed.Scheme, client.STORAGE_SCHEME) { return errors.New("Copying between buckets is not supported") } @@ -149,7 +149,7 @@ func UploadStorageObjectAll(ctx context.Context, api storage.StorageAPI, remoteP } fmt.Fprintln(os.Stderr, "Uploading:", filePath, "=>", dstPath) job := func() error { - err := api.UploadObject(ctx, dstPath, filePath, fsys, opts...) + err := api.UploadObject(ctx, dstPath, filePath, utils.NewRootFS(fsys), opts...) if err != nil && strings.Contains(err.Error(), `"error":"Bucket not found"`) { // Retry after creating bucket if bucket, prefix := client.SplitBucketPrefix(dstPath); len(prefix) > 0 { @@ -162,7 +162,7 @@ func UploadStorageObjectAll(ctx context.Context, api storage.StorageAPI, remoteP if _, err := api.CreateBucket(ctx, body); err != nil { return err } - err = api.UploadObject(ctx, dstPath, filePath, fsys, opts...) + err = api.UploadObject(ctx, dstPath, filePath, utils.NewRootFS(fsys), opts...) } } return err diff --git a/pkg/storage/batch.go b/pkg/storage/batch.go index 8a681242d..63638e9a9 100644 --- a/pkg/storage/batch.go +++ b/pkg/storage/batch.go @@ -91,17 +91,9 @@ func (s *StorageAPI) UpsertObjects(ctx context.Context, bucketConfig config.Buck } fmt.Fprintln(os.Stderr, "Uploading:", filePath, "=>", dstPath) job := func() error { - f, err := fsys.Open(filePath) - if err != nil { - return errors.Errorf("failed to open file: %w", err) - } - defer f.Close() - fo, err := ParseFileOptions(f) - if err != nil { - return err - } - fo.Overwrite = true - return s.UploadObjectStream(ctx, dstPath, f, *fo) + return s.UploadObject(ctx, dstPath, filePath, fsys, func(fo *FileOptions) { + fo.Overwrite = true + }) } return jq.Put(job) } diff --git a/pkg/storage/objects.go b/pkg/storage/objects.go index f048cecf6..f338a63b2 100644 --- a/pkg/storage/objects.go +++ b/pkg/storage/objects.go @@ -4,9 +4,11 @@ import ( "context" "io" "io/fs" + "mime" "net/http" "os" "path" + "path/filepath" "strings" "github.com/go-errors/errors" @@ -88,7 +90,7 @@ func ParseFileOptions(f fs.File, opts ...func(*FileOptions)) (*FileOptions, erro return fo, nil } -func (s *StorageAPI) UploadObject(ctx context.Context, remotePath, localPath string, fsys afero.Fs, opts ...func(*FileOptions)) error { +func (s *StorageAPI) UploadObject(ctx context.Context, remotePath, localPath string, fsys fs.FS, opts ...func(*FileOptions)) error { f, err := fsys.Open(localPath) if err != nil { return errors.Errorf("failed to open file: %w", err) @@ -98,6 +100,13 @@ func (s *StorageAPI) UploadObject(ctx context.Context, remotePath, localPath str if err != nil { return err } + // For text/plain content types, we try to determine a more specific type + // based on the file extension, as the initial detection might be too generic + if strings.Contains(fo.ContentType, "text/plain") { + if extensionType := mime.TypeByExtension(filepath.Ext(localPath)); extensionType != "" { + fo.ContentType = extensionType + } + } return s.UploadObjectStream(ctx, remotePath, f, *fo) } diff --git a/pkg/storage/objects_test.go b/pkg/storage/objects_test.go new file mode 100644 index 000000000..a2e132a9b --- /dev/null +++ b/pkg/storage/objects_test.go @@ -0,0 +1,92 @@ +package storage + +import ( + "context" + "mime" + "net/http" + "testing" + fs "testing/fstest" + + "github.com/h2non/gock" + "github.com/stretchr/testify/assert" + "github.com/supabase/cli/internal/testing/apitest" + "github.com/supabase/cli/pkg/fetcher" +) + +var mockApi = StorageAPI{Fetcher: fetcher.NewFetcher( + "http://127.0.0.1", +)} + +func TestParseFileOptionsContentTypeDetection(t *testing.T) { + tests := []struct { + name string + content []byte + filename string + opts []func(*FileOptions) + wantMimeType string + wantCacheCtrl string + }{ + { + name: "detects PNG image", + content: []byte{0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A}, // PNG header + filename: "test.image", + wantMimeType: "image/png", + wantCacheCtrl: "max-age=3600", + }, + { + name: "detects JavaScript file", + content: []byte("const hello = () => console.log('Hello, World!');"), + filename: "script.js", + wantMimeType: mime.TypeByExtension(".js"), + wantCacheCtrl: "max-age=3600", + }, + { + name: "detects CSS file", + content: []byte(".header { color: #333; font-size: 16px; }"), + filename: "styles.css", + wantMimeType: mime.TypeByExtension(".css"), + wantCacheCtrl: "max-age=3600", + }, + { + name: "detects SQL file", + content: []byte("SELECT * FROM users WHERE id = 1;"), + filename: "query.sql", + wantMimeType: mime.TypeByExtension(".sql"), + wantCacheCtrl: "max-age=3600", + }, + { + name: "use text/plain as fallback for unrecognized extensions", + content: []byte("const hello = () => console.log('Hello, World!');"), + filename: "main.nonexistent", + wantMimeType: "text/plain; charset=utf-8", + wantCacheCtrl: "max-age=3600", + }, + { + name: "respects custom content type", + content: []byte("const hello = () => console.log('Hello, World!');"), + filename: "custom.js", + wantMimeType: "application/custom", + wantCacheCtrl: "max-age=3600", + opts: []func(*FileOptions){func(fo *FileOptions) { fo.ContentType = "application/custom" }}, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + // Create a temporary file with test content + fsys := fs.MapFS{tt.filename: &fs.MapFile{Data: tt.content}} + // Setup mock api + defer gock.OffAll() + gock.New("http://127.0.0.1"). + Post("/storage/v1/object/"+tt.filename). + MatchHeader("Content-Type", tt.wantMimeType). + MatchHeader("Cache-Control", tt.wantCacheCtrl). + Reply(http.StatusOK) + // Parse options + err := mockApi.UploadObject(context.Background(), tt.filename, tt.filename, fsys, tt.opts...) + // Assert results + assert.NoError(t, err) + assert.Empty(t, apitest.ListUnmatchedRequests()) + }) + } +} From ce47b342b0452606b04108fb654e3afebb87d53b Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Fri, 10 Jan 2025 12:01:20 +0800 Subject: [PATCH 264/305] feat: support encrypted values in config (#3013) * feat: support encrypted values in config * feat: parse smtp pass as encrypted secret * chore: parse encrypted sms secret * chore: parse encrypted hook secret * chore: parse encrypted external secret * chore: remove project ref arg from auth diff * chore: increase dupl detection threshold --- .golangci.yml | 2 +- cmd/link.go | 1 + go.mod | 7 +- go.sum | 12 +- internal/config/push/push.go | 7 +- internal/link/link.go | 1 - internal/start/start.go | 24 +- pkg/config/auth.go | 306 ++++++++++-------- pkg/config/auth_test.go | 137 +++++--- pkg/config/config.go | 71 ++-- pkg/config/config_test.go | 12 +- pkg/config/secret.go | 83 +++++ pkg/config/secret_test.go | 52 +++ .../local_enabled_remote_disabled.diff | 2 +- .../local_enabled_and_disabled.diff | 4 +- .../local_disabled_remote_enabled.diff | 2 +- .../local_enabled_remote_disabled.diff | 6 +- .../local_enabled_remote_disabled.diff | 2 +- pkg/config/updater.go | 2 +- 19 files changed, 472 insertions(+), 261 deletions(-) create mode 100644 pkg/config/secret.go create mode 100644 pkg/config/secret_test.go diff --git a/.golangci.yml b/.golangci.yml index 9d5189836..b91c1afd6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -20,4 +20,4 @@ linters-settings: stylecheck: checks: ["all", "-ST1003"] dupl: - threshold: 200 + threshold: 250 diff --git a/cmd/link.go b/cmd/link.go index b1aec1d7a..59c93545c 100644 --- a/cmd/link.go +++ b/cmd/link.go @@ -31,6 +31,7 @@ var ( return err } fsys := afero.NewOsFs() + utils.Config.ProjectId = flags.ProjectRef if err := utils.LoadConfigFS(fsys); err != nil { return err } diff --git a/go.mod b/go.mod index 62b544b34..4e5fcaff0 100644 --- a/go.mod +++ b/go.mod @@ -17,6 +17,7 @@ require ( github.com/docker/docker v27.4.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 + github.com/ecies/go/v2 v2.0.10 github.com/getsentry/sentry-go v0.31.1 github.com/go-errors/errors v1.5.1 github.com/go-git/go-git/v5 v5.13.1 @@ -111,6 +112,7 @@ require ( github.com/daixiang0/gci v0.13.5 // indirect github.com/danieljoos/wincred v1.2.2 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 // indirect github.com/denis-tingaikin/go-header v0.5.0 // indirect github.com/distribution/reference v0.6.0 // indirect github.com/dlclark/regexp2 v1.11.0 // indirect @@ -120,6 +122,7 @@ require ( github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect github.com/docker/go-metrics v0.0.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect + github.com/ethereum/go-ethereum v1.14.12 // indirect github.com/ettle/strcase v0.2.0 // indirect github.com/fatih/color v1.18.0 // indirect github.com/fatih/structtag v1.2.0 // indirect @@ -215,7 +218,7 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-localereader v0.0.1 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect github.com/mgechev/revive v1.5.1 // indirect github.com/microcosm-cc/bluemonday v1.0.25 // indirect github.com/miekg/pkcs11 v1.1.1 // indirect @@ -244,7 +247,7 @@ require ( github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/polyfloyd/go-errorlint v1.7.0 // indirect github.com/prometheus/client_golang v1.12.1 // indirect - github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a // indirect github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/procfs v0.7.3 // indirect github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1 // indirect diff --git a/go.sum b/go.sum index 8b6bf5eda..d475808d6 100644 --- a/go.sum +++ b/go.sum @@ -215,6 +215,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0 h1:rpfIENRNNilwHwZeG5+P150SMrnNEcHYvcCuK6dPZSg= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0= github.com/deepmap/oapi-codegen/v2 v2.2.0 h1:FW4f7C0Xb6EaezBSB3GYw2QGwHD5ChDflG+3xSZBdvY= github.com/deepmap/oapi-codegen/v2 v2.2.0/go.mod h1:L4zUv7ULYDtYSb/aYk/xO3OYcQU6BoU/0viULkbi2DE= github.com/denis-tingaikin/go-header v0.5.0 h1:SRdnP5ZKvcO9KKRP1KJrhFR3RrlGuD+42t4429eC9k8= @@ -248,6 +250,8 @@ github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDD github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 h1:UhxFibDNY/bfvqU5CAUmr9zpesgbU6SWc8/B4mflAE4= github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNEkKy96OOhEzfZl+yxihPEzKnqJwvfuSUqbZE= github.com/dvsekhvalnov/jose2go v0.0.0-20170216131308-f21a8cedbbae/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= +github.com/ecies/go/v2 v2.0.10 h1:AaLxGio0MLLbvWur4rKnLzw+K9zI+wMScIDAtqCqOtU= +github.com/ecies/go/v2 v2.0.10/go.mod h1:N73OyuR6tuKznit2LhXjrZ0XAQ234uKbzYz8pEPYzlI= github.com/elazarl/goproxy v1.2.3 h1:xwIyKHbaP5yfT6O9KIeYJR5549MXRQkoQMRXGztz8YQ= github.com/elazarl/goproxy v1.2.3/go.mod h1:YfEbZtqP4AetfO6d40vWchF3znWX7C7Vd6ZMfdL8z64= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= @@ -257,6 +261,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= +github.com/ethereum/go-ethereum v1.14.12 h1:8hl57x77HSUo+cXExrURjU/w1VhL+ShCTJrTwcCQSe4= +github.com/ethereum/go-ethereum v1.14.12/go.mod h1:RAC2gVMWJ6FkxSPESfbshrcKpIokgQKsVKmAuqdekDY= github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q= github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= @@ -678,8 +684,9 @@ github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRC github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.6.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mgechev/revive v1.5.1 h1:hE+QPeq0/wIzJwOphdVyUJ82njdd8Khp4fUIHGZHW3M= github.com/mgechev/revive v1.5.1/go.mod h1:lC9AhkJIBs5zwx8wkudyHrU+IJkrEKmpCmGMnIJPk4o= github.com/microcosm-cc/bluemonday v1.0.25 h1:4NEwSfiJ+Wva0VxN5B8OwMicaJvD8r9tlJWm9rtloEg= @@ -792,8 +799,9 @@ github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1: github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a h1:CmF68hwI0XsOQ5UwlBopMi2Ow4Pbg32akc4KIVCOm+Y= +github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/common v0.0.0-20180110214958-89604d197083/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= diff --git a/internal/config/push/push.go b/internal/config/push/push.go index a4c901473..b1b887765 100644 --- a/internal/config/push/push.go +++ b/internal/config/push/push.go @@ -11,15 +11,12 @@ import ( ) func Run(ctx context.Context, ref string, fsys afero.Fs) error { + utils.Config.ProjectId = ref if err := utils.LoadConfigFS(fsys); err != nil { return err } client := config.NewConfigUpdater(*utils.GetSupabase()) - remote, err := utils.Config.GetRemoteByProjectRef(ref) - if err != nil { - // Use base config when no remote is declared - remote.ProjectId = ref - } + remote, _ := utils.Config.GetRemoteByProjectRef(ref) fmt.Fprintln(os.Stderr, "Pushing config to project:", remote.ProjectId) console := utils.NewConsole() keep := func(name string) bool { diff --git a/internal/link/link.go b/internal/link/link.go index e791271b8..d35321e2e 100644 --- a/internal/link/link.go +++ b/internal/link/link.go @@ -26,7 +26,6 @@ import ( func Run(ctx context.Context, projectRef string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { copy := utils.Config.Clone() - copy.Auth.HashSecrets(projectRef) original, err := cliConfig.ToTomlBytes(copy) if err != nil { fmt.Fprintln(utils.GetDebugLogger(), err) diff --git a/internal/start/start.go b/internal/start/start.go index c3684c14b..6f75d1377 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -507,7 +507,7 @@ EOF fmt.Sprintf("GOTRUE_SMTP_HOST=%s", utils.Config.Auth.Email.Smtp.Host), fmt.Sprintf("GOTRUE_SMTP_PORT=%d", utils.Config.Auth.Email.Smtp.Port), fmt.Sprintf("GOTRUE_SMTP_USER=%s", utils.Config.Auth.Email.Smtp.User), - fmt.Sprintf("GOTRUE_SMTP_PASS=%s", utils.Config.Auth.Email.Smtp.Pass), + fmt.Sprintf("GOTRUE_SMTP_PASS=%s", utils.Config.Auth.Email.Smtp.Pass.Value), fmt.Sprintf("GOTRUE_SMTP_ADMIN_EMAIL=%s", utils.Config.Auth.Email.Smtp.AdminEmail), fmt.Sprintf("GOTRUE_SMTP_SENDER_NAME=%s", utils.Config.Auth.Email.Smtp.SenderName), ) @@ -550,7 +550,7 @@ EOF env, "GOTRUE_SMS_PROVIDER=twilio", "GOTRUE_SMS_TWILIO_ACCOUNT_SID="+utils.Config.Auth.Sms.Twilio.AccountSid, - "GOTRUE_SMS_TWILIO_AUTH_TOKEN="+utils.Config.Auth.Sms.Twilio.AuthToken, + "GOTRUE_SMS_TWILIO_AUTH_TOKEN="+utils.Config.Auth.Sms.Twilio.AuthToken.Value, "GOTRUE_SMS_TWILIO_MESSAGE_SERVICE_SID="+utils.Config.Auth.Sms.Twilio.MessageServiceSid, ) case utils.Config.Auth.Sms.TwilioVerify.Enabled: @@ -558,21 +558,21 @@ EOF env, "GOTRUE_SMS_PROVIDER=twilio_verify", "GOTRUE_SMS_TWILIO_VERIFY_ACCOUNT_SID="+utils.Config.Auth.Sms.TwilioVerify.AccountSid, - "GOTRUE_SMS_TWILIO_VERIFY_AUTH_TOKEN="+utils.Config.Auth.Sms.TwilioVerify.AuthToken, + "GOTRUE_SMS_TWILIO_VERIFY_AUTH_TOKEN="+utils.Config.Auth.Sms.TwilioVerify.AuthToken.Value, "GOTRUE_SMS_TWILIO_VERIFY_MESSAGE_SERVICE_SID="+utils.Config.Auth.Sms.TwilioVerify.MessageServiceSid, ) case utils.Config.Auth.Sms.Messagebird.Enabled: env = append( env, "GOTRUE_SMS_PROVIDER=messagebird", - "GOTRUE_SMS_MESSAGEBIRD_ACCESS_KEY="+utils.Config.Auth.Sms.Messagebird.AccessKey, + "GOTRUE_SMS_MESSAGEBIRD_ACCESS_KEY="+utils.Config.Auth.Sms.Messagebird.AccessKey.Value, "GOTRUE_SMS_MESSAGEBIRD_ORIGINATOR="+utils.Config.Auth.Sms.Messagebird.Originator, ) case utils.Config.Auth.Sms.Textlocal.Enabled: env = append( env, "GOTRUE_SMS_PROVIDER=textlocal", - "GOTRUE_SMS_TEXTLOCAL_API_KEY="+utils.Config.Auth.Sms.Textlocal.ApiKey, + "GOTRUE_SMS_TEXTLOCAL_API_KEY="+utils.Config.Auth.Sms.Textlocal.ApiKey.Value, "GOTRUE_SMS_TEXTLOCAL_SENDER="+utils.Config.Auth.Sms.Textlocal.Sender, ) case utils.Config.Auth.Sms.Vonage.Enabled: @@ -580,7 +580,7 @@ EOF env, "GOTRUE_SMS_PROVIDER=vonage", "GOTRUE_SMS_VONAGE_API_KEY="+utils.Config.Auth.Sms.Vonage.ApiKey, - "GOTRUE_SMS_VONAGE_API_SECRET="+utils.Config.Auth.Sms.Vonage.ApiSecret, + "GOTRUE_SMS_VONAGE_API_SECRET="+utils.Config.Auth.Sms.Vonage.ApiSecret.Value, "GOTRUE_SMS_VONAGE_FROM="+utils.Config.Auth.Sms.Vonage.From, ) } @@ -590,7 +590,7 @@ EOF env, "GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_ENABLED=true", "GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_URI="+hook.URI, - "GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_SECRETS="+hook.Secrets, + "GOTRUE_HOOK_MFA_VERIFICATION_ATTEMPT_SECRETS="+hook.Secrets.Value, ) } if hook := utils.Config.Auth.Hook.PasswordVerificationAttempt; hook != nil && hook.Enabled { @@ -598,7 +598,7 @@ EOF env, "GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_ENABLED=true", "GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_URI="+hook.URI, - "GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_SECRETS="+hook.Secrets, + "GOTRUE_HOOK_PASSWORD_VERIFICATION_ATTEMPT_SECRETS="+hook.Secrets.Value, ) } if hook := utils.Config.Auth.Hook.CustomAccessToken; hook != nil && hook.Enabled { @@ -606,7 +606,7 @@ EOF env, "GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_ENABLED=true", "GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_URI="+hook.URI, - "GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_SECRETS="+hook.Secrets, + "GOTRUE_HOOK_CUSTOM_ACCESS_TOKEN_SECRETS="+hook.Secrets.Value, ) } if hook := utils.Config.Auth.Hook.SendSMS; hook != nil && hook.Enabled { @@ -614,7 +614,7 @@ EOF env, "GOTRUE_HOOK_SEND_SMS_ENABLED=true", "GOTRUE_HOOK_SEND_SMS_URI="+hook.URI, - "GOTRUE_HOOK_SEND_SMS_SECRETS="+hook.Secrets, + "GOTRUE_HOOK_SEND_SMS_SECRETS="+hook.Secrets.Value, ) } if hook := utils.Config.Auth.Hook.SendEmail; hook != nil && hook.Enabled { @@ -622,7 +622,7 @@ EOF env, "GOTRUE_HOOK_SEND_EMAIL_ENABLED=true", "GOTRUE_HOOK_SEND_EMAIL_URI="+hook.URI, - "GOTRUE_HOOK_SEND_EMAIL_SECRETS="+hook.Secrets, + "GOTRUE_HOOK_SEND_EMAIL_SECRETS="+hook.Secrets.Value, ) } @@ -640,7 +640,7 @@ EOF env, fmt.Sprintf("GOTRUE_EXTERNAL_%s_ENABLED=%v", strings.ToUpper(name), config.Enabled), fmt.Sprintf("GOTRUE_EXTERNAL_%s_CLIENT_ID=%s", strings.ToUpper(name), config.ClientId), - fmt.Sprintf("GOTRUE_EXTERNAL_%s_SECRET=%s", strings.ToUpper(name), config.Secret), + fmt.Sprintf("GOTRUE_EXTERNAL_%s_SECRET=%s", strings.ToUpper(name), config.Secret.Value), fmt.Sprintf("GOTRUE_EXTERNAL_%s_SKIP_NONCE_CHECK=%t", strings.ToUpper(name), config.SkipNonceCheck), ) diff --git a/pkg/config/auth.go b/pkg/config/auth.go index b93123bd2..098764fff 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -119,7 +119,7 @@ type ( Host string `toml:"host"` Port uint16 `toml:"port"` User string `toml:"user"` - Pass string `toml:"pass"` + Pass Secret `toml:"pass"` AdminEmail string `toml:"admin_email"` SenderName string `toml:"sender_name"` } @@ -174,7 +174,7 @@ type ( hookConfig struct { Enabled bool `toml:"enabled"` URI string `toml:"uri"` - Secrets string `toml:"secrets"` + Secrets Secret `toml:"secrets"` } sessions struct { @@ -186,32 +186,32 @@ type ( Enabled bool `toml:"enabled"` AccountSid string `toml:"account_sid"` MessageServiceSid string `toml:"message_service_sid"` - AuthToken string `toml:"auth_token" mapstructure:"auth_token"` + AuthToken Secret `toml:"auth_token" mapstructure:"auth_token"` } messagebirdConfig struct { Enabled bool `toml:"enabled"` Originator string `toml:"originator"` - AccessKey string `toml:"access_key" mapstructure:"access_key"` + AccessKey Secret `toml:"access_key" mapstructure:"access_key"` } textlocalConfig struct { Enabled bool `toml:"enabled"` Sender string `toml:"sender"` - ApiKey string `toml:"api_key" mapstructure:"api_key"` + ApiKey Secret `toml:"api_key" mapstructure:"api_key"` } vonageConfig struct { Enabled bool `toml:"enabled"` From string `toml:"from"` ApiKey string `toml:"api_key" mapstructure:"api_key"` - ApiSecret string `toml:"api_secret" mapstructure:"api_secret"` + ApiSecret Secret `toml:"api_secret" mapstructure:"api_secret"` } provider struct { Enabled bool `toml:"enabled"` ClientId string `toml:"client_id"` - Secret string `toml:"secret"` + Secret Secret `toml:"secret"` Url string `toml:"url"` RedirectUri string `toml:"redirect_uri"` SkipNonceCheck bool `toml:"skip_nonce_check"` @@ -265,24 +265,24 @@ func (h hook) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if hook := h.CustomAccessToken; hook != nil { if body.HookCustomAccessTokenEnabled = &hook.Enabled; hook.Enabled { body.HookCustomAccessTokenUri = &hook.URI - if len(hook.Secrets) > 0 { - body.HookCustomAccessTokenSecrets = &hook.Secrets + if len(hook.Secrets.Value) > 0 { + body.HookCustomAccessTokenSecrets = &hook.Secrets.Value } } } if hook := h.SendEmail; hook != nil { if body.HookSendEmailEnabled = &hook.Enabled; hook.Enabled { body.HookSendEmailUri = &hook.URI - if len(hook.Secrets) > 0 { - body.HookSendEmailSecrets = &hook.Secrets + if len(hook.Secrets.Value) > 0 { + body.HookSendEmailSecrets = &hook.Secrets.Value } } } if hook := h.SendSMS; hook != nil { if body.HookSendSmsEnabled = &hook.Enabled; hook.Enabled { body.HookSendSmsUri = &hook.URI - if len(hook.Secrets) > 0 { - body.HookSendSmsSecrets = &hook.Secrets + if len(hook.Secrets.Value) > 0 { + body.HookSendSmsSecrets = &hook.Secrets.Value } } } @@ -290,16 +290,16 @@ func (h hook) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if hook := h.MFAVerificationAttempt; hook != nil { if body.HookMfaVerificationAttemptEnabled = &hook.Enabled; hook.Enabled { body.HookMfaVerificationAttemptUri = &hook.URI - if len(hook.Secrets) > 0 { - body.HookMfaVerificationAttemptSecrets = &hook.Secrets + if len(hook.Secrets.Value) > 0 { + body.HookMfaVerificationAttemptSecrets = &hook.Secrets.Value } } } if hook := h.PasswordVerificationAttempt; hook != nil { if body.HookPasswordVerificationAttemptEnabled = &hook.Enabled; hook.Enabled { body.HookPasswordVerificationAttemptUri = &hook.URI - if len(hook.Secrets) > 0 { - body.HookPasswordVerificationAttemptSecrets = &hook.Secrets + if len(hook.Secrets.Value) > 0 { + body.HookPasswordVerificationAttemptSecrets = &hook.Secrets.Value } } } @@ -310,8 +310,8 @@ func (h *hook) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { // Ignore disabled hooks because their envs are not loaded if hook.Enabled { hook.URI = cast.Val(remoteConfig.HookCustomAccessTokenUri, "") - if hook.Secrets != hashPrefix { - hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookCustomAccessTokenSecrets, "") + if len(hook.Secrets.SHA256) > 0 { + hook.Secrets.SHA256 = cast.Val(remoteConfig.HookCustomAccessTokenSecrets, "") } } hook.Enabled = cast.Val(remoteConfig.HookCustomAccessTokenEnabled, false) @@ -319,8 +319,8 @@ func (h *hook) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if hook := h.SendEmail; hook != nil { if hook.Enabled { hook.URI = cast.Val(remoteConfig.HookSendEmailUri, "") - if hook.Secrets != hashPrefix { - hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendEmailSecrets, "") + if len(hook.Secrets.SHA256) > 0 { + hook.Secrets.SHA256 = cast.Val(remoteConfig.HookSendEmailSecrets, "") } } hook.Enabled = cast.Val(remoteConfig.HookSendEmailEnabled, false) @@ -328,8 +328,8 @@ func (h *hook) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if hook := h.SendSMS; hook != nil { if hook.Enabled { hook.URI = cast.Val(remoteConfig.HookSendSmsUri, "") - if hook.Secrets != hashPrefix { - hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookSendSmsSecrets, "") + if len(hook.Secrets.SHA256) > 0 { + hook.Secrets.SHA256 = cast.Val(remoteConfig.HookSendSmsSecrets, "") } } hook.Enabled = cast.Val(remoteConfig.HookSendSmsEnabled, false) @@ -338,8 +338,8 @@ func (h *hook) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if hook := h.MFAVerificationAttempt; hook != nil { if hook.Enabled { hook.URI = cast.Val(remoteConfig.HookMfaVerificationAttemptUri, "") - if hook.Secrets != hashPrefix { - hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookMfaVerificationAttemptSecrets, "") + if len(hook.Secrets.SHA256) > 0 { + hook.Secrets.SHA256 = cast.Val(remoteConfig.HookMfaVerificationAttemptSecrets, "") } } hook.Enabled = cast.Val(remoteConfig.HookMfaVerificationAttemptEnabled, false) @@ -347,8 +347,8 @@ func (h *hook) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if hook := h.PasswordVerificationAttempt; hook != nil { if hook.Enabled { hook.URI = cast.Val(remoteConfig.HookPasswordVerificationAttemptUri, "") - if hook.Secrets != hashPrefix { - hook.Secrets = hashPrefix + cast.Val(remoteConfig.HookPasswordVerificationAttemptSecrets, "") + if len(hook.Secrets.SHA256) > 0 { + hook.Secrets.SHA256 = cast.Val(remoteConfig.HookPasswordVerificationAttemptSecrets, "") } } hook.Enabled = cast.Val(remoteConfig.HookPasswordVerificationAttemptEnabled, false) @@ -512,7 +512,9 @@ func (s smtp) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { body.SmtpHost = &s.Host body.SmtpPort = cast.Ptr(strconv.Itoa(int(s.Port))) body.SmtpUser = &s.User - body.SmtpPass = &s.Pass + if len(s.Pass.Value) > 0 { + body.SmtpPass = &s.Pass.Value + } body.SmtpAdminEmail = &s.AdminEmail body.SmtpSenderName = &s.SenderName } @@ -528,7 +530,9 @@ func (s *smtp) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { } s.Host = cast.Val(remoteConfig.SmtpHost, "") s.User = cast.Val(remoteConfig.SmtpUser, "") - s.Pass = hashPrefix + cast.Val(remoteConfig.SmtpPass, "") + if len(s.Pass.SHA256) > 0 { + s.Pass.SHA256 = cast.Val(remoteConfig.SmtpPass, "") + } s.AdminEmail = cast.Val(remoteConfig.SmtpAdminEmail, "") s.SenderName = cast.Val(remoteConfig.SmtpSenderName, "") portStr := cast.Val(remoteConfig.SmtpPort, "0") @@ -552,34 +556,34 @@ func (s sms) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { switch { case s.Twilio.Enabled: body.SmsProvider = cast.Ptr("twilio") - if len(s.Twilio.AuthToken) > 0 { - body.SmsTwilioAuthToken = &s.Twilio.AuthToken + if len(s.Twilio.AuthToken.Value) > 0 { + body.SmsTwilioAuthToken = &s.Twilio.AuthToken.Value } body.SmsTwilioAccountSid = &s.Twilio.AccountSid body.SmsTwilioMessageServiceSid = &s.Twilio.MessageServiceSid case s.TwilioVerify.Enabled: body.SmsProvider = cast.Ptr("twilio_verify") - if len(s.TwilioVerify.AuthToken) > 0 { - body.SmsTwilioVerifyAuthToken = &s.TwilioVerify.AuthToken + if len(s.TwilioVerify.AuthToken.Value) > 0 { + body.SmsTwilioVerifyAuthToken = &s.TwilioVerify.AuthToken.Value } body.SmsTwilioVerifyAccountSid = &s.TwilioVerify.AccountSid body.SmsTwilioVerifyMessageServiceSid = &s.TwilioVerify.MessageServiceSid case s.Messagebird.Enabled: body.SmsProvider = cast.Ptr("messagebird") - if len(s.Messagebird.AccessKey) > 0 { - body.SmsMessagebirdAccessKey = &s.Messagebird.AccessKey + if len(s.Messagebird.AccessKey.Value) > 0 { + body.SmsMessagebirdAccessKey = &s.Messagebird.AccessKey.Value } body.SmsMessagebirdOriginator = &s.Messagebird.Originator case s.Textlocal.Enabled: body.SmsProvider = cast.Ptr("textlocal") - if len(s.Textlocal.ApiKey) > 0 { - body.SmsTextlocalApiKey = &s.Textlocal.ApiKey + if len(s.Textlocal.ApiKey.Value) > 0 { + body.SmsTextlocalApiKey = &s.Textlocal.ApiKey.Value } body.SmsTextlocalSender = &s.Textlocal.Sender case s.Vonage.Enabled: body.SmsProvider = cast.Ptr("vonage") - if len(s.Vonage.ApiSecret) > 0 { - body.SmsVonageApiSecret = &s.Vonage.ApiSecret + if len(s.Vonage.ApiSecret.Value) > 0 { + body.SmsVonageApiSecret = &s.Vonage.ApiSecret.Value } body.SmsVonageApiKey = &s.Vonage.ApiKey body.SmsVonageFrom = &s.Vonage.From @@ -595,30 +599,30 @@ func (s *sms) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { // We are only interested in the provider that's enabled locally switch { case s.Twilio.Enabled: - if s.Twilio.AuthToken != hashPrefix { - s.Twilio.AuthToken = hashPrefix + cast.Val(remoteConfig.SmsTwilioAuthToken, "") + if len(s.Twilio.AuthToken.SHA256) > 0 { + s.Twilio.AuthToken.SHA256 = cast.Val(remoteConfig.SmsTwilioAuthToken, "") } s.Twilio.AccountSid = cast.Val(remoteConfig.SmsTwilioAccountSid, "") s.Twilio.MessageServiceSid = cast.Val(remoteConfig.SmsTwilioMessageServiceSid, "") case s.TwilioVerify.Enabled: - if s.TwilioVerify.AuthToken != hashPrefix { - s.TwilioVerify.AuthToken = hashPrefix + cast.Val(remoteConfig.SmsTwilioVerifyAuthToken, "") + if len(s.TwilioVerify.AuthToken.SHA256) > 0 { + s.TwilioVerify.AuthToken.SHA256 = cast.Val(remoteConfig.SmsTwilioVerifyAuthToken, "") } s.TwilioVerify.AccountSid = cast.Val(remoteConfig.SmsTwilioVerifyAccountSid, "") s.TwilioVerify.MessageServiceSid = cast.Val(remoteConfig.SmsTwilioVerifyMessageServiceSid, "") case s.Messagebird.Enabled: - if s.Messagebird.AccessKey != hashPrefix { - s.Messagebird.AccessKey = hashPrefix + cast.Val(remoteConfig.SmsMessagebirdAccessKey, "") + if len(s.Messagebird.AccessKey.SHA256) > 0 { + s.Messagebird.AccessKey.SHA256 = cast.Val(remoteConfig.SmsMessagebirdAccessKey, "") } s.Messagebird.Originator = cast.Val(remoteConfig.SmsMessagebirdOriginator, "") case s.Textlocal.Enabled: - if s.Textlocal.ApiKey != hashPrefix { - s.Textlocal.ApiKey = hashPrefix + cast.Val(remoteConfig.SmsTextlocalApiKey, "") + if len(s.Textlocal.ApiKey.SHA256) > 0 { + s.Textlocal.ApiKey.SHA256 = cast.Val(remoteConfig.SmsTextlocalApiKey, "") } s.Textlocal.Sender = cast.Val(remoteConfig.SmsTextlocalSender, "") case s.Vonage.Enabled: - if s.Vonage.ApiSecret != hashPrefix { - s.Vonage.ApiSecret = hashPrefix + cast.Val(remoteConfig.SmsVonageApiSecret, "") + if len(s.Vonage.ApiSecret.SHA256) > 0 { + s.Vonage.ApiSecret.SHA256 = cast.Val(remoteConfig.SmsVonageApiSecret, "") } s.Vonage.ApiKey = cast.Val(remoteConfig.SmsVonageApiKey, "") s.Vonage.From = cast.Val(remoteConfig.SmsVonageFrom, "") @@ -643,120 +647,158 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["apple"]; ok { if body.ExternalAppleEnabled = &p.Enabled; *body.ExternalAppleEnabled { body.ExternalAppleClientId = &p.ClientId - body.ExternalAppleSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalAppleSecret = &p.Secret.Value + } } } if p, ok := e["azure"]; ok { if body.ExternalAzureEnabled = &p.Enabled; *body.ExternalAzureEnabled { body.ExternalAzureClientId = &p.ClientId - body.ExternalAzureSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalAzureSecret = &p.Secret.Value + } body.ExternalAzureUrl = &p.Url } } if p, ok := e["bitbucket"]; ok { if body.ExternalBitbucketEnabled = &p.Enabled; *body.ExternalBitbucketEnabled { body.ExternalBitbucketClientId = &p.ClientId - body.ExternalBitbucketSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalBitbucketSecret = &p.Secret.Value + } } } if p, ok := e["discord"]; ok { if body.ExternalDiscordEnabled = &p.Enabled; *body.ExternalDiscordEnabled { body.ExternalDiscordClientId = &p.ClientId - body.ExternalDiscordSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalDiscordSecret = &p.Secret.Value + } } } if p, ok := e["facebook"]; ok { if body.ExternalFacebookEnabled = &p.Enabled; *body.ExternalFacebookEnabled { body.ExternalFacebookClientId = &p.ClientId - body.ExternalFacebookSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalFacebookSecret = &p.Secret.Value + } } } if p, ok := e["figma"]; ok { if body.ExternalFigmaEnabled = &p.Enabled; *body.ExternalFigmaEnabled { body.ExternalFigmaClientId = &p.ClientId - body.ExternalFigmaSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalFigmaSecret = &p.Secret.Value + } } } if p, ok := e["github"]; ok { if body.ExternalGithubEnabled = &p.Enabled; *body.ExternalGithubEnabled { body.ExternalGithubClientId = &p.ClientId - body.ExternalGithubSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalGithubSecret = &p.Secret.Value + } } } if p, ok := e["gitlab"]; ok { if body.ExternalGitlabEnabled = &p.Enabled; *body.ExternalGitlabEnabled { body.ExternalGitlabClientId = &p.ClientId - body.ExternalGitlabSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalGitlabSecret = &p.Secret.Value + } body.ExternalGitlabUrl = &p.Url } } if p, ok := e["google"]; ok { if body.ExternalGoogleEnabled = &p.Enabled; *body.ExternalGoogleEnabled { body.ExternalGoogleClientId = &p.ClientId - body.ExternalGoogleSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalGoogleSecret = &p.Secret.Value + } body.ExternalGoogleSkipNonceCheck = &p.SkipNonceCheck } } if p, ok := e["kakao"]; ok { if body.ExternalKakaoEnabled = &p.Enabled; *body.ExternalKakaoEnabled { body.ExternalKakaoClientId = &p.ClientId - body.ExternalKakaoSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalKakaoSecret = &p.Secret.Value + } } } if p, ok := e["keycloak"]; ok { if body.ExternalKeycloakEnabled = &p.Enabled; *body.ExternalKeycloakEnabled { body.ExternalKeycloakClientId = &p.ClientId - body.ExternalKeycloakSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalKeycloakSecret = &p.Secret.Value + } body.ExternalKeycloakUrl = &p.Url } } if p, ok := e["linkedin_oidc"]; ok { if body.ExternalLinkedinOidcEnabled = &p.Enabled; *body.ExternalLinkedinOidcEnabled { body.ExternalLinkedinOidcClientId = &p.ClientId - body.ExternalLinkedinOidcSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalLinkedinOidcSecret = &p.Secret.Value + } } } if p, ok := e["notion"]; ok { if body.ExternalNotionEnabled = &p.Enabled; *body.ExternalNotionEnabled { body.ExternalNotionClientId = &p.ClientId - body.ExternalNotionSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalNotionSecret = &p.Secret.Value + } } } if p, ok := e["slack_oidc"]; ok { if body.ExternalSlackOidcEnabled = &p.Enabled; *body.ExternalSlackOidcEnabled { body.ExternalSlackOidcClientId = &p.ClientId - body.ExternalSlackOidcSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalSlackOidcSecret = &p.Secret.Value + } } } if p, ok := e["spotify"]; ok { if body.ExternalSpotifyEnabled = &p.Enabled; *body.ExternalSpotifyEnabled { body.ExternalSpotifyClientId = &p.ClientId - body.ExternalSpotifySecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalSpotifySecret = &p.Secret.Value + } } } if p, ok := e["twitch"]; ok { if body.ExternalTwitchEnabled = &p.Enabled; *body.ExternalTwitchEnabled { body.ExternalTwitchClientId = &p.ClientId - body.ExternalTwitchSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalTwitchSecret = &p.Secret.Value + } } } if p, ok := e["twitter"]; ok { if body.ExternalTwitterEnabled = &p.Enabled; *body.ExternalTwitterEnabled { body.ExternalTwitterClientId = &p.ClientId - body.ExternalTwitterSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalTwitterSecret = &p.Secret.Value + } } } if p, ok := e["workos"]; ok { if body.ExternalWorkosEnabled = &p.Enabled; *body.ExternalWorkosEnabled { body.ExternalWorkosClientId = &p.ClientId - body.ExternalWorkosSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalWorkosSecret = &p.Secret.Value + } body.ExternalWorkosUrl = &p.Url } } if p, ok := e["zoom"]; ok { if body.ExternalZoomEnabled = &p.Enabled; *body.ExternalZoomEnabled { body.ExternalZoomClientId = &p.ClientId - body.ExternalZoomSecret = &p.Secret + if len(p.Secret.Value) > 0 { + body.ExternalZoomSecret = &p.Secret.Value + } } } } @@ -772,7 +814,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if ids := cast.Val(remoteConfig.ExternalAppleAdditionalClientIds, ""); len(ids) > 0 { p.ClientId += "," + ids } - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalAppleSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalAppleSecret, "") + } } p.Enabled = cast.Val(remoteConfig.ExternalAppleEnabled, false) e["apple"] = p @@ -781,7 +825,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["azure"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalAzureClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalAzureSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalAzureSecret, "") + } p.Url = cast.Val(remoteConfig.ExternalAzureUrl, "") } p.Enabled = cast.Val(remoteConfig.ExternalAzureEnabled, false) @@ -791,7 +837,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["bitbucket"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalBitbucketClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalBitbucketSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalBitbucketSecret, "") + } } p.Enabled = cast.Val(remoteConfig.ExternalBitbucketEnabled, false) e["bitbucket"] = p @@ -800,7 +848,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["discord"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalDiscordClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalDiscordSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalDiscordSecret, "") + } } p.Enabled = cast.Val(remoteConfig.ExternalDiscordEnabled, false) e["discord"] = p @@ -809,7 +859,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["facebook"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalFacebookClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalFacebookSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalFacebookSecret, "") + } } p.Enabled = cast.Val(remoteConfig.ExternalFacebookEnabled, false) e["facebook"] = p @@ -818,7 +870,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["figma"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalFigmaClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalFigmaSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalFigmaSecret, "") + } } p.Enabled = cast.Val(remoteConfig.ExternalFigmaEnabled, false) e["figma"] = p @@ -827,7 +881,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["github"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalGithubClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalGithubSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalGithubSecret, "") + } } p.Enabled = cast.Val(remoteConfig.ExternalGithubEnabled, false) e["github"] = p @@ -836,7 +892,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["gitlab"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalGitlabClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalGitlabSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalGitlabSecret, "") + } p.Url = cast.Val(remoteConfig.ExternalGitlabUrl, "") } p.Enabled = cast.Val(remoteConfig.ExternalGitlabEnabled, false) @@ -849,7 +907,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if ids := cast.Val(remoteConfig.ExternalGoogleAdditionalClientIds, ""); len(ids) > 0 { p.ClientId += "," + ids } - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalGoogleSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalGoogleSecret, "") + } p.SkipNonceCheck = cast.Val(remoteConfig.ExternalGoogleSkipNonceCheck, false) } p.Enabled = cast.Val(remoteConfig.ExternalGoogleEnabled, false) @@ -859,7 +919,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["kakao"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalKakaoClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalKakaoSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalKakaoSecret, "") + } } p.Enabled = cast.Val(remoteConfig.ExternalKakaoEnabled, false) e["kakao"] = p @@ -868,7 +930,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["keycloak"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalKeycloakClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalKeycloakSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalKeycloakSecret, "") + } p.Url = cast.Val(remoteConfig.ExternalKeycloakUrl, "") } p.Enabled = cast.Val(remoteConfig.ExternalKeycloakEnabled, false) @@ -878,7 +942,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["linkedin_oidc"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalLinkedinOidcClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalLinkedinOidcSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalLinkedinOidcSecret, "") + } } p.Enabled = cast.Val(remoteConfig.ExternalLinkedinOidcEnabled, false) e["linkedin_oidc"] = p @@ -887,7 +953,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["notion"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalNotionClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalNotionSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalNotionSecret, "") + } } p.Enabled = cast.Val(remoteConfig.ExternalNotionEnabled, false) e["notion"] = p @@ -896,7 +964,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["slack_oidc"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalSlackOidcClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalSlackOidcSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalSlackOidcSecret, "") + } } p.Enabled = cast.Val(remoteConfig.ExternalSlackOidcEnabled, false) e["slack_oidc"] = p @@ -905,7 +975,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["spotify"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalSpotifyClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalSpotifySecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalSpotifySecret, "") + } } p.Enabled = cast.Val(remoteConfig.ExternalSpotifyEnabled, false) e["spotify"] = p @@ -914,7 +986,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["twitch"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalTwitchClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalTwitchSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalTwitchSecret, "") + } } p.Enabled = cast.Val(remoteConfig.ExternalTwitchEnabled, false) e["twitch"] = p @@ -923,7 +997,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["twitter"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalTwitterClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalTwitterSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalTwitterSecret, "") + } } p.Enabled = cast.Val(remoteConfig.ExternalTwitterEnabled, false) e["twitter"] = p @@ -932,7 +1008,9 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["workos"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalWorkosClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalWorkosSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalWorkosSecret, "") + } p.Url = cast.Val(remoteConfig.ExternalWorkosUrl, "") } p.Enabled = cast.Val(remoteConfig.ExternalWorkosEnabled, false) @@ -942,16 +1020,17 @@ func (e external) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if p, ok := e["zoom"]; ok { if p.Enabled { p.ClientId = cast.Val(remoteConfig.ExternalZoomClientId, "") - p.Secret = hashPrefix + cast.Val(remoteConfig.ExternalZoomSecret, "") + if len(p.Secret.SHA256) > 0 { + p.Secret.SHA256 = cast.Val(remoteConfig.ExternalZoomSecret, "") + } } p.Enabled = cast.Val(remoteConfig.ExternalZoomEnabled, false) e["zoom"] = p } } -func (a *auth) DiffWithRemote(projectRef string, remoteConfig v1API.AuthConfigResponse) ([]byte, error) { +func (a *auth) DiffWithRemote(remoteConfig v1API.AuthConfigResponse) ([]byte, error) { copy := a.Clone() - copy.HashSecrets(projectRef) // Convert the config values into easily comparable remoteConfig values currentValue, err := ToTomlBytes(copy) if err != nil { @@ -964,52 +1043,3 @@ func (a *auth) DiffWithRemote(projectRef string, remoteConfig v1API.AuthConfigRe } return diff.Diff("remote[auth]", remoteCompare, "local[auth]", currentValue), nil } - -const hashPrefix = "hash:" - -func (a *auth) HashSecrets(key string) { - hash := func(v string) string { - if len(v) == 0 { - return hashPrefix - } - return hashPrefix + sha256Hmac(key, v) - } - if a.Email.Smtp != nil && a.Email.Smtp.IsEnabled() { - a.Email.Smtp.Pass = hash(a.Email.Smtp.Pass) - } - // Only hash secrets for locally enabled providers because other envs won't be loaded - switch { - case a.Sms.Twilio.Enabled: - a.Sms.Twilio.AuthToken = hash(a.Sms.Twilio.AuthToken) - case a.Sms.TwilioVerify.Enabled: - a.Sms.TwilioVerify.AuthToken = hash(a.Sms.TwilioVerify.AuthToken) - case a.Sms.Messagebird.Enabled: - a.Sms.Messagebird.AccessKey = hash(a.Sms.Messagebird.AccessKey) - case a.Sms.Textlocal.Enabled: - a.Sms.Textlocal.ApiKey = hash(a.Sms.Textlocal.ApiKey) - case a.Sms.Vonage.Enabled: - a.Sms.Vonage.ApiSecret = hash(a.Sms.Vonage.ApiSecret) - } - if a.Hook.MFAVerificationAttempt != nil && a.Hook.MFAVerificationAttempt.Enabled { - a.Hook.MFAVerificationAttempt.Secrets = hash(a.Hook.MFAVerificationAttempt.Secrets) - } - if a.Hook.PasswordVerificationAttempt != nil && a.Hook.PasswordVerificationAttempt.Enabled { - a.Hook.PasswordVerificationAttempt.Secrets = hash(a.Hook.PasswordVerificationAttempt.Secrets) - } - if a.Hook.CustomAccessToken != nil && a.Hook.CustomAccessToken.Enabled { - a.Hook.CustomAccessToken.Secrets = hash(a.Hook.CustomAccessToken.Secrets) - } - if a.Hook.SendSMS != nil && a.Hook.SendSMS.Enabled { - a.Hook.SendSMS.Secrets = hash(a.Hook.SendSMS.Secrets) - } - if a.Hook.SendEmail != nil && a.Hook.SendEmail.Enabled { - a.Hook.SendEmail.Secrets = hash(a.Hook.SendEmail.Secrets) - } - for name, provider := range a.External { - if provider.Enabled { - provider.Secret = hash(provider.Secret) - } - a.External[name] = provider - } - // TODO: support SecurityCaptchaSecret in local config -} diff --git a/pkg/config/auth_test.go b/pkg/config/auth_test.go index e659da166..b34139715 100644 --- a/pkg/config/auth_test.go +++ b/pkg/config/auth_test.go @@ -48,7 +48,7 @@ func TestAuthDiff(t *testing.T) { c.MinimumPasswordLength = 6 c.PasswordRequirements = LettersDigits // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ SiteUrl: cast.Ptr("http://127.0.0.1:3000"), UriAllowList: cast.Ptr("https://127.0.0.1:3000"), JwtExp: cast.Ptr(3600), @@ -78,7 +78,7 @@ func TestAuthDiff(t *testing.T) { c.MinimumPasswordLength = 6 c.PasswordRequirements = LowerUpperLettersDigitsSymbols // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ SiteUrl: cast.Ptr(""), UriAllowList: cast.Ptr("https://127.0.0.1:3000,https://ref.supabase.co"), JwtExp: cast.Ptr(0), @@ -99,7 +99,7 @@ func TestAuthDiff(t *testing.T) { c := newWithDefaults() c.EnableSignup = false // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ SiteUrl: cast.Ptr(""), UriAllowList: cast.Ptr(""), JwtExp: cast.Ptr(0), @@ -124,22 +124,34 @@ func TestHookDiff(t *testing.T) { CustomAccessToken: &hookConfig{ Enabled: true, URI: "http://example.com", - Secrets: "test-secret", + Secrets: Secret{ + Value: "test-secret", + SHA256: "ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252", + }, }, SendSMS: &hookConfig{ Enabled: true, URI: "http://example.com", - Secrets: "test-secret", + Secrets: Secret{ + Value: "test-secret", + SHA256: "ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252", + }, }, SendEmail: &hookConfig{ Enabled: true, URI: "https://example.com", - Secrets: "test-secret", + Secrets: Secret{ + Value: "test-secret", + SHA256: "ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252", + }, }, MFAVerificationAttempt: &hookConfig{ Enabled: true, URI: "https://example.com", - Secrets: "test-secret", + Secrets: Secret{ + Value: "test-secret", + SHA256: "ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252", + }, }, PasswordVerificationAttempt: &hookConfig{ Enabled: true, @@ -147,7 +159,7 @@ func TestHookDiff(t *testing.T) { }, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ HookCustomAccessTokenEnabled: cast.Ptr(true), HookCustomAccessTokenUri: cast.Ptr("http://example.com"), HookCustomAccessTokenSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), @@ -177,7 +189,7 @@ func TestHookDiff(t *testing.T) { SendSMS: &hookConfig{ Enabled: false, URI: "https://example.com", - Secrets: "test-secret", + Secrets: Secret{Value: "test-secret"}, }, SendEmail: &hookConfig{ Enabled: false, @@ -189,7 +201,7 @@ func TestHookDiff(t *testing.T) { PasswordVerificationAttempt: nil, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ HookCustomAccessTokenEnabled: cast.Ptr(true), HookCustomAccessTokenUri: cast.Ptr("http://example.com"), HookCustomAccessTokenSecrets: cast.Ptr("ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252"), @@ -215,12 +227,18 @@ func TestHookDiff(t *testing.T) { CustomAccessToken: &hookConfig{ Enabled: true, URI: "http://example.com", - Secrets: "test-secret", + Secrets: Secret{ + Value: "test-secret", + SHA256: "ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252", + }, }, SendSMS: &hookConfig{ Enabled: true, URI: "https://example.com", - Secrets: "test-secret", + Secrets: Secret{ + Value: "test-secret", + SHA256: "ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252", + }, }, SendEmail: &hookConfig{ Enabled: true, @@ -233,7 +251,7 @@ func TestHookDiff(t *testing.T) { PasswordVerificationAttempt: nil, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ HookCustomAccessTokenEnabled: cast.Ptr(false), HookCustomAccessTokenUri: cast.Ptr("pg-functions://postgres/public/customToken"), HookSendSmsEnabled: cast.Ptr(false), @@ -261,7 +279,7 @@ func TestHookDiff(t *testing.T) { PasswordVerificationAttempt: &hookConfig{Enabled: false}, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ HookCustomAccessTokenEnabled: cast.Ptr(false), HookSendSmsEnabled: cast.Ptr(false), HookSendEmailEnabled: cast.Ptr(false), @@ -298,7 +316,7 @@ func TestMfaDiff(t *testing.T) { MaxEnrolledFactors: 10, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ MfaMaxEnrolledFactors: cast.Ptr(10), MfaTotpEnrollEnabled: cast.Ptr(true), MfaTotpVerifyEnabled: cast.Ptr(true), @@ -330,7 +348,7 @@ func TestMfaDiff(t *testing.T) { }, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ MfaMaxEnrolledFactors: cast.Ptr(10), MfaTotpEnrollEnabled: cast.Ptr(false), MfaTotpVerifyEnabled: cast.Ptr(false), @@ -358,7 +376,7 @@ func TestMfaDiff(t *testing.T) { }, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ MfaMaxEnrolledFactors: cast.Ptr(10), MfaTotpEnrollEnabled: cast.Ptr(false), MfaTotpVerifyEnabled: cast.Ptr(false), @@ -411,11 +429,14 @@ func TestEmailDiff(t *testing.T) { }, }, Smtp: &smtp{ - Enabled: cast.Ptr(true), - Host: "smtp.sendgrid.net", - Port: 587, - User: "apikey", - Pass: "test-key", + Enabled: cast.Ptr(true), + Host: "smtp.sendgrid.net", + Port: 587, + User: "apikey", + Pass: Secret{ + Value: "test-key", + SHA256: "ed64b7695a606bc6ab4fcb41fe815b5ddf1063ccbc87afe1fa89756635db520e", + }, AdminEmail: "admin@email.com", SenderName: "Admin", }, @@ -424,7 +445,7 @@ func TestEmailDiff(t *testing.T) { OtpExpiry: 3600, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ ExternalEmailEnabled: cast.Ptr(true), MailerSecureEmailChangeEnabled: cast.Ptr(true), MailerAutoconfirm: cast.Ptr(false), @@ -489,10 +510,13 @@ func TestEmailDiff(t *testing.T) { }, }, Smtp: &smtp{ - Host: "smtp.sendgrid.net", - Port: 587, - User: "apikey", - Pass: "test-key", + Host: "smtp.sendgrid.net", + Port: 587, + User: "apikey", + Pass: Secret{ + Value: "test-key", + SHA256: "ed64b7695a606bc6ab4fcb41fe815b5ddf1063ccbc87afe1fa89756635db520e", + }, AdminEmail: "admin@email.com", SenderName: "Admin", }, @@ -501,7 +525,7 @@ func TestEmailDiff(t *testing.T) { OtpExpiry: 86400, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ ExternalEmailEnabled: cast.Ptr(false), MailerSecureEmailChangeEnabled: cast.Ptr(false), MailerAutoconfirm: cast.Ptr(true), @@ -537,7 +561,7 @@ func TestEmailDiff(t *testing.T) { OtpExpiry: 86400, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ ExternalEmailEnabled: cast.Ptr(true), MailerSecureEmailChangeEnabled: cast.Ptr(true), MailerAutoconfirm: cast.Ptr(false), @@ -583,11 +607,14 @@ func TestEmailDiff(t *testing.T) { "reauthentication": {}, }, Smtp: &smtp{ - Enabled: cast.Ptr(false), - Host: "smtp.sendgrid.net", - Port: 587, - User: "apikey", - Pass: "test-key", + Enabled: cast.Ptr(false), + Host: "smtp.sendgrid.net", + Port: 587, + User: "apikey", + Pass: Secret{ + Value: "test-key", + SHA256: "ed64b7695a606bc6ab4fcb41fe815b5ddf1063ccbc87afe1fa89756635db520e", + }, AdminEmail: "admin@email.com", SenderName: "Admin", }, @@ -596,7 +623,7 @@ func TestEmailDiff(t *testing.T) { OtpExpiry: 3600, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ ExternalEmailEnabled: cast.Ptr(false), MailerSecureEmailChangeEnabled: cast.Ptr(false), MailerAutoconfirm: cast.Ptr(true), @@ -624,11 +651,14 @@ func TestSmsDiff(t *testing.T) { Enabled: true, AccountSid: "test-account", MessageServiceSid: "test-service", - AuthToken: "test-token", + AuthToken: Secret{ + Value: "test-token", + SHA256: "c84443bc59b92caef8ec8500ff443584793756749523811eb333af2bbc74fc88", + }, }, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(true), SmsAutoconfirm: cast.Ptr(true), SmsMaxFrequency: cast.Ptr(60), @@ -662,7 +692,7 @@ func TestSmsDiff(t *testing.T) { t.Run("local disabled remote enabled", func(t *testing.T) { c := newWithDefaults() // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(true), SmsAutoconfirm: cast.Ptr(true), SmsMaxFrequency: cast.Ptr(60), @@ -693,11 +723,14 @@ func TestSmsDiff(t *testing.T) { Messagebird: messagebirdConfig{ Enabled: true, Originator: "test-originator", - AccessKey: "test-access-key", + AccessKey: Secret{ + Value: "test-access-key", + SHA256: "ab60d03fc809fb02dae838582f3ddc13d1d6cb32ffba77c4b969dd3caa496f13", + }, }, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(false), SmsAutoconfirm: cast.Ptr(false), SmsMaxFrequency: cast.Ptr(0), @@ -725,7 +758,7 @@ func TestSmsDiff(t *testing.T) { MaxFrequency: time.Minute, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(false), SmsAutoconfirm: cast.Ptr(true), SmsMaxFrequency: cast.Ptr(60), @@ -749,7 +782,7 @@ func TestSmsDiff(t *testing.T) { c := newWithDefaults() c.Sms.EnableSignup = true // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(false), SmsProvider: cast.Ptr("twilio"), }) @@ -762,7 +795,7 @@ func TestSmsDiff(t *testing.T) { c := newWithDefaults() c.Sms.Messagebird.Enabled = true // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ ExternalPhoneEnabled: cast.Ptr(false), SmsProvider: cast.Ptr("messagebird"), SmsMessagebirdAccessKey: cast.Ptr(""), @@ -798,7 +831,7 @@ func TestExternalDiff(t *testing.T) { "zoom": {Enabled: true}, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ ExternalAppleAdditionalClientIds: cast.Ptr(""), ExternalAppleClientId: cast.Ptr(""), ExternalAppleEnabled: cast.Ptr(true), @@ -879,12 +912,18 @@ func TestExternalDiff(t *testing.T) { "apple": { Enabled: true, ClientId: "test-client-1,test-client-2", - Secret: "test-secret", + Secret: Secret{ + Value: "test-secret", + SHA256: "ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252", + }, }, "azure": { Enabled: true, ClientId: "test-client-1", - Secret: "test-secret", + Secret: Secret{ + Value: "test-secret", + SHA256: "ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252", + }, }, "bitbucket": {}, "discord": {}, @@ -895,7 +934,7 @@ func TestExternalDiff(t *testing.T) { "google": { Enabled: false, ClientId: "test-client-2", - Secret: "env(test_secret)", + Secret: Secret{Value: "env(test_secret)"}, SkipNonceCheck: false, }, // "kakao": {}, @@ -910,7 +949,7 @@ func TestExternalDiff(t *testing.T) { "zoom": {}, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ ExternalAppleAdditionalClientIds: cast.Ptr("test-client-2"), ExternalAppleClientId: cast.Ptr("test-client-1"), ExternalAppleEnabled: cast.Ptr(false), @@ -953,7 +992,7 @@ func TestExternalDiff(t *testing.T) { "zoom": {}, } // Run test - diff, err := c.DiffWithRemote("", v1API.AuthConfigResponse{ + diff, err := c.DiffWithRemote(v1API.AuthConfigResponse{ ExternalAppleEnabled: cast.Ptr(false), ExternalAzureEnabled: cast.Ptr(false), ExternalBitbucketEnabled: cast.Ptr(false), diff --git a/pkg/config/config.go b/pkg/config/config.go index 35b84eb68..837f305a9 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -412,22 +412,27 @@ func (c *config) loadFromReader(v *viper.Viper, r io.Reader) error { v.Set("functions."+key, function{}) } } - if err := v.UnmarshalExact(c, viper.DecodeHook(mapstructure.ComposeDecodeHookFunc( - mapstructure.StringToTimeDurationHookFunc(), - mapstructure.StringToIPHookFunc(), - mapstructure.StringToSliceHookFunc(","), - mapstructure.TextUnmarshallerHookFunc(), - LoadEnvHook, - // TODO: include decrypt secret hook - )), func(dc *mapstructure.DecoderConfig) { + if err := v.UnmarshalExact(c, func(dc *mapstructure.DecoderConfig) { dc.TagName = "toml" dc.Squash = true + dc.DecodeHook = c.newDecodeHook(LoadEnvHook) }); err != nil { return errors.Errorf("failed to parse config: %w", err) } return nil } +func (c *config) newDecodeHook(fs ...mapstructure.DecodeHookFunc) mapstructure.DecodeHookFunc { + fs = append(fs, + mapstructure.StringToTimeDurationHookFunc(), + mapstructure.StringToIPHookFunc(), + mapstructure.StringToSliceHookFunc(","), + mapstructure.TextUnmarshallerHookFunc(), + DecryptSecretHookFunc(c.ProjectId), + ) + return mapstructure.ComposeDecodeHookFunc(fs...) +} + // Loads envs prefixed with supabase_ to struct fields tagged with mapstructure. func (c *config) loadFromEnv() error { v := viper.New() @@ -449,13 +454,7 @@ func (c *config) loadFromEnv() error { return errors.Errorf("failed to merge env config: %w", err) } // Writes viper state back to config struct, with automatic env substitution - if err := v.UnmarshalExact(c, viper.DecodeHook(mapstructure.ComposeDecodeHookFunc( - mapstructure.StringToTimeDurationHookFunc(), - mapstructure.StringToIPHookFunc(), - mapstructure.StringToSliceHookFunc(","), - mapstructure.TextUnmarshallerHookFunc(), - // TODO: include decrypt secret hook - ))); err != nil { + if err := v.UnmarshalExact(c, viper.DecodeHook(c.newDecodeHook())); err != nil { return errors.Errorf("failed to parse env override: %w", err) } return nil @@ -795,13 +794,13 @@ func assertEnvLoaded(s string) error { } func LoadEnvHook(f reflect.Kind, t reflect.Kind, data interface{}) (interface{}, error) { - if f != reflect.String || t != reflect.String { + if f != reflect.String { return data, nil } value := data.(string) if matches := envPattern.FindStringSubmatch(value); len(matches) > 1 { - if v, exists := os.LookupEnv(matches[1]); exists { - value = v + if env, exists := os.LookupEnv(matches[1]); exists { + value = env } } return value, nil @@ -912,13 +911,13 @@ func (e *email) validate(fsys fs.FS) (err error) { if len(e.Smtp.User) == 0 { return errors.New("Missing required field in config: auth.email.smtp.user") } - if len(e.Smtp.Pass) == 0 { + if len(e.Smtp.Pass.Value) == 0 { return errors.New("Missing required field in config: auth.email.smtp.pass") } if len(e.Smtp.AdminEmail) == 0 { return errors.New("Missing required field in config: auth.email.smtp.admin_email") } - if err := assertEnvLoaded(e.Smtp.Pass); err != nil { + if err := assertEnvLoaded(e.Smtp.Pass.Value); err != nil { return err } } @@ -934,10 +933,10 @@ func (s *sms) validate() (err error) { if len(s.Twilio.MessageServiceSid) == 0 { return errors.New("Missing required field in config: auth.sms.twilio.message_service_sid") } - if len(s.Twilio.AuthToken) == 0 { + if len(s.Twilio.AuthToken.Value) == 0 { return errors.New("Missing required field in config: auth.sms.twilio.auth_token") } - if err := assertEnvLoaded(s.Twilio.AuthToken); err != nil { + if err := assertEnvLoaded(s.Twilio.AuthToken.Value); err != nil { return err } case s.TwilioVerify.Enabled: @@ -947,30 +946,30 @@ func (s *sms) validate() (err error) { if len(s.TwilioVerify.MessageServiceSid) == 0 { return errors.New("Missing required field in config: auth.sms.twilio_verify.message_service_sid") } - if len(s.TwilioVerify.AuthToken) == 0 { + if len(s.TwilioVerify.AuthToken.Value) == 0 { return errors.New("Missing required field in config: auth.sms.twilio_verify.auth_token") } - if err := assertEnvLoaded(s.TwilioVerify.AuthToken); err != nil { + if err := assertEnvLoaded(s.TwilioVerify.AuthToken.Value); err != nil { return err } case s.Messagebird.Enabled: if len(s.Messagebird.Originator) == 0 { return errors.New("Missing required field in config: auth.sms.messagebird.originator") } - if len(s.Messagebird.AccessKey) == 0 { + if len(s.Messagebird.AccessKey.Value) == 0 { return errors.New("Missing required field in config: auth.sms.messagebird.access_key") } - if err := assertEnvLoaded(s.Messagebird.AccessKey); err != nil { + if err := assertEnvLoaded(s.Messagebird.AccessKey.Value); err != nil { return err } case s.Textlocal.Enabled: if len(s.Textlocal.Sender) == 0 { return errors.New("Missing required field in config: auth.sms.textlocal.sender") } - if len(s.Textlocal.ApiKey) == 0 { + if len(s.Textlocal.ApiKey.Value) == 0 { return errors.New("Missing required field in config: auth.sms.textlocal.api_key") } - if err := assertEnvLoaded(s.Textlocal.ApiKey); err != nil { + if err := assertEnvLoaded(s.Textlocal.ApiKey.Value); err != nil { return err } case s.Vonage.Enabled: @@ -980,13 +979,13 @@ func (s *sms) validate() (err error) { if len(s.Vonage.ApiKey) == 0 { return errors.New("Missing required field in config: auth.sms.vonage.api_key") } - if len(s.Vonage.ApiSecret) == 0 { + if len(s.Vonage.ApiSecret.Value) == 0 { return errors.New("Missing required field in config: auth.sms.vonage.api_secret") } if err := assertEnvLoaded(s.Vonage.ApiKey); err != nil { return err } - if err := assertEnvLoaded(s.Vonage.ApiSecret); err != nil { + if err := assertEnvLoaded(s.Vonage.ApiSecret.Value); err != nil { return err } case s.EnableSignup: @@ -1010,13 +1009,13 @@ func (e external) validate() (err error) { if provider.ClientId == "" { return errors.Errorf("Missing required field in config: auth.external.%s.client_id", ext) } - if !sliceContains([]string{"apple", "google"}, ext) && provider.Secret == "" { + if !sliceContains([]string{"apple", "google"}, ext) && len(provider.Secret.Value) == 0 { return errors.Errorf("Missing required field in config: auth.external.%s.secret", ext) } if err := assertEnvLoaded(provider.ClientId); err != nil { return err } - if err := assertEnvLoaded(provider.Secret); err != nil { + if err := assertEnvLoaded(provider.Secret.Value); err != nil { return err } if err := assertEnvLoaded(provider.RedirectUri); err != nil { @@ -1075,18 +1074,18 @@ func (h *hookConfig) validate(hookType string) (err error) { } switch strings.ToLower(parsed.Scheme) { case "http", "https": - if len(h.Secrets) == 0 { + if len(h.Secrets.Value) == 0 { return errors.Errorf("Missing required field in config: auth.hook.%s.secrets", hookType) - } else if err := assertEnvLoaded(h.Secrets); err != nil { + } else if err := assertEnvLoaded(h.Secrets.Value); err != nil { return err } - for _, secret := range strings.Split(h.Secrets, "|") { + for _, secret := range strings.Split(h.Secrets.Value, "|") { if !hookSecretPattern.MatchString(secret) { return errors.Errorf(`Invalid hook config: auth.hook.%s.secrets must be formatted as "v1,whsec_"`, hookType) } } case "pg-functions": - if len(h.Secrets) > 0 { + if len(h.Secrets.Value) > 0 { return errors.Errorf("Invalid hook config: auth.hook.%s.secrets is unsupported for pg-functions URI", hookType) } default: diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index e1678f2ed..45b2d04f6 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -45,7 +45,7 @@ func TestConfigParsing(t *testing.T) { assert.NoError(t, config.Load("", fsys)) // Check error assert.Equal(t, "hello", config.Auth.External["azure"].ClientId) - assert.Equal(t, "this is cool", config.Auth.External["azure"].Secret) + assert.Equal(t, "this is cool", config.Auth.External["azure"].Secret.Value) assert.Equal(t, []string{ "https://127.0.0.1:3000", "http://localhost:3000/auth/callback", @@ -214,7 +214,7 @@ func TestValidateHookURI(t *testing.T) { hookConfig: hookConfig{ Enabled: true, URI: "http://example.com", - Secrets: "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw==", + Secrets: Secret{Value: "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw=="}, }, }, { @@ -222,7 +222,7 @@ func TestValidateHookURI(t *testing.T) { hookConfig: hookConfig{ Enabled: true, URI: "https://example.com", - Secrets: "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw==", + Secrets: Secret{Value: "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw=="}, }, }, { @@ -237,7 +237,7 @@ func TestValidateHookURI(t *testing.T) { hookConfig: hookConfig{ Enabled: true, URI: "ftp://example.com", - Secrets: "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw==", + Secrets: Secret{Value: "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw=="}, }, errorMsg: "Invalid hook config: auth.hook.invalid URI with unsupported scheme.uri should be a HTTP, HTTPS, or pg-functions URI", }, @@ -246,7 +246,7 @@ func TestValidateHookURI(t *testing.T) { hookConfig: hookConfig{ Enabled: true, URI: "http://a b.com", - Secrets: "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw==", + Secrets: Secret{Value: "v1,whsec_aWxpa2VzdXBhYmFzZXZlcnltdWNoYW5kaWhvcGV5b3Vkb3Rvbw=="}, }, errorMsg: "failed to parse template url: parse \"http://a b.com\": invalid character \" \" in host name", }, @@ -263,7 +263,7 @@ func TestValidateHookURI(t *testing.T) { hookConfig: hookConfig{ Enabled: true, URI: "pg-functions://functionName", - Secrets: "test-secret", + Secrets: Secret{Value: "test-secret"}, }, errorMsg: "Invalid hook config: auth.hook.valid pg-functions URI with unsupported secrets.secrets is unsupported for pg-functions URI", }, diff --git a/pkg/config/secret.go b/pkg/config/secret.go new file mode 100644 index 000000000..64da04d77 --- /dev/null +++ b/pkg/config/secret.go @@ -0,0 +1,83 @@ +package config + +import ( + "encoding/base64" + "os" + "reflect" + "strings" + + ecies "github.com/ecies/go/v2" + "github.com/go-errors/errors" + "github.com/mitchellh/mapstructure" +) + +type Secret struct { + Value string + SHA256 string +} + +const HASHED_PREFIX = "hash:" + +func (s Secret) MarshalText() (text []byte, err error) { + if len(s.SHA256) == 0 { + return []byte{}, nil + } + return []byte(HASHED_PREFIX + s.SHA256), nil +} + +const ENCRYPTED_PREFIX = "encrypted:" + +// Decrypt secret values following dotenvx convention: +// https://github.com/dotenvx/dotenvx/blob/main/src/lib/helpers/decryptKeyValue.js +func decrypt(key, value string) (string, error) { + if !strings.HasPrefix(value, ENCRYPTED_PREFIX) { + return value, nil + } + if len(key) == 0 { + return value, errors.New("missing private key") + } + // Verify private key exists + privateKey, err := ecies.NewPrivateKeyFromHex(key) + if err != nil { + return value, errors.Errorf("failed to hex decode private key: %w", err) + } + // Verify ciphertext is base64 encoded + encoded := value[len(ENCRYPTED_PREFIX):] + ciphertext, err := base64.StdEncoding.DecodeString(encoded) + if err != nil { + return value, errors.Errorf("failed to base64 decode secret: %w", err) + } + // Return decrypted value + plaintext, err := ecies.Decrypt(privateKey, ciphertext) + if err != nil { + return value, errors.Errorf("failed to decrypt secret: %w", err) + } + return string(plaintext), nil +} + +func DecryptSecretHookFunc(hashKey string) mapstructure.DecodeHookFunc { + return func(f reflect.Type, t reflect.Type, data interface{}) (interface{}, error) { + if f.Kind() != reflect.String { + return data, nil + } + var result Secret + if t != reflect.TypeOf(result) { + return data, nil + } + ciphertext := data.(string) + // Skip hashing unloaded env + if matches := envPattern.FindStringSubmatch(ciphertext); len(matches) > 1 { + return result, nil + } + var err error + privKey := os.Getenv("DOTENV_PRIVATE_KEY") + for _, k := range strings.Split(privKey, ",") { + result.Value, err = decrypt(k, ciphertext) + if err == nil && len(result.Value) > 0 { + result.SHA256 = sha256Hmac(hashKey, result.Value) + break + } + } + return result, err + } +} diff --git a/pkg/config/secret_test.go b/pkg/config/secret_test.go new file mode 100644 index 000000000..c4bf74e5b --- /dev/null +++ b/pkg/config/secret_test.go @@ -0,0 +1,52 @@ +package config + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestDecryptSecret(t *testing.T) { + key := "7fd7210cef8f331ee8c55897996aaaafd853a2b20a4dc73d6d75759f65d2a7eb" + value := "encrypted:BKiXH15AyRzeohGyUrmB6cGjSklCrrBjdesQlX1VcXo/Xp20Bi2gGZ3AlIqxPQDmjVAALnhZamKnuY73l8Dz1P+BYiZUgxTSLzdCvdYUyVbNekj2UudbdUizBViERtZkuQwZHIv/" + + t.Run("decrypts secret value", func(t *testing.T) { + // Run test + plaintext, err := decrypt(key, value) + // Check error + assert.NoError(t, err) + assert.Equal(t, "value", plaintext) + }) + + t.Run("throws error on missing key", func(t *testing.T) { + // Run test + plaintext, err := decrypt("", value) + // Check error + assert.ErrorContains(t, err, "missing private key") + assert.Equal(t, value, plaintext) + }) + + t.Run("throws error on non-hex key", func(t *testing.T) { + // Run test + plaintext, err := decrypt("invalid", value) + // Check error + assert.ErrorContains(t, err, "failed to hex decode private key: cannot decode hex string") + assert.Equal(t, value, plaintext) + }) + + t.Run("throws error on non-base64 value", func(t *testing.T) { + // Run test + plaintext, err := decrypt(key, "encrypted:invalid") + // Check error + assert.ErrorContains(t, err, "failed to base64 decode secret: illegal base64 data at input byte 4") + assert.Equal(t, "encrypted:invalid", plaintext) + }) + + t.Run("throws error on empty ciphertext", func(t *testing.T) { + // Run test + plaintext, err := decrypt(key, "encrypted:") + // Check error + assert.ErrorContains(t, err, "failed to decrypt secret: invalid length of message") + assert.Equal(t, "encrypted:", plaintext) + }) +} diff --git a/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff index 85d30362a..ad89a5d1e 100644 --- a/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff +++ b/pkg/config/testdata/TestEmailDiff/local_enabled_remote_disabled.diff @@ -46,7 +46,7 @@ diff remote[auth] local[auth] -host = "" -port = 0 -user = "" --pass = "hash:" +-pass = "" -admin_email = "" -sender_name = "" +host = "smtp.sendgrid.net" diff --git a/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff b/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff index 089d74eee..8b78fb240 100644 --- a/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff +++ b/pkg/config/testdata/TestExternalDiff/local_enabled_and_disabled.diff @@ -16,7 +16,7 @@ diff remote[auth] local[auth] [external.azure] -enabled = false -client_id = "" --secret = "hash:" +-secret = "" +enabled = true +client_id = "test-client-1" +secret = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" @@ -30,5 +30,5 @@ diff remote[auth] local[auth] -enabled = true +enabled = false client_id = "test-client-2" - secret = "env(test_secret)" + secret = "" url = "" diff --git a/pkg/config/testdata/TestHookDiff/local_disabled_remote_enabled.diff b/pkg/config/testdata/TestHookDiff/local_disabled_remote_enabled.diff index c8cf4c5f0..247618f0c 100644 --- a/pkg/config/testdata/TestHookDiff/local_disabled_remote_enabled.diff +++ b/pkg/config/testdata/TestHookDiff/local_disabled_remote_enabled.diff @@ -18,7 +18,7 @@ diff remote[auth] local[auth] -enabled = true +enabled = false uri = "https://example.com" - secrets = "test-secret" + secrets = "" [hook.send_email] -enabled = true +enabled = false diff --git a/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff index dc80e57a3..556b13ff5 100644 --- a/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff +++ b/pkg/config/testdata/TestHookDiff/local_enabled_remote_disabled.diff @@ -8,11 +8,11 @@ diff remote[auth] local[auth] -enabled = false +enabled = true uri = "pg-functions://postgres/public/verifyMFA" - secrets = "hash:" + secrets = "" [hook.custom_access_token] -enabled = false -uri = "pg-functions://postgres/public/customToken" --secrets = "hash:" +-secrets = "" +enabled = true +uri = "http://example.com" +secrets = "hash:ce62bb9bcced294fd4afe668f8ab3b50a89cf433093c526fffa3d0e46bf55252" @@ -26,6 +26,6 @@ diff remote[auth] local[auth] -uri = "https://example.com" +enabled = true +uri = "pg-functions://postgres/public/sendEmail" - secrets = "hash:" + secrets = "" [mfa] diff --git a/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff b/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff index 4418013bf..02f0b76cd 100644 --- a/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff +++ b/pkg/config/testdata/TestSmsDiff/local_enabled_remote_disabled.diff @@ -25,7 +25,7 @@ diff remote[auth] local[auth] [sms.messagebird] -enabled = false -originator = "" --access_key = "hash:" +-access_key = "" +enabled = true +originator = "test-originator" +access_key = "hash:ab60d03fc809fb02dae838582f3ddc13d1d6cb32ffba77c4b969dd3caa496f13" diff --git a/pkg/config/updater.go b/pkg/config/updater.go index 445000d0b..e5f42aceb 100644 --- a/pkg/config/updater.go +++ b/pkg/config/updater.go @@ -110,7 +110,7 @@ func (u *ConfigUpdater) UpdateAuthConfig(ctx context.Context, projectRef string, } else if authConfig.JSON200 == nil { return errors.Errorf("unexpected status %d: %s", authConfig.StatusCode(), string(authConfig.Body)) } - authDiff, err := c.DiffWithRemote(projectRef, *authConfig.JSON200) + authDiff, err := c.DiffWithRemote(*authConfig.JSON200) if err != nil { return err } else if len(authDiff) == 0 { From 98984514541b84bd2e5288e776128e3d686117ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Jan 2025 05:03:32 +0000 Subject: [PATCH 265/305] chore(deps): bump github.com/spf13/afero from 1.11.0 to 1.12.0 (#3027) Bumps [github.com/spf13/afero](https://github.com/spf13/afero) from 1.11.0 to 1.12.0. - [Release notes](https://github.com/spf13/afero/releases) - [Commits](https://github.com/spf13/afero/compare/v1.11.0...v1.12.0) --- updated-dependencies: - dependency-name: github.com/spf13/afero dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 10 +++++----- go.sum | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index 4e5fcaff0..6a14704f6 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ require ( github.com/muesli/reflow v0.3.0 github.com/oapi-codegen/runtime v1.1.1 github.com/slack-go/slack v0.15.0 - github.com/spf13/afero v1.11.0 + github.com/spf13/afero v1.12.0 github.com/spf13/cobra v1.8.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.19.0 @@ -322,7 +322,7 @@ require ( go.uber.org/automaxprocs v1.6.0 // indirect go.uber.org/multierr v1.9.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.31.0 // indirect + golang.org/x/crypto v0.32.0 // indirect golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect golang.org/x/net v0.33.0 // indirect @@ -330,9 +330,9 @@ require ( golang.org/x/sys v0.29.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/tools v0.28.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect - google.golang.org/protobuf v1.35.1 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 // indirect + google.golang.org/protobuf v1.36.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/go.sum b/go.sum index d475808d6..556191612 100644 --- a/go.sum +++ b/go.sum @@ -894,8 +894,8 @@ github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9yS github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= github.com/sourcegraph/go-diff v0.7.0 h1:9uLlrd5T46OXs5qpp8L/MTltk0zikUGi0sNNyCpA8G0= github.com/sourcegraph/go-diff v0.7.0/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs= -github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= -github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= +github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs= +github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4= github.com/spf13/cast v0.0.0-20150508191742-4d07383ffe94/go.mod h1:r2rcYCSwa1IExKTDiTfzaxqT2FNHs8hODu4LnUfgKEg= github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= @@ -1080,8 +1080,8 @@ golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.20.0/go.mod h1:Xwo95rrVNIoSMx9wa1JroENMToLWn3RNVrTBpLHgZPQ= golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= +golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1315,8 +1315,8 @@ golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= -golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/time v0.8.0 h1:9i3RxcPv3PZnitoVGMPDKZSq1xW1gK1Xy3ArNOGZfEg= +golang.org/x/time v0.8.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -1445,10 +1445,10 @@ google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7Fc google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 h1:fVoAXEKA4+yufmbdVYv+SE73+cPZbbbe8paLsHfkK+U= -google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53/go.mod h1:riSXTwQ4+nqmPGtobMFyW5FqVAmIs0St6VPp4Ug7CE4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 h1:X58yt85/IXCx0Y3ZwN6sEIKZzQtDEYaBWrDvErdXrRE= -google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53/go.mod h1:GX3210XPVPUjJbTUbvwI8f2IpZDMZuPJWDzDuebbviI= +google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576 h1:CkkIfIt50+lT6NHAVoRYEyAvQGFM7xEwXUUywFvEb3Q= +google.golang.org/genproto/googleapis/api v0.0.0-20241209162323-e6fa225c2576/go.mod h1:1R3kvZ1dtP3+4p4d3G8uJ8rFk/fWlScl38vanWACI08= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 h1:TqExAhdPaB60Ux47Cn0oLV07rGnxZzIsaRhQaqS666A= +google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8/go.mod h1:lcTa1sDdWEIHMWlITnIczmw5w60CF9ffkb8Z+DVmmjA= google.golang.org/grpc v1.0.5/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -1476,8 +1476,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= -google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= +google.golang.org/protobuf v1.36.1 h1:yBPeRvTftaleIgM3PZ/WBIZ7XM/eEYAaEyCwvyjq/gk= +google.golang.org/protobuf v1.36.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/cenkalti/backoff.v2 v2.2.1 h1:eJ9UAg01/HIHG987TwxvnzK2MgxXq97YY6rYDpY9aII= From 88cd60986ae2bbe46abcabd980a4023b8ae8a8c3 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Fri, 10 Jan 2025 18:00:20 +0800 Subject: [PATCH 266/305] fix: unmarshal remote override into base config (#3028) * fix: unmarshal remote override into base config * chore: account for project ref flag when loading config * fix: restore project id from base config --- cmd/link.go | 4 +- internal/bootstrap/bootstrap.go | 2 +- internal/config/push/push.go | 10 ++- internal/db/branch/create/create.go | 3 +- internal/db/branch/delete/delete.go | 3 +- internal/db/branch/switch_/switch_.go | 3 +- internal/db/diff/diff.go | 3 +- internal/db/diff/pgadmin.go | 3 +- internal/db/pull/pull.go | 3 +- internal/db/push/push.go | 7 +- internal/db/remote/changes/changes.go | 3 +- internal/db/remote/commit/commit.go | 3 +- internal/db/reset/reset.go | 9 +-- internal/db/start/start.go | 3 +- internal/functions/deploy/deploy.go | 8 +- internal/functions/download/download.go | 3 +- internal/functions/new/new.go | 3 +- internal/functions/serve/serve.go | 3 +- internal/gen/types/types.go | 3 +- internal/migration/squash/squash.go | 3 +- internal/seed/buckets/buckets.go | 5 +- internal/start/start.go | 2 +- internal/status/status.go | 3 +- internal/stop/stop.go | 3 +- internal/storage/cp/cp.go | 3 +- internal/utils/config.go | 12 --- internal/utils/flags/config_path.go | 22 ++++++ internal/utils/flags/db_url.go | 6 +- pkg/config/config.go | 98 ++++++++++--------------- pkg/config/config_test.go | 10 +-- pkg/config/testdata/config.toml | 5 +- 31 files changed, 124 insertions(+), 127 deletions(-) create mode 100644 internal/utils/flags/config_path.go diff --git a/cmd/link.go b/cmd/link.go index 59c93545c..65b8b5f08 100644 --- a/cmd/link.go +++ b/cmd/link.go @@ -8,7 +8,6 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" "github.com/supabase/cli/internal/link" - "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/internal/utils/flags" "golang.org/x/term" ) @@ -31,8 +30,7 @@ var ( return err } fsys := afero.NewOsFs() - utils.Config.ProjectId = flags.ProjectRef - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } return link.Run(ctx, flags.ProjectRef, fsys) diff --git a/internal/bootstrap/bootstrap.go b/internal/bootstrap/bootstrap.go index 677ef1530..8310a82fb 100644 --- a/internal/bootstrap/bootstrap.go +++ b/internal/bootstrap/bootstrap.go @@ -95,7 +95,7 @@ func Run(ctx context.Context, starter StarterTemplate, fsys afero.Fs, options .. return err } // 4. Link project - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } link.LinkServices(ctx, flags.ProjectRef, tenant.NewApiKey(keys).Anon, fsys) diff --git a/internal/config/push/push.go b/internal/config/push/push.go index b1b887765..d2dadddc3 100644 --- a/internal/config/push/push.go +++ b/internal/config/push/push.go @@ -7,16 +7,20 @@ import ( "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/config" ) func Run(ctx context.Context, ref string, fsys afero.Fs) error { - utils.Config.ProjectId = ref - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } client := config.NewConfigUpdater(*utils.GetSupabase()) - remote, _ := utils.Config.GetRemoteByProjectRef(ref) + remote, err := utils.Config.GetRemoteByProjectRef(ref) + if err != nil { + // Use base config when no remote is declared + remote.ProjectId = ref + } fmt.Fprintln(os.Stderr, "Pushing config to project:", remote.ProjectId) console := utils.NewConsole() keep := func(name string) bool { diff --git a/internal/db/branch/create/create.go b/internal/db/branch/create/create.go index 085e10f9d..550128376 100644 --- a/internal/db/branch/create/create.go +++ b/internal/db/branch/create/create.go @@ -14,6 +14,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" ) var ( @@ -22,7 +23,7 @@ var ( ) func Run(branch string, fsys afero.Fs) error { - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } if err := utils.AssertSupabaseDbIsRunning(); err != nil { diff --git a/internal/db/branch/delete/delete.go b/internal/db/branch/delete/delete.go index f59f5e51c..ea14cd34d 100644 --- a/internal/db/branch/delete/delete.go +++ b/internal/db/branch/delete/delete.go @@ -12,10 +12,11 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" ) func Run(branch string, fsys afero.Fs) error { - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } if err := utils.AssertSupabaseDbIsRunning(); err != nil { diff --git a/internal/db/branch/switch_/switch_.go b/internal/db/branch/switch_/switch_.go index 462b26c69..d11803e88 100644 --- a/internal/db/branch/switch_/switch_.go +++ b/internal/db/branch/switch_/switch_.go @@ -12,12 +12,13 @@ import ( "github.com/spf13/afero" "github.com/supabase/cli/internal/db/reset" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" ) func Run(ctx context.Context, target string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { // 1. Sanity checks { - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } if err := utils.AssertSupabaseDbIsRunning(); err != nil { diff --git a/internal/db/diff/diff.go b/internal/db/diff/diff.go index 6c5faa892..d54f5e534 100644 --- a/internal/db/diff/diff.go +++ b/internal/db/diff/diff.go @@ -24,6 +24,7 @@ import ( "github.com/supabase/cli/internal/db/start" "github.com/supabase/cli/internal/gen/keys" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/migration" "github.com/supabase/cli/pkg/parser" ) @@ -32,7 +33,7 @@ type DiffFunc func(context.Context, string, string, []string) (string, error) func Run(ctx context.Context, schema []string, file string, config pgconn.Config, differ DiffFunc, fsys afero.Fs, options ...func(*pgx.ConnConfig)) (err error) { // Sanity checks. - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } if utils.IsLocalDatabase(config) { diff --git a/internal/db/diff/pgadmin.go b/internal/db/diff/pgadmin.go index 298023580..55046bf24 100644 --- a/internal/db/diff/pgadmin.go +++ b/internal/db/diff/pgadmin.go @@ -11,6 +11,7 @@ import ( "github.com/supabase/cli/internal/db/start" "github.com/supabase/cli/internal/migration/new" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/config" ) @@ -35,7 +36,7 @@ func SaveDiff(out, file string, fsys afero.Fs) error { func RunPgAdmin(ctx context.Context, schema []string, file string, config pgconn.Config, fsys afero.Fs) error { // Sanity checks. { - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } if err := utils.AssertSupabaseDbIsRunning(); err != nil { diff --git a/internal/db/pull/pull.go b/internal/db/pull/pull.go index f6a235e11..6cc8dccab 100644 --- a/internal/db/pull/pull.go +++ b/internal/db/pull/pull.go @@ -18,6 +18,7 @@ import ( "github.com/supabase/cli/internal/migration/new" "github.com/supabase/cli/internal/migration/repair" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/migration" ) @@ -35,7 +36,7 @@ var ( func Run(ctx context.Context, schema []string, config pgconn.Config, name string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { // 1. Sanity checks. - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } // 2. Check postgres connection diff --git a/internal/db/push/push.go b/internal/db/push/push.go index 2141255ae..7e5241558 100644 --- a/internal/db/push/push.go +++ b/internal/db/push/push.go @@ -31,9 +31,10 @@ func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, } var seeds []migration.SeedFile if includeSeed { - if remote, _ := utils.Config.GetRemoteByProjectRef(flags.ProjectRef); !remote.Db.Seed.Enabled { - fmt.Fprintln(os.Stderr, "Skipping seed because it is disabled in config.toml for project:", remote.ProjectId) - } else if seeds, err = migration.GetPendingSeeds(ctx, remote.Db.Seed.SqlPaths, conn, afero.NewIOFS(fsys)); err != nil { + // TODO: flag should override config but we don't resolve glob paths when seed is disabled. + if !utils.Config.Db.Seed.Enabled { + fmt.Fprintln(os.Stderr, "Skipping seed because it is disabled in config.toml for project:", flags.ProjectRef) + } else if seeds, err = migration.GetPendingSeeds(ctx, utils.Config.Db.Seed.SqlPaths, conn, afero.NewIOFS(fsys)); err != nil { return err } } diff --git a/internal/db/remote/changes/changes.go b/internal/db/remote/changes/changes.go index c735b5984..9aa4a47b0 100644 --- a/internal/db/remote/changes/changes.go +++ b/internal/db/remote/changes/changes.go @@ -8,6 +8,7 @@ import ( "github.com/spf13/afero" "github.com/supabase/cli/internal/db/diff" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/migration" ) @@ -15,7 +16,7 @@ var output string func Run(ctx context.Context, schema []string, config pgconn.Config, fsys afero.Fs) error { // Sanity checks. - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } diff --git a/internal/db/remote/commit/commit.go b/internal/db/remote/commit/commit.go index f9062d492..6e00a0295 100644 --- a/internal/db/remote/commit/commit.go +++ b/internal/db/remote/commit/commit.go @@ -15,12 +15,13 @@ import ( "github.com/supabase/cli/internal/migration/list" "github.com/supabase/cli/internal/migration/repair" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/migration" ) func Run(ctx context.Context, schema []string, config pgconn.Config, fsys afero.Fs) error { // Sanity checks. - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } diff --git a/internal/db/reset/reset.go b/internal/db/reset/reset.go index 3830a019d..307f14f55 100644 --- a/internal/db/reset/reset.go +++ b/internal/db/reset/reset.go @@ -27,7 +27,6 @@ import ( "github.com/supabase/cli/internal/migration/repair" "github.com/supabase/cli/internal/seed/buckets" "github.com/supabase/cli/internal/utils" - "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/migration" ) @@ -250,15 +249,11 @@ func resetRemote(ctx context.Context, version string, config pgconn.Config, fsys if err := migration.ApplyMigrations(ctx, migrations, conn, afero.NewIOFS(fsys)); err != nil { return err } - remote, _ := utils.Config.GetRemoteByProjectRef(flags.ProjectRef) - if !remote.Db.Seed.Enabled { - fmt.Fprintln(os.Stderr, "Skipping seed because it is disabled in config.toml for project:", remote.ProjectId) - return nil - } else if !utils.Config.Db.Seed.Enabled { + if !utils.Config.Db.Seed.Enabled { // Skip because --no-seed flag is set return nil } - seeds, err := migration.GetPendingSeeds(ctx, remote.Db.Seed.SqlPaths, conn, afero.NewIOFS(fsys)) + seeds, err := migration.GetPendingSeeds(ctx, utils.Config.Db.Seed.SqlPaths, conn, afero.NewIOFS(fsys)) if err != nil { return err } diff --git a/internal/db/start/start.go b/internal/db/start/start.go index aa8b9cee5..4180fe05c 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -23,6 +23,7 @@ import ( "github.com/supabase/cli/internal/migration/apply" "github.com/supabase/cli/internal/status" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/migration" ) @@ -39,7 +40,7 @@ var ( ) func Run(ctx context.Context, fromBackup string, fsys afero.Fs) error { - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } if err := utils.AssertSupabaseDbIsRunning(); err == nil { diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index 5ee2ae845..5b6bb8e47 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -18,7 +18,7 @@ import ( func Run(ctx context.Context, slugs []string, projectRef string, noVerifyJWT *bool, importMapPath string, fsys afero.Fs) error { // Load function config and project id - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } else if len(slugs) > 0 { for _, s := range slugs { @@ -60,8 +60,7 @@ func GetFunctionSlugs(fsys afero.Fs) (slugs []string, err error) { } } // Add all function slugs declared in config file - remote, _ := utils.Config.GetRemoteByProjectRef(flags.ProjectRef) - for slug := range remote.Functions { + for slug := range utils.Config.Functions { slugs = append(slugs, slug) } return slugs, nil @@ -82,10 +81,9 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, if len(importMapPath) > 0 && !filepath.IsAbs(importMapPath) { importMapPath = filepath.Join(utils.CurrentDirAbs, importMapPath) } - remote, _ := utils.Config.GetRemoteByProjectRef(flags.ProjectRef) functionConfig := make(config.FunctionConfig, len(slugs)) for _, name := range slugs { - function := remote.Functions[name] + function := utils.Config.Functions[name] // Precedence order: flag > config > fallback functionDir := filepath.Join(utils.FunctionsDir, name) if len(function.Entrypoint) == 0 { diff --git a/internal/functions/download/download.go b/internal/functions/download/download.go index e3b68cae9..ca99c1bcf 100644 --- a/internal/functions/download/download.go +++ b/internal/functions/download/download.go @@ -16,6 +16,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/api" ) @@ -112,7 +113,7 @@ func Run(ctx context.Context, slug string, projectRef string, useLegacyBundle bo return RunLegacy(ctx, slug, projectRef, fsys) } // 1. Sanity check - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } // 2. Download eszip to temp file diff --git a/internal/functions/new/new.go b/internal/functions/new/new.go index f787ce90c..5eca5b67a 100644 --- a/internal/functions/new/new.go +++ b/internal/functions/new/new.go @@ -11,6 +11,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" ) var ( @@ -45,7 +46,7 @@ func Run(ctx context.Context, slug string, fsys afero.Fs) error { } // Load config if available - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { utils.CmdSuggestion = "" } diff --git a/internal/functions/serve/serve.go b/internal/functions/serve/serve.go index 62811d769..485d8c7cf 100644 --- a/internal/functions/serve/serve.go +++ b/internal/functions/serve/serve.go @@ -19,6 +19,7 @@ import ( "github.com/supabase/cli/internal/functions/deploy" "github.com/supabase/cli/internal/secrets/set" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" ) type InspectMode string @@ -70,7 +71,7 @@ var ( func Run(ctx context.Context, envFilePath string, noVerifyJWT *bool, importMapPath string, runtimeOption RuntimeOption, fsys afero.Fs) error { // 1. Sanity checks. - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } if err := utils.AssertSupabaseDbIsRunning(); err != nil { diff --git a/internal/gen/types/types.go b/internal/gen/types/types.go index b399cfb5c..9ffc7dc72 100644 --- a/internal/gen/types/types.go +++ b/internal/gen/types/types.go @@ -31,8 +31,7 @@ func Run(ctx context.Context, projectId string, dbConfig pgconn.Config, lang str originalURL := utils.ToPostgresURL(dbConfig) // Add default schemas if --schema flag is not specified if len(schemas) == 0 { - remote, _ := utils.Config.GetRemoteByProjectRef(projectId) - schemas = utils.RemoveDuplicates(append([]string{"public"}, remote.Api.Schemas...)) + schemas = utils.RemoveDuplicates(append([]string{"public"}, utils.Config.Api.Schemas...)) } included := strings.Join(schemas, ",") diff --git a/internal/migration/squash/squash.go b/internal/migration/squash/squash.go index 2ed9e6252..4aad8b832 100644 --- a/internal/migration/squash/squash.go +++ b/internal/migration/squash/squash.go @@ -20,6 +20,7 @@ import ( "github.com/supabase/cli/internal/migration/list" "github.com/supabase/cli/internal/migration/repair" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/migration" ) @@ -34,7 +35,7 @@ func Run(ctx context.Context, version string, config pgconn.Config, fsys afero.F return err } } - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } // 1. Squash local migrations diff --git a/internal/seed/buckets/buckets.go b/internal/seed/buckets/buckets.go index b460fdc79..365c3a395 100644 --- a/internal/seed/buckets/buckets.go +++ b/internal/seed/buckets/buckets.go @@ -26,9 +26,8 @@ func Run(ctx context.Context, projectRef string, interactive bool, fsys afero.Fs } return shouldOverwrite } - remote, _ := utils.Config.GetRemoteByProjectRef(projectRef) - if err := api.UpsertBuckets(ctx, remote.Storage.Buckets, filter); err != nil { + if err := api.UpsertBuckets(ctx, utils.Config.Storage.Buckets, filter); err != nil { return err } - return api.UpsertObjects(ctx, remote.Storage.Buckets, utils.NewRootFS(fsys)) + return api.UpsertObjects(ctx, utils.Config.Storage.Buckets, utils.NewRootFS(fsys)) } diff --git a/internal/start/start.go b/internal/start/start.go index 6f75d1377..2501d5b8d 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -37,7 +37,7 @@ import ( func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string, ignoreHealthCheck bool) error { // Sanity checks. { - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } if err := utils.AssertSupabaseDbIsRunning(); err == nil { diff --git a/internal/status/status.go b/internal/status/status.go index 1b9d02f90..68eae2fe3 100644 --- a/internal/status/status.go +++ b/internal/status/status.go @@ -19,6 +19,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/fetcher" ) @@ -67,7 +68,7 @@ func (c *CustomName) toValues(exclude ...string) map[string]string { func Run(ctx context.Context, names CustomName, format string, fsys afero.Fs) error { // Sanity checks. - if err := utils.LoadConfigFS(fsys); err != nil { + if err := flags.LoadConfig(fsys); err != nil { return err } if err := assertContainerHealthy(ctx, utils.DbId); err != nil { diff --git a/internal/stop/stop.go b/internal/stop/stop.go index 39c5e00e5..da98f1600 100644 --- a/internal/stop/stop.go +++ b/internal/stop/stop.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/types/volume" "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" + "github.com/supabase/cli/internal/utils/flags" ) func Run(ctx context.Context, backup bool, projectId string, all bool, fsys afero.Fs) error { @@ -17,7 +18,7 @@ func Run(ctx context.Context, backup bool, projectId string, all bool, fsys afer // Sanity checks. if len(projectId) > 0 { utils.Config.ProjectId = projectId - } else if err := utils.LoadConfigFS(fsys); err != nil { + } else if err := flags.LoadConfig(fsys); err != nil { return err } searchProjectIdFilter = utils.Config.ProjectId diff --git a/internal/storage/cp/cp.go b/internal/storage/cp/cp.go index e2e304ced..4ead44639 100644 --- a/internal/storage/cp/cp.go +++ b/internal/storage/cp/cp.go @@ -115,7 +115,6 @@ func UploadStorageObjectAll(ctx context.Context, api storage.StorageAPI, remoteP return err } } - remote, _ := utils.Config.GetRemoteByProjectRef(flags.ProjectRef) // Overwrites existing object when using --recursive flag opts = append(opts, func(fo *storage.FileOptions) { fo.Overwrite = true @@ -154,7 +153,7 @@ func UploadStorageObjectAll(ctx context.Context, api storage.StorageAPI, remoteP // Retry after creating bucket if bucket, prefix := client.SplitBucketPrefix(dstPath); len(prefix) > 0 { body := storage.CreateBucketRequest{Name: bucket} - if config, ok := remote.Storage.Buckets[bucket]; ok { + if config, ok := utils.Config.Storage.Buckets[bucket]; ok { body.Public = config.Public body.FileSizeLimit = int64(config.FileSizeLimit) body.AllowedMimeTypes = config.AllowedMimeTypes diff --git a/internal/utils/config.go b/internal/utils/config.go index 3f89dc75c..06d42d443 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -2,7 +2,6 @@ package utils import ( _ "embed" - "fmt" "io/fs" "net" "net/url" @@ -101,17 +100,6 @@ func GetDockerIds() []string { var Config = config.NewConfig(config.WithHostname(GetHostname())) -func LoadConfigFS(fsys afero.Fs) error { - if err := Config.Load("", NewRootFS(fsys)); err != nil { - if errors.Is(err, os.ErrNotExist) { - CmdSuggestion = fmt.Sprintf("Have you set up the project with %s?", Aqua("supabase init")) - } - return err - } - UpdateDockerIds() - return nil -} - // Adapts fs.FS to support absolute paths type rootFS struct { fsys afero.Fs diff --git a/internal/utils/flags/config_path.go b/internal/utils/flags/config_path.go new file mode 100644 index 000000000..d0ed105c7 --- /dev/null +++ b/internal/utils/flags/config_path.go @@ -0,0 +1,22 @@ +package flags + +import ( + "fmt" + "os" + + "github.com/go-errors/errors" + "github.com/spf13/afero" + "github.com/supabase/cli/internal/utils" +) + +func LoadConfig(fsys afero.Fs) error { + utils.Config.ProjectId = ProjectRef + if err := utils.Config.Load("", utils.NewRootFS(fsys)); err != nil { + if errors.Is(err, os.ErrNotExist) { + utils.CmdSuggestion = fmt.Sprintf("Have you set up the project with %s?", utils.Aqua("supabase init")) + } + return err + } + utils.UpdateDockerIds() + return nil +} diff --git a/internal/utils/flags/db_url.go b/internal/utils/flags/db_url.go index 013453b86..04565939d 100644 --- a/internal/utils/flags/db_url.go +++ b/internal/utils/flags/db_url.go @@ -61,7 +61,7 @@ func ParseDatabaseConfig(flagSet *pflag.FlagSet, fsys afero.Fs) error { DbConfig = *config } case local: - if err := utils.LoadConfigFS(fsys); err != nil { + if err := LoadConfig(fsys); err != nil { return err } // Ignore other PG settings @@ -71,10 +71,10 @@ func ParseDatabaseConfig(flagSet *pflag.FlagSet, fsys afero.Fs) error { DbConfig.Password = utils.Config.Db.Password DbConfig.Database = "postgres" case linked: - if err := utils.LoadConfigFS(fsys); err != nil { + if err := LoadProjectRef(fsys); err != nil { return err } - if err := LoadProjectRef(fsys); err != nil { + if err := LoadConfig(fsys); err != nil { return err } DbConfig = NewDbConfigWithPassword(ProjectRef) diff --git a/pkg/config/config.go b/pkg/config/config.go index 837f305a9..93cc252c9 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -136,8 +136,7 @@ type ( config struct { baseConfig `mapstructure:",squash"` - Overrides map[string]interface{} `toml:"remotes"` - Remotes map[string]baseConfig `toml:"-"` + Remotes map[string]baseConfig `toml:"remotes"` } realtime struct { @@ -360,6 +359,7 @@ var ( invalidProjectId = regexp.MustCompile("[^a-zA-Z0-9_.-]+") envPattern = regexp.MustCompile(`^env\((.*)\)$`) + refPattern = regexp.MustCompile(`^[a-z]{20}$`) ) func (c *config) Eject(w io.Writer) error { @@ -406,6 +406,24 @@ func (c *config) loadFromReader(v *viper.Viper, r io.Reader) error { if err := v.MergeConfig(r); err != nil { return errors.Errorf("failed to merge config: %w", err) } + // Find [remotes.*] block to override base config + baseId := v.GetString("project_id") + idToName := map[string]string{baseId: "base"} + for name, remote := range v.GetStringMap("remotes") { + projectId := v.GetString(fmt.Sprintf("remotes.%s.project_id", name)) + // Track remote project_id to check for duplication + if other, exists := idToName[projectId]; exists { + return errors.Errorf("duplicate project_id for [remotes.%s] and %s", name, other) + } + idToName[projectId] = fmt.Sprintf("[remotes.%s]", name) + if projectId == c.ProjectId { + fmt.Fprintln(os.Stderr, "Loading config override:", idToName[projectId]) + if err := v.MergeConfigMap(remote.(map[string]any)); err != nil { + return err + } + v.Set("project_id", baseId) + } + } // Manually parse [functions.*] to empty struct for backwards compatibility for key, value := range v.GetStringMap("functions") { if m, ok := value.(map[string]any); ok && len(m) == 0 { @@ -532,50 +550,11 @@ func (c *config) Load(path string, fsys fs.FS) error { if version, err := fs.ReadFile(fsys, builder.PgmetaVersionPath); err == nil && len(version) > 0 { c.Studio.PgmetaImage = replaceImageTag(pgmetaImage, string(version)) } - // Resolve remote config, then base config - idToName := map[string]string{} - c.Remotes = make(map[string]baseConfig, len(c.Overrides)) - for name, remote := range c.Overrides { - base := c.baseConfig.Clone() - // On remotes branches set seed as disabled by default - base.Db.Seed.Enabled = false - // Encode a toml file with only config overrides - var buf bytes.Buffer - if err := toml.NewEncoder(&buf).Encode(remote); err != nil { - return errors.Errorf("failed to encode map to TOML: %w", err) - } - // Decode overrides using base config as defaults - if metadata, err := toml.NewDecoder(&buf).Decode(&base); err != nil { - return errors.Errorf("failed to decode remote config: %w", err) - } else if undecoded := metadata.Undecoded(); len(undecoded) > 0 { - fmt.Fprintf(os.Stderr, "WARN: unknown config fields: %+v\n", undecoded) - } - // Cross validate remote project id - if base.ProjectId == c.baseConfig.ProjectId { - fmt.Fprintf(os.Stderr, "WARN: project_id is missing for [remotes.%s]\n", name) - } else if other, exists := idToName[base.ProjectId]; exists { - return errors.Errorf("duplicate project_id for [remotes.%s] and [remotes.%s]", other, name) - } else { - idToName[base.ProjectId] = name - } - if err := base.resolve(builder, fsys); err != nil { - return err - } - c.Remotes[name] = base - } + // TODO: replace derived config resolution with viper decode hooks if err := c.baseConfig.resolve(builder, fsys); err != nil { return err } - // Validate base config, then remote config - if err := c.baseConfig.Validate(fsys); err != nil { - return err - } - for name, base := range c.Remotes { - if err := base.Validate(fsys); err != nil { - return errors.Errorf("invalid config for [remotes.%s]: %w", name, err) - } - } - return nil + return c.Validate(fsys) } func (c *baseConfig) resolve(builder pathBuilder, fsys fs.FS) error { @@ -624,13 +603,19 @@ func (c *baseConfig) resolve(builder pathBuilder, fsys fs.FS) error { return c.Db.Seed.loadSeedPaths(builder.SupabaseDirPath, fsys) } -func (c *baseConfig) Validate(fsys fs.FS) error { +func (c *config) Validate(fsys fs.FS) error { if c.ProjectId == "" { return errors.New("Missing required field in config: project_id") } else if sanitized := sanitizeProjectId(c.ProjectId); sanitized != c.ProjectId { fmt.Fprintln(os.Stderr, "WARN: project_id field in config is invalid. Auto-fixing to", sanitized) c.ProjectId = sanitized } + // Since remote config is merged to base, we only need to validate the project_id field. + for name, remote := range c.Remotes { + if !refPattern.MatchString(remote.ProjectId) { + return errors.Errorf("Invalid config for remotes.%s.project_id. Must be like: abcdefghijklmnopqrst", name) + } + } // Validate api config if c.Api.Enabled { if c.Api.Port == 0 { @@ -641,7 +626,7 @@ func (c *baseConfig) Validate(fsys fs.FS) error { if c.Db.Settings.SessionReplicationRole != nil { allowedRoles := []SessionReplicationRole{SessionReplicationRoleOrigin, SessionReplicationRoleReplica, SessionReplicationRoleLocal} if !sliceContains(allowedRoles, *c.Db.Settings.SessionReplicationRole) { - return errors.Errorf("Invalid config for db.session_replication_role: %s. Must be one of: %v", *c.Db.Settings.SessionReplicationRole, allowedRoles) + return errors.Errorf("Invalid config for db.session_replication_role. Must be one of: %v", allowedRoles) } } if c.Db.Port == 0 { @@ -1328,25 +1313,16 @@ func (c *baseConfig) GetServiceImages() []string { } // Retrieve the final base config to use taking into account the remotes override +// Pre: config must be loaded after setting config.ProjectID = "ref" func (c *config) GetRemoteByProjectRef(projectRef string) (baseConfig, error) { - var result []string - // Iterate over all the config.Remotes - for name, remoteConfig := range c.Remotes { - // Check if there is one matching project_id - if remoteConfig.ProjectId == projectRef { - // Check for duplicate project IDs across remotes - result = append(result, name) + base := c.baseConfig.Clone() + for _, remote := range c.Remotes { + if remote.ProjectId == projectRef { + base.ProjectId = projectRef + return base, nil } } - // If no matching remote config is found, return the base config - if len(result) == 0 { - return c.baseConfig, errors.Errorf("no remote found for project_id: %s", projectRef) - } - remote := c.Remotes[result[0]] - if len(result) > 1 { - return remote, errors.Errorf("multiple remotes %v have the same project_id: %s", result, projectRef) - } - return remote, nil + return base, errors.Errorf("no remote found for project_id: %s", projectRef) } func ToTomlBytes(config any) ([]byte, error) { diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 45b2d04f6..2280ae40b 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -88,7 +88,7 @@ func TestConfigParsing(t *testing.T) { staging, ok := config.Remotes["staging"] assert.True(t, ok) // Check the values for production override - assert.Equal(t, config.ProjectId, production.ProjectId) + assert.Equal(t, "vpefcjyosynxeiebfscx", production.ProjectId) assert.Equal(t, "http://feature-auth-branch.com/", production.Auth.SiteUrl) assert.Equal(t, false, production.Auth.EnableSignup) assert.Equal(t, false, production.Auth.External["azure"].Enabled) @@ -96,7 +96,7 @@ func TestConfigParsing(t *testing.T) { // Check seed should be disabled by default for remote configs assert.Equal(t, false, production.Db.Seed.Enabled) // Check the values for the staging override - assert.Equal(t, "staging-project", staging.ProjectId) + assert.Equal(t, "bvikqvbczudanvggcord", staging.ProjectId) assert.Equal(t, []string{"image/png"}, staging.Storage.Buckets["images"].AllowedMimeTypes) assert.Equal(t, true, staging.Db.Seed.Enabled) }) @@ -386,7 +386,7 @@ func TestLoadFunctionImportMap(t *testing.T) { config := NewConfig() fsys := fs.MapFS{ "supabase/config.toml": &fs.MapFile{Data: []byte(` - project_id = "test" + project_id = "bvikqvbczudanvggcord" [functions.hello] `)}, "supabase/functions/hello/deno.json": &fs.MapFile{}, @@ -402,7 +402,7 @@ func TestLoadFunctionImportMap(t *testing.T) { config := NewConfig() fsys := fs.MapFS{ "supabase/config.toml": &fs.MapFile{Data: []byte(` - project_id = "test" + project_id = "bvikqvbczudanvggcord" [functions.hello] `)}, "supabase/functions/hello/deno.jsonc": &fs.MapFile{}, @@ -418,7 +418,7 @@ func TestLoadFunctionImportMap(t *testing.T) { config := NewConfig() fsys := fs.MapFS{ "supabase/config.toml": &fs.MapFile{Data: []byte(` - project_id = "test" + project_id = "bvikqvbczudanvggcord" [functions] hello.import_map = "custom_import_map.json" `)}, diff --git a/pkg/config/testdata/config.toml b/pkg/config/testdata/config.toml index e3093924a..65705646c 100644 --- a/pkg/config/testdata/config.toml +++ b/pkg/config/testdata/config.toml @@ -251,6 +251,9 @@ s3_access_key = "" # Configures AWS_SECRET_ACCESS_KEY for S3 bucket s3_secret_key = "" +[remotes.production] +project_id = "vpefcjyosynxeiebfscx" + [remotes.production.auth] site_url = "http://feature-auth-branch.com/" enable_signup = false @@ -260,7 +263,7 @@ enabled = false client_id = "nope" [remotes.staging] -project_id = "staging-project" +project_id = "bvikqvbczudanvggcord" [remotes.staging.db.seed] enabled = true From 55fc7042155fd8d9caaaada07ca19f4caf57d340 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Sat, 11 Jan 2025 03:22:01 +0800 Subject: [PATCH 267/305] fix: skip hashing unloaded env reference (#3029) * fix: skip hashing unloaded env reference * fix: zero maps and arrays before unmarshaling --- pkg/config/auth.go | 60 ++++++++++++++++++++++---------------------- pkg/config/config.go | 1 + pkg/config/secret.go | 15 ++++++----- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 098764fff..0a7aa66a8 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -265,7 +265,7 @@ func (h hook) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if hook := h.CustomAccessToken; hook != nil { if body.HookCustomAccessTokenEnabled = &hook.Enabled; hook.Enabled { body.HookCustomAccessTokenUri = &hook.URI - if len(hook.Secrets.Value) > 0 { + if len(hook.Secrets.SHA256) > 0 { body.HookCustomAccessTokenSecrets = &hook.Secrets.Value } } @@ -273,7 +273,7 @@ func (h hook) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if hook := h.SendEmail; hook != nil { if body.HookSendEmailEnabled = &hook.Enabled; hook.Enabled { body.HookSendEmailUri = &hook.URI - if len(hook.Secrets.Value) > 0 { + if len(hook.Secrets.SHA256) > 0 { body.HookSendEmailSecrets = &hook.Secrets.Value } } @@ -281,7 +281,7 @@ func (h hook) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if hook := h.SendSMS; hook != nil { if body.HookSendSmsEnabled = &hook.Enabled; hook.Enabled { body.HookSendSmsUri = &hook.URI - if len(hook.Secrets.Value) > 0 { + if len(hook.Secrets.SHA256) > 0 { body.HookSendSmsSecrets = &hook.Secrets.Value } } @@ -290,7 +290,7 @@ func (h hook) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if hook := h.MFAVerificationAttempt; hook != nil { if body.HookMfaVerificationAttemptEnabled = &hook.Enabled; hook.Enabled { body.HookMfaVerificationAttemptUri = &hook.URI - if len(hook.Secrets.Value) > 0 { + if len(hook.Secrets.SHA256) > 0 { body.HookMfaVerificationAttemptSecrets = &hook.Secrets.Value } } @@ -298,7 +298,7 @@ func (h hook) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if hook := h.PasswordVerificationAttempt; hook != nil { if body.HookPasswordVerificationAttemptEnabled = &hook.Enabled; hook.Enabled { body.HookPasswordVerificationAttemptUri = &hook.URI - if len(hook.Secrets.Value) > 0 { + if len(hook.Secrets.SHA256) > 0 { body.HookPasswordVerificationAttemptSecrets = &hook.Secrets.Value } } @@ -512,7 +512,7 @@ func (s smtp) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { body.SmtpHost = &s.Host body.SmtpPort = cast.Ptr(strconv.Itoa(int(s.Port))) body.SmtpUser = &s.User - if len(s.Pass.Value) > 0 { + if len(s.Pass.SHA256) > 0 { body.SmtpPass = &s.Pass.Value } body.SmtpAdminEmail = &s.AdminEmail @@ -556,33 +556,33 @@ func (s sms) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { switch { case s.Twilio.Enabled: body.SmsProvider = cast.Ptr("twilio") - if len(s.Twilio.AuthToken.Value) > 0 { + if len(s.Twilio.AuthToken.SHA256) > 0 { body.SmsTwilioAuthToken = &s.Twilio.AuthToken.Value } body.SmsTwilioAccountSid = &s.Twilio.AccountSid body.SmsTwilioMessageServiceSid = &s.Twilio.MessageServiceSid case s.TwilioVerify.Enabled: body.SmsProvider = cast.Ptr("twilio_verify") - if len(s.TwilioVerify.AuthToken.Value) > 0 { + if len(s.TwilioVerify.AuthToken.SHA256) > 0 { body.SmsTwilioVerifyAuthToken = &s.TwilioVerify.AuthToken.Value } body.SmsTwilioVerifyAccountSid = &s.TwilioVerify.AccountSid body.SmsTwilioVerifyMessageServiceSid = &s.TwilioVerify.MessageServiceSid case s.Messagebird.Enabled: body.SmsProvider = cast.Ptr("messagebird") - if len(s.Messagebird.AccessKey.Value) > 0 { + if len(s.Messagebird.AccessKey.SHA256) > 0 { body.SmsMessagebirdAccessKey = &s.Messagebird.AccessKey.Value } body.SmsMessagebirdOriginator = &s.Messagebird.Originator case s.Textlocal.Enabled: body.SmsProvider = cast.Ptr("textlocal") - if len(s.Textlocal.ApiKey.Value) > 0 { + if len(s.Textlocal.ApiKey.SHA256) > 0 { body.SmsTextlocalApiKey = &s.Textlocal.ApiKey.Value } body.SmsTextlocalSender = &s.Textlocal.Sender case s.Vonage.Enabled: body.SmsProvider = cast.Ptr("vonage") - if len(s.Vonage.ApiSecret.Value) > 0 { + if len(s.Vonage.ApiSecret.SHA256) > 0 { body.SmsVonageApiSecret = &s.Vonage.ApiSecret.Value } body.SmsVonageApiKey = &s.Vonage.ApiKey @@ -647,7 +647,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["apple"]; ok { if body.ExternalAppleEnabled = &p.Enabled; *body.ExternalAppleEnabled { body.ExternalAppleClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalAppleSecret = &p.Secret.Value } } @@ -655,7 +655,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["azure"]; ok { if body.ExternalAzureEnabled = &p.Enabled; *body.ExternalAzureEnabled { body.ExternalAzureClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalAzureSecret = &p.Secret.Value } body.ExternalAzureUrl = &p.Url @@ -664,7 +664,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["bitbucket"]; ok { if body.ExternalBitbucketEnabled = &p.Enabled; *body.ExternalBitbucketEnabled { body.ExternalBitbucketClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalBitbucketSecret = &p.Secret.Value } } @@ -672,7 +672,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["discord"]; ok { if body.ExternalDiscordEnabled = &p.Enabled; *body.ExternalDiscordEnabled { body.ExternalDiscordClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalDiscordSecret = &p.Secret.Value } } @@ -680,7 +680,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["facebook"]; ok { if body.ExternalFacebookEnabled = &p.Enabled; *body.ExternalFacebookEnabled { body.ExternalFacebookClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalFacebookSecret = &p.Secret.Value } } @@ -688,7 +688,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["figma"]; ok { if body.ExternalFigmaEnabled = &p.Enabled; *body.ExternalFigmaEnabled { body.ExternalFigmaClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalFigmaSecret = &p.Secret.Value } } @@ -696,7 +696,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["github"]; ok { if body.ExternalGithubEnabled = &p.Enabled; *body.ExternalGithubEnabled { body.ExternalGithubClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalGithubSecret = &p.Secret.Value } } @@ -704,7 +704,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["gitlab"]; ok { if body.ExternalGitlabEnabled = &p.Enabled; *body.ExternalGitlabEnabled { body.ExternalGitlabClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalGitlabSecret = &p.Secret.Value } body.ExternalGitlabUrl = &p.Url @@ -713,7 +713,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["google"]; ok { if body.ExternalGoogleEnabled = &p.Enabled; *body.ExternalGoogleEnabled { body.ExternalGoogleClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalGoogleSecret = &p.Secret.Value } body.ExternalGoogleSkipNonceCheck = &p.SkipNonceCheck @@ -722,7 +722,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["kakao"]; ok { if body.ExternalKakaoEnabled = &p.Enabled; *body.ExternalKakaoEnabled { body.ExternalKakaoClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalKakaoSecret = &p.Secret.Value } } @@ -730,7 +730,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["keycloak"]; ok { if body.ExternalKeycloakEnabled = &p.Enabled; *body.ExternalKeycloakEnabled { body.ExternalKeycloakClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalKeycloakSecret = &p.Secret.Value } body.ExternalKeycloakUrl = &p.Url @@ -739,7 +739,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["linkedin_oidc"]; ok { if body.ExternalLinkedinOidcEnabled = &p.Enabled; *body.ExternalLinkedinOidcEnabled { body.ExternalLinkedinOidcClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalLinkedinOidcSecret = &p.Secret.Value } } @@ -747,7 +747,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["notion"]; ok { if body.ExternalNotionEnabled = &p.Enabled; *body.ExternalNotionEnabled { body.ExternalNotionClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalNotionSecret = &p.Secret.Value } } @@ -755,7 +755,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["slack_oidc"]; ok { if body.ExternalSlackOidcEnabled = &p.Enabled; *body.ExternalSlackOidcEnabled { body.ExternalSlackOidcClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalSlackOidcSecret = &p.Secret.Value } } @@ -763,7 +763,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["spotify"]; ok { if body.ExternalSpotifyEnabled = &p.Enabled; *body.ExternalSpotifyEnabled { body.ExternalSpotifyClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalSpotifySecret = &p.Secret.Value } } @@ -771,7 +771,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["twitch"]; ok { if body.ExternalTwitchEnabled = &p.Enabled; *body.ExternalTwitchEnabled { body.ExternalTwitchClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalTwitchSecret = &p.Secret.Value } } @@ -779,7 +779,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["twitter"]; ok { if body.ExternalTwitterEnabled = &p.Enabled; *body.ExternalTwitterEnabled { body.ExternalTwitterClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalTwitterSecret = &p.Secret.Value } } @@ -787,7 +787,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["workos"]; ok { if body.ExternalWorkosEnabled = &p.Enabled; *body.ExternalWorkosEnabled { body.ExternalWorkosClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalWorkosSecret = &p.Secret.Value } body.ExternalWorkosUrl = &p.Url @@ -796,7 +796,7 @@ func (e external) toAuthConfigBody(body *v1API.UpdateAuthConfigBody) { if p, ok := e["zoom"]; ok { if body.ExternalZoomEnabled = &p.Enabled; *body.ExternalZoomEnabled { body.ExternalZoomClientId = &p.ClientId - if len(p.Secret.Value) > 0 { + if len(p.Secret.SHA256) > 0 { body.ExternalZoomSecret = &p.Secret.Value } } diff --git a/pkg/config/config.go b/pkg/config/config.go index 93cc252c9..c5862a995 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -433,6 +433,7 @@ func (c *config) loadFromReader(v *viper.Viper, r io.Reader) error { if err := v.UnmarshalExact(c, func(dc *mapstructure.DecoderConfig) { dc.TagName = "toml" dc.Squash = true + dc.ZeroFields = true dc.DecodeHook = c.newDecodeHook(LoadEnvHook) }); err != nil { return errors.Errorf("failed to parse config: %w", err) diff --git a/pkg/config/secret.go b/pkg/config/secret.go index 64da04d77..3f0611673 100644 --- a/pkg/config/secret.go +++ b/pkg/config/secret.go @@ -64,17 +64,16 @@ func DecryptSecretHookFunc(hashKey string) mapstructure.DecodeHookFunc { if t != reflect.TypeOf(result) { return data, nil } - ciphertext := data.(string) - // Skip hashing unloaded env - if matches := envPattern.FindStringSubmatch(ciphertext); len(matches) > 1 { - return result, nil - } var err error privKey := os.Getenv("DOTENV_PRIVATE_KEY") for _, k := range strings.Split(privKey, ",") { - result.Value, err = decrypt(k, ciphertext) - if err == nil && len(result.Value) > 0 { - result.SHA256 = sha256Hmac(hashKey, result.Value) + // Use the first private key that successfully decrypts the secret + if result.Value, err = decrypt(k, data.(string)); err == nil { + // Unloaded env() references may be returned verbatim. + // Don't hash those values as they are meaningless. + if !envPattern.MatchString(result.Value) { + result.SHA256 = sha256Hmac(hashKey, result.Value) + } break } } From 76272d38274f74ee0d735b4283f9511a8db42f3d Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Sun, 12 Jan 2025 00:22:00 +0800 Subject: [PATCH 268/305] fix: initialise empty map for email template (#3032) --- pkg/config/auth.go | 96 ++++++++++++++++++++++---------------------- pkg/config/config.go | 9 +---- 2 files changed, 49 insertions(+), 56 deletions(-) diff --git a/pkg/config/auth.go b/pkg/config/auth.go index 0a7aa66a8..33b6f9ea2 100644 --- a/pkg/config/auth.go +++ b/pkg/config/auth.go @@ -442,60 +442,60 @@ func (e *email) fromAuthConfig(remoteConfig v1API.AuthConfigResponse) { if len(e.Template) == 0 { return } - var tmpl emailTemplate - tmpl = e.Template["invite"] - if tmpl.Subject != nil { - tmpl.Subject = remoteConfig.MailerSubjectsInvite - } - if tmpl.Content != nil { - tmpl.Content = remoteConfig.MailerTemplatesInviteContent - } - e.Template["invite"] = tmpl - - tmpl = e.Template["confirmation"] - if tmpl.Subject != nil { - tmpl.Subject = remoteConfig.MailerSubjectsConfirmation - } - if tmpl.Content != nil { - tmpl.Content = remoteConfig.MailerTemplatesConfirmationContent - } - e.Template["confirmation"] = tmpl - - tmpl = e.Template["recovery"] - if tmpl.Subject != nil { - tmpl.Subject = remoteConfig.MailerSubjectsRecovery - } - if tmpl.Content != nil { - tmpl.Content = remoteConfig.MailerTemplatesRecoveryContent - } - e.Template["recovery"] = tmpl - - tmpl = e.Template["magic_link"] - if tmpl.Subject != nil { - tmpl.Subject = remoteConfig.MailerSubjectsMagicLink + if t, ok := e.Template["invite"]; ok { + if t.Subject != nil { + t.Subject = remoteConfig.MailerSubjectsInvite + } + if t.Content != nil { + t.Content = remoteConfig.MailerTemplatesInviteContent + } + e.Template["invite"] = t } - if tmpl.Content != nil { - tmpl.Content = remoteConfig.MailerTemplatesMagicLinkContent + if t, ok := e.Template["confirmation"]; ok { + if t.Subject != nil { + t.Subject = remoteConfig.MailerSubjectsConfirmation + } + if t.Content != nil { + t.Content = remoteConfig.MailerTemplatesConfirmationContent + } + e.Template["confirmation"] = t } - e.Template["magic_link"] = tmpl - - tmpl = e.Template["email_change"] - if tmpl.Subject != nil { - tmpl.Subject = remoteConfig.MailerSubjectsEmailChange + if t, ok := e.Template["recovery"]; ok { + if t.Subject != nil { + t.Subject = remoteConfig.MailerSubjectsRecovery + } + if t.Content != nil { + t.Content = remoteConfig.MailerTemplatesRecoveryContent + } + e.Template["recovery"] = t } - if tmpl.Content != nil { - tmpl.Content = remoteConfig.MailerTemplatesEmailChangeContent + if t, ok := e.Template["magic_link"]; ok { + if t.Subject != nil { + t.Subject = remoteConfig.MailerSubjectsMagicLink + } + if t.Content != nil { + t.Content = remoteConfig.MailerTemplatesMagicLinkContent + } + e.Template["magic_link"] = t } - e.Template["email_change"] = tmpl - - tmpl = e.Template["reauthentication"] - if tmpl.Subject != nil { - tmpl.Subject = remoteConfig.MailerSubjectsReauthentication + if t, ok := e.Template["email_change"]; ok { + if t.Subject != nil { + t.Subject = remoteConfig.MailerSubjectsEmailChange + } + if t.Content != nil { + t.Content = remoteConfig.MailerTemplatesEmailChangeContent + } + e.Template["email_change"] = t } - if tmpl.Content != nil { - tmpl.Content = remoteConfig.MailerTemplatesReauthenticationContent + if t, ok := e.Template["reauthentication"]; ok { + if t.Subject != nil { + t.Subject = remoteConfig.MailerSubjectsReauthentication + } + if t.Content != nil { + t.Content = remoteConfig.MailerTemplatesReauthenticationContent + } + e.Template["reauthentication"] = t } - e.Template["reauthentication"] = tmpl } func (s smtp) IsEnabled() bool { diff --git a/pkg/config/config.go b/pkg/config/config.go index c5862a995..e9d3c1243 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -311,14 +311,7 @@ func NewConfig(editors ...ConfigEditor) config { Auth: auth{ Image: gotrueImage, Email: email{ - Template: map[string]emailTemplate{ - "invite": {}, - "confirmation": {}, - "recovery": {}, - "magic_link": {}, - "email_change": {}, - "reauthentication": {}, - }, + Template: map[string]emailTemplate{}, }, Sms: sms{ TestOTP: map[string]string{}, From d3de6378791bd0aa8022796591ac2eb8e2aa4925 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Mon, 13 Jan 2025 13:06:42 +0800 Subject: [PATCH 269/305] fix: handle comments in import map jsonc (#3035) * fix: handle comments in import map jsonc * fix: handle comments in vscode settings * fix: use decoder to handle empty data --- go.mod | 1 + go.sum | 2 ++ internal/init/init.go | 9 +++++---- internal/utils/deno.go | 7 ++++--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 6a14704f6..20dee1296 100644 --- a/go.mod +++ b/go.mod @@ -45,6 +45,7 @@ require ( github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.10.0 github.com/stripe/pg-schema-diff v0.8.0 + github.com/tidwall/jsonc v0.3.2 github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 github.com/zalando/go-keyring v0.2.6 go.opentelemetry.io/otel v1.33.0 diff --git a/go.sum b/go.sum index 556191612..022e25c75 100644 --- a/go.sum +++ b/go.sum @@ -946,6 +946,8 @@ github.com/tetafro/godot v1.4.20 h1:z/p8Ek55UdNvzt4TFn2zx2KscpW4rWqcnUrdmvWJj7E= github.com/tetafro/godot v1.4.20/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= github.com/theupdateframework/notary v0.7.0 h1:QyagRZ7wlSpjT5N2qQAh/pN+DVqgekv4DzbAiAiEL3c= github.com/theupdateframework/notary v0.7.0/go.mod h1:c9DRxcmhHmVLDay4/2fUYdISnHqbFDGRSlXPO0AhYWw= +github.com/tidwall/jsonc v0.3.2 h1:ZTKrmejRlAJYdn0kcaFqRAKlxxFIC21pYq8vLa4p2Wc= +github.com/tidwall/jsonc v0.3.2/go.mod h1:dw+3CIxqHi+t8eFSpzzMlcVYxKp08UP5CD8/uSFCyJE= github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3 h1:y4mJRFlM6fUyPhoXuFg/Yu02fg/nIPFMOY8tOqppoFg= github.com/timakin/bodyclose v0.0.0-20241017074812-ed6a65f985e3/go.mod h1:mkjARE7Yr8qU23YcGMSALbIxTQ9r9QBVahQOBRfU460= github.com/timonwong/loggercheck v0.10.1 h1:uVZYClxQFpw55eh+PIoqM7uAOHMrhVcDoWDery9R8Lg= diff --git a/internal/init/init.go b/internal/init/init.go index f4e470b02..72241a0e0 100644 --- a/internal/init/init.go +++ b/internal/init/init.go @@ -1,6 +1,7 @@ package init import ( + "bytes" "context" _ "embed" "encoding/json" @@ -12,6 +13,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" + "github.com/tidwall/jsonc" ) var ( @@ -100,15 +102,14 @@ func updateGitIgnore(ignorePath string, fsys afero.Fs) error { type VSCodeSettings map[string]interface{} func loadUserSettings(path string, fsys afero.Fs) (VSCodeSettings, error) { - // Open our jsonFile - jsonFile, err := fsys.Open(path) + data, err := afero.ReadFile(fsys, path) if err != nil { return nil, errors.Errorf("failed to load settings file: %w", err) } - defer jsonFile.Close() + data = jsonc.ToJSONInPlace(data) // Parse and unmarshal JSON file. var userSettings VSCodeSettings - dec := json.NewDecoder(jsonFile) + dec := json.NewDecoder(bytes.NewReader(data)) if err := dec.Decode(&userSettings); err != nil { return nil, errors.Errorf("failed to parse settings: %w", err) } diff --git a/internal/utils/deno.go b/internal/utils/deno.go index 7a6006202..978f0bb63 100644 --- a/internal/utils/deno.go +++ b/internal/utils/deno.go @@ -19,6 +19,7 @@ import ( "github.com/go-errors/errors" "github.com/spf13/afero" + "github.com/tidwall/jsonc" ) var ( @@ -215,13 +216,13 @@ type ImportMap struct { } func NewImportMap(absJsonPath string, fsys afero.Fs) (*ImportMap, error) { - contents, err := fsys.Open(absJsonPath) + data, err := afero.ReadFile(fsys, absJsonPath) if err != nil { return nil, errors.Errorf("failed to load import map: %w", err) } - defer contents.Close() + data = jsonc.ToJSONInPlace(data) result := ImportMap{} - decoder := json.NewDecoder(contents) + decoder := json.NewDecoder(bytes.NewReader(data)) if err := decoder.Decode(&result); err != nil { return nil, errors.Errorf("failed to parse import map: %w", err) } From bce4f666341e4da39ae6235c4653a0fce1e80f5a Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Mon, 13 Jan 2025 13:44:04 +0800 Subject: [PATCH 270/305] fix: clarify minimum length of auth hook secret (#3036) --- pkg/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index e9d3c1243..b2104e507 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -1060,7 +1060,7 @@ func (h *hookConfig) validate(hookType string) (err error) { } for _, secret := range strings.Split(h.Secrets.Value, "|") { if !hookSecretPattern.MatchString(secret) { - return errors.Errorf(`Invalid hook config: auth.hook.%s.secrets must be formatted as "v1,whsec_"`, hookType) + return errors.Errorf(`Invalid hook config: auth.hook.%s.secrets must be formatted as "v1,whsec_" with a minimum length of 32 characters.`, hookType) } } case "pg-functions": From 888c236929949eaaaaea5387597464cbccc0fca4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=83=A5=EB=83=90=EC=B1=A0?= Date: Mon, 13 Jan 2025 15:36:02 +0900 Subject: [PATCH 271/305] fix: bump edge-runtime to 1.66.4 (#3034) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index e39d799a9..9b0bec9dc 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20241202-71e5240" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.66.3" + edgeRuntimeImage = "supabase/edge-runtime:v1.66.4" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.167.0" From f9f9d958711bc679f2d8473cc9f1d70bb36aa98a Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Tue, 14 Jan 2025 00:59:21 +0800 Subject: [PATCH 272/305] fix: defaults to json when initialising import map (#3038) fix: defaults to json import map --- internal/functions/deploy/deploy.go | 17 ++++++++++++++--- internal/functions/new/new.go | 6 +++--- internal/functions/new/new_test.go | 6 +++--- internal/functions/new/templates/deno.json | 3 +++ internal/functions/new/templates/deno.jsonc | 6 ------ pkg/config/config_test.go | 2 +- 6 files changed, 24 insertions(+), 16 deletions(-) create mode 100644 internal/functions/new/templates/deno.json delete mode 100644 internal/functions/new/templates/deno.jsonc diff --git a/internal/functions/deploy/deploy.go b/internal/functions/deploy/deploy.go index 5b6bb8e47..196d2e8a7 100644 --- a/internal/functions/deploy/deploy.go +++ b/internal/functions/deploy/deploy.go @@ -113,11 +113,22 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool, functionConfig[name] = function } if len(functionsUsingDeprecatedImportMap) > 0 { - fmt.Fprintln(os.Stderr, utils.Yellow("WARNING:"), "Functions using deprecated import_map.json (please migrate to deno.jsonc):", utils.Aqua(strings.Join(functionsUsingDeprecatedImportMap, ", "))) + fmt.Fprintln(os.Stderr, + utils.Yellow("WARNING:"), + "Functions using deprecated import_map.json (please migrate to deno.json):", + utils.Aqua(strings.Join(functionsUsingDeprecatedImportMap, ", ")), + ) } if len(functionsUsingDeprecatedGlobalFallback) > 0 { - fmt.Fprintln(os.Stderr, utils.Yellow("WARNING:"), "Functions using fallback import map:", utils.Aqua(strings.Join(functionsUsingDeprecatedGlobalFallback, ", "))) - fmt.Fprintln(os.Stderr, "Please use recommended per function dependency declaration ", utils.Aqua("https://supabase.com/docs/guides/functions/import-maps")) + fmt.Fprintln(os.Stderr, + utils.Yellow("WARNING:"), + "Functions using fallback import map:", + utils.Aqua(strings.Join(functionsUsingDeprecatedGlobalFallback, ", ")), + ) + fmt.Fprintln(os.Stderr, + "Please use recommended per function dependency declaration ", + utils.Aqua("https://supabase.com/docs/guides/functions/import-maps"), + ) } return functionConfig, nil } diff --git a/internal/functions/new/new.go b/internal/functions/new/new.go index 5eca5b67a..67a9893e2 100644 --- a/internal/functions/new/new.go +++ b/internal/functions/new/new.go @@ -17,7 +17,7 @@ import ( var ( //go:embed templates/index.ts indexEmbed string - //go:embed templates/deno.jsonc + //go:embed templates/deno.json denoEmbed string //go:embed templates/.npmrc npmrcEmbed string @@ -57,8 +57,8 @@ func Run(ctx context.Context, slug string, fsys afero.Fs) error { return errors.Errorf("failed to create function entrypoint: %w", err) } - if err := afero.WriteFile(fsys, filepath.Join(funcDir, "deno.jsonc"), []byte(denoEmbed), 0644); err != nil { - return errors.Errorf("failed to create deno.jsonc config: %w", err) + if err := afero.WriteFile(fsys, filepath.Join(funcDir, "deno.json"), []byte(denoEmbed), 0644); err != nil { + return errors.Errorf("failed to create deno.json config: %w", err) } if err := afero.WriteFile(fsys, filepath.Join(funcDir, ".npmrc"), []byte(npmrcEmbed), 0644); err != nil { diff --git a/internal/functions/new/new_test.go b/internal/functions/new/new_test.go index 56a24f705..8e00fa656 100644 --- a/internal/functions/new/new_test.go +++ b/internal/functions/new/new_test.go @@ -25,10 +25,10 @@ func TestNewCommand(t *testing.T) { "curl -i --location --request POST 'http://127.0.0.1:54321/functions/v1/test-func'", ) - // Verify deno.jsonc exists - denoPath := filepath.Join(utils.FunctionsDir, "test-func", "deno.jsonc") + // Verify deno.json exists + denoPath := filepath.Join(utils.FunctionsDir, "test-func", "deno.json") _, err = afero.ReadFile(fsys, denoPath) - assert.NoError(t, err, "deno.jsonc should be created") + assert.NoError(t, err, "deno.json should be created") // Verify .npmrc exists npmrcPath := filepath.Join(utils.FunctionsDir, "test-func", ".npmrc") diff --git a/internal/functions/new/templates/deno.json b/internal/functions/new/templates/deno.json new file mode 100644 index 000000000..f6ca8454c --- /dev/null +++ b/internal/functions/new/templates/deno.json @@ -0,0 +1,3 @@ +{ + "imports": {} +} diff --git a/internal/functions/new/templates/deno.jsonc b/internal/functions/new/templates/deno.jsonc deleted file mode 100644 index 97275ba5e..000000000 --- a/internal/functions/new/templates/deno.jsonc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "imports": { - // Add your dependencies here - // See: https://supabase.com/docs/guides/functions/import-maps#using-denojson-recommended - } -} diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 2280ae40b..e13e67e59 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -410,7 +410,7 @@ func TestLoadFunctionImportMap(t *testing.T) { } // Run test assert.NoError(t, config.Load("", fsys)) - // Check that deno.json was set as import map + // Check that deno.jsonc was set as import map assert.Equal(t, "supabase/functions/hello/deno.jsonc", config.Functions["hello"].ImportMap) }) From 0eaa4b977ac1804e50e8645d405cedfc8c0c86fa Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Mon, 13 Jan 2025 18:04:36 +0100 Subject: [PATCH 273/305] fix(studio): Bump studio version to 20250113-83c9420 (#3037) Bump studio version. --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 9b0bec9dc..3aa5c9d7d 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -10,7 +10,7 @@ const ( inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" pgmetaImage = "supabase/postgres-meta:v0.84.2" - studioImage = "supabase/studio:20241202-71e5240" + studioImage = "supabase/studio:20250113-83c9420" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.66.4" vectorImage = "timberio/vector:0.28.1-alpine" From 7536f94c69f84af0030f6e0ad3af79e009257e70 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 04:51:27 +0000 Subject: [PATCH 274/305] chore(deps): bump github.com/docker/docker from 27.4.1+incompatible to 27.5.0+incompatible (#3041) chore(deps): bump github.com/docker/docker Bumps [github.com/docker/docker](https://github.com/docker/docker) from 27.4.1+incompatible to 27.5.0+incompatible. - [Release notes](https://github.com/docker/docker/releases) - [Commits](https://github.com/docker/docker/compare/v27.4.1...v27.5.0) --- updated-dependencies: - dependency-name: github.com/docker/docker dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 20dee1296..61ab941e3 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/containers/common v0.61.0 github.com/deepmap/oapi-codegen/v2 v2.2.0 github.com/docker/cli v27.4.1+incompatible - github.com/docker/docker v27.4.1+incompatible + github.com/docker/docker v27.5.0+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 github.com/ecies/go/v2 v2.0.10 diff --git a/go.sum b/go.sum index 022e25c75..20750229f 100644 --- a/go.sum +++ b/go.sum @@ -233,8 +233,8 @@ github.com/docker/cli v27.4.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvM github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v27.4.1+incompatible h1:ZJvcY7gfwHn1JF48PfbyXg7Jyt9ZCWDW+GGXOIxEwp4= -github.com/docker/docker v27.4.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.5.0+incompatible h1:um++2NcQtGRTz5eEgO6aJimo6/JxrTXC941hd05JO6U= +github.com/docker/docker v27.5.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo= github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0= From 52cc07d506b26fa2fbefc10027336c7731b75e10 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 04:56:18 +0000 Subject: [PATCH 275/305] chore(deps): bump github.com/docker/cli from 27.4.1+incompatible to 27.5.0+incompatible (#3040) chore(deps): bump github.com/docker/cli Bumps [github.com/docker/cli](https://github.com/docker/cli) from 27.4.1+incompatible to 27.5.0+incompatible. - [Commits](https://github.com/docker/cli/compare/v27.4.1...v27.5.0) --- updated-dependencies: - dependency-name: github.com/docker/cli dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 61ab941e3..9bae3cbe8 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/charmbracelet/lipgloss v0.12.1 github.com/containers/common v0.61.0 github.com/deepmap/oapi-codegen/v2 v2.2.0 - github.com/docker/cli v27.4.1+incompatible + github.com/docker/cli v27.5.0+incompatible github.com/docker/docker v27.5.0+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 diff --git a/go.sum b/go.sum index 20750229f..14de6fa09 100644 --- a/go.sum +++ b/go.sum @@ -228,8 +228,8 @@ github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxK github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk= github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE= -github.com/docker/cli v27.4.1+incompatible h1:VzPiUlRJ/xh+otB75gva3r05isHMo5wXDfPRi5/b4hI= -github.com/docker/cli v27.4.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v27.5.0+incompatible h1:aMphQkcGtpHixwwhAXJT1rrK/detk2JIvDaFkLctbGM= +github.com/docker/cli v27.5.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= From 4665c044f6b06a19b3b0e93c754e42e51e16a716 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 14 Jan 2025 05:01:47 +0000 Subject: [PATCH 276/305] chore(deps): bump google.golang.org/grpc from 1.69.2 to 1.69.4 (#3039) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.69.2 to 1.69.4. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.69.2...v1.69.4) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9bae3cbe8..efa4c92b8 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( golang.org/x/mod v0.22.0 golang.org/x/oauth2 v0.25.0 golang.org/x/term v0.28.0 - google.golang.org/grpc v1.69.2 + google.golang.org/grpc v1.69.4 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.12.0 ) diff --git a/go.sum b/go.sum index 14de6fa09..aa602cf62 100644 --- a/go.sum +++ b/go.sum @@ -1464,8 +1464,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.69.2 h1:U3S9QEtbXC0bYNvRtcoklF3xGtLViumSYxWykJS+7AU= -google.golang.org/grpc v1.69.2/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= +google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A= +google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From d27db81d36e480a61cb3738981718740b77f6534 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 15 Jan 2025 01:15:15 +0800 Subject: [PATCH 277/305] fix: exclude pgmq schema from db dump and pull (#3043) fix: exclude pgmq schema from db dump --- internal/db/dump/dump.go | 1 + internal/utils/misc.go | 1 + pkg/migration/drop.go | 1 + 3 files changed, 3 insertions(+) diff --git a/internal/db/dump/dump.go b/internal/db/dump/dump.go index 94e2ba7af..352942921 100644 --- a/internal/db/dump/dump.go +++ b/internal/db/dump/dump.go @@ -82,6 +82,7 @@ func dumpData(ctx context.Context, config pgconn.Config, schema, excludeTable [] "graphql", "graphql_public", // "net", + // "pgmq", // "pgsodium", // "pgsodium_masks", "pgtle", diff --git a/internal/utils/misc.go b/internal/utils/misc.go index 202d80d0a..32a2fdf15 100644 --- a/internal/utils/misc.go +++ b/internal/utils/misc.go @@ -74,6 +74,7 @@ var ( "graphql", "graphql_public", "net", + "pgmq", "pgsodium", "pgsodium_masks", "pgtle", diff --git a/pkg/migration/drop.go b/pkg/migration/drop.go index 362f2a9d2..4fcdd805c 100644 --- a/pkg/migration/drop.go +++ b/pkg/migration/drop.go @@ -24,6 +24,7 @@ var ( `\_realtime`, `\_supavisor`, "pgbouncer", + "pgmq", "pgsodium", "pgtle", `supabase\_migrations`, From 7417d66fd0ce7cad4ae760d4666ae61c1524f66b Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Wed, 15 Jan 2025 14:08:01 +0900 Subject: [PATCH 278/305] fix(config): dotenvx loading (#3042) * fix(secrets): look for and try all DOTENV_PRIVATE_KEY * fix(env): look for dotenv in supabase folder and look for local env.keys * fix: apply pr comments * fix: apply PR comments --- pkg/config/config.go | 3 ++- pkg/config/secret.go | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index b2104e507..4d9a971ea 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -806,6 +806,7 @@ func sanitizeProjectId(src string) string { func loadDefaultEnv() error { env := viper.GetString("ENV") + if env == "" { env = "development" } @@ -813,7 +814,7 @@ func loadDefaultEnv() error { if env != "test" { filenames = append(filenames, ".env.local") } - filenames = append(filenames, ".env."+env, ".env") + filenames = append(filenames, ".env."+env, ".env", filepath.Join("supabase", ".env."+env), filepath.Join("supabase", ".env")) for _, path := range filenames { if err := loadEnvIfExists(path); err != nil { return err diff --git a/pkg/config/secret.go b/pkg/config/secret.go index 3f0611673..eab7f3f00 100644 --- a/pkg/config/secret.go +++ b/pkg/config/secret.go @@ -64,8 +64,20 @@ func DecryptSecretHookFunc(hashKey string) mapstructure.DecodeHookFunc { if t != reflect.TypeOf(result) { return data, nil } + // Get all env vars and filter for DOTENV_PRIVATE_KEY + var privateKeys []string + for _, env := range os.Environ() { + key := strings.Split(env, "=")[0] + if key == "DOTENV_PRIVATE_KEY" || strings.HasPrefix(key, "DOTENV_PRIVATE_KEY_") { + if value := os.Getenv(key); value != "" { + privateKeys = append(privateKeys, value) + } + } + } + + // Try each private key var err error - privKey := os.Getenv("DOTENV_PRIVATE_KEY") + privKey := strings.Join(privateKeys, ",") for _, k := range strings.Split(privKey, ",") { // Use the first private key that successfully decrypts the secret if result.Value, err = decrypt(k, data.(string)); err == nil { @@ -77,6 +89,7 @@ func DecryptSecretHookFunc(hashKey string) mapstructure.DecodeHookFunc { break } } + // If we get here, none of the keys worked return result, err } } From 678f978e1101ed508a4af5cf5741fe4b39984293 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 15 Jan 2025 21:30:57 +0800 Subject: [PATCH 279/305] fix: load nested env files up to repo directory (#3048) --- pkg/config/config.go | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 4d9a971ea..b11844d45 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -475,7 +475,7 @@ func (c *config) loadFromEnv() error { func (c *config) Load(path string, fsys fs.FS) error { builder := NewPathBuilder(path) // Load secrets from .env file - if err := loadDefaultEnv(); err != nil { + if err := loadNestedEnv(builder.SupabaseDirPath); err != nil { return err } if err := c.loadFromFile(builder.ConfigPath, fsys); err != nil { @@ -804,9 +804,30 @@ func sanitizeProjectId(src string) string { return truncateText(sanitized, maxProjectIdLength) } -func loadDefaultEnv() error { +func loadNestedEnv(basePath string) error { + repoDir, err := os.Getwd() + if err != nil { + return errors.Errorf("failed to get repo directory: %w", err) + } + if !filepath.IsAbs(basePath) { + basePath = filepath.Join(repoDir, basePath) + } env := viper.GetString("ENV") + for cwd := basePath; cwd != repoDir; cwd = filepath.Dir(cwd) { + if err := os.Chdir(cwd); err != nil && !errors.Is(err, os.ErrNotExist) { + return errors.Errorf("failed to change directory: %w", err) + } + if err := loadDefaultEnv(env); err != nil { + return err + } + } + if err := os.Chdir(repoDir); err != nil { + return errors.Errorf("failed to restore directory: %w", err) + } + return nil +} +func loadDefaultEnv(env string) error { if env == "" { env = "development" } @@ -814,7 +835,7 @@ func loadDefaultEnv() error { if env != "test" { filenames = append(filenames, ".env.local") } - filenames = append(filenames, ".env."+env, ".env", filepath.Join("supabase", ".env."+env), filepath.Join("supabase", ".env")) + filenames = append(filenames, ".env."+env, ".env") for _, path := range filenames { if err := loadEnvIfExists(path); err != nil { return err From fb0cd153aaca87e654b86699d2760b9324c490f8 Mon Sep 17 00:00:00 2001 From: Lakshan Perera Date: Thu, 16 Jan 2025 01:10:03 +1100 Subject: [PATCH 280/305] feat: support adding static files to Edge Functions (#3045) --- internal/functions/deploy/bundle.go | 6 +++++- internal/functions/deploy/bundle_test.go | 2 +- internal/functions/serve/serve.go | 3 +++ internal/functions/serve/templates/main.ts | 3 +++ pkg/config/config.go | 12 ++++++++---- pkg/config/constants.go | 2 +- pkg/config/templates/config.toml | 3 +++ pkg/function/api.go | 2 +- pkg/function/batch.go | 2 +- pkg/function/batch_test.go | 2 +- pkg/function/bundle.go | 5 ++++- pkg/function/bundle_test.go | 2 +- 12 files changed, 32 insertions(+), 12 deletions(-) diff --git a/internal/functions/deploy/bundle.go b/internal/functions/deploy/bundle.go index 02f31863f..c82826bec 100644 --- a/internal/functions/deploy/bundle.go +++ b/internal/functions/deploy/bundle.go @@ -25,7 +25,7 @@ func NewDockerBundler(fsys afero.Fs) function.EszipBundler { return &dockerBundler{fsys: fsys} } -func (b *dockerBundler) Bundle(ctx context.Context, entrypoint string, importMap string, output io.Writer) error { +func (b *dockerBundler) Bundle(ctx context.Context, entrypoint string, importMap string, staticFiles []string, output io.Writer) error { // Create temp directory to store generated eszip slug := filepath.Base(filepath.Dir(entrypoint)) fmt.Fprintln(os.Stderr, "Bundling Function:", utils.Bold(slug)) @@ -54,9 +54,13 @@ func (b *dockerBundler) Bundle(ctx context.Context, entrypoint string, importMap if len(importMap) > 0 { cmd = append(cmd, "--import-map", utils.ToDockerPath(importMap)) } + for _, staticFile := range staticFiles { + cmd = append(cmd, "--static", utils.ToDockerPath(staticFile)) + } if viper.GetBool("DEBUG") { cmd = append(cmd, "--verbose") } + env := []string{} if custom_registry := os.Getenv("NPM_CONFIG_REGISTRY"); custom_registry != "" { env = append(env, "NPM_CONFIG_REGISTRY="+custom_registry) diff --git a/internal/functions/deploy/bundle_test.go b/internal/functions/deploy/bundle_test.go index f8a68f439..45b5aedd3 100644 --- a/internal/functions/deploy/bundle_test.go +++ b/internal/functions/deploy/bundle_test.go @@ -43,7 +43,7 @@ func TestDockerBundle(t *testing.T) { apitest.MockDockerStart(utils.Docker, imageUrl, containerId) require.NoError(t, apitest.MockDockerLogsExitCode(utils.Docker, containerId, 1)) // Run test - err = NewDockerBundler(fsys).Bundle(context.Background(), "", "", &body) + err = NewDockerBundler(fsys).Bundle(context.Background(), "", "", []string{}, &body) // Check error assert.ErrorContains(t, err, "error running container: exit 1") assert.Empty(t, apitest.ListUnmatchedRequests()) diff --git a/internal/functions/serve/serve.go b/internal/functions/serve/serve.go index 485d8c7cf..2f09fed16 100644 --- a/internal/functions/serve/serve.go +++ b/internal/functions/serve/serve.go @@ -230,6 +230,9 @@ func populatePerFunctionConfigs(cwd, importMapPath string, noVerifyJWT *bool, fs fc.ImportMap = utils.ToDockerPath(fc.ImportMap) fc.Entrypoint = utils.ToDockerPath(fc.Entrypoint) functionsConfig[slug] = fc + for i, val := range fc.StaticFiles { + fc.StaticFiles[i] = utils.ToDockerPath(val) + } } functionsConfigBytes, err := json.Marshal(functionsConfig) if err != nil { diff --git a/internal/functions/serve/templates/main.ts b/internal/functions/serve/templates/main.ts index 03d4bc9a1..534409a98 100644 --- a/internal/functions/serve/templates/main.ts +++ b/internal/functions/serve/templates/main.ts @@ -178,6 +178,8 @@ Deno.serve({ const absEntrypoint = posix.join(Deno.cwd(), functionsConfig[functionName].entrypointPath); const maybeEntrypoint = posix.toFileUrl(absEntrypoint).href; + const staticPatterns = functionsConfig[functionName].staticFiles; + try { const worker = await EdgeRuntime.userWorkers.create({ servicePath, @@ -195,6 +197,7 @@ Deno.serve({ context: { useReadSyncFileAPI: true, }, + staticPatterns, }); return await worker.fetch(req); diff --git a/pkg/config/config.go b/pkg/config/config.go index b11844d45..a0bddf074 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -178,10 +178,11 @@ type ( FunctionConfig map[string]function function struct { - Enabled *bool `toml:"enabled" json:"-"` - VerifyJWT *bool `toml:"verify_jwt" json:"verifyJWT"` - ImportMap string `toml:"import_map" json:"importMapPath,omitempty"` - Entrypoint string `toml:"entrypoint" json:"entrypointPath,omitempty"` + Enabled *bool `toml:"enabled" json:"-"` + VerifyJWT *bool `toml:"verify_jwt" json:"verifyJWT"` + ImportMap string `toml:"import_map" json:"importMapPath,omitempty"` + Entrypoint string `toml:"entrypoint" json:"entrypointPath,omitempty"` + StaticFiles []string `toml:"static_files" json:"staticFiles,omitempty"` } analytics struct { @@ -592,6 +593,9 @@ func (c *baseConfig) resolve(builder pathBuilder, fsys fs.FS) error { } else if !filepath.IsAbs(function.ImportMap) { function.ImportMap = filepath.Join(builder.SupabaseDirPath, function.ImportMap) } + for i, val := range function.StaticFiles { + function.StaticFiles[i] = filepath.Join(builder.SupabaseDirPath, val) + } c.Functions[slug] = function } return c.Db.Seed.loadSeedPaths(builder.SupabaseDirPath, fsys) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 3aa5c9d7d..4183b4857 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -12,7 +12,7 @@ const ( pgmetaImage = "supabase/postgres-meta:v0.84.2" studioImage = "supabase/studio:20250113-83c9420" imageProxyImage = "darthsim/imgproxy:v3.8.0" - edgeRuntimeImage = "supabase/edge-runtime:v1.66.4" + edgeRuntimeImage = "supabase/edge-runtime:v1.66.5" vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.167.0" diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index 6c50b1447..c8528d8f5 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -257,6 +257,9 @@ inspector_port = 8083 # Uncomment to specify a custom file path to the entrypoint. # Supported file extensions are: .ts, .js, .mjs, .jsx, .tsx # entrypoint = "./functions/MY_FUNCTION_NAME/index.ts" +# Specifies static files to be bundled with the function. Supports glob patterns. +# For example, if you want to serve static HTML pages in your function: +# static_files = [ "./functions/MY_FUNCTION_NAME/*.html" ] [analytics] enabled = true diff --git a/pkg/function/api.go b/pkg/function/api.go index e3f641dee..9fdf52b51 100644 --- a/pkg/function/api.go +++ b/pkg/function/api.go @@ -14,7 +14,7 @@ type EdgeRuntimeAPI struct { } type EszipBundler interface { - Bundle(ctx context.Context, entrypoint string, importMap string, output io.Writer) error + Bundle(ctx context.Context, entrypoint string, importMap string, staticFiles []string, output io.Writer) error } func NewEdgeRuntimeAPI(project string, client api.ClientWithResponses, bundler EszipBundler) EdgeRuntimeAPI { diff --git a/pkg/function/batch.go b/pkg/function/batch.go index 43f837fc4..d06e5bf04 100644 --- a/pkg/function/batch.go +++ b/pkg/function/batch.go @@ -45,7 +45,7 @@ func (s *EdgeRuntimeAPI) UpsertFunctions(ctx context.Context, functionConfig con } } var body bytes.Buffer - if err := s.eszip.Bundle(ctx, function.Entrypoint, function.ImportMap, &body); err != nil { + if err := s.eszip.Bundle(ctx, function.Entrypoint, function.ImportMap, function.StaticFiles, &body); err != nil { return err } // Update if function already exists diff --git a/pkg/function/batch_test.go b/pkg/function/batch_test.go index 1489cd329..101cabb79 100644 --- a/pkg/function/batch_test.go +++ b/pkg/function/batch_test.go @@ -17,7 +17,7 @@ import ( type MockBundler struct { } -func (b *MockBundler) Bundle(ctx context.Context, entrypoint string, importMap string, output io.Writer) error { +func (b *MockBundler) Bundle(ctx context.Context, entrypoint string, importMap string, staticFiles []string, output io.Writer) error { return nil } diff --git a/pkg/function/bundle.go b/pkg/function/bundle.go index ed12806e8..d015624ba 100644 --- a/pkg/function/bundle.go +++ b/pkg/function/bundle.go @@ -28,7 +28,7 @@ func NewNativeBundler(tempDir string, fsys fs.FS) EszipBundler { // Use a package private variable to allow testing without gosec complaining about G204 var edgeRuntimeBin = "edge-runtime" -func (b *nativeBundler) Bundle(ctx context.Context, entrypoint string, importMap string, output io.Writer) error { +func (b *nativeBundler) Bundle(ctx context.Context, entrypoint string, importMap string, staticFiles []string, output io.Writer) error { slug := filepath.Base(filepath.Dir(entrypoint)) outputPath := filepath.Join(b.tempDir, slug+".eszip") // TODO: make edge runtime write to stdout @@ -36,6 +36,9 @@ func (b *nativeBundler) Bundle(ctx context.Context, entrypoint string, importMap if len(importMap) > 0 { args = append(args, "--import-map", importMap) } + for _, staticFile := range staticFiles { + args = append(args, "--static", staticFile) + } cmd := exec.CommandContext(ctx, edgeRuntimeBin, args...) cmd.Stderr = os.Stderr cmd.Stdout = os.Stdout diff --git a/pkg/function/bundle_test.go b/pkg/function/bundle_test.go index 1aa63f212..b29d3bc87 100644 --- a/pkg/function/bundle_test.go +++ b/pkg/function/bundle_test.go @@ -36,7 +36,7 @@ func TestBundleFunction(t *testing.T) { // Setup mock bundler bundler := nativeBundler{fsys: fsys} // Run test - err := bundler.Bundle(context.Background(), "hello/index.ts", "", &body) + err := bundler.Bundle(context.Background(), "hello/index.ts", "", nil, &body) // Check error assert.NoError(t, err) assert.Equal(t, compressedEszipMagicID+";", body.String()) From 694c4c00f92c6cd7a8d6f33af97e043fbc171fed Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Thu, 16 Jan 2025 15:37:59 +0800 Subject: [PATCH 281/305] fix: update gitignore file to exclude dotenvx files (#3049) --- internal/init/templates/.gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/init/templates/.gitignore b/internal/init/templates/.gitignore index a3ad88055..ad9264f0b 100644 --- a/internal/init/templates/.gitignore +++ b/internal/init/templates/.gitignore @@ -1,4 +1,8 @@ # Supabase .branches .temp -.env + +# dotenvx +.env.keys +.env.local +.env.*.local From ec01c4b975614d13b815c58bc6976273b1e3e352 Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Fri, 17 Jan 2025 02:54:05 +0800 Subject: [PATCH 282/305] fix: stop nested env at cwd --- pkg/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index a0bddf074..24487cafa 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -817,7 +817,7 @@ func loadNestedEnv(basePath string) error { basePath = filepath.Join(repoDir, basePath) } env := viper.GetString("ENV") - for cwd := basePath; cwd != repoDir; cwd = filepath.Dir(cwd) { + for cwd := basePath; cwd != filepath.Dir(repoDir); cwd = filepath.Dir(cwd) { if err := os.Chdir(cwd); err != nil && !errors.Is(err, os.ErrNotExist) { return errors.Errorf("failed to change directory: %w", err) } From 48b977abe01645e35e2649ddfd05c0e5c6d5c8d4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 17 Jan 2025 04:54:16 +0000 Subject: [PATCH 283/305] chore(deps): bump github.com/containers/common from 0.61.0 to 0.61.1 (#3053) Bumps [github.com/containers/common](https://github.com/containers/common) from 0.61.0 to 0.61.1. - [Release notes](https://github.com/containers/common/releases) - [Commits](https://github.com/containers/common/compare/v0.61.0...v0.61.1) --- updated-dependencies: - dependency-name: github.com/containers/common dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index efa4c92b8..ac6ee387e 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/charmbracelet/bubbletea v0.25.0 github.com/charmbracelet/glamour v0.7.0 github.com/charmbracelet/lipgloss v0.12.1 - github.com/containers/common v0.61.0 + github.com/containers/common v0.61.1 github.com/deepmap/oapi-codegen/v2 v2.2.0 github.com/docker/cli v27.5.0+incompatible github.com/docker/docker v27.5.0+incompatible @@ -107,7 +107,7 @@ require ( github.com/cloudflare/circl v1.3.7 // indirect github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect github.com/containerd/log v0.1.0 // indirect - github.com/containers/storage v1.56.0 // indirect + github.com/containers/storage v1.56.1 // indirect github.com/curioswitch/go-reassign v0.3.0 // indirect github.com/cyphar/filepath-securejoin v0.3.6 // indirect github.com/daixiang0/gci v0.13.5 // indirect diff --git a/go.sum b/go.sum index aa602cf62..f33730d7b 100644 --- a/go.sum +++ b/go.sum @@ -192,10 +192,10 @@ github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 h1:q2hJAaP1k2 github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I= github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo= -github.com/containers/common v0.61.0 h1:j/84PTqZIKKYy42OEJsZmjZ4g4Kq2ERuC3tqp2yWdh4= -github.com/containers/common v0.61.0/go.mod h1:NGRISq2vTFPSbhNqj6MLwyes4tWSlCnqbJg7R77B8xc= -github.com/containers/storage v1.56.0 h1:DZ9KSkj6M2tvj/4bBoaJu3QDHRl35BwsZ4kmLJS97ZI= -github.com/containers/storage v1.56.0/go.mod h1:c6WKowcAlED/DkWGNuL9bvGYqIWCVy7isRMdCSKWNjk= +github.com/containers/common v0.61.1 h1:jpk385ZFEx3MAX+sjwOoTZElvpgsGi0YJHuRmrhF/j8= +github.com/containers/common v0.61.1/go.mod h1:C+TfkhTV+ADp1Hu+BMIAYPvSFix21swYo9PZuCKoSUM= +github.com/containers/storage v1.56.1 h1:gDZj/S6Zxus4Xx42X6iNB3ODXuh0qoOdH/BABfrvcKo= +github.com/containers/storage v1.56.1/go.mod h1:c6WKowcAlED/DkWGNuL9bvGYqIWCVy7isRMdCSKWNjk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= From 8c03aa7c84b5fad5d9ae8637a9fc634d76018719 Mon Sep 17 00:00:00 2001 From: Fabrizio Date: Fri, 17 Jan 2025 09:18:31 +0100 Subject: [PATCH 284/305] fix(storage): enhance imgproxy limits (#3054) fix: enhance imgproxy limits --- internal/start/start.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/start/start.go b/internal/start/start.go index 2501d5b8d..1359d78a8 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -883,6 +883,10 @@ EOF "IMGPROXY_BIND=:5001", "IMGPROXY_LOCAL_FILESYSTEM_ROOT=/", "IMGPROXY_USE_ETAG=/", + "IMGPROXY_MAX_SRC_RESOLUTION=50", + "IMGPROXY_MAX_SRC_FILE_SIZE=25000000", + "IMGPROXY_MAX_ANIMATION_FRAMES=60", + "IMGPROXY_ENABLE_WEBP_DETECTION=true", }, Healthcheck: &container.HealthConfig{ Test: []string{"CMD", "imgproxy", "health"}, From 26d1a02e560f40813b0e4e597a0f66b01de7d3f7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 04:46:38 +0000 Subject: [PATCH 285/305] chore(deps): bump go.opentelemetry.io/otel from 1.33.0 to 1.34.0 (#3057) Bumps [go.opentelemetry.io/otel](https://github.com/open-telemetry/opentelemetry-go) from 1.33.0 to 1.34.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.33.0...v1.34.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/otel dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index ac6ee387e..f287b4b97 100644 --- a/go.mod +++ b/go.mod @@ -48,7 +48,7 @@ require ( github.com/tidwall/jsonc v0.3.2 github.com/withfig/autocomplete-tools/packages/cobra v1.2.0 github.com/zalando/go-keyring v0.2.6 - go.opentelemetry.io/otel v1.33.0 + go.opentelemetry.io/otel v1.34.0 golang.org/x/mod v0.22.0 golang.org/x/oauth2 v0.25.0 golang.org/x/term v0.28.0 @@ -314,10 +314,10 @@ require ( go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect - go.opentelemetry.io/otel/metric v1.33.0 // indirect + go.opentelemetry.io/otel/metric v1.34.0 // indirect go.opentelemetry.io/otel/sdk v1.31.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.31.0 // indirect - go.opentelemetry.io/otel/trace v1.33.0 // indirect + go.opentelemetry.io/otel/trace v1.34.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/automaxprocs v1.6.0 // indirect diff --git a/go.sum b/go.sum index f33730d7b..0b1a3f5a5 100644 --- a/go.sum +++ b/go.sum @@ -1018,8 +1018,8 @@ go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJyS go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk= go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8= -go.opentelemetry.io/otel v1.33.0 h1:/FerN9bax5LoK51X/sI0SVYrjSE0/yUL7DpxW4K3FWw= -go.opentelemetry.io/otel v1.33.0/go.mod h1:SUUkR6csvUQl+yjReHu5uM3EtVV7MBm5FHKRlNx4I8I= +go.opentelemetry.io/otel v1.34.0 h1:zRLXxLCgL1WyKsPVrgbSdMN4c0FMkDAskSTQP+0hdUY= +go.opentelemetry.io/otel v1.34.0/go.mod h1:OWFPOQ+h4G8xpyjgqo4SxJYdDQ/qmRH+wivy7zzx9oI= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0 h1:U2guen0GhqH8o/G2un8f/aG/y++OuW6MyCo6hT9prXk= go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.28.0/go.mod h1:yeGZANgEcpdx/WK0IvvRFC+2oLiMS2u4L/0Rj2M2Qr0= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 h1:3Q/xZUyC1BBkualc9ROb4G8qkH90LXEIICcs5zv1OYY= @@ -1028,14 +1028,14 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 h1:R3X6Z go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0/go.mod h1:QWFXnDavXWwMx2EEcZsf3yxgEKAqsxQ+Syjp+seyInw= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 h1:j9+03ymgYhPKmeXGk5Zu+cIZOlVzd9Zv7QIiyItjFBU= go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0/go.mod h1:Y5+XiUG4Emn1hTfciPzGPJaSI+RpDts6BnCIir0SLqk= -go.opentelemetry.io/otel/metric v1.33.0 h1:r+JOocAyeRVXD8lZpjdQjzMadVZp2M4WmQ+5WtEnklQ= -go.opentelemetry.io/otel/metric v1.33.0/go.mod h1:L9+Fyctbp6HFTddIxClbQkjtubW6O9QS3Ann/M82u6M= +go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= +go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk= go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0= go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc= go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8= -go.opentelemetry.io/otel/trace v1.33.0 h1:cCJuF7LRjUFso9LPnEAHJDB2pqzp+hbO8eu1qqW2d/s= -go.opentelemetry.io/otel/trace v1.33.0/go.mod h1:uIcdVUZMpTAmz0tI1z04GoVSezK37CbGV4fr1f2nBck= +go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= +go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= From 38a8816b7ec208331aa55b78538c7f0946675b36 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Mon, 20 Jan 2025 18:07:50 +0900 Subject: [PATCH 286/305] feat(settings): add track_activity_query_size setting configuration (#3052) * feat(settings): add track_activity_query_size setting configuration * Update cmd/snippets.go Co-authored-by: Han Qiao * chore: fix lint * chore: use single quotes * chore: remove prettierc * chore: use string instead of number for size --------- Co-authored-by: Han Qiao --- api/beta.yaml | 533 +++++++++++--- internal/branches/list/list.go | 7 +- internal/snippets/download/download.go | 8 +- pkg/api/client.gen.go | 943 ++++++++++++++++++++++++- pkg/api/types.gen.go | 262 ++++++- pkg/config/db.go | 3 + 6 files changed, 1608 insertions(+), 148 deletions(-) diff --git a/api/beta.yaml b/api/beta.yaml index cd6c20a15..5163460d6 100644 --- a/api/beta.yaml +++ b/api/beta.yaml @@ -79,6 +79,31 @@ paths: - Environments security: - bearer: [] + /v1/branches/{branch_id}/push: + post: + operationId: v1-push-a-branch + summary: Pushes a database branch + description: Pushes the specified database branch + parameters: + - name: branch_id + required: true + in: path + description: Branch ID + schema: + type: string + responses: + '201': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/BranchUpdateResponse' + '500': + description: Failed to push database branch + tags: + - Environments + security: + - bearer: [] /v1/branches/{branch_id}/reset: post: operationId: v1-reset-a-branch @@ -97,7 +122,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/BranchResetResponse' + $ref: '#/components/schemas/BranchUpdateResponse' '500': description: Failed to reset database branch tags: @@ -272,11 +297,58 @@ paths: security: - oauth2: - write + /v1/oauth/revoke: + post: + operationId: v1-revoke-token + summary: '[Beta] Revoke oauth app authorization and it''s corresponding tokens' + parameters: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/OAuthRevokeTokenBodyDto' + responses: + '204': + description: '' + tags: + - OAuth + security: + - oauth2: + - write /v1/snippets: get: operationId: v1-list-all-snippets summary: Lists SQL snippets for the logged in user parameters: + - name: cursor + required: false + in: query + schema: + type: string + - name: limit + required: false + in: query + schema: + type: string + minimum: 1 + maximum: 100 + - name: sort_by + required: false + in: query + schema: + enum: + - name + - inserted_at + type: string + - name: sort_order + required: false + in: query + schema: + enum: + - asc + - desc + type: string - name: project_ref required: false in: query @@ -304,6 +376,7 @@ paths: required: true in: path schema: + format: uuid type: string responses: '200': @@ -1962,6 +2035,133 @@ paths: - Auth security: - bearer: [] + /v1/projects/{ref}/pause: + post: + operationId: v1-pause-a-project + summary: Pauses the given project + parameters: + - name: ref + required: true + in: path + description: Project ref + schema: + minLength: 20 + maxLength: 20 + type: string + responses: + '200': + description: '' + '403': + description: '' + tags: + - Projects + security: + - bearer: [] + /v1/projects/{ref}/restore: + get: + operationId: v1-list-available-restore-versions + summary: Lists available restore versions for the given project + parameters: + - name: ref + required: true + in: path + schema: + type: string + responses: + '200': + description: '' + content: + application/json: + schema: + $ref: >- + #/components/schemas/GetProjectAvailableRestoreVersionsResponse + '403': + description: '' + tags: + - Projects + security: + - bearer: [] + post: + operationId: v1-restore-a-project + summary: Restores the given project + parameters: + - name: ref + required: true + in: path + schema: + type: string + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/RestoreProjectBodyDto' + responses: + '200': + description: '' + '403': + description: '' + tags: + - Projects + security: + - bearer: [] + /v1/projects/{ref}/restore/cancel: + post: + operationId: v1-cancel-a-project-restoration + summary: Cancels the given project restoration + parameters: + - name: ref + required: true + in: path + schema: + type: string + responses: + '200': + description: '' + '403': + description: '' + tags: + - Projects + security: + - bearer: [] + /v1/projects/{ref}/analytics/endpoints/logs.all: + get: + operationId: getLogs + summary: Gets project's logs + parameters: + - name: iso_timestamp_end + required: false + in: query + schema: + type: string + - name: iso_timestamp_start + required: false + in: query + schema: + type: string + - name: sql + required: false + in: query + schema: + type: string + - name: ref + required: true + in: path + schema: + type: string + responses: + '200': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/V1AnalyticsResponse' + '403': + description: '' + tags: + - Analytics + security: + - bearer: [] /v1/projects/{ref}/database/query: post: operationId: v1-run-a-query @@ -2021,6 +2221,36 @@ paths: security: - bearer: [] /v1/projects/{ref}/functions: + get: + operationId: v1-list-all-functions + summary: List all functions + description: Returns all functions you've previously added to the specified project. + parameters: + - name: ref + required: true + in: path + description: Project ref + schema: + minLength: 20 + maxLength: 20 + type: string + responses: + '200': + description: '' + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/FunctionResponse' + '403': + description: '' + '500': + description: Failed to retrieve project's functions + tags: + - Edge Functions + security: + - bearer: [] post: operationId: v1-create-a-function summary: Create a function @@ -2096,36 +2326,6 @@ paths: - Edge Functions security: - bearer: [] - get: - operationId: v1-list-all-functions - summary: List all functions - description: Returns all functions you've previously added to the specified project. - parameters: - - name: ref - required: true - in: path - description: Project ref - schema: - minLength: 20 - maxLength: 20 - type: string - responses: - '200': - description: '' - content: - application/json: - schema: - type: array - items: - $ref: '#/components/schemas/FunctionResponse' - '403': - description: '' - '500': - description: Failed to retrieve project's functions - tags: - - Edge Functions - security: - - bearer: [] /v1/projects/{ref}/functions/{function_slug}: get: operationId: v1-get-a-function @@ -2645,33 +2845,33 @@ components: BranchDetailResponse: type: object properties: - db_port: - type: integer - ref: - type: string - postgres_version: - type: string - postgres_engine: - type: string - release_channel: - type: string status: + type: string enum: + - INACTIVE - ACTIVE_HEALTHY - ACTIVE_UNHEALTHY - COMING_UP + - UNKNOWN - GOING_DOWN - - INACTIVE - INIT_FAILED - REMOVED - - RESTARTING - - UNKNOWN + - RESTORING - UPGRADING - PAUSING - - RESTORING - RESTORE_FAILED + - RESTARTING - PAUSE_FAILED - RESIZING + db_port: + type: integer + ref: + type: string + postgres_version: + type: string + postgres_engine: + type: string + release_channel: type: string db_host: type: string @@ -2682,25 +2882,30 @@ components: jwt_secret: type: string required: + - status - db_port - ref - postgres_version - postgres_engine - release_channel - - status - db_host UpdateBranchBody: type: object properties: + reset_on_push: + type: boolean + deprecated: true + description: >- + This field is deprecated and will be ignored. Use v1-reset-a-branch + endpoint directly instead. branch_name: type: string git_branch: type: string - reset_on_push: - type: boolean persistent: type: boolean status: + type: string enum: - CREATING_PROJECT - RUNNING_MIGRATIONS @@ -2708,7 +2913,6 @@ components: - MIGRATIONS_FAILED - FUNCTIONS_DEPLOYED - FUNCTIONS_FAILED - type: string BranchResponse: type: object properties: @@ -2716,8 +2920,18 @@ components: type: integer format: int32 latest_check_run_id: - type: integer - format: int64 + type: number + deprecated: true + description: This field is deprecated and will not be populated. + status: + type: string + enum: + - CREATING_PROJECT + - RUNNING_MIGRATIONS + - MIGRATIONS_PASSED + - MIGRATIONS_FAILED + - FUNCTIONS_DEPLOYED + - FUNCTIONS_FAILED id: type: string name: @@ -2730,32 +2944,20 @@ components: type: boolean git_branch: type: string - reset_on_push: - type: boolean persistent: type: boolean - status: - enum: - - CREATING_PROJECT - - RUNNING_MIGRATIONS - - MIGRATIONS_PASSED - - MIGRATIONS_FAILED - - FUNCTIONS_DEPLOYED - - FUNCTIONS_FAILED - type: string created_at: type: string updated_at: type: string required: + - status - id - name - project_ref - parent_project_ref - is_default - - reset_on_push - persistent - - status - created_at - updated_at BranchDeleteResponse: @@ -2765,7 +2967,7 @@ components: type: string required: - message - BranchResetResponse: + BranchUpdateResponse: type: object properties: workflow_run_id: @@ -2815,34 +3017,34 @@ components: type: string description: Creation timestamp example: '2023-03-29T16:32:59Z' - database: - $ref: '#/components/schemas/V1DatabaseResponse' status: + type: string enum: + - INACTIVE - ACTIVE_HEALTHY - ACTIVE_UNHEALTHY - COMING_UP + - UNKNOWN - GOING_DOWN - - INACTIVE - INIT_FAILED - REMOVED - - RESTARTING - - UNKNOWN + - RESTORING - UPGRADING - PAUSING - - RESTORING - RESTORE_FAILED + - RESTARTING - PAUSE_FAILED - RESIZING - type: string + database: + $ref: '#/components/schemas/V1DatabaseResponse' required: - id - organization_id - name - region - created_at - - database - status + - database V1CreateProjectBodyDto: type: object properties: @@ -2851,7 +3053,7 @@ components: description: Database password name: type: string - description: Name of your project, should not contain dots + description: Name of your project organization_id: type: string description: Slug of your organization @@ -2917,11 +3119,13 @@ components: - beta - ga - withdrawn + - preview description: Release channel. If not provided, GA will be used. postgres_engine: type: string enum: - '15' + - 17-oriole description: >- Postgres engine version. If not provided, the latest version will be used. @@ -2952,23 +3156,23 @@ components: description: Creation timestamp example: '2023-03-29T16:32:59Z' status: + type: string enum: + - INACTIVE - ACTIVE_HEALTHY - ACTIVE_UNHEALTHY - COMING_UP + - UNKNOWN - GOING_DOWN - - INACTIVE - INIT_FAILED - REMOVED - - RESTARTING - - UNKNOWN + - RESTORING - UPGRADING - PAUSING - - RESTORING - RESTORE_FAILED + - RESTARTING - PAUSE_FAILED - RESIZING - type: string required: - id - organization_id @@ -3037,6 +3241,21 @@ components: - token_type - access_token - refresh_token + OAuthRevokeTokenBodyDto: + type: object + properties: + client_id: + type: string + format: uuid + client_secret: + type: string + refresh_token: + type: string + required: + - client_id + - client_secret + - refresh_token + additionalProperties: false SnippetProject: type: object properties: @@ -3083,6 +3302,7 @@ components: type: string description: type: string + nullable: true project: $ref: '#/components/schemas/SnippetProject' owner: @@ -3096,6 +3316,7 @@ components: - type - visibility - name + - description - project - owner - updated_by @@ -3106,6 +3327,8 @@ components: type: array items: $ref: '#/components/schemas/SnippetMeta' + cursor: + type: string required: - data SnippetContent: @@ -3145,6 +3368,7 @@ components: type: string description: type: string + nullable: true project: $ref: '#/components/schemas/SnippetProject' owner: @@ -3160,6 +3384,7 @@ components: - type - visibility - name + - description - project - owner - updated_by @@ -3258,6 +3483,7 @@ components: - beta - ga - withdrawn + - preview PostgresEngine: type: string description: >- @@ -3265,6 +3491,7 @@ components: used. enum: - '15' + - 17-oriole CreateBranchBody: type: object properties: @@ -3852,13 +4079,23 @@ components: type: boolean required: - enabled + StorageFeatureS3Protocol: + type: object + properties: + enabled: + type: boolean + required: + - enabled StorageFeatures: type: object properties: imageTransformation: $ref: '#/components/schemas/StorageFeatureImageTransformation' + s3Protocol: + $ref: '#/components/schemas/StorageFeatureS3Protocol' required: - imageTransformation + - s3Protocol StorageConfigResponse: type: object properties: @@ -3889,6 +4126,8 @@ components: type: string maintenance_work_mem: type: string + track_activity_query_size: + type: string max_connections: type: integer minimum: 1 @@ -3952,6 +4191,8 @@ components: type: string maintenance_work_mem: type: string + track_activity_query_size: + type: string max_connections: type: integer minimum: 1 @@ -4028,6 +4269,11 @@ components: SupavisorConfigResponse: type: object properties: + database_type: + type: string + enum: + - PRIMARY + - READ_REPLICA db_port: type: integer default_pool_size: @@ -4038,11 +4284,6 @@ components: nullable: true identifier: type: string - database_type: - enum: - - PRIMARY - - READ_REPLICA - type: string is_using_scram_auth: type: boolean db_user: @@ -4059,11 +4300,11 @@ components: - session type: string required: + - database_type - db_port - default_pool_size - max_client_conn - identifier - - database_type - is_using_scram_auth - db_user - db_host @@ -5208,33 +5449,101 @@ components: - type - inserted_at - updated_at - V1RunQueryBody: + ProjectAvailableRestoreVersion: type: object properties: - query: + version: + type: string + release_channel: + type: string + enum: + - internal + - alpha + - beta + - ga + - withdrawn + - preview + postgres_engine: type: string + enum: + - '13' + - '14' + - '15' + - 17-oriole required: - - query - V1CreateFunctionBody: + - version + - release_channel + - postgres_engine + GetProjectAvailableRestoreVersionsResponse: type: object properties: - slug: + available_versions: + type: array + items: + $ref: '#/components/schemas/ProjectAvailableRestoreVersion' + required: + - available_versions + RestoreProjectBodyDto: + type: object + properties: + release_channel: type: string - pattern: /^[A-Za-z0-9_-]+$/ - name: + enum: + - internal + - alpha + - beta + - ga + - withdrawn + - preview + description: >- + Release channel version. If not provided, GeneralAvailability will + be used. + postgres_engine: type: string - body: + enum: + - '15' + - 17-oriole + description: >- + Postgres engine version. If not provided, the latest version from + the given release channel will be used. + V1AnalyticsResponse: + type: object + properties: + error: + oneOf: + - properties: + code: + type: number + errors: + type: array + items: + properties: + domain: + type: string + location: + type: string + locationType: + type: string + message: + type: string + reason: + type: string + message: + type: string + status: + type: string + - type: string + result: + type: array + items: + type: object + V1RunQueryBody: + type: object + properties: + query: type: string - verify_jwt: - type: boolean - compute_multiplier: - type: number - minimum: 1 - maximum: 4 required: - - slug - - name - - body + - query FunctionResponse: type: object properties: @@ -5276,6 +5585,26 @@ components: - slug - name - status + V1CreateFunctionBody: + type: object + properties: + slug: + type: string + pattern: /^[A-Za-z0-9_-]+$/ + name: + type: string + body: + type: string + verify_jwt: + type: boolean + compute_multiplier: + type: number + minimum: 1 + maximum: 4 + required: + - slug + - name + - body FunctionSlugResponse: type: object properties: diff --git a/internal/branches/list/list.go b/internal/branches/list/list.go index 7a153138f..79eb75e2a 100644 --- a/internal/branches/list/list.go +++ b/internal/branches/list/list.go @@ -22,8 +22,8 @@ func Run(ctx context.Context, fsys afero.Fs) error { return errors.New("Unexpected error listing preview branches: " + string(resp.Body)) } - table := `|ID|NAME|DEFAULT|GIT BRANCH|RESET ON PUSH|STATUS|CREATED AT (UTC)|UPDATED AT (UTC)| -|-|-|-|-|-|-|-|-| + table := `|ID|NAME|DEFAULT|GIT BRANCH|STATUS|CREATED AT (UTC)|UPDATED AT (UTC)| +|-|-|-|-|-|-|-| ` for _, branch := range *resp.JSON200 { gitBranch := " " @@ -31,12 +31,11 @@ func Run(ctx context.Context, fsys afero.Fs) error { gitBranch = *branch.GitBranch } table += fmt.Sprintf( - "|`%s`|`%s`|`%t`|`%s`|`%t`|`%s`|`%s`|`%s`|\n", + "|`%s`|`%s`|`%t`|`%s`|`%s`|`%s`|`%s`|\n", branch.Id, strings.ReplaceAll(branch.Name, "|", "\\|"), branch.IsDefault, strings.ReplaceAll(gitBranch, "|", "\\|"), - branch.ResetOnPush, branch.Status, utils.FormatTimestamp(branch.CreatedAt), utils.FormatTimestamp(branch.UpdatedAt), diff --git a/internal/snippets/download/download.go b/internal/snippets/download/download.go index 7f1f3a463..22b45dd68 100644 --- a/internal/snippets/download/download.go +++ b/internal/snippets/download/download.go @@ -5,12 +5,18 @@ import ( "fmt" "github.com/go-errors/errors" + "github.com/google/uuid" "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" ) func Run(ctx context.Context, snippetId string, fsys afero.Fs) error { - resp, err := utils.GetSupabase().V1GetASnippetWithResponse(ctx, snippetId) + // Convert string to UUID + id, err := uuid.Parse(snippetId) + if err != nil { + return fmt.Errorf("invalid snippet ID: %w", err) + } + resp, err := utils.GetSupabase().V1GetASnippetWithResponse(ctx, id) if err != nil { return errors.Errorf("failed to download snippet: %w", err) } diff --git a/pkg/api/client.gen.go b/pkg/api/client.gen.go index fcbe8eaeb..8a5b498d4 100644 --- a/pkg/api/client.gen.go +++ b/pkg/api/client.gen.go @@ -14,6 +14,7 @@ import ( "strings" "github.com/oapi-codegen/runtime" + openapi_types "github.com/oapi-codegen/runtime/types" ) // RequestEditorFn is the function signature for the RequestEditor callback function @@ -100,12 +101,20 @@ type ClientInterface interface { V1UpdateABranchConfig(ctx context.Context, branchId string, body V1UpdateABranchConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1PushABranch request + V1PushABranch(ctx context.Context, branchId string, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1ResetABranch request V1ResetABranch(ctx context.Context, branchId string, reqEditors ...RequestEditorFn) (*http.Response, error) // V1AuthorizeUser request V1AuthorizeUser(ctx context.Context, params *V1AuthorizeUserParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1RevokeTokenWithBody request with any body + V1RevokeTokenWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + V1RevokeToken(ctx context.Context, body V1RevokeTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1ExchangeOauthTokenWithBody request with any body V1ExchangeOauthTokenWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -139,6 +148,9 @@ type ClientInterface interface { // V1GetProject request V1GetProject(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetLogs request + GetLogs(ctx context.Context, ref string, params *GetLogsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1GetProjectApiKeys request V1GetProjectApiKeys(ctx context.Context, ref string, params *V1GetProjectApiKeysParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -311,6 +323,9 @@ type ClientInterface interface { V1UpdateNetworkRestrictions(ctx context.Context, ref string, body V1UpdateNetworkRestrictionsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1PauseAProject request + V1PauseAProject(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1GetPgsodiumConfig request V1GetPgsodiumConfig(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -343,6 +358,17 @@ type ClientInterface interface { // V1DisableReadonlyModeTemporarily request V1DisableReadonlyModeTemporarily(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1ListAvailableRestoreVersions request + V1ListAvailableRestoreVersions(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + + // V1RestoreAProjectWithBody request with any body + V1RestoreAProjectWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + V1RestoreAProject(ctx context.Context, ref string, body V1RestoreAProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // V1CancelAProjectRestoration request + V1CancelAProjectRestoration(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1BulkDeleteSecretsWithBody request with any body V1BulkDeleteSecretsWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -401,7 +427,7 @@ type ClientInterface interface { V1ListAllSnippets(ctx context.Context, params *V1ListAllSnippetsParams, reqEditors ...RequestEditorFn) (*http.Response, error) // V1GetASnippet request - V1GetASnippet(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) + V1GetASnippet(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) } func (c *Client) V1DeleteABranch(ctx context.Context, branchId string, reqEditors ...RequestEditorFn) (*http.Response, error) { @@ -452,6 +478,18 @@ func (c *Client) V1UpdateABranchConfig(ctx context.Context, branchId string, bod return c.Client.Do(req) } +func (c *Client) V1PushABranch(ctx context.Context, branchId string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1PushABranchRequest(c.Server, branchId) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) V1ResetABranch(ctx context.Context, branchId string, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewV1ResetABranchRequest(c.Server, branchId) if err != nil { @@ -476,6 +514,30 @@ func (c *Client) V1AuthorizeUser(ctx context.Context, params *V1AuthorizeUserPar return c.Client.Do(req) } +func (c *Client) V1RevokeTokenWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1RevokeTokenRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) V1RevokeToken(ctx context.Context, body V1RevokeTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1RevokeTokenRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) V1ExchangeOauthTokenWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewV1ExchangeOauthTokenRequestWithBody(c.Server, contentType, body) if err != nil { @@ -620,6 +682,18 @@ func (c *Client) V1GetProject(ctx context.Context, ref string, reqEditors ...Req return c.Client.Do(req) } +func (c *Client) GetLogs(ctx context.Context, ref string, params *GetLogsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetLogsRequest(c.Server, ref, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) V1GetProjectApiKeys(ctx context.Context, ref string, params *V1GetProjectApiKeysParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewV1GetProjectApiKeysRequest(c.Server, ref, params) if err != nil { @@ -1376,6 +1450,18 @@ func (c *Client) V1UpdateNetworkRestrictions(ctx context.Context, ref string, bo return c.Client.Do(req) } +func (c *Client) V1PauseAProject(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1PauseAProjectRequest(c.Server, ref) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) V1GetPgsodiumConfig(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewV1GetPgsodiumConfigRequest(c.Server, ref) if err != nil { @@ -1520,6 +1606,54 @@ func (c *Client) V1DisableReadonlyModeTemporarily(ctx context.Context, ref strin return c.Client.Do(req) } +func (c *Client) V1ListAvailableRestoreVersions(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1ListAvailableRestoreVersionsRequest(c.Server, ref) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) V1RestoreAProjectWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1RestoreAProjectRequestWithBody(c.Server, ref, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) V1RestoreAProject(ctx context.Context, ref string, body V1RestoreAProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1RestoreAProjectRequest(c.Server, ref, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) V1CancelAProjectRestoration(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1CancelAProjectRestorationRequest(c.Server, ref) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) V1BulkDeleteSecretsWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewV1BulkDeleteSecretsRequestWithBody(c.Server, ref, contentType, body) if err != nil { @@ -1772,7 +1906,7 @@ func (c *Client) V1ListAllSnippets(ctx context.Context, params *V1ListAllSnippet return c.Client.Do(req) } -func (c *Client) V1GetASnippet(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*http.Response, error) { +func (c *Client) V1GetASnippet(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewV1GetASnippetRequest(c.Server, id) if err != nil { return nil, err @@ -1899,6 +2033,40 @@ func NewV1UpdateABranchConfigRequestWithBody(server string, branchId string, con return req, nil } +// NewV1PushABranchRequest generates requests for V1PushABranch +func NewV1PushABranchRequest(server string, branchId string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "branch_id", runtime.ParamLocationPath, branchId) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/branches/%s/push", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewV1ResetABranchRequest generates requests for V1ResetABranch func NewV1ResetABranchRequest(server string, branchId string) (*http.Request, error) { var err error @@ -2082,6 +2250,46 @@ func NewV1AuthorizeUserRequest(server string, params *V1AuthorizeUserParams) (*h return req, nil } +// NewV1RevokeTokenRequest calls the generic V1RevokeToken builder with application/json body +func NewV1RevokeTokenRequest(server string, body V1RevokeTokenJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewV1RevokeTokenRequestWithBody(server, "application/json", bodyReader) +} + +// NewV1RevokeTokenRequestWithBody generates requests for V1RevokeToken with any type of body +func NewV1RevokeTokenRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/oauth/revoke") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewV1ExchangeOauthTokenRequestWithFormdataBody calls the generic V1ExchangeOauthToken builder with application/x-www-form-urlencoded body func NewV1ExchangeOauthTokenRequestWithFormdataBody(server string, body V1ExchangeOauthTokenFormdataRequestBody) (*http.Request, error) { var bodyReader io.Reader @@ -2392,6 +2600,94 @@ func NewV1GetProjectRequest(server string, ref string) (*http.Request, error) { return req, nil } +// NewGetLogsRequest generates requests for GetLogs +func NewGetLogsRequest(server string, ref string, params *GetLogsParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/analytics/endpoints/logs.all", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if params.IsoTimestampEnd != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "iso_timestamp_end", runtime.ParamLocationQuery, *params.IsoTimestampEnd); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.IsoTimestampStart != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "iso_timestamp_start", runtime.ParamLocationQuery, *params.IsoTimestampStart); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Sql != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "sql", runtime.ParamLocationQuery, *params.Sql); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewV1GetProjectApiKeysRequest generates requests for V1GetProjectApiKeys func NewV1GetProjectApiKeysRequest(server string, ref string, params *V1GetProjectApiKeysParams) (*http.Request, error) { var err error @@ -4621,8 +4917,8 @@ func NewV1UpdateNetworkRestrictionsRequestWithBody(server string, ref string, co return req, nil } -// NewV1GetPgsodiumConfigRequest generates requests for V1GetPgsodiumConfig -func NewV1GetPgsodiumConfigRequest(server string, ref string) (*http.Request, error) { +// NewV1PauseAProjectRequest generates requests for V1PauseAProject +func NewV1PauseAProjectRequest(server string, ref string) (*http.Request, error) { var err error var pathParam0 string @@ -4637,7 +4933,7 @@ func NewV1GetPgsodiumConfigRequest(server string, ref string) (*http.Request, er return nil, err } - operationPath := fmt.Sprintf("/v1/projects/%s/pgsodium", pathParam0) + operationPath := fmt.Sprintf("/v1/projects/%s/pause", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -4647,7 +4943,7 @@ func NewV1GetPgsodiumConfigRequest(server string, ref string) (*http.Request, er return nil, err } - req, err := http.NewRequest("GET", queryURL.String(), nil) + req, err := http.NewRequest("POST", queryURL.String(), nil) if err != nil { return nil, err } @@ -4655,14 +4951,48 @@ func NewV1GetPgsodiumConfigRequest(server string, ref string) (*http.Request, er return req, nil } -// NewV1UpdatePgsodiumConfigRequest calls the generic V1UpdatePgsodiumConfig builder with application/json body -func NewV1UpdatePgsodiumConfigRequest(server string, ref string, body V1UpdatePgsodiumConfigJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) +// NewV1GetPgsodiumConfigRequest generates requests for V1GetPgsodiumConfig +func NewV1GetPgsodiumConfigRequest(server string, ref string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/pgsodium", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewV1UpdatePgsodiumConfigRequest calls the generic V1UpdatePgsodiumConfig builder with application/json body +func NewV1UpdatePgsodiumConfigRequest(server string, ref string, body V1UpdatePgsodiumConfigJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) return NewV1UpdatePgsodiumConfigRequestWithBody(server, ref, "application/json", bodyReader) } @@ -4945,6 +5275,121 @@ func NewV1DisableReadonlyModeTemporarilyRequest(server string, ref string) (*htt return req, nil } +// NewV1ListAvailableRestoreVersionsRequest generates requests for V1ListAvailableRestoreVersions +func NewV1ListAvailableRestoreVersionsRequest(server string, ref string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/restore", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewV1RestoreAProjectRequest calls the generic V1RestoreAProject builder with application/json body +func NewV1RestoreAProjectRequest(server string, ref string, body V1RestoreAProjectJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewV1RestoreAProjectRequestWithBody(server, ref, "application/json", bodyReader) +} + +// NewV1RestoreAProjectRequestWithBody generates requests for V1RestoreAProject with any type of body +func NewV1RestoreAProjectRequestWithBody(server string, ref string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/restore", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewV1CancelAProjectRestorationRequest generates requests for V1CancelAProjectRestoration +func NewV1CancelAProjectRestorationRequest(server string, ref string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/restore/cancel", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewV1BulkDeleteSecretsRequest calls the generic V1BulkDeleteSecrets builder with application/json body func NewV1BulkDeleteSecretsRequest(server string, ref string, body V1BulkDeleteSecretsJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader @@ -5565,6 +6010,70 @@ func NewV1ListAllSnippetsRequest(server string, params *V1ListAllSnippetsParams) if params != nil { queryValues := queryURL.Query() + if params.Cursor != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "cursor", runtime.ParamLocationQuery, *params.Cursor); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.SortBy != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "sort_by", runtime.ParamLocationQuery, *params.SortBy); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.SortOrder != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "sort_order", runtime.ParamLocationQuery, *params.SortOrder); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + if params.ProjectRef != nil { if queryFrag, err := runtime.StyleParamWithLocation("form", true, "project_ref", runtime.ParamLocationQuery, *params.ProjectRef); err != nil { @@ -5593,7 +6102,7 @@ func NewV1ListAllSnippetsRequest(server string, params *V1ListAllSnippetsParams) } // NewV1GetASnippetRequest generates requests for V1GetASnippet -func NewV1GetASnippetRequest(server string, id string) (*http.Request, error) { +func NewV1GetASnippetRequest(server string, id openapi_types.UUID) (*http.Request, error) { var err error var pathParam0 string @@ -5680,12 +6189,20 @@ type ClientWithResponsesInterface interface { V1UpdateABranchConfigWithResponse(ctx context.Context, branchId string, body V1UpdateABranchConfigJSONRequestBody, reqEditors ...RequestEditorFn) (*V1UpdateABranchConfigResponse, error) + // V1PushABranchWithResponse request + V1PushABranchWithResponse(ctx context.Context, branchId string, reqEditors ...RequestEditorFn) (*V1PushABranchResponse, error) + // V1ResetABranchWithResponse request V1ResetABranchWithResponse(ctx context.Context, branchId string, reqEditors ...RequestEditorFn) (*V1ResetABranchResponse, error) // V1AuthorizeUserWithResponse request V1AuthorizeUserWithResponse(ctx context.Context, params *V1AuthorizeUserParams, reqEditors ...RequestEditorFn) (*V1AuthorizeUserResponse, error) + // V1RevokeTokenWithBodyWithResponse request with any body + V1RevokeTokenWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1RevokeTokenResponse, error) + + V1RevokeTokenWithResponse(ctx context.Context, body V1RevokeTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*V1RevokeTokenResponse, error) + // V1ExchangeOauthTokenWithBodyWithResponse request with any body V1ExchangeOauthTokenWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1ExchangeOauthTokenResponse, error) @@ -5719,6 +6236,9 @@ type ClientWithResponsesInterface interface { // V1GetProjectWithResponse request V1GetProjectWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetProjectResponse, error) + // GetLogsWithResponse request + GetLogsWithResponse(ctx context.Context, ref string, params *GetLogsParams, reqEditors ...RequestEditorFn) (*GetLogsResponse, error) + // V1GetProjectApiKeysWithResponse request V1GetProjectApiKeysWithResponse(ctx context.Context, ref string, params *V1GetProjectApiKeysParams, reqEditors ...RequestEditorFn) (*V1GetProjectApiKeysResponse, error) @@ -5891,6 +6411,9 @@ type ClientWithResponsesInterface interface { V1UpdateNetworkRestrictionsWithResponse(ctx context.Context, ref string, body V1UpdateNetworkRestrictionsJSONRequestBody, reqEditors ...RequestEditorFn) (*V1UpdateNetworkRestrictionsResponse, error) + // V1PauseAProjectWithResponse request + V1PauseAProjectWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1PauseAProjectResponse, error) + // V1GetPgsodiumConfigWithResponse request V1GetPgsodiumConfigWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetPgsodiumConfigResponse, error) @@ -5923,6 +6446,17 @@ type ClientWithResponsesInterface interface { // V1DisableReadonlyModeTemporarilyWithResponse request V1DisableReadonlyModeTemporarilyWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1DisableReadonlyModeTemporarilyResponse, error) + // V1ListAvailableRestoreVersionsWithResponse request + V1ListAvailableRestoreVersionsWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1ListAvailableRestoreVersionsResponse, error) + + // V1RestoreAProjectWithBodyWithResponse request with any body + V1RestoreAProjectWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1RestoreAProjectResponse, error) + + V1RestoreAProjectWithResponse(ctx context.Context, ref string, body V1RestoreAProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*V1RestoreAProjectResponse, error) + + // V1CancelAProjectRestorationWithResponse request + V1CancelAProjectRestorationWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1CancelAProjectRestorationResponse, error) + // V1BulkDeleteSecretsWithBodyWithResponse request with any body V1BulkDeleteSecretsWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1BulkDeleteSecretsResponse, error) @@ -5981,7 +6515,7 @@ type ClientWithResponsesInterface interface { V1ListAllSnippetsWithResponse(ctx context.Context, params *V1ListAllSnippetsParams, reqEditors ...RequestEditorFn) (*V1ListAllSnippetsResponse, error) // V1GetASnippetWithResponse request - V1GetASnippetWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*V1GetASnippetResponse, error) + V1GetASnippetWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*V1GetASnippetResponse, error) } type V1DeleteABranchResponse struct { @@ -6050,10 +6584,32 @@ func (r V1UpdateABranchConfigResponse) StatusCode() int { return 0 } +type V1PushABranchResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *BranchUpdateResponse +} + +// Status returns HTTPResponse.Status +func (r V1PushABranchResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r V1PushABranchResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type V1ResetABranchResponse struct { Body []byte HTTPResponse *http.Response - JSON201 *BranchResetResponse + JSON201 *BranchUpdateResponse } // Status returns HTTPResponse.Status @@ -6093,6 +6649,27 @@ func (r V1AuthorizeUserResponse) StatusCode() int { return 0 } +type V1RevokeTokenResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r V1RevokeTokenResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r V1RevokeTokenResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type V1ExchangeOauthTokenResponse struct { Body []byte HTTPResponse *http.Response @@ -6291,6 +6868,28 @@ func (r V1GetProjectResponse) StatusCode() int { return 0 } +type GetLogsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *V1AnalyticsResponse +} + +// Status returns HTTPResponse.Status +func (r GetLogsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r GetLogsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type V1GetProjectApiKeysResponse struct { Body []byte HTTPResponse *http.Response @@ -7295,6 +7894,27 @@ func (r V1UpdateNetworkRestrictionsResponse) StatusCode() int { return 0 } +type V1PauseAProjectResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r V1PauseAProjectResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r V1PauseAProjectResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type V1GetPgsodiumConfigResponse struct { Body []byte HTTPResponse *http.Response @@ -7468,6 +8088,70 @@ func (r V1DisableReadonlyModeTemporarilyResponse) StatusCode() int { return 0 } +type V1ListAvailableRestoreVersionsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *GetProjectAvailableRestoreVersionsResponse +} + +// Status returns HTTPResponse.Status +func (r V1ListAvailableRestoreVersionsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r V1ListAvailableRestoreVersionsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type V1RestoreAProjectResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r V1RestoreAProjectResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r V1RestoreAProjectResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type V1CancelAProjectRestorationResponse struct { + Body []byte + HTTPResponse *http.Response +} + +// Status returns HTTPResponse.Status +func (r V1CancelAProjectRestorationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r V1CancelAProjectRestorationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type V1BulkDeleteSecretsResponse struct { Body []byte HTTPResponse *http.Response @@ -7853,6 +8537,15 @@ func (c *ClientWithResponses) V1UpdateABranchConfigWithResponse(ctx context.Cont return ParseV1UpdateABranchConfigResponse(rsp) } +// V1PushABranchWithResponse request returning *V1PushABranchResponse +func (c *ClientWithResponses) V1PushABranchWithResponse(ctx context.Context, branchId string, reqEditors ...RequestEditorFn) (*V1PushABranchResponse, error) { + rsp, err := c.V1PushABranch(ctx, branchId, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1PushABranchResponse(rsp) +} + // V1ResetABranchWithResponse request returning *V1ResetABranchResponse func (c *ClientWithResponses) V1ResetABranchWithResponse(ctx context.Context, branchId string, reqEditors ...RequestEditorFn) (*V1ResetABranchResponse, error) { rsp, err := c.V1ResetABranch(ctx, branchId, reqEditors...) @@ -7871,6 +8564,23 @@ func (c *ClientWithResponses) V1AuthorizeUserWithResponse(ctx context.Context, p return ParseV1AuthorizeUserResponse(rsp) } +// V1RevokeTokenWithBodyWithResponse request with arbitrary body returning *V1RevokeTokenResponse +func (c *ClientWithResponses) V1RevokeTokenWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1RevokeTokenResponse, error) { + rsp, err := c.V1RevokeTokenWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1RevokeTokenResponse(rsp) +} + +func (c *ClientWithResponses) V1RevokeTokenWithResponse(ctx context.Context, body V1RevokeTokenJSONRequestBody, reqEditors ...RequestEditorFn) (*V1RevokeTokenResponse, error) { + rsp, err := c.V1RevokeToken(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1RevokeTokenResponse(rsp) +} + // V1ExchangeOauthTokenWithBodyWithResponse request with arbitrary body returning *V1ExchangeOauthTokenResponse func (c *ClientWithResponses) V1ExchangeOauthTokenWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1ExchangeOauthTokenResponse, error) { rsp, err := c.V1ExchangeOauthTokenWithBody(ctx, contentType, body, reqEditors...) @@ -7976,6 +8686,15 @@ func (c *ClientWithResponses) V1GetProjectWithResponse(ctx context.Context, ref return ParseV1GetProjectResponse(rsp) } +// GetLogsWithResponse request returning *GetLogsResponse +func (c *ClientWithResponses) GetLogsWithResponse(ctx context.Context, ref string, params *GetLogsParams, reqEditors ...RequestEditorFn) (*GetLogsResponse, error) { + rsp, err := c.GetLogs(ctx, ref, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetLogsResponse(rsp) +} + // V1GetProjectApiKeysWithResponse request returning *V1GetProjectApiKeysResponse func (c *ClientWithResponses) V1GetProjectApiKeysWithResponse(ctx context.Context, ref string, params *V1GetProjectApiKeysParams, reqEditors ...RequestEditorFn) (*V1GetProjectApiKeysResponse, error) { rsp, err := c.V1GetProjectApiKeys(ctx, ref, params, reqEditors...) @@ -8526,6 +9245,15 @@ func (c *ClientWithResponses) V1UpdateNetworkRestrictionsWithResponse(ctx contex return ParseV1UpdateNetworkRestrictionsResponse(rsp) } +// V1PauseAProjectWithResponse request returning *V1PauseAProjectResponse +func (c *ClientWithResponses) V1PauseAProjectWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1PauseAProjectResponse, error) { + rsp, err := c.V1PauseAProject(ctx, ref, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1PauseAProjectResponse(rsp) +} + // V1GetPgsodiumConfigWithResponse request returning *V1GetPgsodiumConfigResponse func (c *ClientWithResponses) V1GetPgsodiumConfigWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetPgsodiumConfigResponse, error) { rsp, err := c.V1GetPgsodiumConfig(ctx, ref, reqEditors...) @@ -8630,6 +9358,41 @@ func (c *ClientWithResponses) V1DisableReadonlyModeTemporarilyWithResponse(ctx c return ParseV1DisableReadonlyModeTemporarilyResponse(rsp) } +// V1ListAvailableRestoreVersionsWithResponse request returning *V1ListAvailableRestoreVersionsResponse +func (c *ClientWithResponses) V1ListAvailableRestoreVersionsWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1ListAvailableRestoreVersionsResponse, error) { + rsp, err := c.V1ListAvailableRestoreVersions(ctx, ref, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1ListAvailableRestoreVersionsResponse(rsp) +} + +// V1RestoreAProjectWithBodyWithResponse request with arbitrary body returning *V1RestoreAProjectResponse +func (c *ClientWithResponses) V1RestoreAProjectWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1RestoreAProjectResponse, error) { + rsp, err := c.V1RestoreAProjectWithBody(ctx, ref, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1RestoreAProjectResponse(rsp) +} + +func (c *ClientWithResponses) V1RestoreAProjectWithResponse(ctx context.Context, ref string, body V1RestoreAProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*V1RestoreAProjectResponse, error) { + rsp, err := c.V1RestoreAProject(ctx, ref, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1RestoreAProjectResponse(rsp) +} + +// V1CancelAProjectRestorationWithResponse request returning *V1CancelAProjectRestorationResponse +func (c *ClientWithResponses) V1CancelAProjectRestorationWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1CancelAProjectRestorationResponse, error) { + rsp, err := c.V1CancelAProjectRestoration(ctx, ref, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1CancelAProjectRestorationResponse(rsp) +} + // V1BulkDeleteSecretsWithBodyWithResponse request with arbitrary body returning *V1BulkDeleteSecretsResponse func (c *ClientWithResponses) V1BulkDeleteSecretsWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1BulkDeleteSecretsResponse, error) { rsp, err := c.V1BulkDeleteSecretsWithBody(ctx, ref, contentType, body, reqEditors...) @@ -8814,7 +9577,7 @@ func (c *ClientWithResponses) V1ListAllSnippetsWithResponse(ctx context.Context, } // V1GetASnippetWithResponse request returning *V1GetASnippetResponse -func (c *ClientWithResponses) V1GetASnippetWithResponse(ctx context.Context, id string, reqEditors ...RequestEditorFn) (*V1GetASnippetResponse, error) { +func (c *ClientWithResponses) V1GetASnippetWithResponse(ctx context.Context, id openapi_types.UUID, reqEditors ...RequestEditorFn) (*V1GetASnippetResponse, error) { rsp, err := c.V1GetASnippet(ctx, id, reqEditors...) if err != nil { return nil, err @@ -8900,6 +9663,32 @@ func ParseV1UpdateABranchConfigResponse(rsp *http.Response) (*V1UpdateABranchCon return response, nil } +// ParseV1PushABranchResponse parses an HTTP response from a V1PushABranchWithResponse call +func ParseV1PushABranchResponse(rsp *http.Response) (*V1PushABranchResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &V1PushABranchResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest BranchUpdateResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + } + + return response, nil +} + // ParseV1ResetABranchResponse parses an HTTP response from a V1ResetABranchWithResponse call func ParseV1ResetABranchResponse(rsp *http.Response) (*V1ResetABranchResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -8915,7 +9704,7 @@ func ParseV1ResetABranchResponse(rsp *http.Response) (*V1ResetABranchResponse, e switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest BranchResetResponse + var dest BranchUpdateResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -8942,6 +9731,22 @@ func ParseV1AuthorizeUserResponse(rsp *http.Response) (*V1AuthorizeUserResponse, return response, nil } +// ParseV1RevokeTokenResponse parses an HTTP response from a V1RevokeTokenWithResponse call +func ParseV1RevokeTokenResponse(rsp *http.Response) (*V1RevokeTokenResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &V1RevokeTokenResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + // ParseV1ExchangeOauthTokenResponse parses an HTTP response from a V1ExchangeOauthTokenWithResponse call func ParseV1ExchangeOauthTokenResponse(rsp *http.Response) (*V1ExchangeOauthTokenResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -9176,6 +9981,32 @@ func ParseV1GetProjectResponse(rsp *http.Response) (*V1GetProjectResponse, error return response, nil } +// ParseGetLogsResponse parses an HTTP response from a GetLogsWithResponse call +func ParseGetLogsResponse(rsp *http.Response) (*GetLogsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetLogsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest V1AnalyticsResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParseV1GetProjectApiKeysResponse parses an HTTP response from a V1GetProjectApiKeysWithResponse call func ParseV1GetProjectApiKeysResponse(rsp *http.Response) (*V1GetProjectApiKeysResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -10292,6 +11123,22 @@ func ParseV1UpdateNetworkRestrictionsResponse(rsp *http.Response) (*V1UpdateNetw return response, nil } +// ParseV1PauseAProjectResponse parses an HTTP response from a V1PauseAProjectWithResponse call +func ParseV1PauseAProjectResponse(rsp *http.Response) (*V1PauseAProjectResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &V1PauseAProjectResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + // ParseV1GetPgsodiumConfigResponse parses an HTTP response from a V1GetPgsodiumConfigWithResponse call func ParseV1GetPgsodiumConfigResponse(rsp *http.Response) (*V1GetPgsodiumConfigResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -10470,6 +11317,64 @@ func ParseV1DisableReadonlyModeTemporarilyResponse(rsp *http.Response) (*V1Disab return response, nil } +// ParseV1ListAvailableRestoreVersionsResponse parses an HTTP response from a V1ListAvailableRestoreVersionsWithResponse call +func ParseV1ListAvailableRestoreVersionsResponse(rsp *http.Response) (*V1ListAvailableRestoreVersionsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &V1ListAvailableRestoreVersionsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest GetProjectAvailableRestoreVersionsResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseV1RestoreAProjectResponse parses an HTTP response from a V1RestoreAProjectWithResponse call +func ParseV1RestoreAProjectResponse(rsp *http.Response) (*V1RestoreAProjectResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &V1RestoreAProjectResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + +// ParseV1CancelAProjectRestorationResponse parses an HTTP response from a V1CancelAProjectRestorationWithResponse call +func ParseV1CancelAProjectRestorationResponse(rsp *http.Response) (*V1CancelAProjectRestorationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &V1CancelAProjectRestorationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + return response, nil +} + // ParseV1BulkDeleteSecretsResponse parses an HTTP response from a V1BulkDeleteSecretsWithResponse call func ParseV1BulkDeleteSecretsResponse(rsp *http.Response) (*V1BulkDeleteSecretsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/pkg/api/types.gen.go b/pkg/api/types.gen.go index 4cfa1556b..1bb326b91 100644 --- a/pkg/api/types.gen.go +++ b/pkg/api/types.gen.go @@ -7,6 +7,7 @@ import ( "encoding/json" "github.com/oapi-codegen/runtime" + openapi_types "github.com/oapi-codegen/runtime/types" ) const ( @@ -169,7 +170,26 @@ const ( // Defines values for PostgresEngine. const ( - PostgresEngineN15 PostgresEngine = "15" + PostgresEngineN15 PostgresEngine = "15" + PostgresEngineN17Oriole PostgresEngine = "17-oriole" +) + +// Defines values for ProjectAvailableRestoreVersionPostgresEngine. +const ( + ProjectAvailableRestoreVersionPostgresEngineN13 ProjectAvailableRestoreVersionPostgresEngine = "13" + ProjectAvailableRestoreVersionPostgresEngineN14 ProjectAvailableRestoreVersionPostgresEngine = "14" + ProjectAvailableRestoreVersionPostgresEngineN15 ProjectAvailableRestoreVersionPostgresEngine = "15" + ProjectAvailableRestoreVersionPostgresEngineN17Oriole ProjectAvailableRestoreVersionPostgresEngine = "17-oriole" +) + +// Defines values for ProjectAvailableRestoreVersionReleaseChannel. +const ( + ProjectAvailableRestoreVersionReleaseChannelAlpha ProjectAvailableRestoreVersionReleaseChannel = "alpha" + ProjectAvailableRestoreVersionReleaseChannelBeta ProjectAvailableRestoreVersionReleaseChannel = "beta" + ProjectAvailableRestoreVersionReleaseChannelGa ProjectAvailableRestoreVersionReleaseChannel = "ga" + ProjectAvailableRestoreVersionReleaseChannelInternal ProjectAvailableRestoreVersionReleaseChannel = "internal" + ProjectAvailableRestoreVersionReleaseChannelPreview ProjectAvailableRestoreVersionReleaseChannel = "preview" + ProjectAvailableRestoreVersionReleaseChannelWithdrawn ProjectAvailableRestoreVersionReleaseChannel = "withdrawn" ) // Defines values for ReleaseChannel. @@ -178,9 +198,26 @@ const ( ReleaseChannelBeta ReleaseChannel = "beta" ReleaseChannelGa ReleaseChannel = "ga" ReleaseChannelInternal ReleaseChannel = "internal" + ReleaseChannelPreview ReleaseChannel = "preview" ReleaseChannelWithdrawn ReleaseChannel = "withdrawn" ) +// Defines values for RestoreProjectBodyDtoPostgresEngine. +const ( + RestoreProjectBodyDtoPostgresEngineN15 RestoreProjectBodyDtoPostgresEngine = "15" + RestoreProjectBodyDtoPostgresEngineN17Oriole RestoreProjectBodyDtoPostgresEngine = "17-oriole" +) + +// Defines values for RestoreProjectBodyDtoReleaseChannel. +const ( + RestoreProjectBodyDtoReleaseChannelAlpha RestoreProjectBodyDtoReleaseChannel = "alpha" + RestoreProjectBodyDtoReleaseChannelBeta RestoreProjectBodyDtoReleaseChannel = "beta" + RestoreProjectBodyDtoReleaseChannelGa RestoreProjectBodyDtoReleaseChannel = "ga" + RestoreProjectBodyDtoReleaseChannelInternal RestoreProjectBodyDtoReleaseChannel = "internal" + RestoreProjectBodyDtoReleaseChannelPreview RestoreProjectBodyDtoReleaseChannel = "preview" + RestoreProjectBodyDtoReleaseChannelWithdrawn RestoreProjectBodyDtoReleaseChannel = "withdrawn" +) + // Defines values for SetUpReadReplicaBodyReadReplicaRegion. const ( SetUpReadReplicaBodyReadReplicaRegionApEast1 SetUpReadReplicaBodyReadReplicaRegion = "ap-east-1" @@ -319,7 +356,8 @@ const ( // Defines values for V1CreateProjectBodyDtoPostgresEngine. const ( - V1CreateProjectBodyDtoPostgresEngineN15 V1CreateProjectBodyDtoPostgresEngine = "15" + V1CreateProjectBodyDtoPostgresEngineN15 V1CreateProjectBodyDtoPostgresEngine = "15" + V1CreateProjectBodyDtoPostgresEngineN17Oriole V1CreateProjectBodyDtoPostgresEngine = "17-oriole" ) // Defines values for V1CreateProjectBodyDtoRegion. @@ -350,6 +388,7 @@ const ( V1CreateProjectBodyDtoReleaseChannelBeta V1CreateProjectBodyDtoReleaseChannel = "beta" V1CreateProjectBodyDtoReleaseChannelGa V1CreateProjectBodyDtoReleaseChannel = "ga" V1CreateProjectBodyDtoReleaseChannelInternal V1CreateProjectBodyDtoReleaseChannel = "internal" + V1CreateProjectBodyDtoReleaseChannelPreview V1CreateProjectBodyDtoReleaseChannel = "preview" V1CreateProjectBodyDtoReleaseChannelWithdrawn V1CreateProjectBodyDtoReleaseChannel = "withdrawn" ) @@ -451,6 +490,18 @@ const ( V1GetServicesHealthParamsServicesStorage V1GetServicesHealthParamsServices = "storage" ) +// Defines values for V1ListAllSnippetsParamsSortBy. +const ( + InsertedAt V1ListAllSnippetsParamsSortBy = "inserted_at" + Name V1ListAllSnippetsParamsSortBy = "name" +) + +// Defines values for V1ListAllSnippetsParamsSortOrder. +const ( + Asc V1ListAllSnippetsParamsSortOrder = "asc" + Desc V1ListAllSnippetsParamsSortOrder = "desc" +) + // ActivateVanitySubdomainResponse defines model for ActivateVanitySubdomainResponse. type ActivateVanitySubdomainResponse struct { CustomDomain string `json:"custom_domain"` @@ -715,25 +766,21 @@ type BranchDetailResponse struct { // BranchDetailResponseStatus defines model for BranchDetailResponse.Status. type BranchDetailResponseStatus string -// BranchResetResponse defines model for BranchResetResponse. -type BranchResetResponse struct { - Message string `json:"message"` - WorkflowRunId string `json:"workflow_run_id"` -} - // BranchResponse defines model for BranchResponse. type BranchResponse struct { - CreatedAt string `json:"created_at"` - GitBranch *string `json:"git_branch,omitempty"` - Id string `json:"id"` - IsDefault bool `json:"is_default"` - LatestCheckRunId *int64 `json:"latest_check_run_id,omitempty"` + CreatedAt string `json:"created_at"` + GitBranch *string `json:"git_branch,omitempty"` + Id string `json:"id"` + IsDefault bool `json:"is_default"` + + // LatestCheckRunId This field is deprecated and will not be populated. + // Deprecated: + LatestCheckRunId *float32 `json:"latest_check_run_id,omitempty"` Name string `json:"name"` ParentProjectRef string `json:"parent_project_ref"` Persistent bool `json:"persistent"` PrNumber *int32 `json:"pr_number,omitempty"` ProjectRef string `json:"project_ref"` - ResetOnPush bool `json:"reset_on_push"` Status BranchResponseStatus `json:"status"` UpdatedAt string `json:"updated_at"` } @@ -741,6 +788,12 @@ type BranchResponse struct { // BranchResponseStatus defines model for BranchResponse.Status. type BranchResponseStatus string +// BranchUpdateResponse defines model for BranchUpdateResponse. +type BranchUpdateResponse struct { + Message string `json:"message"` + WorkflowRunId string `json:"workflow_run_id"` +} + // CfResponse defines model for CfResponse. type CfResponse struct { Errors []map[string]interface{} `json:"errors"` @@ -907,6 +960,11 @@ type FunctionSlugResponse struct { // FunctionSlugResponseStatus defines model for FunctionSlugResponse.Status. type FunctionSlugResponseStatus string +// GetProjectAvailableRestoreVersionsResponse defines model for GetProjectAvailableRestoreVersionsResponse. +type GetProjectAvailableRestoreVersionsResponse struct { + AvailableVersions []ProjectAvailableRestoreVersion `json:"available_versions"` +} + // GetProviderResponse defines model for GetProviderResponse. type GetProviderResponse struct { CreatedAt *string `json:"created_at,omitempty"` @@ -946,6 +1004,13 @@ type NetworkRestrictionsResponseEntitlement string // NetworkRestrictionsResponseStatus defines model for NetworkRestrictionsResponse.Status. type NetworkRestrictionsResponseStatus string +// OAuthRevokeTokenBodyDto defines model for OAuthRevokeTokenBodyDto. +type OAuthRevokeTokenBodyDto struct { + ClientId openapi_types.UUID `json:"client_id"` + ClientSecret string `json:"client_secret"` + RefreshToken string `json:"refresh_token"` +} + // OAuthTokenBody defines model for OAuthTokenBody. type OAuthTokenBody struct { ClientId string `json:"client_id"` @@ -1009,6 +1074,7 @@ type PostgresConfigResponse struct { SessionReplicationRole *PostgresConfigResponseSessionReplicationRole `json:"session_replication_role,omitempty"` SharedBuffers *string `json:"shared_buffers,omitempty"` StatementTimeout *string `json:"statement_timeout,omitempty"` + TrackActivityQuerySize *string `json:"track_activity_query_size,omitempty"` TrackCommitTimestamp *bool `json:"track_commit_timestamp,omitempty"` WalKeepSize *string `json:"wal_keep_size,omitempty"` WalSenderTimeout *string `json:"wal_sender_timeout,omitempty"` @@ -1032,6 +1098,19 @@ type PostgrestConfigWithJWTSecretResponse struct { MaxRows int `json:"max_rows"` } +// ProjectAvailableRestoreVersion defines model for ProjectAvailableRestoreVersion. +type ProjectAvailableRestoreVersion struct { + PostgresEngine ProjectAvailableRestoreVersionPostgresEngine `json:"postgres_engine"` + ReleaseChannel ProjectAvailableRestoreVersionReleaseChannel `json:"release_channel"` + Version string `json:"version"` +} + +// ProjectAvailableRestoreVersionPostgresEngine defines model for ProjectAvailableRestoreVersion.PostgresEngine. +type ProjectAvailableRestoreVersionPostgresEngine string + +// ProjectAvailableRestoreVersionReleaseChannel defines model for ProjectAvailableRestoreVersion.ReleaseChannel. +type ProjectAvailableRestoreVersionReleaseChannel string + // ProjectUpgradeEligibilityResponse defines model for ProjectUpgradeEligibilityResponse. type ProjectUpgradeEligibilityResponse struct { CurrentAppVersion string `json:"current_app_version"` @@ -1093,6 +1172,21 @@ type RemoveReadReplicaBody struct { DatabaseIdentifier string `json:"database_identifier"` } +// RestoreProjectBodyDto defines model for RestoreProjectBodyDto. +type RestoreProjectBodyDto struct { + // PostgresEngine Postgres engine version. If not provided, the latest version from the given release channel will be used. + PostgresEngine *RestoreProjectBodyDtoPostgresEngine `json:"postgres_engine,omitempty"` + + // ReleaseChannel Release channel version. If not provided, GeneralAvailability will be used. + ReleaseChannel *RestoreProjectBodyDtoReleaseChannel `json:"release_channel,omitempty"` +} + +// RestoreProjectBodyDtoPostgresEngine Postgres engine version. If not provided, the latest version from the given release channel will be used. +type RestoreProjectBodyDtoPostgresEngine string + +// RestoreProjectBodyDtoReleaseChannel Release channel version. If not provided, GeneralAvailability will be used. +type RestoreProjectBodyDtoReleaseChannel string + // SamlDescriptor defines model for SamlDescriptor. type SamlDescriptor struct { AttributeMapping *AttributeMapping `json:"attribute_mapping,omitempty"` @@ -1126,12 +1220,13 @@ type SnippetContent struct { // SnippetList defines model for SnippetList. type SnippetList struct { - Data []SnippetMeta `json:"data"` + Cursor *string `json:"cursor,omitempty"` + Data []SnippetMeta `json:"data"` } // SnippetMeta defines model for SnippetMeta. type SnippetMeta struct { - Description *string `json:"description,omitempty"` + Description *string `json:"description"` Id string `json:"id"` InsertedAt string `json:"inserted_at"` Name string `json:"name"` @@ -1158,7 +1253,7 @@ type SnippetProject struct { // SnippetResponse defines model for SnippetResponse. type SnippetResponse struct { Content SnippetContent `json:"content"` - Description *string `json:"description,omitempty"` + Description *string `json:"description"` Id string `json:"id"` InsertedAt string `json:"inserted_at"` Name string `json:"name"` @@ -1216,9 +1311,15 @@ type StorageFeatureImageTransformation struct { Enabled bool `json:"enabled"` } +// StorageFeatureS3Protocol defines model for StorageFeatureS3Protocol. +type StorageFeatureS3Protocol struct { + Enabled bool `json:"enabled"` +} + // StorageFeatures defines model for StorageFeatures. type StorageFeatures struct { ImageTransformation StorageFeatureImageTransformation `json:"imageTransformation"` + S3Protocol StorageFeatureS3Protocol `json:"s3Protocol"` } // SubdomainAvailabilityResponse defines model for SubdomainAvailabilityResponse. @@ -1449,9 +1550,12 @@ type UpdateAuthConfigBodyPasswordRequiredCharacters string // UpdateBranchBody defines model for UpdateBranchBody. type UpdateBranchBody struct { - BranchName *string `json:"branch_name,omitempty"` - GitBranch *string `json:"git_branch,omitempty"` - Persistent *bool `json:"persistent,omitempty"` + BranchName *string `json:"branch_name,omitempty"` + GitBranch *string `json:"git_branch,omitempty"` + Persistent *bool `json:"persistent,omitempty"` + + // ResetOnPush This field is deprecated and will be ignored. Use v1-reset-a-branch endpoint directly instead. + // Deprecated: ResetOnPush *bool `json:"reset_on_push,omitempty"` Status *UpdateBranchBodyStatus `json:"status,omitempty"` } @@ -1500,6 +1604,7 @@ type UpdatePostgresConfigBody struct { SessionReplicationRole *UpdatePostgresConfigBodySessionReplicationRole `json:"session_replication_role,omitempty"` SharedBuffers *string `json:"shared_buffers,omitempty"` StatementTimeout *string `json:"statement_timeout,omitempty"` + TrackActivityQuerySize *string `json:"track_activity_query_size,omitempty"` TrackCommitTimestamp *bool `json:"track_commit_timestamp,omitempty"` WalKeepSize *string `json:"wal_keep_size,omitempty"` WalSenderTimeout *string `json:"wal_sender_timeout,omitempty"` @@ -1567,6 +1672,34 @@ type UpgradeDatabaseBody struct { TargetVersion string `json:"target_version"` } +// V1AnalyticsResponse defines model for V1AnalyticsResponse. +type V1AnalyticsResponse struct { + Error *V1AnalyticsResponse_Error `json:"error,omitempty"` + Result *[]map[string]interface{} `json:"result,omitempty"` +} + +// V1AnalyticsResponseError0 defines model for . +type V1AnalyticsResponseError0 struct { + Code *float32 `json:"code,omitempty"` + Errors *[]struct { + Domain *string `json:"domain,omitempty"` + Location *string `json:"location,omitempty"` + LocationType *string `json:"locationType,omitempty"` + Message *string `json:"message,omitempty"` + Reason *string `json:"reason,omitempty"` + } `json:"errors,omitempty"` + Message *string `json:"message,omitempty"` + Status *string `json:"status,omitempty"` +} + +// V1AnalyticsResponseError1 defines model for . +type V1AnalyticsResponseError1 = string + +// V1AnalyticsResponse_Error defines model for V1AnalyticsResponse.Error. +type V1AnalyticsResponse_Error struct { + union json.RawMessage +} + // V1Backup defines model for V1Backup. type V1Backup struct { InsertedAt string `json:"inserted_at"` @@ -1605,7 +1738,7 @@ type V1CreateProjectBodyDto struct { // Deprecated: KpsEnabled *bool `json:"kps_enabled,omitempty"` - // Name Name of your project, should not contain dots + // Name Name of your project Name string `json:"name"` // OrganizationId Slug of your organization @@ -1850,6 +1983,13 @@ type V1AuthorizeUserParamsResponseType string // V1AuthorizeUserParamsCodeChallengeMethod defines parameters for V1AuthorizeUser. type V1AuthorizeUserParamsCodeChallengeMethod string +// GetLogsParams defines parameters for GetLogs. +type GetLogsParams struct { + IsoTimestampEnd *string `form:"iso_timestamp_end,omitempty" json:"iso_timestamp_end,omitempty"` + IsoTimestampStart *string `form:"iso_timestamp_start,omitempty" json:"iso_timestamp_start,omitempty"` + Sql *string `form:"sql,omitempty" json:"sql,omitempty"` +} + // V1GetProjectApiKeysParams defines parameters for V1GetProjectApiKeys. type V1GetProjectApiKeysParams struct { Reveal bool `form:"reveal" json:"reveal"` @@ -1924,12 +2064,25 @@ type V1GetPostgresUpgradeStatusParams struct { // V1ListAllSnippetsParams defines parameters for V1ListAllSnippets. type V1ListAllSnippetsParams struct { - ProjectRef *string `form:"project_ref,omitempty" json:"project_ref,omitempty"` + Cursor *string `form:"cursor,omitempty" json:"cursor,omitempty"` + Limit *string `form:"limit,omitempty" json:"limit,omitempty"` + SortBy *V1ListAllSnippetsParamsSortBy `form:"sort_by,omitempty" json:"sort_by,omitempty"` + SortOrder *V1ListAllSnippetsParamsSortOrder `form:"sort_order,omitempty" json:"sort_order,omitempty"` + ProjectRef *string `form:"project_ref,omitempty" json:"project_ref,omitempty"` } +// V1ListAllSnippetsParamsSortBy defines parameters for V1ListAllSnippets. +type V1ListAllSnippetsParamsSortBy string + +// V1ListAllSnippetsParamsSortOrder defines parameters for V1ListAllSnippets. +type V1ListAllSnippetsParamsSortOrder string + // V1UpdateABranchConfigJSONRequestBody defines body for V1UpdateABranchConfig for application/json ContentType. type V1UpdateABranchConfigJSONRequestBody = UpdateBranchBody +// V1RevokeTokenJSONRequestBody defines body for V1RevokeToken for application/json ContentType. +type V1RevokeTokenJSONRequestBody = OAuthRevokeTokenBodyDto + // V1ExchangeOauthTokenFormdataRequestBody defines body for V1ExchangeOauthToken for application/x-www-form-urlencoded ContentType. type V1ExchangeOauthTokenFormdataRequestBody = OAuthTokenBody @@ -2002,6 +2155,9 @@ type V1RemoveAReadReplicaJSONRequestBody = RemoveReadReplicaBody // V1SetupAReadReplicaJSONRequestBody defines body for V1SetupAReadReplica for application/json ContentType. type V1SetupAReadReplicaJSONRequestBody = SetUpReadReplicaBody +// V1RestoreAProjectJSONRequestBody defines body for V1RestoreAProject for application/json ContentType. +type V1RestoreAProjectJSONRequestBody = RestoreProjectBodyDto + // V1BulkDeleteSecretsJSONRequestBody defines body for V1BulkDeleteSecrets for application/json ContentType. type V1BulkDeleteSecretsJSONRequestBody = V1BulkDeleteSecretsJSONBody @@ -2134,6 +2290,68 @@ func (t *AttributeValue_Default) UnmarshalJSON(b []byte) error { return err } +// AsV1AnalyticsResponseError0 returns the union data inside the V1AnalyticsResponse_Error as a V1AnalyticsResponseError0 +func (t V1AnalyticsResponse_Error) AsV1AnalyticsResponseError0() (V1AnalyticsResponseError0, error) { + var body V1AnalyticsResponseError0 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromV1AnalyticsResponseError0 overwrites any union data inside the V1AnalyticsResponse_Error as the provided V1AnalyticsResponseError0 +func (t *V1AnalyticsResponse_Error) FromV1AnalyticsResponseError0(v V1AnalyticsResponseError0) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeV1AnalyticsResponseError0 performs a merge with any union data inside the V1AnalyticsResponse_Error, using the provided V1AnalyticsResponseError0 +func (t *V1AnalyticsResponse_Error) MergeV1AnalyticsResponseError0(v V1AnalyticsResponseError0) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +// AsV1AnalyticsResponseError1 returns the union data inside the V1AnalyticsResponse_Error as a V1AnalyticsResponseError1 +func (t V1AnalyticsResponse_Error) AsV1AnalyticsResponseError1() (V1AnalyticsResponseError1, error) { + var body V1AnalyticsResponseError1 + err := json.Unmarshal(t.union, &body) + return body, err +} + +// FromV1AnalyticsResponseError1 overwrites any union data inside the V1AnalyticsResponse_Error as the provided V1AnalyticsResponseError1 +func (t *V1AnalyticsResponse_Error) FromV1AnalyticsResponseError1(v V1AnalyticsResponseError1) error { + b, err := json.Marshal(v) + t.union = b + return err +} + +// MergeV1AnalyticsResponseError1 performs a merge with any union data inside the V1AnalyticsResponse_Error, using the provided V1AnalyticsResponseError1 +func (t *V1AnalyticsResponse_Error) MergeV1AnalyticsResponseError1(v V1AnalyticsResponseError1) error { + b, err := json.Marshal(v) + if err != nil { + return err + } + + merged, err := runtime.JSONMerge(t.union, b) + t.union = merged + return err +} + +func (t V1AnalyticsResponse_Error) MarshalJSON() ([]byte, error) { + b, err := t.union.MarshalJSON() + return b, err +} + +func (t *V1AnalyticsResponse_Error) UnmarshalJSON(b []byte) error { + err := t.union.UnmarshalJSON(b) + return err +} + // AsAuthHealthResponse returns the union data inside the V1ServiceHealthResponse_Info as a AuthHealthResponse func (t V1ServiceHealthResponse_Info) AsAuthHealthResponse() (AuthHealthResponse, error) { var body AuthHealthResponse diff --git a/pkg/config/db.go b/pkg/config/db.go index 2a1d31cad..d18cf8ebd 100644 --- a/pkg/config/db.go +++ b/pkg/config/db.go @@ -43,6 +43,7 @@ type ( SessionReplicationRole *SessionReplicationRole `toml:"session_replication_role"` SharedBuffers *string `toml:"shared_buffers"` StatementTimeout *string `toml:"statement_timeout"` + TrackActivityQuerySize *string `toml:"track_activity_query_size"` TrackCommitTimestamp *bool `toml:"track_commit_timestamp"` WalKeepSize *string `toml:"wal_keep_size"` WalSenderTimeout *string `toml:"wal_sender_timeout"` @@ -105,6 +106,7 @@ func (a *settings) ToUpdatePostgresConfigBody() v1API.UpdatePostgresConfigBody { body.MaxWalSize = a.MaxWalSize body.SessionReplicationRole = (*v1API.UpdatePostgresConfigBodySessionReplicationRole)(a.SessionReplicationRole) body.StatementTimeout = a.StatementTimeout + body.TrackActivityQuerySize = a.TrackActivityQuerySize body.TrackCommitTimestamp = a.TrackCommitTimestamp body.WalKeepSize = a.WalKeepSize body.WalSenderTimeout = a.WalSenderTimeout @@ -131,6 +133,7 @@ func (a *settings) FromRemotePostgresConfig(remoteConfig v1API.PostgresConfigRes a.SessionReplicationRole = (*SessionReplicationRole)(remoteConfig.SessionReplicationRole) a.SharedBuffers = remoteConfig.SharedBuffers a.StatementTimeout = remoteConfig.StatementTimeout + a.TrackActivityQuerySize = remoteConfig.TrackActivityQuerySize a.TrackCommitTimestamp = remoteConfig.TrackCommitTimestamp a.WalKeepSize = remoteConfig.WalKeepSize a.WalSenderTimeout = remoteConfig.WalSenderTimeout From 9509bc68fae7c93907f64941ea08aa4fe243f5aa Mon Sep 17 00:00:00 2001 From: Takumi Hara <69781798+takumihara@users.noreply.github.com> Date: Mon, 20 Jan 2025 20:04:29 +0900 Subject: [PATCH 287/305] fix: use direct DbHost from response in `branches get` (#3056) --- internal/branches/get/get.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/branches/get/get.go b/internal/branches/get/get.go index 22f3274e7..387e4ab79 100644 --- a/internal/branches/get/get.go +++ b/internal/branches/get/get.go @@ -34,7 +34,7 @@ func Run(ctx context.Context, branchId string, fsys afero.Fs) error { } config := pgconn.Config{ - Host: utils.GetSupabaseDbHost(resp.JSON200.DbHost), + Host: resp.JSON200.DbHost, Port: cast.UIntToUInt16(cast.IntToUint(resp.JSON200.DbPort)), User: *resp.JSON200.DbUser, Password: *resp.JSON200.DbPass, From 3f522278340482c68308a4cb5e099c83c5933663 Mon Sep 17 00:00:00 2001 From: Andrew Valleteau Date: Wed, 22 Jan 2025 10:23:25 +0900 Subject: [PATCH 288/305] feat(postgrest-config): add delete command to cli for convenience (#3060) --- cmd/postgres.go | 16 ++++++++ internal/postgresConfig/delete/delete.go | 48 ++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 internal/postgresConfig/delete/delete.go diff --git a/cmd/postgres.go b/cmd/postgres.go index 1c2e0e127..a1f9c376b 100644 --- a/cmd/postgres.go +++ b/cmd/postgres.go @@ -3,6 +3,7 @@ package cmd import ( "github.com/spf13/afero" "github.com/spf13/cobra" + "github.com/supabase/cli/internal/postgresConfig/delete" "github.com/supabase/cli/internal/postgresConfig/get" "github.com/supabase/cli/internal/postgresConfig/update" "github.com/supabase/cli/internal/utils/flags" @@ -33,8 +34,18 @@ Custom configuration also overrides the optimizations generated based on the com }, } + postgresConfigDeleteCmd = &cobra.Command{ + Use: "delete", + Short: "Delete specific Postgres database config overrides", + Long: "Delete specific config overrides, reverting them to their default values.", + RunE: func(cmd *cobra.Command, args []string) error { + return delete.Run(cmd.Context(), flags.ProjectRef, postgresConfigKeysToDelete, noRestart, afero.NewOsFs()) + }, + } + postgresConfigValues []string postgresConfigUpdateReplaceMode bool + postgresConfigKeysToDelete []string noRestart bool ) @@ -42,11 +53,16 @@ func init() { postgresCmd.PersistentFlags().StringVar(&flags.ProjectRef, "project-ref", "", "Project ref of the Supabase project.") postgresCmd.AddCommand(postgresConfigGetCmd) postgresCmd.AddCommand(postgresConfigUpdateCmd) + postgresCmd.AddCommand(postgresConfigDeleteCmd) updateFlags := postgresConfigUpdateCmd.Flags() updateFlags.StringSliceVar(&postgresConfigValues, "config", []string{}, "Config overrides specified as a 'key=value' pair") updateFlags.BoolVar(&postgresConfigUpdateReplaceMode, "replace-existing-overrides", false, "If true, replaces all existing overrides with the ones provided. If false (default), merges existing overrides with the ones provided.") updateFlags.BoolVar(&noRestart, "no-restart", false, "Do not restart the database after updating config.") + deleteFlags := postgresConfigDeleteCmd.Flags() + deleteFlags.StringSliceVar(&postgresConfigKeysToDelete, "config", []string{}, "Config keys to delete (comma-separated)") + deleteFlags.BoolVar(&noRestart, "no-restart", false, "Do not restart the database after deleting config.") + rootCmd.AddCommand(postgresCmd) } diff --git a/internal/postgresConfig/delete/delete.go b/internal/postgresConfig/delete/delete.go new file mode 100644 index 000000000..20b7b978f --- /dev/null +++ b/internal/postgresConfig/delete/delete.go @@ -0,0 +1,48 @@ +package delete + +import ( + "bytes" + "context" + "encoding/json" + "strings" + + "github.com/go-errors/errors" + "github.com/spf13/afero" + "github.com/supabase/cli/internal/postgresConfig/get" + "github.com/supabase/cli/internal/utils" +) + +func Run(ctx context.Context, projectRef string, configKeys []string, noRestart bool, fsys afero.Fs) error { + // 1. Get current config + currentConfig, err := get.GetCurrentPostgresConfig(ctx, projectRef) + if err != nil { + return err + } + + // 2. Remove specified keys + for _, key := range configKeys { + delete(currentConfig, strings.TrimSpace(key)) + } + + // 3. Update config with removed keys + if noRestart { + currentConfig["restart_database"] = false + } + bts, err := json.Marshal(currentConfig) + if err != nil { + return errors.Errorf("failed to serialize config overrides: %w", err) + } + + resp, err := utils.GetSupabase().V1UpdatePostgresConfigWithBodyWithResponse(ctx, projectRef, "application/json", bytes.NewReader(bts)) + if err != nil { + return errors.Errorf("failed to update config overrides: %w", err) + } + if resp.JSON200 == nil { + if resp.StatusCode() == 400 { + return errors.Errorf("failed to update config overrides: %s (%s). This usually indicates that an unsupported or invalid config override was attempted. Please refer to https://supabase.com/docs/guides/platform/custom-postgres-config", resp.Status(), string(resp.Body)) + } + return errors.Errorf("failed to update config overrides: %s (%s)", resp.Status(), string(resp.Body)) + } + + return get.Run(ctx, projectRef, fsys) +} From 7c26c046e3e680ef4279f54601fc219ef0e3be82 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Wed, 22 Jan 2025 15:37:53 +0800 Subject: [PATCH 289/305] fix: ignore envs declared with empty value (#3062) --- pkg/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 24487cafa..56c76323e 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -782,7 +782,7 @@ func LoadEnvHook(f reflect.Kind, t reflect.Kind, data interface{}) (interface{}, } value := data.(string) if matches := envPattern.FindStringSubmatch(value); len(matches) > 1 { - if env, exists := os.LookupEnv(matches[1]); exists { + if env := os.Getenv(matches[1]); len(env) > 0 { value = env } } From 73e0b2d43d53ddcd6cecc1bcf67a1186ab682bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Caba=C3=A7o?= Date: Thu, 23 Jan 2025 03:09:51 +0000 Subject: [PATCH 290/305] fix: Exclude realtime messages publication from publication dropping (#3063) --- pkg/migration/queries/drop.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/migration/queries/drop.sql b/pkg/migration/queries/drop.sql index ae2332524..c25d1a14f 100644 --- a/pkg/migration/queries/drop.sql +++ b/pkg/migration/queries/drop.sql @@ -81,7 +81,7 @@ begin select * from pg_publication p where - p.pubname != 'supabase_realtime' + p.pubname not like 'supabase_realtime%' loop execute format('drop publication if exists %I', rec.pubname); end loop; From 354815f5c2c42c660ef2bb9dc3811d57b66d8702 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 23 Jan 2025 04:18:30 +0000 Subject: [PATCH 291/305] chore(deps): bump github.com/docker/cli from 27.5.0+incompatible to 27.5.1+incompatible (#3066) chore(deps): bump github.com/docker/cli Bumps [github.com/docker/cli](https://github.com/docker/cli) from 27.5.0+incompatible to 27.5.1+incompatible. - [Commits](https://github.com/docker/cli/compare/v27.5.0...v27.5.1) --- updated-dependencies: - dependency-name: github.com/docker/cli dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f287b4b97..3dc66254c 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/charmbracelet/lipgloss v0.12.1 github.com/containers/common v0.61.1 github.com/deepmap/oapi-codegen/v2 v2.2.0 - github.com/docker/cli v27.5.0+incompatible + github.com/docker/cli v27.5.1+incompatible github.com/docker/docker v27.5.0+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 diff --git a/go.sum b/go.sum index 0b1a3f5a5..dc4acad16 100644 --- a/go.sum +++ b/go.sum @@ -228,8 +228,8 @@ github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxK github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk= github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE= -github.com/docker/cli v27.5.0+incompatible h1:aMphQkcGtpHixwwhAXJT1rrK/detk2JIvDaFkLctbGM= -github.com/docker/cli v27.5.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v27.5.1+incompatible h1:JB9cieUT9YNiMITtIsguaN55PLOHhBSz3LKVc6cqWaY= +github.com/docker/cli v27.5.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= From db01dd3254cc3bb8c64d810ada204685ca7383cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 23 Jan 2025 04:23:04 +0000 Subject: [PATCH 292/305] chore(deps): bump github.com/go-git/go-git/v5 from 5.13.1 to 5.13.2 (#3067) Bumps [github.com/go-git/go-git/v5](https://github.com/go-git/go-git) from 5.13.1 to 5.13.2. - [Release notes](https://github.com/go-git/go-git/releases) - [Commits](https://github.com/go-git/go-git/compare/v5.13.1...v5.13.2) --- updated-dependencies: - dependency-name: github.com/go-git/go-git/v5 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 10 +++++----- go.sum | 24 ++++++++++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index 3dc66254c..b17612180 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,7 @@ require ( github.com/ecies/go/v2 v2.0.10 github.com/getsentry/sentry-go v0.31.1 github.com/go-errors/errors v1.5.1 - github.com/go-git/go-git/v5 v5.13.1 + github.com/go-git/go-git/v5 v5.13.2 github.com/go-xmlfmt/xmlfmt v1.1.3 github.com/golang-jwt/jwt/v5 v5.2.1 github.com/golangci/golangci-lint v1.63.4 @@ -74,7 +74,7 @@ require ( github.com/Masterminds/semver/v3 v3.3.0 // indirect github.com/Microsoft/go-winio v0.6.2 // indirect github.com/OpenPeeDeeP/depguard/v2 v2.2.0 // indirect - github.com/ProtonMail/go-crypto v1.1.3 // indirect + github.com/ProtonMail/go-crypto v1.1.5 // indirect github.com/alecthomas/chroma/v2 v2.8.0 // indirect github.com/alecthomas/go-check-sumtype v0.3.1 // indirect github.com/alexkohler/nakedret/v2 v2.0.5 // indirect @@ -136,7 +136,7 @@ require ( github.com/ghostiam/protogetter v0.3.8 // indirect github.com/go-critic/go-critic v0.11.5 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.6.1 // indirect + github.com/go-git/go-billy/v5 v5.6.2 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect @@ -243,7 +243,7 @@ require ( github.com/opencontainers/image-spec v1.1.0 // indirect github.com/pelletier/go-toml/v2 v2.2.3 // indirect github.com/perimeterx/marshmallow v1.1.5 // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect + github.com/pjbgf/sha1cd v0.3.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/polyfloyd/go-errorlint v1.7.0 // indirect @@ -326,7 +326,7 @@ require ( golang.org/x/crypto v0.32.0 // indirect golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c // indirect golang.org/x/exp/typeparams v0.0.0-20241108190413-2d47ceb2692f // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.34.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.29.0 // indirect golang.org/x/text v0.21.0 // indirect diff --git a/go.sum b/go.sum index dc4acad16..3859da0f1 100644 --- a/go.sum +++ b/go.sum @@ -71,8 +71,8 @@ github.com/Netflix/go-env v0.1.2 h1:0DRoLR9lECQ9Zqvkswuebm3jJ/2enaDX6Ei8/Z+EnK0= github.com/Netflix/go-env v0.1.2/go.mod h1:WlIhYi++8FlKNJtrop1mjXYAJMzv1f43K4MqCoh0yGE= github.com/OpenPeeDeeP/depguard/v2 v2.2.0 h1:vDfG60vDtIuf0MEOhmLlLLSzqaRM8EMcgJPdp74zmpA= github.com/OpenPeeDeeP/depguard/v2 v2.2.0/go.mod h1:CIzddKRvLBC4Au5aYP/i3nyaWQ+ClszLIuVocRiCYFQ= -github.com/ProtonMail/go-crypto v1.1.3 h1:nRBOetoydLeUb4nHajyO2bKqMLfWQ/ZPwkXqXxPxCFk= -github.com/ProtonMail/go-crypto v1.1.3/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= +github.com/ProtonMail/go-crypto v1.1.5 h1:eoAQfK2dwL+tFSFpr7TbOaPNUbPiJj4fLYwwGE1FQO4= +github.com/ProtonMail/go-crypto v1.1.5/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d h1:hi6J4K6DKrR4/ljxn6SF6nURyu785wKMuQcjt7H3VCQ= github.com/Shopify/logrus-bugsnag v0.0.0-20170309145241-6dbc35f2c30d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= @@ -252,8 +252,8 @@ github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7/go.mod h1:cyGadeNE github.com/dvsekhvalnov/jose2go v0.0.0-20170216131308-f21a8cedbbae/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= github.com/ecies/go/v2 v2.0.10 h1:AaLxGio0MLLbvWur4rKnLzw+K9zI+wMScIDAtqCqOtU= github.com/ecies/go/v2 v2.0.10/go.mod h1:N73OyuR6tuKznit2LhXjrZ0XAQ234uKbzYz8pEPYzlI= -github.com/elazarl/goproxy v1.2.3 h1:xwIyKHbaP5yfT6O9KIeYJR5549MXRQkoQMRXGztz8YQ= -github.com/elazarl/goproxy v1.2.3/go.mod h1:YfEbZtqP4AetfO6d40vWchF3znWX7C7Vd6ZMfdL8z64= +github.com/elazarl/goproxy v1.4.0 h1:4GyuSbFa+s26+3rmYNSuUVsx+HgPrV1bk1jXI0l9wjM= +github.com/elazarl/goproxy v1.4.0/go.mod h1:X/5W/t+gzDyLfHW4DrMdpjqYjpXsURlBt9lpBDxZZZQ= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -299,12 +299,12 @@ github.com/go-errors/errors v1.5.1 h1:ZwEMSLRCapFLflTpT7NKaAc7ukJ8ZPEjzlxt8rPN8b github.com/go-errors/errors v1.5.1/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.6.1 h1:u+dcrgaguSSkbjzHwelEjc0Yj300NUevrrPphk/SoRA= -github.com/go-git/go-billy/v5 v5.6.1/go.mod h1:0AsLr1z2+Uksi4NlElmMblP5rPcDZNRCD8ujZCRR2BE= +github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UNbRM= +github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= -github.com/go-git/go-git/v5 v5.13.1 h1:DAQ9APonnlvSWpvolXWIuV6Q6zXy2wHbN4cVlNR5Q+M= -github.com/go-git/go-git/v5 v5.13.1/go.mod h1:qryJB4cSBoq3FRoBRf5A77joojuBcmPJ0qu3XXXVixc= +github.com/go-git/go-git/v5 v5.13.2 h1:7O7xvsK7K+rZPKW6AQR1YyNhfywkv7B8/FsP3ki6Zv0= +github.com/go-git/go-git/v5 v5.13.2/go.mod h1:hWdW5P4YZRjmpGHwRH2v3zkWcNl6HeXaXQEMGb3NJ9A= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -773,8 +773,8 @@ github.com/perimeterx/marshmallow v1.1.5 h1:a2LALqQ1BlHM8PZblsDdidgv1mWi1DgC2UmX github.com/perimeterx/marshmallow v1.1.5/go.mod h1:dsXbUu8CRzfYP5a87xpp0xq9S3u0Vchtcl8we9tYaXw= github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pingcap/errors v0.11.4/go.mod h1:Oi8TUi2kEtXXLMJk9l1cGmz20kV3TaQ0usTwv5KuLY8= -github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= -github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= +github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4= +github.com/pjbgf/sha1cd v0.3.2/go.mod h1:zQWigSxVmsHEZow5qaLtPYxpcKMMQpa09ixqBxuCS6A= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -1182,8 +1182,8 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= +golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= From 3952af0512c1da1b3521e28ec464f53482f882fa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 23 Jan 2025 04:27:55 +0000 Subject: [PATCH 293/305] chore(deps): bump github.com/docker/docker from 27.5.0+incompatible to 27.5.1+incompatible (#3068) chore(deps): bump github.com/docker/docker Bumps [github.com/docker/docker](https://github.com/docker/docker) from 27.5.0+incompatible to 27.5.1+incompatible. - [Release notes](https://github.com/docker/docker/releases) - [Commits](https://github.com/docker/docker/compare/v27.5.0...v27.5.1) --- updated-dependencies: - dependency-name: github.com/docker/docker dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b17612180..9a03e71a0 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/containers/common v0.61.1 github.com/deepmap/oapi-codegen/v2 v2.2.0 github.com/docker/cli v27.5.1+incompatible - github.com/docker/docker v27.5.0+incompatible + github.com/docker/docker v27.5.1+incompatible github.com/docker/go-connections v0.5.0 github.com/docker/go-units v0.5.0 github.com/ecies/go/v2 v2.0.10 diff --git a/go.sum b/go.sum index 3859da0f1..7a82524d1 100644 --- a/go.sum +++ b/go.sum @@ -233,8 +233,8 @@ github.com/docker/cli v27.5.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvM github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v27.5.0+incompatible h1:um++2NcQtGRTz5eEgO6aJimo6/JxrTXC941hd05JO6U= -github.com/docker/docker v27.5.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.5.1+incompatible h1:4PYU5dnBYqRQi0294d1FBECqT9ECWeQAIfE8q4YnPY8= +github.com/docker/docker v27.5.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZSeVMrFgOr3T+zrFAo= github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0= From 60b221e8d0b2d1b09ae843389ffcd09a0521d16e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Caba=C3=A7o?= Date: Thu, 23 Jan 2025 08:26:29 +0000 Subject: [PATCH 294/305] fix: Bump realtime image (#3069) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 4183b4857..300754972 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -16,7 +16,7 @@ const ( vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.167.0" - realtimeImage = "supabase/realtime:v2.33.70" + realtimeImage = "supabase/realtime:v2.34.2" storageImage = "supabase/storage-api:v1.14.5" logflareImage = "supabase/logflare:1.4.0" // Append to JobImages when adding new dependencies below From 337aacd0dc90f25d2a65a3c4af2030e44ee588d5 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Thu, 23 Jan 2025 18:00:05 +0800 Subject: [PATCH 295/305] fix: warn uninitialised envs instead of error (#3065) --- pkg/config/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 56c76323e..5d7616575 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -771,7 +771,7 @@ func (c *config) Validate(fsys fs.FS) error { func assertEnvLoaded(s string) error { if matches := envPattern.FindStringSubmatch(s); len(matches) > 1 { - return errors.Errorf(`Error evaluating "%s": environment variable %s is unset.`, s, matches[1]) + fmt.Fprintln(os.Stderr, "WARN: environment variable is unset:", matches[1]) } return nil } From c45c25701ed3535d715aadade54f46e5753fb7ab Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 24 Jan 2025 04:16:38 +0000 Subject: [PATCH 296/305] chore(deps): bump google.golang.org/grpc from 1.69.4 to 1.70.0 (#3072) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.69.4 to 1.70.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](https://github.com/grpc/grpc-go/compare/v1.69.4...v1.70.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 9a03e71a0..caefe0083 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( golang.org/x/mod v0.22.0 golang.org/x/oauth2 v0.25.0 golang.org/x/term v0.28.0 - google.golang.org/grpc v1.69.4 + google.golang.org/grpc v1.70.0 gopkg.in/yaml.v3 v3.0.1 gotest.tools/gotestsum v1.12.0 ) @@ -315,8 +315,8 @@ require ( go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 // indirect go.opentelemetry.io/otel/metric v1.34.0 // indirect - go.opentelemetry.io/otel/sdk v1.31.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.31.0 // indirect + go.opentelemetry.io/otel/sdk v1.32.0 // indirect + go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.34.0 // indirect go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/atomic v1.9.0 // indirect diff --git a/go.sum b/go.sum index 7a82524d1..7607a8b4e 100644 --- a/go.sum +++ b/go.sum @@ -1030,10 +1030,10 @@ go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0 h1:j9+03 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0/go.mod h1:Y5+XiUG4Emn1hTfciPzGPJaSI+RpDts6BnCIir0SLqk= go.opentelemetry.io/otel/metric v1.34.0 h1:+eTR3U0MyfWjRDhmFMxe2SsW64QrZ84AOhvqS7Y+PoQ= go.opentelemetry.io/otel/metric v1.34.0/go.mod h1:CEDrp0fy2D0MvkXE+dPV7cMi8tWZwX3dmaIhwPOaqHE= -go.opentelemetry.io/otel/sdk v1.31.0 h1:xLY3abVHYZ5HSfOg3l2E5LUj2Cwva5Y7yGxnSW9H5Gk= -go.opentelemetry.io/otel/sdk v1.31.0/go.mod h1:TfRbMdhvxIIr/B2N2LQW2S5v9m3gOQ/08KsbbO5BPT0= -go.opentelemetry.io/otel/sdk/metric v1.31.0 h1:i9hxxLJF/9kkvfHppyLL55aW7iIJz4JjxTeYusH7zMc= -go.opentelemetry.io/otel/sdk/metric v1.31.0/go.mod h1:CRInTMVvNhUKgSAMbKyTMxqOBC0zgyxzW55lZzX43Y8= +go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= +go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= +go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU= +go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ= go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC8mh/k= go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= @@ -1464,8 +1464,8 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.69.4 h1:MF5TftSMkd8GLw/m0KM6V8CMOCY6NZ1NQDPGFgbTt4A= -google.golang.org/grpc v1.69.4/go.mod h1:vyjdE6jLBI76dgpDojsFGNaHlxdjXN9ghpnd2o7JGZ4= +google.golang.org/grpc v1.70.0 h1:pWFv03aZoHzlRKHWicjsZytKAiYCtNS0dHbXnIdq7jQ= +google.golang.org/grpc v1.70.0/go.mod h1:ofIJqVKDXx/JiXrwr2IG4/zwdH9txy3IlF40RmcJSQw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= From dde5a42b25e6f090e6d09a9db9b16349ce9eb605 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Fri, 24 Jan 2025 17:13:50 +0800 Subject: [PATCH 297/305] fix: ignore deprecated realtime publication (#3073) --- pkg/migration/queries/drop.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/migration/queries/drop.sql b/pkg/migration/queries/drop.sql index c25d1a14f..6dd8d8647 100644 --- a/pkg/migration/queries/drop.sql +++ b/pkg/migration/queries/drop.sql @@ -81,7 +81,7 @@ begin select * from pg_publication p where - p.pubname not like 'supabase_realtime%' + p.pubname not like 'supabase_realtime%' and p.pubname not like 'realtime_messages%' loop execute format('drop publication if exists %I', rec.pubname); end loop; From f158e2b7745ec0f5b0de7a0bbb9da0e903f2b0bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filipe=20Caba=C3=A7o?= Date: Fri, 24 Jan 2025 11:58:48 +0000 Subject: [PATCH 298/305] fix: Bump realtime image (#3074) --- pkg/config/constants.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 300754972..43054e3d5 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -16,7 +16,7 @@ const ( vectorImage = "timberio/vector:0.28.1-alpine" supavisorImage = "supabase/supavisor:1.1.56" gotrueImage = "supabase/gotrue:v2.167.0" - realtimeImage = "supabase/realtime:v2.34.2" + realtimeImage = "supabase/realtime:v2.34.7" storageImage = "supabase/storage-api:v1.14.5" logflareImage = "supabase/logflare:1.4.0" // Append to JobImages when adding new dependencies below From d8fe26d7242cd1868814e33b79b6dde1fd670316 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 28 Jan 2025 04:45:40 +0000 Subject: [PATCH 299/305] chore(deps): bump aws-actions/configure-aws-credentials from 4.0.2 to 4.0.3 (#3079) chore(deps): bump aws-actions/configure-aws-credentials Bumps [aws-actions/configure-aws-credentials](https://github.com/aws-actions/configure-aws-credentials) from 4.0.2 to 4.0.3. - [Release notes](https://github.com/aws-actions/configure-aws-credentials/releases) - [Changelog](https://github.com/aws-actions/configure-aws-credentials/blob/main/CHANGELOG.md) - [Commits](https://github.com/aws-actions/configure-aws-credentials/compare/v4.0.2...v4.0.3) --- updated-dependencies: - dependency-name: aws-actions/configure-aws-credentials dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/mirror-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/mirror-image.yml b/.github/workflows/mirror-image.yml index 99210c98c..b3338a9fa 100644 --- a/.github/workflows/mirror-image.yml +++ b/.github/workflows/mirror-image.yml @@ -26,7 +26,7 @@ jobs: TAG=${{ inputs.image }} echo "image=${TAG##*/}" >> $GITHUB_OUTPUT - name: configure aws credentials - uses: aws-actions/configure-aws-credentials@v4.0.2 + uses: aws-actions/configure-aws-credentials@v4.0.3 with: role-to-assume: ${{ secrets.PROD_AWS_ROLE }} aws-region: us-east-1 From 355bfd4984d308970708f83a358f193c96330ead Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Thu, 30 Jan 2025 12:22:31 +0800 Subject: [PATCH 300/305] fix: clean up storage schema on db reset (#3083) --- pkg/migration/queries/drop.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/migration/queries/drop.sql b/pkg/migration/queries/drop.sql index 6dd8d8647..71564659c 100644 --- a/pkg/migration/queries/drop.sql +++ b/pkg/migration/queries/drop.sql @@ -33,12 +33,13 @@ begin execute format('drop table if exists %I.%I cascade', rec.relnamespace::regnamespace::name, rec.relname); end loop; - -- truncate tables in auth, webhooks, and migrations schema + -- truncate tables in auth, storage, webhooks, and migrations schema for rec in select * from pg_class c where (c.relnamespace::regnamespace::name = 'auth' and c.relname != 'schema_migrations' + or c.relnamespace::regnamespace::name = 'storage' and c.relname != 'migrations' or c.relnamespace::regnamespace::name = 'supabase_functions' and c.relname != 'migrations' or c.relnamespace::regnamespace::name = 'supabase_migrations') and c.relkind = 'r' From d9737834dcc385c5af527a47e381dbcea18df4a7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Jan 2025 04:34:23 +0000 Subject: [PATCH 301/305] chore(deps): bump github.com/spf13/pflag from 1.0.5 to 1.0.6 (#3084) Bumps [github.com/spf13/pflag](https://github.com/spf13/pflag) from 1.0.5 to 1.0.6. - [Release notes](https://github.com/spf13/pflag/releases) - [Commits](https://github.com/spf13/pflag/compare/v1.0.5...v1.0.6) --- updated-dependencies: - dependency-name: github.com/spf13/pflag dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index caefe0083..9728b719b 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,7 @@ require ( github.com/slack-go/slack v0.15.0 github.com/spf13/afero v1.12.0 github.com/spf13/cobra v1.8.1 - github.com/spf13/pflag v1.0.5 + github.com/spf13/pflag v1.0.6 github.com/spf13/viper v1.19.0 github.com/stretchr/testify v1.10.0 github.com/stripe/pg-schema-diff v0.8.0 diff --git a/go.sum b/go.sum index 7607a8b4e..c0e03ab90 100644 --- a/go.sum +++ b/go.sum @@ -904,8 +904,9 @@ github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/jwalterweatherman v0.0.0-20141219030609-3d60171a6431/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.0/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o= +github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v0.0.0-20150530192845-be5ff3e4840c/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= github.com/spf13/viper v1.19.0/go.mod h1:GQUN9bilAbhU/jgc1bKs99f/suXKeUMct8Adx5+Ntkg= From 46e1b39294217e27f13f60bfe0777d6de3862ed9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 30 Jan 2025 17:58:10 +0000 Subject: [PATCH 302/305] chore(deps): bump github.com/ethereum/go-ethereum from 1.14.12 to 1.14.13 (#3087) chore(deps): bump github.com/ethereum/go-ethereum Bumps [github.com/ethereum/go-ethereum](https://github.com/ethereum/go-ethereum) from 1.14.12 to 1.14.13. - [Release notes](https://github.com/ethereum/go-ethereum/releases) - [Commits](https://github.com/ethereum/go-ethereum/compare/v1.14.12...v1.14.13) --- updated-dependencies: - dependency-name: github.com/ethereum/go-ethereum dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9728b719b..68a057c2b 100644 --- a/go.mod +++ b/go.mod @@ -123,7 +123,7 @@ require ( github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect github.com/docker/go-metrics v0.0.1 // indirect github.com/emirpasic/gods v1.18.1 // indirect - github.com/ethereum/go-ethereum v1.14.12 // indirect + github.com/ethereum/go-ethereum v1.14.13 // indirect github.com/ettle/strcase v0.2.0 // indirect github.com/fatih/color v1.18.0 // indirect github.com/fatih/structtag v1.2.0 // indirect diff --git a/go.sum b/go.sum index c0e03ab90..7af9ae762 100644 --- a/go.sum +++ b/go.sum @@ -261,8 +261,8 @@ github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.m github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= -github.com/ethereum/go-ethereum v1.14.12 h1:8hl57x77HSUo+cXExrURjU/w1VhL+ShCTJrTwcCQSe4= -github.com/ethereum/go-ethereum v1.14.12/go.mod h1:RAC2gVMWJ6FkxSPESfbshrcKpIokgQKsVKmAuqdekDY= +github.com/ethereum/go-ethereum v1.14.13 h1:L81Wmv0OUP6cf4CW6wtXsr23RUrDhKs2+Y9Qto+OgHU= +github.com/ethereum/go-ethereum v1.14.13/go.mod h1:RAC2gVMWJ6FkxSPESfbshrcKpIokgQKsVKmAuqdekDY= github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q= github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= From 867ef973f3626ccde12725ad8650a48fb4a5c6ea Mon Sep 17 00:00:00 2001 From: Ivan Vasilov Date: Fri, 31 Jan 2025 06:20:57 +0100 Subject: [PATCH 303/305] fix(studio): Bump studio version to 20250130-b048539 (#3085) --- internal/start/start.go | 2 +- pkg/config/constants.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/start/start.go b/internal/start/start.go index 1359d78a8..86331a3cb 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -983,7 +983,7 @@ EOF "HOSTNAME=0.0.0.0", }, Healthcheck: &container.HealthConfig{ - Test: []string{"CMD-SHELL", `node --eval="fetch('http://127.0.0.1:3000/api/profile').then((r) => {if (!r.ok) throw new Error(r.status)})"`}, + Test: []string{"CMD-SHELL", `node --eval="fetch('http://localhost:3000/api/platform/profile').then((r) => {if (!r.ok) throw new Error(r.status)})"`}, Interval: 10 * time.Second, Timeout: 2 * time.Second, Retries: 3, diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 43054e3d5..56be17077 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -10,7 +10,7 @@ const ( inbucketImage = "inbucket/inbucket:3.0.3" postgrestImage = "postgrest/postgrest:v12.2.0" pgmetaImage = "supabase/postgres-meta:v0.84.2" - studioImage = "supabase/studio:20250113-83c9420" + studioImage = "supabase/studio:20250130-b048539" imageProxyImage = "darthsim/imgproxy:v3.8.0" edgeRuntimeImage = "supabase/edge-runtime:v1.66.5" vectorImage = "timberio/vector:0.28.1-alpine" From 5017dcb70a8b7a64e418b547446ed016534e6415 Mon Sep 17 00:00:00 2001 From: szTheory Date: Fri, 31 Jan 2025 01:11:56 -0500 Subject: [PATCH 304/305] fix: typo in error message when creating seed table (#3089) * migration history: fix typo in create seed table error message * fix typo --- pkg/migration/history.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/migration/history.go b/pkg/migration/history.go index 2ca14167b..ca35d2da2 100644 --- a/pkg/migration/history.go +++ b/pkg/migration/history.go @@ -58,7 +58,7 @@ func CreateSeedTable(ctx context.Context, conn *pgx.Conn) error { batch.ExecParams(CREATE_VERSION_SCHEMA, nil, nil, nil, nil) batch.ExecParams(CREATE_SEED_TABLE, nil, nil, nil, nil) if _, err := conn.PgConn().ExecBatch(ctx, &batch).ReadAll(); err != nil { - return errors.Errorf("failed to create migration table: %w", err) + return errors.Errorf("failed to create seed table: %w", err) } return nil } From 722c81497202f1389a2f20a13a9d3662f144aa75 Mon Sep 17 00:00:00 2001 From: Han Qiao Date: Fri, 31 Jan 2025 14:44:16 +0800 Subject: [PATCH 305/305] feat: update vault secrets from config (#3080) * feat: update vault secrets from config * chore: create or update vault secrets * chore: move vault to pkg --- internal/db/push/push.go | 4 +++ internal/db/reset/reset.go | 18 ++-------- internal/db/start/start.go | 5 +++ internal/migration/up/up.go | 4 +++ pkg/config/db.go | 19 +++++----- pkg/config/templates/config.toml | 3 ++ pkg/config/testdata/config.toml | 3 ++ pkg/vault/batch.go | 60 ++++++++++++++++++++++++++++++++ 8 files changed, 92 insertions(+), 24 deletions(-) create mode 100644 pkg/vault/batch.go diff --git a/internal/db/push/push.go b/internal/db/push/push.go index 7e5241558..4a1fdf6df 100644 --- a/internal/db/push/push.go +++ b/internal/db/push/push.go @@ -14,6 +14,7 @@ import ( "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/vault" ) func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, includeSeed bool, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { @@ -82,6 +83,9 @@ func Run(ctx context.Context, dryRun, ignoreVersionMismatch bool, includeRoles, } else if !shouldPush { return errors.New(context.Canceled) } + if err := vault.UpsertVaultSecrets(ctx, utils.Config.Db.Vault, conn); err != nil { + return err + } if err := migration.ApplyMigrations(ctx, pending, conn, afero.NewIOFS(fsys)); err != nil { return err } diff --git a/internal/db/reset/reset.go b/internal/db/reset/reset.go index 307f14f55..d3e33e582 100644 --- a/internal/db/reset/reset.go +++ b/internal/db/reset/reset.go @@ -23,11 +23,11 @@ import ( "github.com/supabase/cli/internal/db/start" "github.com/supabase/cli/internal/gen/keys" "github.com/supabase/cli/internal/migration/apply" - "github.com/supabase/cli/internal/migration/list" "github.com/supabase/cli/internal/migration/repair" "github.com/supabase/cli/internal/seed/buckets" "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/vault" ) func Run(ctx context.Context, version string, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { @@ -242,22 +242,10 @@ func resetRemote(ctx context.Context, version string, config pgconn.Config, fsys if err := migration.DropUserSchemas(ctx, conn); err != nil { return err } - migrations, err := list.LoadPartialMigrations(version, fsys) - if err != nil { - return err - } - if err := migration.ApplyMigrations(ctx, migrations, conn, afero.NewIOFS(fsys)); err != nil { + if err := vault.UpsertVaultSecrets(ctx, utils.Config.Db.Vault, conn); err != nil { return err } - if !utils.Config.Db.Seed.Enabled { - // Skip because --no-seed flag is set - return nil - } - seeds, err := migration.GetPendingSeeds(ctx, utils.Config.Db.Seed.SqlPaths, conn, afero.NewIOFS(fsys)) - if err != nil { - return err - } - return migration.SeedData(ctx, seeds, conn, afero.NewIOFS(fsys)) + return apply.MigrateAndSeed(ctx, version, conn, fsys) } func LikeEscapeSchema(schemas []string) (result []string) { diff --git a/internal/db/start/start.go b/internal/db/start/start.go index 4180fe05c..85b5c6e35 100644 --- a/internal/db/start/start.go +++ b/internal/db/start/start.go @@ -25,6 +25,7 @@ import ( "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/internal/utils/flags" "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/vault" ) var ( @@ -372,6 +373,10 @@ func SetupDatabase(ctx context.Context, conn *pgx.Conn, host string, w io.Writer if err := initSchema(ctx, conn, host, w); err != nil { return err } + // Create vault secrets first so roles.sql can reference them + if err := vault.UpsertVaultSecrets(ctx, utils.Config.Db.Vault, conn); err != nil { + return err + } err := migration.SeedGlobals(ctx, []string{utils.CustomRolesPath}, conn, afero.NewIOFS(fsys)) if errors.Is(err, os.ErrNotExist) { return nil diff --git a/internal/migration/up/up.go b/internal/migration/up/up.go index d33117f33..331abce66 100644 --- a/internal/migration/up/up.go +++ b/internal/migration/up/up.go @@ -11,6 +11,7 @@ import ( "github.com/spf13/afero" "github.com/supabase/cli/internal/utils" "github.com/supabase/cli/pkg/migration" + "github.com/supabase/cli/pkg/vault" ) func Run(ctx context.Context, includeAll bool, config pgconn.Config, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error { @@ -23,6 +24,9 @@ func Run(ctx context.Context, includeAll bool, config pgconn.Config, fsys afero. if err != nil { return err } + if err := vault.UpsertVaultSecrets(ctx, utils.Config.Db.Vault, conn); err != nil { + return err + } return migration.ApplyMigrations(ctx, pending, conn, afero.NewIOFS(fsys)) } diff --git a/pkg/config/db.go b/pkg/config/db.go index d18cf8ebd..eaa02e036 100644 --- a/pkg/config/db.go +++ b/pkg/config/db.go @@ -51,15 +51,16 @@ type ( } db struct { - Image string `toml:"-"` - Port uint16 `toml:"port"` - ShadowPort uint16 `toml:"shadow_port"` - MajorVersion uint `toml:"major_version"` - Password string `toml:"-"` - RootKey string `toml:"-" mapstructure:"root_key"` - Pooler pooler `toml:"pooler"` - Seed seed `toml:"seed"` - Settings settings `toml:"settings"` + Image string `toml:"-"` + Port uint16 `toml:"port"` + ShadowPort uint16 `toml:"shadow_port"` + MajorVersion uint `toml:"major_version"` + Password string `toml:"-"` + RootKey string `toml:"-" mapstructure:"root_key"` + Pooler pooler `toml:"pooler"` + Seed seed `toml:"seed"` + Settings settings `toml:"settings"` + Vault map[string]Secret `toml:"vault"` } seed struct { diff --git a/pkg/config/templates/config.toml b/pkg/config/templates/config.toml index c8528d8f5..c91ec4b31 100644 --- a/pkg/config/templates/config.toml +++ b/pkg/config/templates/config.toml @@ -42,6 +42,9 @@ default_pool_size = 20 # Maximum number of client connections allowed. max_client_conn = 100 +# [db.vault] +# secret_key = "env(SECRET_VALUE)" + [db.seed] # If enabled, seeds the database after migrations during a db reset. enabled = true diff --git a/pkg/config/testdata/config.toml b/pkg/config/testdata/config.toml index 65705646c..8fcffa41d 100644 --- a/pkg/config/testdata/config.toml +++ b/pkg/config/testdata/config.toml @@ -42,6 +42,9 @@ default_pool_size = 20 # Maximum number of client connections allowed. max_client_conn = 100 +[db.vault] +test_key = "test_value" + [db.seed] # If enabled, seeds the database after migrations during a db reset. enabled = true diff --git a/pkg/vault/batch.go b/pkg/vault/batch.go new file mode 100644 index 000000000..8f44bb797 --- /dev/null +++ b/pkg/vault/batch.go @@ -0,0 +1,60 @@ +package vault + +import ( + "context" + "fmt" + "os" + + "github.com/go-errors/errors" + "github.com/jackc/pgx/v4" + "github.com/supabase/cli/pkg/config" + "github.com/supabase/cli/pkg/pgxv5" +) + +const ( + CREATE_VAULT_KV = "SELECT vault.create_secret($1, $2)" + READ_VAULT_KV = "SELECT id, name FROM vault.secrets WHERE name = ANY($1)" + UPDATE_VAULT_KV = "SELECT vault.update_secret($1, $2)" +) + +type VaultTable struct { + Id string + Name string +} + +func UpsertVaultSecrets(ctx context.Context, secrets map[string]config.Secret, conn *pgx.Conn) error { + var keys []string + toInsert := map[string]string{} + for k, v := range secrets { + if len(v.SHA256) > 0 { + keys = append(keys, k) + toInsert[k] = v.Value + } + } + if len(keys) == 0 { + return nil + } + fmt.Fprintln(os.Stderr, "Updating vault secrets...") + rows, err := conn.Query(ctx, READ_VAULT_KV, keys) + if err != nil { + return errors.Errorf("failed to read vault: %w", err) + } + toUpdate, err := pgxv5.CollectRows[VaultTable](rows) + if err != nil { + return err + } + batch := pgx.Batch{} + for _, r := range toUpdate { + secret := secrets[r.Name] + batch.Queue(UPDATE_VAULT_KV, r.Id, secret.Value) + delete(toInsert, r.Name) + } + // Remaining secrets should be created + for k, v := range toInsert { + batch.Queue(CREATE_VAULT_KV, v, k) + } + if err := conn.SendBatch(ctx, &batch).Close(); err != nil { + return errors.Errorf("failed to update vault: %w", err) + } + return nil +}