Skip to content

API Enhancement: Make the config edgedb.toml path passable  #271

@4thel00z

Description

@4thel00z

Describe the bug
Currently CreateClientDSN hardcodes the config locations, which could be an optional default param:

func CreateClientDSN(ctx context.Context, dsn string, opts Options) (*Client, error) { // nolint:gocritic,lll
	cfg, err := parseConnectDSNAndArgs(dsn, &opts, newCfgPaths())

Which creates:

<some date> edgedb.ConfigurationError: no `edgedb.toml` found and no connection options specified either via arguments to connect API or via environment variables EDGEDB_HOST/EDGEDB_PORT, EDGEDB_INSTANCE, EDGEDB_DSN or EDGEDB_CREDENTIALS_FILE

This implies a certain dir structure, which might not be what you want for your project.

Reproduction

Create an empty project, throw this in main.go

package main

import (
	"context"
	"github.com/edgedb/edgedb-go"
	"log"
)

func main() {
	ctx := context.Background()
	client, err := edgedb.CreateClient(ctx, edgedb.Options{})
	if err != nil {
		log.Fatal(err)
	}
	defer client.Close()

}

Expected behavior

I can provide a value (potentially, via edgedb.Options that is respected and thrown into resolveTOML:

func (r *configResolver) resolveTOML(paths *cfgPaths) error {
	toml, err := findEdgeDBTOML(paths)
	if err != nil {
		return err
	}

	stashDir, err := stashPath(filepath.Dir(toml), paths)
	if err != nil {
		return err
	}
	
	// snip...

Happy to contribute

Versions (please complete the following information):

  • OS : Linux/x64
  • EdgeDB version: 2.15+75c3494
  • EdgeDB CLI version: EdgeDB CLI 3.1.0+69bd230
  • edgedb-go version: github.com/edgedb/edgedb-go v0.13.6
  • Go version: 1.20

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions