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

init db: fix: specifying env db url requires repo config file #595

Merged
merged 1 commit into from
Jul 17, 2024
Merged
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
19 changes: 3 additions & 16 deletions internal/command/init_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@ package command
import (
"errors"
"fmt"
"os"
"strings"

"github.com/spf13/cobra"

"github.com/simplesurance/baur/v5/internal/command/term"
"github.com/simplesurance/baur/v5/pkg/baur"
"github.com/simplesurance/baur/v5/pkg/storage"
)

Expand Down Expand Up @@ -45,20 +43,9 @@ func initDb(_ *cobra.Command, args []string) {
if len(args) == 1 {
dbURL = args[0]
} else {
repo, err := findRepository()
if err != nil {
if os.IsNotExist(err) {
stderr.Printf("could not find '%s' repository config file.\n"+
"Run '%s' first or pass the Postgres URL as argument.\n",
term.Highlight(baur.RepositoryCfgFile), term.Highlight(cmdInitRepo))
exitFunc(exitCodeError)
}

stderr.Println(err)
exitFunc(exitCodeError)
}

dbURL = mustGetPSQLURI(repo.Cfg)
var err error
dbURL, err = postgresqlURL()
exitOnErr(err)
}

storageClt, err := newStorageClient(dbURL)
Expand Down
Loading