Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: elastic/go-ucfg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.6.4
Choose a base ref
...
head repository: elastic/go-ucfg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.6.5
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Oct 26, 2018

  1. Adding a ResolverNOOP (#122)

    This resolver will return the key wrapped in the field reference syntax.
    This allow you to hide sensitive information present in the environment
    or by other resolvers.
    ph authored Oct 26, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    6a5daf7 View commit details
  2. Prepare for v0.6.5 (#123)

    Update changelog for v0.6.5 release
    ph authored Oct 26, 2018
    Copy the full SHA
    92d4388 View commit details
Showing with 40 additions and 1 deletion.
  1. +7 −1 CHANGELOG.md
  2. +13 −0 opts.go
  3. +20 −0 ucfg_test.go
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -14,6 +14,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Fixed

## [0.6.5]

### Added
- Added a NOOP Resolver that will return the key wrapped in the field reference syntax. #122

## [0.6.4]

### Fixed
@@ -220,7 +225,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Introduced CHANGELOG.md for documenting changes to ucfg.


[Unreleased]: https://github.com/elastic/go-ucfg/compare/v0.6.4...HEAD
[Unreleased]: https://github.com/elastic/go-ucfg/compare/v0.6.5...HEAD
[0.6.4]: https://github.com/elastic/go-ucfg/compare/v0.6.4...v0.6.5
[0.6.4]: https://github.com/elastic/go-ucfg/compare/v0.6.3...v0.6.4
[0.6.3]: https://github.com/elastic/go-ucfg/compare/v0.6.2...v0.6.3
[0.6.2]: https://github.com/elastic/go-ucfg/compare/v0.6.1...v0.6.2
13 changes: 13 additions & 0 deletions opts.go
Original file line number Diff line number Diff line change
@@ -123,6 +123,19 @@ func doResolveEnv(o *options) {
})
}

// ResolveNOOP option add a resolver that will not search the value but instead will return the
// provided key wrap with the field reference syntax. This is useful if you don't to expose values
// from envionment variable or other resolvers.
//
// Example: "mysecret" => ${mysecret}"
var ResolveNOOP Option = doResolveNOOP

func doResolveNOOP(o *options) {
o.resolvers = append(o.resolvers, func(name string) (string, error) {
return "${" + name + "}", nil
})
}

var (
// ReplacesValues option configures all merging and unpacking operations to
// replace old dictionaries and arrays while merging. Value merging can be
20 changes: 20 additions & 0 deletions ucfg_test.go
Original file line number Diff line number Diff line change
@@ -300,3 +300,23 @@ func TestMultipleDirectReference(t *testing.T) {
}
})
}

func TestResolveNOOP(t *testing.T) {
opts := []Option{
PathSep("."),
ResolveNOOP,
}

cfg := map[string]interface{}{
"a.top": "top-level",
"f.l.reference": "${a.key}",
}

c, err := NewFrom(cfg, opts...)
assert.NoError(t, err)

v, err := c.String("f.l.reference", -1, opts...)
if assert.NoError(t, err) {
assert.Equal(t, "${a.key}", v)
}
}