Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update IsEmpty logic in finalizeClientTemplateConfig #11930

Merged
merged 1 commit into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .changelog/11902.txt
Original file line number Diff line number Diff line change
@@ -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.
```
5 changes: 4 additions & 1 deletion client/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,10 @@ func (c *ClientTemplateConfig) IsEmpty() bool {
return true
}

return c.BlockQueryWaitTime == nil &&
return !c.DisableSandbox &&
len(c.FunctionDenylist) == 0 &&
len(c.FunctionBlacklist) == 0 &&
c.BlockQueryWaitTime == nil &&
c.BlockQueryWaitTimeHCL == "" &&
c.MaxStale == nil &&
c.MaxStaleHCL == "" &&
Expand Down
35 changes: 35 additions & 0 deletions command/agent/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,41 @@ func TestConfig_LoadConsulTemplateConfig(t *testing.T) {
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) {
testCases := []struct {
name string
Expand Down
9 changes: 9 additions & 0 deletions command/agent/test-resources/client_with_basic_template.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

client {
enabled = true

template {
disable_file_sandbox = true
function_denylist = []
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"client": {
"enabled": true,
"template": {
"disable_file_sandbox": true,
"function_denylist": []
}
}
}