Skip to content

Commit

Permalink
Update go ucfg (#7510)
Browse files Browse the repository at this point in the history
* Update go-ucfg to 0.6.0

* Update NewConfigFrom

- update NewConfigFrom to treat raw string input as YAML contents
- Introduce MustNewConfigFrom, which throws a panic on error
  • Loading branch information
Steffen Siering authored and exekias committed Jul 5, 2018
1 parent f257471 commit 0ece14d
Show file tree
Hide file tree
Showing 28 changed files with 715 additions and 62 deletions.
4 changes: 2 additions & 2 deletions NOTICE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ Apache License 2.0

--------------------------------------------------------------------
Dependency: github.com/elastic/go-ucfg
Version: v0.5.1
Revision: 0ba28e36add27704e6b49a7ed8557989a8f4a635
Version: v0.6.0
Revision: 9c66f5c432b1d25bdb449a1e588d58b5d0cd7268
License type (autodetected): Apache-2.0
./vendor/github.com/elastic/go-ucfg/LICENSE:
--------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion libbeat/autodiscover/providers/jolokia/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (
// Config for Jolokia Discovery autodiscover provider
type Config struct {
// List of network interfaces to use for discovery probes
Interfaces []InterfaceConfig `config:"interfaces" validate:"nonzero"`
Interfaces []InterfaceConfig `config:"interfaces,replace" validate:"nonzero"`

Builders []*common.Config `config:"builders"`
Appenders []*common.Config `config:"appenders"`
Expand Down
27 changes: 27 additions & 0 deletions libbeat/common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,38 @@ func NewConfig() *Config {
return fromConfig(ucfg.New())
}

// NewConfigFrom creates a new Config object from the given input.
// From can be any kind of structured data (struct, map, array, slice).
//
// If from is a string, the contents is treated like raw YAML input. The string
// will be parsed and a structure config object is build from the parsed
// result.
func NewConfigFrom(from interface{}) (*Config, error) {
if str, ok := from.(string); ok {
c, err := yaml.NewConfig([]byte(str), configOpts...)
return fromConfig(c), err
}

c, err := ucfg.NewFrom(from, configOpts...)
return fromConfig(c), err
}

// MustNewConfigFrom creates a new Config object from the given input.
// From can be any kind of structured data (struct, map, array, slice).
//
// If from is a string, the contents is treated like raw YAML input. The string
// will be parsed and a structure config object is build from the parsed
// result.
//
// MustNewConfigFrom panics if an error occurs.
func MustNewConfigFrom(from interface{}) *Config {
cfg, err := NewConfigFrom(from)
if err != nil {
panic(err)
}
return cfg
}

func MergeConfigs(cfgs ...*Config) (*Config, error) {
config := NewConfig()
for _, c := range cfgs {
Expand Down
11 changes: 10 additions & 1 deletion vendor/github.com/elastic/go-ucfg/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/elastic/go-ucfg/cfgutil/cfgutil.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/elastic/go-ucfg/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/elastic/go-ucfg/error.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/elastic/go-ucfg/errpred.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/elastic/go-ucfg/fieldset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/elastic/go-ucfg/flag/file.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/elastic/go-ucfg/flag/flag.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/elastic/go-ucfg/flag/util.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/elastic/go-ucfg/flag/value.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/elastic/go-ucfg/getset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/elastic/go-ucfg/internal/parse/parse.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/github.com/elastic/go-ucfg/json/json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0ece14d

Please sign in to comment.