mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-11 23:31:03 +00:00
Merge pull request #1350 from jaffee/generate-config-and-toml-fix
fix generate-config command, use single toml lib
This commit is contained in:
commit
f802f3bc5c
5 changed files with 22 additions and 35 deletions
16
Gopkg.lock
generated
16
Gopkg.lock
generated
|
|
@ -1,12 +1,6 @@
|
|||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/BurntSushi/toml"
|
||||
packages = ["."]
|
||||
revision = "b26d9c308763d68093482582cea63d69be07a0f0"
|
||||
version = "v0.3.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/CAFxX/gcnotifier"
|
||||
|
|
@ -212,14 +206,22 @@
|
|||
[[projects]]
|
||||
name = "github.com/shirou/gopsutil"
|
||||
packages = [
|
||||
"cpu",
|
||||
"host",
|
||||
"internal/common",
|
||||
"mem",
|
||||
"net",
|
||||
"process"
|
||||
]
|
||||
revision = "bfe3c2e8f406bf352bc8df81f98c752224867349"
|
||||
version = "v2.17.11"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/shirou/w32"
|
||||
packages = ["."]
|
||||
revision = "bb4de0191aa41b5507caa14b0650cdbddcd9280b"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/spf13/afero"
|
||||
|
|
@ -302,6 +304,6 @@
|
|||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "8f633d73d966ca439d2fdf3704a41d8ea59be8ed9a2cab0ab73de4b72c5772ba"
|
||||
inputs-digest = "325d0fb217ec7f1509186ff947e184f6c8e65941f06000eb110180e65816b1a4"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
|||
|
|
@ -18,9 +18,11 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"github.com/pelletier/go-toml"
|
||||
"github.com/pilosa/pilosa"
|
||||
"github.com/pilosa/pilosa/server"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// GenerateConfigCommand represents a command for printing a default config.
|
||||
|
|
@ -37,28 +39,11 @@ func NewGenerateConfigCommand(stdin io.Reader, stdout, stderr io.Writer) *Genera
|
|||
|
||||
// Run prints out the default config.
|
||||
func (cmd *GenerateConfigCommand) Run(ctx context.Context) error {
|
||||
fmt.Fprintln(cmd.Stdout, strings.TrimSpace(`
|
||||
data-dir = "~/.pilosa"
|
||||
bind = "localhost:10101"
|
||||
max-writes-per-request = 5000
|
||||
|
||||
[cluster]
|
||||
replicas = 1
|
||||
hosts = [
|
||||
"localhost:10101",
|
||||
]
|
||||
|
||||
[anti-entropy]
|
||||
interval = "10m0s"
|
||||
|
||||
[profile]
|
||||
cpu = ""
|
||||
cpu-time = "30s"
|
||||
|
||||
[metric]
|
||||
service = "statsd"
|
||||
host = "127.0.0.1:8125"
|
||||
poll-interval = "0m15s"
|
||||
`)+"\n")
|
||||
conf := server.NewConfig()
|
||||
ret, err := toml.Marshal(*conf)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "unmarshaling default config")
|
||||
}
|
||||
fmt.Fprintf(cmd.Stdout, "%s\n", ret)
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func TestGenerateConfigCommand_Run(t *testing.T) {
|
|||
io.Copy(&buf, r)
|
||||
if err != nil {
|
||||
t.Fatalf("Config Run doesn't work: %s", err)
|
||||
} else if !strings.Contains(buf.String(), "localhost:10101") {
|
||||
} else if !strings.Contains(buf.String(), ":10101") {
|
||||
t.Fatalf("Unexpected config: %s", buf.String())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ type Config struct {
|
|||
Handler struct {
|
||||
// CORS Allowed Origins
|
||||
AllowedOrigins []string `toml:"allowed-origins"`
|
||||
}
|
||||
} `toml:"handler"`
|
||||
|
||||
// TLS
|
||||
TLS TLSConfig `toml:"tls"`
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import (
|
|||
"testing"
|
||||
"testing/quick"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/pelletier/go-toml"
|
||||
"github.com/pilosa/pilosa"
|
||||
"github.com/pilosa/pilosa/server"
|
||||
"github.com/pilosa/pilosa/test"
|
||||
|
|
@ -374,7 +374,7 @@ func GenerateSetCommands(n int, rand *rand.Rand) []SetCommand {
|
|||
// ParseConfig parses s into a Config.
|
||||
func ParseConfig(s string) (server.Config, error) {
|
||||
var c server.Config
|
||||
_, err := toml.Decode(s, &c)
|
||||
err := toml.Unmarshal([]byte(s), &c)
|
||||
return c, err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue