OSS changes to allow for parsing the enterprise DNS config prop… (#6959)

pull/6969/head
Matt Keeler 2019-12-18 10:16:35 -05:00 committed by GitHub
parent d2d1f98423
commit 3faee222f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 6 deletions

View File

@ -99,7 +99,7 @@ func NewBuilder(flags Flags) (*Builder, error) {
b := &Builder{ b := &Builder{
Flags: flags, Flags: flags,
Head: []Source{DefaultSource()}, Head: []Source{DefaultSource(), DefaultEnterpriseSource()},
} }
if b.boolVal(b.Flags.DevMode) { if b.boolVal(b.Flags.DevMode) {
@ -128,7 +128,7 @@ func NewBuilder(flags Flags) (*Builder, error) {
Data: s, Data: s,
}) })
} }
b.Tail = append(b.Tail, NonUserSource(), DefaultConsulSource(), DefaultEnterpriseSource(), DefaultVersionSource()) b.Tail = append(b.Tail, NonUserSource(), DefaultConsulSource(), OverrideEnterpriseSource(), DefaultVersionSource())
if b.boolVal(b.Flags.DevMode) { if b.boolVal(b.Flags.DevMode) {
b.Tail = append(b.Tail, DevConsulSource()) b.Tail = append(b.Tail, DevConsulSource())
} }

View File

@ -2,11 +2,22 @@
package config package config
// DefaultEnterpriseSource returns the consul agent configuration for the enterprise mode. // DefaultEnterpriseSource returns the consul agent configuration for enterprise mode.
// This should be merged in the tail after the DefaultConsulSource. // These can be overridden by the user and therefore this source should be merged in the
// head and processed before user configuration.
func DefaultEnterpriseSource() Source { func DefaultEnterpriseSource() Source {
return Source{ return Source{
Name: "enterprise", Name: "enterprise-defaults",
Format: "hcl",
Data: ``,
}
}
// OverrideEnterpriseSource returns the consul agent configuration for the enterprise mode.
// This should be merged in the tail after the DefaultConsulSource.
func OverrideEnterpriseSource() Source {
return Source{
Name: "enterprise-overrides",
Format: "hcl", Format: "hcl",
Data: ``, Data: ``,
} }

View File

@ -5,3 +5,9 @@ package config
var entMetaJSON = `{}` var entMetaJSON = `{}`
var entRuntimeConfigSanitize = `{}` var entRuntimeConfigSanitize = `{}`
var entFullDNSJSONConfig = ``
var entFullDNSHCLConfig = ``
var entFullRuntimeConfig = EnterpriseRuntimeConfig{}

View File

@ -3782,7 +3782,7 @@ func TestFullConfig(t *testing.T) {
}, },
"udp_answer_limit": 29909, "udp_answer_limit": 29909,
"use_cache": true, "use_cache": true,
"cache_max_age": "5m" "cache_max_age": "5m"` + entFullDNSJSONConfig + `
}, },
"enable_acl_replication": true, "enable_acl_replication": true,
"enable_agent_tls_for_checks": true, "enable_agent_tls_for_checks": true,
@ -4382,6 +4382,7 @@ func TestFullConfig(t *testing.T) {
udp_answer_limit = 29909 udp_answer_limit = 29909
use_cache = true use_cache = true
cache_max_age = "5m" cache_max_age = "5m"
` + entFullDNSHCLConfig + `
} }
enable_acl_replication = true enable_acl_replication = true
enable_agent_tls_for_checks = true enable_agent_tls_for_checks = true
@ -5484,6 +5485,7 @@ func TestFullConfig(t *testing.T) {
"args": []interface{}{"dltjDJ2a", "flEa7C2d"}, "args": []interface{}{"dltjDJ2a", "flEa7C2d"},
}, },
}, },
EnterpriseRuntimeConfig: entFullRuntimeConfig,
} }
warns := []string{ warns := []string{