report listener and storage types as found keys (#15383)
* report listener and storage types as found keys * changelog
This commit is contained in:
parent
01bd627ee9
commit
0c955eb743
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:bug
|
||||||
|
command: do not report listener and storage types as key not found warnings
|
||||||
|
```
|
|
@ -562,6 +562,7 @@ func ParseConfig(d, source string) (*Config, error) {
|
||||||
if err := ParseStorage(result, o, "storage"); err != nil {
|
if err := ParseStorage(result, o, "storage"); err != nil {
|
||||||
return nil, fmt.Errorf("error parsing 'storage': %w", err)
|
return nil, fmt.Errorf("error parsing 'storage': %w", err)
|
||||||
}
|
}
|
||||||
|
result.found(result.Storage.Type, result.Storage.Type)
|
||||||
} else {
|
} else {
|
||||||
delete(result.UnusedKeys, "backend")
|
delete(result.UnusedKeys, "backend")
|
||||||
if o := list.Filter("backend"); len(o.Items) > 0 {
|
if o := list.Filter("backend"); len(o.Items) > 0 {
|
||||||
|
@ -967,3 +968,8 @@ func (c *Config) Prune() {
|
||||||
c.Telemetry.UnusedKeys = nil
|
c.Telemetry.UnusedKeys = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Config) found(s, k string) {
|
||||||
|
delete(c.UnusedKeys, s)
|
||||||
|
c.FoundKeys = append(c.FoundKeys, k)
|
||||||
|
}
|
||||||
|
|
|
@ -51,3 +51,7 @@ func TestParseSeals(t *testing.T) {
|
||||||
func TestUnknownFieldValidation(t *testing.T) {
|
func TestUnknownFieldValidation(t *testing.T) {
|
||||||
testUnknownFieldValidation(t)
|
testUnknownFieldValidation(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestUnknownFieldValidationListenerAndStorage(t *testing.T) {
|
||||||
|
testUnknownFieldValidationStorageAndListener(t)
|
||||||
|
}
|
||||||
|
|
|
@ -525,6 +525,16 @@ func testUnknownFieldValidation(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testUnknownFieldValidationStorageAndListener(t *testing.T) {
|
||||||
|
config, err := LoadConfigFile("./test-fixtures/storage-listener-config.json")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("err: %s", err)
|
||||||
|
}
|
||||||
|
if len(config.UnusedKeys) != 0 {
|
||||||
|
t.Fatalf("unused keys for valid config are %+v\n", config.UnusedKeys)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func testLoadConfigFile_json(t *testing.T) {
|
func testLoadConfigFile_json(t *testing.T) {
|
||||||
config, err := LoadConfigFile("./test-fixtures/config.hcl.json")
|
config, err := LoadConfigFile("./test-fixtures/config.hcl.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"api_addr": "https://localhost:8200",
|
||||||
|
"default_lease_ttl": "6h",
|
||||||
|
"disable_mlock": true,
|
||||||
|
"listener": {
|
||||||
|
"tcp": {
|
||||||
|
"address": "0.0.0.0:8200"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"log_level": "info",
|
||||||
|
"storage": {
|
||||||
|
"consul": {
|
||||||
|
"address": "127.0.0.1:8500"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ui": true
|
||||||
|
}
|
|
@ -167,6 +167,7 @@ func ParseListeners(result *SharedConfig, list *ast.ObjectList) error {
|
||||||
l.Type = strings.ToLower(l.Type)
|
l.Type = strings.ToLower(l.Type)
|
||||||
switch l.Type {
|
switch l.Type {
|
||||||
case "tcp", "unix":
|
case "tcp", "unix":
|
||||||
|
result.found(l.Type, l.Type)
|
||||||
default:
|
default:
|
||||||
return multierror.Prefix(fmt.Errorf("unsupported listener type %q", l.Type), fmt.Sprintf("listeners.%d:", i))
|
return multierror.Prefix(fmt.Errorf("unsupported listener type %q", l.Type), fmt.Sprintf("listeners.%d:", i))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue