Skip to content

Commit

Permalink
fix: allow absolute paths in config file
Browse files Browse the repository at this point in the history
  • Loading branch information
sweatybridge committed Aug 8, 2024
1 parent f21c9df commit 4b0083e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/seed/buckets/buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ func Run(ctx context.Context, projectRef string, interactive bool, fsys afero.Fs
}
resolved[name] = bucket
}
return api.UpsertObjects(ctx, resolved, 5, afero.NewIOFS(fsys))
return api.UpsertObjects(ctx, resolved, 5, utils.NewRootFS(fsys))
}
16 changes: 15 additions & 1 deletion internal/utils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package utils
import (
_ "embed"
"fmt"
"io/fs"
"net"
"net/url"
"os"
Expand Down Expand Up @@ -101,7 +102,7 @@ func GetDockerIds() []string {
var Config = config.NewConfig(config.WithHostname(GetHostname()))

func LoadConfigFS(fsys afero.Fs) error {
if err := Config.Load("", afero.NewIOFS(fsys)); err != nil {
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"))
}
Expand All @@ -111,6 +112,19 @@ func LoadConfigFS(fsys afero.Fs) error {
return nil
}

// Adapts fs.FS to support absolute paths
type rootFS struct {
fsys afero.Fs
}

func (f *rootFS) Open(name string) (fs.File, error) {
return f.fsys.Open(name)
}

func NewRootFS(fsys afero.Fs) fs.FS {
return &rootFS{fsys: fsys}
}

func ToRealtimeEnv(addr config.AddressFamily) string {
if addr == config.AddressIPv6 {
return "-proto_dist inet6_tcp"
Expand Down

0 comments on commit 4b0083e

Please sign in to comment.