Skip to content

Commit

Permalink
use runner.LoadConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
bojand committed Jun 1, 2020
1 parent f4b2141 commit c62c49f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
3 changes: 1 addition & 2 deletions cmd/ghz/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"strings"

"github.com/alecthomas/kingpin"
"github.com/jinzhu/configor"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"

Expand Down Expand Up @@ -197,7 +196,7 @@ func main() {
var cfg runner.Config

if cfgPath != "" {
err := configor.Load(&cfg, cfgPath)
err := runner.LoadConfig(cfgPath, &cfg)
kingpin.FatalIfError(err, "")

args := os.Args[1:]
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
go.uber.org/multierr v1.3.0
go.uber.org/zap v1.13.0
golang.org/x/net v0.0.0-20191021144547-ec77196f6094
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc // indirect
golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f // indirect
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a // indirect
google.golang.org/grpc v1.24.0
gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5 h1:hKsoRgsbwY1NafxrwTs+k64bikrLBkAgPir1TNCj3Zs=
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc h1:NCy3Ohtk6Iny5V/reW2Ktypo4zIpWBdRJ1uFMjBxdg8=
golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f h1:3MlESg/jvTr87F4ttA/q4B+uhe/q6qleC9/DP+IwQmY=
golang.org/x/tools v0.0.0-20191127201027-ecd32218bd7f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
Expand Down
3 changes: 2 additions & 1 deletion runner/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ func checkData(data interface{}) error {
return nil
}

func loadConfig(p string, c *Config) error {
// LoadConfig loads the config from a file
func LoadConfig(p string, c *Config) error {
err := configor.Load(c, p)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions runner/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestConfig_Load(t *testing.T) {
t.Run("toml "+tt.name, func(t *testing.T) {
var actual Config
cfgPath := "../testdata/config/config" + strconv.Itoa(i) + ".toml"
err := loadConfig(cfgPath, &actual)
err := LoadConfig(cfgPath, &actual)
if tt.ok {
assert.NoError(t, err)
assert.Equal(t, tt.expected, &actual)
Expand All @@ -81,7 +81,7 @@ func TestConfig_Load(t *testing.T) {
t.Run("json "+tt.name, func(t *testing.T) {
var actual Config
cfgPath := "../testdata/config/config" + strconv.Itoa(i) + ".toml"
err := loadConfig(cfgPath, &actual)
err := LoadConfig(cfgPath, &actual)
if tt.ok {
assert.NoError(t, err)
assert.Equal(t, tt.expected, &actual)
Expand All @@ -93,7 +93,7 @@ func TestConfig_Load(t *testing.T) {
t.Run("yaml "+tt.name, func(t *testing.T) {
var actual Config
cfgPath := "../testdata/config/config" + strconv.Itoa(i) + ".yaml"
err := loadConfig(cfgPath, &actual)
err := LoadConfig(cfgPath, &actual)
if tt.ok {
assert.NoError(t, err)
assert.Equal(t, tt.expected, &actual)
Expand Down

0 comments on commit c62c49f

Please sign in to comment.