Skip to content

Commit

Permalink
chore: remove deprecated start flag
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatybridge committed Jan 16, 2024
1 parent ba4244d commit 41860b8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 35 deletions.
9 changes: 1 addition & 8 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"github.com/spf13/afero"
"github.com/spf13/cobra"
"github.com/supabase/cli/internal/start"
"github.com/supabase/cli/internal/utils/flags"
)

var (
Expand All @@ -20,13 +19,7 @@ var (
Use: "start",
Short: "Start containers for Supabase local development",
RunE: func(cmd *cobra.Command, args []string) error {
fsys := afero.NewOsFs()
if preview {
if _, err := flags.LoadProjectRef(fsys); err != nil {
return err
}
}
return start.Run(cmd.Context(), fsys, excludedContainers, ignoreHealthCheck, flags.ProjectRef)
return start.Run(cmd.Context(), afero.NewOsFs(), excludedContainers, ignoreHealthCheck)
},
}
)
Expand Down
30 changes: 7 additions & 23 deletions internal/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ import (
"github.com/supabase/cli/internal/db/reset"
"github.com/supabase/cli/internal/db/start"
"github.com/supabase/cli/internal/functions/serve"
"github.com/supabase/cli/internal/gen/keys"
"github.com/supabase/cli/internal/status"
"github.com/supabase/cli/internal/utils"
)

func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string, ignoreHealthCheck bool, projectRef string) error {
func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string, ignoreHealthCheck bool) error {
// Sanity checks.
{
if err := utils.LoadConfigFS(fsys); err != nil {
Expand All @@ -45,27 +44,12 @@ func Run(ctx context.Context, fsys afero.Fs, excludedContainers []string, ignore
}

if err := utils.RunProgram(ctx, func(p utils.Program, ctx context.Context) error {
var dbConfig pgconn.Config
if len(projectRef) > 0 {
branch := keys.GetGitBranch(fsys)
if err := keys.GenerateSecrets(ctx, projectRef, branch, fsys); err != nil {
return err
}
dbConfig = pgconn.Config{
Host: fmt.Sprintf("%s-%s.fly.dev", projectRef, branch),
Port: 5432,
User: "postgres",
Password: utils.Config.Db.Password,
Database: "postgres",
}
} else {
dbConfig = pgconn.Config{
Host: utils.DbId,
Port: 5432,
User: "postgres",
Password: utils.Config.Db.Password,
Database: "postgres",
}
dbConfig := pgconn.Config{
Host: utils.DbId,
Port: 5432,
User: "postgres",
Password: utils.Config.Db.Password,
Database: "postgres",
}
return run(p, ctx, fsys, excludedContainers, dbConfig)
}); err != nil {
Expand Down
10 changes: 6 additions & 4 deletions internal/start/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

func TestStartCommand(t *testing.T) {
t.Run("throws error on missing config", func(t *testing.T) {
err := Run(context.Background(), afero.NewMemMapFs(), []string{}, false, "")
err := Run(context.Background(), afero.NewMemMapFs(), []string{}, false)
assert.ErrorIs(t, err, os.ErrNotExist)
})

Expand All @@ -32,7 +32,7 @@ func TestStartCommand(t *testing.T) {
fsys := afero.NewMemMapFs()
require.NoError(t, afero.WriteFile(fsys, utils.ConfigPath, []byte("malformed"), 0644))
// Run test
err := Run(context.Background(), fsys, []string{}, false, "")
err := Run(context.Background(), fsys, []string{}, false)
// Check error
assert.ErrorContains(t, err, "toml: line 0: unexpected EOF; expected key separator '='")
})
Expand All @@ -48,7 +48,7 @@ func TestStartCommand(t *testing.T) {
Get("/v" + utils.Docker.ClientVersion() + "/containers").
ReplyError(errors.New("network error"))
// Run test
err := Run(context.Background(), fsys, []string{}, false, "")
err := Run(context.Background(), fsys, []string{}, false)
// Check error
assert.ErrorContains(t, err, "network error")
assert.Empty(t, apitest.ListUnmatchedRequests())
Expand Down Expand Up @@ -76,7 +76,7 @@ func TestStartCommand(t *testing.T) {
Reply(http.StatusOK).
JSON(types.ContainerJSON{})
// Run test
err := Run(context.Background(), fsys, []string{}, false, "")
err := Run(context.Background(), fsys, []string{}, false)
// Check error
assert.NoError(t, err)
assert.Empty(t, apitest.ListUnmatchedRequests())
Expand Down Expand Up @@ -110,6 +110,7 @@ func TestDatabaseStart(t *testing.T) {
}
// Start postgres
utils.DbId = "test-postgres"
utils.ConfigId = "test-config"
utils.Config.Db.Port = 54322
utils.Config.Db.MajorVersion = 15
gock.New(utils.Docker.DaemonHost()).
Expand Down Expand Up @@ -205,6 +206,7 @@ func TestDatabaseStart(t *testing.T) {
JSON(types.ImageInspect{})
// Start postgres
utils.DbId = "test-postgres"
utils.ConfigId = "test-config"
utils.Config.Db.Port = 54322
utils.Config.Db.MajorVersion = 15
gock.New(utils.Docker.DaemonHost()).
Expand Down

0 comments on commit 41860b8

Please sign in to comment.