Change name of public function

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2019-05-30 16:25:37 -06:00
parent 437e16ca71
commit 451d4bb05c
2 changed files with 8 additions and 7 deletions

View File

@@ -37,12 +37,13 @@ import (
var allowUnknownTopLevelField = int32(0)
// AllowUnknownTopLevelConfigurationField sets if the processing of a
// configuration file returns an error if it finds an unknown top-level
// configuration option.
func AllowUnknownTopLevelConfigurationField(allow bool) {
// NoErrOnUnknownFields can be used to change the behavior the processing
// of a configuration file. By default, an error is reported if unknown
// fields are found. If `noError` is set to true, no error will be reported
// if top-level unknown fields are found.
func NoErrOnUnknownFields(noError bool) {
var val int32
if allow {
if noError {
val = int32(1)
}
atomic.StoreInt32(&allowUnknownTopLevelField, val)

View File

@@ -1836,8 +1836,8 @@ func TestHandleUnknownTopLevelConfigurationField(t *testing.T) {
}
// Verify that if that is set, we get no error
AllowUnknownTopLevelConfigurationField(true)
defer AllowUnknownTopLevelConfigurationField(false)
NoErrOnUnknownFields(true)
defer NoErrOnUnknownFields(false)
if err := opts.ProcessConfigFile(conf); err != nil {
t.Fatalf("Unexpected error: %v", err)