Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/supabase/cli/internal/db/test"
"github.com/supabase/cli/internal/utils"
"github.com/supabase/cli/internal/utils/flags"
"github.com/supabase/cli/internal/utils/primitives"
)

var (
Expand Down Expand Up @@ -190,7 +191,7 @@ var (
Short: "Resets the local database to current migrations",
RunE: func(cmd *cobra.Command, args []string) error {
if noSeed {
utils.Config.Db.Seed.Enabled = false
utils.Config.Db.Seed.Enabled = primitives.Ptr(false)
}
return reset.Run(cmd.Context(), migrationVersion, flags.DbConfig, afero.NewOsFs())
},
Expand Down
5 changes: 3 additions & 2 deletions cmd/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/internal/utils/primitives"
)

var (
Expand Down Expand Up @@ -106,9 +107,9 @@ var (
}

if len(inspectMode.Value) > 0 {
runtimeOption.InspectMode = utils.Ptr(serve.InspectMode(inspectMode.Value))
runtimeOption.InspectMode = primitives.Ptr(serve.InspectMode(inspectMode.Value))
} else if inspectBrk {
runtimeOption.InspectMode = utils.Ptr(serve.InspectModeBrk)
runtimeOption.InspectMode = primitives.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]")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ require (
require (
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
4d63.com/gochecknoglobals v0.2.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.0.14 // indirect
github.com/Antonboom/errname v0.1.13 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
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=
Expand Down
7 changes: 4 additions & 3 deletions internal/branches/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/supabase/cli/internal/testing/apitest"
"github.com/supabase/cli/internal/utils"
"github.com/supabase/cli/internal/utils/flags"
"github.com/supabase/cli/internal/utils/primitives"
"github.com/supabase/cli/pkg/api"
)

Expand All @@ -36,7 +37,7 @@ func TestCreateCommand(t *testing.T) {
})
// Run test
err := Run(context.Background(), api.CreateBranchBody{
Region: utils.Ptr("sin"),
Region: primitives.Ptr("sin"),
}, fsys)
// Check error
assert.NoError(t, err)
Expand All @@ -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: primitives.Ptr("sin"),
}, fsys)
// Check error
assert.ErrorIs(t, err, net.ErrClosed)
Expand All @@ -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: primitives.Ptr("sin"),
}, fsys)
// Check error
assert.ErrorContains(t, err, "Unexpected error creating preview branch:")
Expand Down
5 changes: 3 additions & 2 deletions internal/db/reset/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ 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/primitives"
"github.com/supabase/cli/pkg/migration"
)

Expand Down Expand Up @@ -54,7 +55,7 @@ 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 primitives.SafeBool(utils.Config.Storage.Enabled) {
if err := start.WaitForHealthyService(ctx, 30*time.Second, utils.StorageId); err != nil {
return err
}
Expand Down Expand Up @@ -114,7 +115,7 @@ func resetDatabase15(ctx context.Context, version string, fsys afero.Fs, options
}
// Skip syslog if vector container is not started
if _, err := utils.Docker.ContainerInspect(ctx, utils.VectorId); err != nil {
utils.Config.Analytics.Enabled = false
utils.Config.Analytics.Enabled = primitives.Ptr(false)
}
config := start.NewContainerConfig()
hostConfig := start.NewHostConfig()
Expand Down
3 changes: 2 additions & 1 deletion internal/db/reset/reset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"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/primitives"
"github.com/supabase/cli/pkg/migration"
"github.com/supabase/cli/pkg/pgtest"
)
Expand Down Expand Up @@ -377,7 +378,7 @@ func TestResetRemote(t *testing.T) {
helper.MockMigrationHistory(conn).
Query(migration.INSERT_MIGRATION_VERSION, "0", "schema", nil).
Reply("INSERT 0 1")
utils.Config.Db.Seed.Enabled = false
utils.Config.Db.Seed.Enabled = primitives.Ptr(false)
// Run test
err := resetRemote(context.Background(), "", dbConfig, fsys, conn.Intercept)
// No error should be raised since we're skipping the seed
Expand Down
9 changes: 5 additions & 4 deletions internal/db/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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/primitives"
"github.com/supabase/cli/pkg/migration"
)

