diff --git a/agent/structs/config_entry.go b/agent/structs/config_entry.go index 922076a82..5a5536094 100644 --- a/agent/structs/config_entry.go +++ b/agent/structs/config_entry.go @@ -306,8 +306,11 @@ func DecodeConfigEntry(raw map[string]interface{}) (ConfigEntry, error) { } for _, k := range md.Unused { - switch k { - case "CreateIndex", "ModifyIndex": + switch { + case k == "CreateIndex" || k == "ModifyIndex": + break + case strings.HasSuffix(strings.ToLower(k), "namespace"): + err = multierror.Append(err, fmt.Errorf("invalid config key %q, namespaces is a consul enterprise feature", k)) default: err = multierror.Append(err, fmt.Errorf("invalid config key %q", k)) } diff --git a/agent/structs/config_entry_test.go b/agent/structs/config_entry_test.go index 9f699aa2c..1819f64c4 100644 --- a/agent/structs/config_entry_test.go +++ b/agent/structs/config_entry_test.go @@ -86,6 +86,59 @@ func TestDecodeConfigEntry(t *testing.T) { }, }, }, + { + name: "namespaces invalid top level", + snake: ` + kind = "terminating-gateway" + name = "terminating-gateway" + namespace = "foo" + `, + camel: ` + Kind = "terminating-gateway" + Name = "terminating-gateway" + Namespace = "foo" + `, + expectErr: `invalid config key "namespace", namespaces is a consul enterprise feature`, + }, + { + name: "namespaces invalid deep", + snake: ` + kind = "ingress-gateway" + name = "ingress-web" + listeners = [ + { + port = 8080 + protocol = "http" + services = [ + { + name = "web" + hosts = ["test.example.com", "test2.example.com"] + namespace = "frontend" + }, + ] + } + ] + `, + camel: ` + Kind = "ingress-gateway" + Name = "ingress-web" + Namespace = "blah" + Listeners = [ + { + Port = 8080 + Protocol = "http" + Services = [ + { + Name = "web" + Hosts = ["test.example.com", "test2.example.com"] + Namespace = "frontend" + }, + ] + }, + ] + `, + expectErr: `invalid config key "listeners[0].services[0].namespace", namespaces is a consul enterprise feature`, + }, { name: "service-defaults", snake: `