Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4thel00z opened this issue May 29, 2023 · 1 comment
Open

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

4thel00z opened this issue May 29, 2023 · 1 comment

Comments

@4thel00z
Copy link

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.

@fmoor
Copy link
Member

fmoor commented May 30, 2023

Thanks for opening this issue @4thel00z! We will consider adding this feature. In the mean time you can work around this by setting the EDGEDB_INSTANCE environment variable to the name of your project instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants