vault/internalshared/configutil/merge.go
hashicorp-copywrite[bot] 0b12cdcfd1
[COMPLIANCE] License changes (#22290)
* Adding explicit MPL license for sub-package.

This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository.

* Adding explicit MPL license for sub-package.

This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository.

* Updating the license from MPL to Business Source License.

Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl.

* add missing license headers

* Update copyright file headers to BUS-1.1

* Fix test that expected exact offset on hcl file

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Sarah Thompson <sthompson@hashicorp.com>
Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
2023-08-10 18:14:03 -07:00

103 lines
2.3 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
package configutil
func (c *SharedConfig) Merge(c2 *SharedConfig) *SharedConfig {
if c2 == nil {
return c
}
result := new(SharedConfig)
for _, l := range c.Listeners {
result.Listeners = append(result.Listeners, l)
}
for _, l := range c2.Listeners {
result.Listeners = append(result.Listeners, l)
}
for _, userlockout := range c.UserLockouts {
result.UserLockouts = append(result.UserLockouts, userlockout)
}
for _, userlockout := range c2.UserLockouts {
result.UserLockouts = append(result.UserLockouts, userlockout)
}
result.HCPLinkConf = c.HCPLinkConf
if c2.HCPLinkConf != nil {
result.HCPLinkConf = c2.HCPLinkConf
}
result.Entropy = c.Entropy
if c2.Entropy != nil {
result.Entropy = c2.Entropy
}
for _, s := range c.Seals {
result.Seals = append(result.Seals, s)
}
for _, s := range c2.Seals {
result.Seals = append(result.Seals, s)
}
result.Telemetry = c.Telemetry
if c2.Telemetry != nil {
result.Telemetry = c2.Telemetry
}
result.DisableMlock = c.DisableMlock
if c2.DisableMlock {
result.DisableMlock = c2.DisableMlock
}
result.DefaultMaxRequestDuration = c.DefaultMaxRequestDuration
if c2.DefaultMaxRequestDuration > result.DefaultMaxRequestDuration {
result.DefaultMaxRequestDuration = c2.DefaultMaxRequestDuration
}
result.LogLevel = c.LogLevel
if c2.LogLevel != "" {
result.LogLevel = c2.LogLevel
}
result.LogFormat = c.LogFormat
if c2.LogFormat != "" {
result.LogFormat = c2.LogFormat
}
result.LogFile = c.LogFile
if c2.LogFile != "" {
result.LogFile = c2.LogFile
}
result.LogRotateBytes = c.LogRotateBytes
if c2.LogRotateBytesRaw != nil {
result.LogRotateBytes = c2.LogRotateBytes
result.LogRotateBytesRaw = c2.LogRotateBytesRaw
}
result.LogRotateMaxFiles = c.LogRotateMaxFiles
if c2.LogRotateMaxFilesRaw != nil {
result.LogRotateMaxFiles = c2.LogRotateMaxFiles
result.LogRotateMaxFilesRaw = c2.LogRotateMaxFilesRaw
}
result.LogRotateDuration = c.LogRotateDuration
if c2.LogRotateDuration != "" {
result.LogRotateDuration = c2.LogRotateDuration
}
result.PidFile = c.PidFile
if c2.PidFile != "" {
result.PidFile = c2.PidFile
}
result.ClusterName = c.ClusterName
if c2.ClusterName != "" {
result.ClusterName = c2.ClusterName
}
return result
}