Expand All @@ -42,7 +43,7 @@ func Run(ctx context.Context, fsys afero.Fs) error {
return err
}
// Skip logflare container in db start
utils.Config.Analytics.Enabled = false
utils.Config.Analytics.Enabled = primitives.Ptr(false)
err := StartDatabase(ctx, fsys, os.Stderr)
if err != nil {
if err := utils.DockerRemoveAll(context.Background(), os.Stderr, utils.Config.ProjectId); err != nil {
Expand Down Expand Up @@ -284,13 +285,13 @@ func initAuthJob(host string) utils.DockerJob {
func initSchema15(ctx context.Context, host string) error {
// Apply service migrations
var initJobs []utils.DockerJob
if utils.Config.Realtime.Enabled {
if primitives.SafeBool(utils.Config.Realtime.Enabled) {
initJobs = append(initJobs, initRealtimeJob(host))
}
if utils.Config.Storage.Enabled {
if primitives.SafeBool(utils.Config.Storage.Enabled) {
initJobs = append(initJobs, initStorageJob(host))
}
if utils.Config.Auth.Enabled {
if primitives.SafeBool(utils.Config.Auth.Enabled) {
initJobs = append(initJobs, initAuthJob(host))
}
logger := utils.GetDebugLogger()
Expand Down
3 changes: 2 additions & 1 deletion internal/functions/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/primitives"
"github.com/supabase/cli/pkg/config"
"github.com/supabase/cli/pkg/function"
)
Expand Down Expand Up @@ -94,7 +95,7 @@ func GetFunctionConfig(slugs []string, importMapPath string, noVerifyJWT *bool,
function.ImportMap = utils.FallbackImportMapPath
}
if noVerifyJWT != nil {
function.VerifyJWT = utils.Ptr(!*noVerifyJWT)
function.VerifyJWT = primitives.Ptr(!*noVerifyJWT)
}
functionConfig[name] = function
}
Expand Down
3 changes: 2 additions & 1 deletion internal/functions/deploy/deploy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/internal/utils/primitives"
"github.com/supabase/cli/pkg/api"
"github.com/supabase/cli/pkg/config"
)
Expand Down Expand Up @@ -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, primitives.Ptr(false), fsys)
// Check error
assert.NoError(t, err)
assert.Equal(t, utils.FallbackImportMapPath, fc[slug].ImportMap)
Expand Down
3 changes: 2 additions & 1 deletion internal/functions/serve/serve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/internal/utils/primitives"
)

func TestServeCommand(t *testing.T) {
Expand Down Expand Up @@ -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", primitives.Ptr(true), "import_map.json", RuntimeOption{}, fsys)
// Check error
assert.ErrorIs(t, err, os.ErrNotExist)
})
Expand Down
9 changes: 5 additions & 4 deletions internal/init/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/internal/utils/primitives"
)

func TestInitCommand(t *testing.T) {
Expand Down Expand Up @@ -83,7 +84,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, primitives.Ptr(true), nil, utils.InitParams{}))
// Validate generated vscode settings
exists, err := afero.Exists(fsys, settingsPath)
assert.NoError(t, err)
Expand All @@ -97,7 +98,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, primitives.Ptr(false), nil, utils.InitParams{}))
// Validate vscode settings file isn't generated
exists, err := afero.Exists(fsys, settingsPath)
assert.NoError(t, err)
Expand All @@ -111,7 +112,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, primitives.Ptr(true), utils.InitParams{}))
// Validate generated intellij deno config
exists, err := afero.Exists(fsys, denoPath)
assert.NoError(t, err)
Expand All @@ -122,7 +123,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, primitives.Ptr(false), utils.InitParams{}))
// Validate intellij deno config file isn't generated
exists, err := afero.Exists(fsys, denoPath)
assert.NoError(t, err)
Expand Down
3 changes: 2 additions & 1 deletion internal/migration/apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/spf13/afero"
"github.com/supabase/cli/internal/migration/list"
"github.com/supabase/cli/internal/utils"
"github.com/supabase/cli/internal/utils/primitives"
"github.com/supabase/cli/pkg/migration"
)

Expand All @@ -20,7 +21,7 @@ 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 {
if !primitives.SafeBool(utils.Config.Db.Seed.Enabled) {
return nil
}
return SeedDatabase(ctx, conn, fsys)
Expand Down
3 changes: 2 additions & 1 deletion internal/migration/apply/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"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/primitives"
"github.com/supabase/cli/pkg/migration"
"github.com/supabase/cli/pkg/pgtest"
)
Expand Down Expand Up @@ -55,7 +56,7 @@ func TestMigrateDatabase(t *testing.T) {
Reply("CREATE SCHEMA").
Query(migration.INSERT_MIGRATION_VERSION, "0", "test", []string{sql}).
Reply("INSERT 0 1")
utils.Config.Db.Seed.Enabled = false
utils.Config.Db.Seed.Enabled = primitives.Ptr(false)
// Run test
err := MigrateAndSeed(context.Background(), "", conn.MockClient(t), fsys)
// No error should be returned since seeding is skipped
Expand Down
Loading