mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
consul-template: revert function_denylist logic (#12071)
* consul-template: replace config rather than append Co-authored-by: Seth Hoenig <seth.a.hoenig@gmail.com>
This commit is contained in:
@@ -396,78 +396,6 @@ func (c *ClientTemplateConfig) Copy() *ClientTemplateConfig {
|
||||
return nc
|
||||
}
|
||||
|
||||
// Merge merges the values of two ClientTemplateConfigs. If first copies the receiver
|
||||
// instance, and then overrides those values with the instance to merge with.
|
||||
func (c *ClientTemplateConfig) Merge(b *ClientTemplateConfig) *ClientTemplateConfig {
|
||||
if c == nil {
|
||||
return b
|
||||
}
|
||||
|
||||
result := *c
|
||||
|
||||
if b == nil {
|
||||
return &result
|
||||
}
|
||||
|
||||
if b.BlockQueryWaitTime != nil {
|
||||
result.BlockQueryWaitTime = b.BlockQueryWaitTime
|
||||
}
|
||||
if b.BlockQueryWaitTimeHCL != "" {
|
||||
result.BlockQueryWaitTimeHCL = b.BlockQueryWaitTimeHCL
|
||||
}
|
||||
|
||||
if b.ConsulRetry != nil {
|
||||
result.ConsulRetry = result.ConsulRetry.Merge(b.ConsulRetry)
|
||||
}
|
||||
|
||||
result.DisableSandbox = b.DisableSandbox
|
||||
|
||||
// Maintain backward compatibility for older clients
|
||||
if len(b.FunctionBlacklist) > 0 {
|
||||
for _, fn := range b.FunctionBlacklist {
|
||||
if !helper.SliceStringContains(result.FunctionBlacklist, fn) {
|
||||
result.FunctionBlacklist = append(result.FunctionBlacklist, fn)
|
||||
}
|
||||
}
|
||||
} else if b.FunctionBlacklist != nil {
|
||||
// No funcs denied
|
||||
result.FunctionBlacklist = []string{}
|
||||
}
|
||||
|
||||
if len(b.FunctionDenylist) > 0 {
|
||||
for _, fn := range b.FunctionDenylist {
|
||||
if !helper.SliceStringContains(result.FunctionDenylist, fn) {
|
||||
result.FunctionDenylist = append(result.FunctionDenylist, fn)
|
||||
}
|
||||
}
|
||||
} else if b.FunctionDenylist != nil {
|
||||
// No funcs denied
|
||||
result.FunctionDenylist = []string{}
|
||||
}
|
||||
|
||||
if b.MaxStale != nil {
|
||||
result.MaxStale = b.MaxStale
|
||||
}
|
||||
|
||||
if b.MaxStaleHCL != "" {
|
||||
result.MaxStaleHCL = b.MaxStaleHCL
|
||||
}
|
||||
|
||||
if b.Wait != nil {
|
||||
result.Wait = result.Wait.Merge(b.Wait)
|
||||
}
|
||||
|
||||
if b.WaitBounds != nil {
|
||||
result.WaitBounds = result.WaitBounds.Merge(b.WaitBounds)
|
||||
}
|
||||
|
||||
if b.VaultRetry != nil {
|
||||
result.VaultRetry = result.VaultRetry.Merge(b.VaultRetry)
|
||||
}
|
||||
|
||||
return &result
|
||||
}
|
||||
|
||||
func (c *ClientTemplateConfig) IsEmpty() bool {
|
||||
if c == nil {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user