Skip to content

Commit

Permalink
Fix generate of config to include database.
Browse files Browse the repository at this point in the history
  • Loading branch information
bahner committed Feb 28, 2024
1 parent 00d96b6 commit 4ba9be4
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 37 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ MODULE_NAME = github.com/bahner/go-ma-actor
export VERSION = "v0.0.2"

GO ?= go
GOOPTS ?= -ldflags="-s -w"
PREFIX ?= /usr/local
KEYSET = go-ma-create-keyset
FETCH = go-ma-fetch-document
Expand All @@ -25,13 +26,13 @@ $(BIN): $(ALL)
sudo install -m755 $(ALL) $(DESTDIR)$(BIN)

$(NAME): tidy
$(GO) build -o $(NAME) ./cmd/actor
$(GO) build -o $(NAME) $(GOOPTS) ./cmd/actor

$(FETCH): tidy
$(GO) build -o $(FETCH) ./cmd/fetch_document
$(GO) build -o $(FETCH) $(GOOPTS) ./cmd/fetch_document

$(KEYSET): tidy
$(GO) build -o $(KEYSET) ./cmd/create_keyset
$(GO) build -o $(KEYSET) $(GOOPTS) ./cmd/create_keyset

init: go.mod tidy

Expand Down
30 changes: 0 additions & 30 deletions config/alias.go

This file was deleted.

5 changes: 5 additions & 0 deletions config/db.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package config

const (
DefaultDB = "~/.ma/ma.db"
)
6 changes: 3 additions & 3 deletions config/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"fmt"
"sync"

"github.com/bahner/go-ma-actor/config"
"github.com/mitchellh/go-homedir"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)

const (
defaultDB = "~/.ma/ma.db"
dbMaxConnections = 1
dbTimeout = 100
)
Expand All @@ -23,9 +23,9 @@ var (

func init() {

pflag.String("db-file", defaultDB, "File to *write* node peers and entities to. If the file does not exist, it will be created.")
pflag.String("db-file", config.DefaultDB, "File to *write* node peers and entities to. If the file does not exist, it will be created.")
viper.BindPFlag("db.file", pflag.Lookup("db-file"))
viper.SetDefault("db.file", defaultDB)
viper.SetDefault("db.file", config.DefaultDB)
}

// Returns expanded path to the db-file file
Expand Down
4 changes: 3 additions & 1 deletion config/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ func generateConfigFile(actor string, node string) {
"home": defaultHome,
"nick": viper.GetString("actor.nick"),
},
"aliases": defaultAliasesDB,
"db": map[string]interface{}{
"file": DefaultDB,
},
"log": map[string]interface{}{
"level": defaultLogLevel,
"file": logFile,
Expand Down

0 comments on commit 4ba9be4

Please sign in to comment.