Update IsEmpty to check for pre-1.2.4 fields (#11930)
This commit is contained in:
parent
7b5ee8a3f3
commit
460416e787
|
@ -0,0 +1,4 @@
|
||||||
|
```release-note:bug
|
||||||
|
template: Fixed a bug where client template configuration that did not include any
|
||||||
|
of the new 1.2.4 configuration options could result in none of the configuration getting set.
|
||||||
|
```
|
|
@ -450,7 +450,10 @@ func (c *ClientTemplateConfig) IsEmpty() bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.BlockQueryWaitTime == nil &&
|
return !c.DisableSandbox &&
|
||||||
|
len(c.FunctionDenylist) == 0 &&
|
||||||
|
len(c.FunctionBlacklist) == 0 &&
|
||||||
|
c.BlockQueryWaitTime == nil &&
|
||||||
c.BlockQueryWaitTimeHCL == "" &&
|
c.BlockQueryWaitTimeHCL == "" &&
|
||||||
c.MaxStale == nil &&
|
c.MaxStale == nil &&
|
||||||
c.MaxStaleHCL == "" &&
|
c.MaxStaleHCL == "" &&
|
||||||
|
|
|
@ -1413,6 +1413,41 @@ func TestConfig_LoadConsulTemplateConfig(t *testing.T) {
|
||||||
require.Equal(t, 20*time.Second, *templateConfig.VaultRetry.MaxBackoff)
|
require.Equal(t, 20*time.Second, *templateConfig.VaultRetry.MaxBackoff)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestConfig_LoadConsulTemplateBasic(t *testing.T) {
|
||||||
|
defaultConfig := DefaultConfig()
|
||||||
|
|
||||||
|
// hcl
|
||||||
|
agentConfig, err := LoadConfig("test-resources/client_with_basic_template.hcl")
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, agentConfig.Client.TemplateConfig)
|
||||||
|
|
||||||
|
agentConfig = defaultConfig.Merge(agentConfig)
|
||||||
|
|
||||||
|
clientAgent := Agent{config: agentConfig}
|
||||||
|
clientConfig, err := clientAgent.clientConfig()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
templateConfig := clientConfig.TemplateConfig
|
||||||
|
require.NotNil(t, templateConfig)
|
||||||
|
require.True(t, templateConfig.DisableSandbox)
|
||||||
|
require.Len(t, templateConfig.FunctionDenylist, 1)
|
||||||
|
|
||||||
|
// json
|
||||||
|
agentConfig, err = LoadConfig("test-resources/client_with_basic_template.json")
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
agentConfig = defaultConfig.Merge(agentConfig)
|
||||||
|
|
||||||
|
clientAgent = Agent{config: agentConfig}
|
||||||
|
clientConfig, err = clientAgent.clientConfig()
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
templateConfig = clientConfig.TemplateConfig
|
||||||
|
require.NotNil(t, templateConfig)
|
||||||
|
require.True(t, templateConfig.DisableSandbox)
|
||||||
|
require.Len(t, templateConfig.FunctionDenylist, 1)
|
||||||
|
}
|
||||||
|
|
||||||
func TestParseMultipleIPTemplates(t *testing.T) {
|
func TestParseMultipleIPTemplates(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
client {
|
||||||
|
enabled = true
|
||||||
|
|
||||||
|
template {
|
||||||
|
disable_file_sandbox = true
|
||||||
|
function_denylist = []
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"client": {
|
||||||
|
"enabled": true,
|
||||||
|
"template": {
|
||||||
|
"disable_file_sandbox": true,
|
||||||
|
"function_denylist": []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue