2023-03-28 19:39:22 +01:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-08-11 09:12:13 -04:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-28 19:39:22 +01:00
|
|
|
|
2021-11-16 12:04:01 -06:00
|
|
|
//go:build !consulent
|
2019-12-09 21:26:41 -05:00
|
|
|
// +build !consulent
|
|
|
|
|
|
|
|
package config
|
|
|
|
|
2020-04-28 09:45:33 -04:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2020-11-20 17:43:32 -05:00
|
|
|
// validateEnterpriseConfig is a function to validate the enterprise specific
|
|
|
|
// configuration items after Parsing but before merging into the overall
|
|
|
|
// configuration. The original intent is to use it to ensure that we warn
|
2023-08-22 09:46:03 -05:00
|
|
|
// for enterprise configurations used in CE.
|
2020-11-20 17:43:32 -05:00
|
|
|
func validateEnterpriseConfigKeys(config *Config) []error {
|
|
|
|
var result []error
|
|
|
|
add := func(k string) {
|
|
|
|
result = append(result, enterpriseConfigKeyError{key: k})
|
2020-04-28 09:45:33 -04:00
|
|
|
}
|
2020-11-20 17:43:32 -05:00
|
|
|
|
|
|
|
if config.ReadReplica != nil {
|
|
|
|
add(`read_replica (or the deprecated non_voting_server)`)
|
|
|
|
}
|
|
|
|
if stringVal(config.SegmentName) != "" {
|
|
|
|
add("segment")
|
|
|
|
}
|
|
|
|
if len(config.Segments) > 0 {
|
|
|
|
add("segments")
|
|
|
|
}
|
2021-07-08 10:03:38 -05:00
|
|
|
if stringVal(config.Partition) != "" {
|
|
|
|
add("partition")
|
|
|
|
}
|
2020-11-20 17:43:32 -05:00
|
|
|
if stringVal(config.Autopilot.RedundancyZoneTag) != "" {
|
|
|
|
add("autopilot.redundancy_zone_tag")
|
|
|
|
}
|
|
|
|
if stringVal(config.Autopilot.UpgradeVersionTag) != "" {
|
|
|
|
add("autopilot.upgrade_version_tag")
|
|
|
|
}
|
|
|
|
if config.Autopilot.DisableUpgradeMigration != nil {
|
|
|
|
add("autopilot.disable_upgrade_migration")
|
|
|
|
}
|
|
|
|
if config.DNS.PreferNamespace != nil {
|
|
|
|
add("dns_config.prefer_namespace")
|
|
|
|
config.DNS.PreferNamespace = nil
|
|
|
|
}
|
|
|
|
if config.ACL.MSPDisableBootstrap != nil {
|
|
|
|
add("acl.msp_disable_bootstrap")
|
|
|
|
config.ACL.MSPDisableBootstrap = nil
|
|
|
|
}
|
|
|
|
if len(config.ACL.Tokens.ManagedServiceProvider) > 0 {
|
|
|
|
add("acl.tokens.managed_service_provider")
|
|
|
|
config.ACL.Tokens.ManagedServiceProvider = nil
|
|
|
|
}
|
2021-05-06 17:09:18 -04:00
|
|
|
if boolVal(config.Audit.Enabled) || len(config.Audit.Sinks) > 0 {
|
2020-11-20 17:43:32 -05:00
|
|
|
add("audit")
|
|
|
|
}
|
2021-05-10 10:10:39 -04:00
|
|
|
if config.LicensePath != nil {
|
|
|
|
add("license_path")
|
|
|
|
config.LicensePath = nil
|
|
|
|
}
|
2023-04-11 15:04:02 -04:00
|
|
|
if config.Reporting.License.Enabled != nil {
|
|
|
|
add("reporting.license.enabled")
|
|
|
|
config.Reporting.License.Enabled = nil
|
|
|
|
}
|
2020-11-20 17:43:32 -05:00
|
|
|
|
|
|
|
return result
|
|
|
|
}
|
2020-04-28 09:45:33 -04:00
|
|
|
|
|
|
|
type enterpriseConfigKeyError struct {
|
|
|
|
key string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e enterpriseConfigKeyError) Error() string {
|
|
|
|
return fmt.Sprintf("%q is a Consul Enterprise configuration and will have no effect", e.key)
|
|
|
|
}
|
|
|
|
|
2020-12-21 13:55:53 -05:00
|
|
|
func (*builder) BuildEnterpriseRuntimeConfig(_ *RuntimeConfig, _ *Config) error {
|
2020-08-27 13:15:10 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-12-21 13:55:53 -05:00
|
|
|
func (*builder) validateEnterpriseConfig(_ RuntimeConfig) error {
|
2020-08-27 13:15:10 -04:00
|
|
|
return nil
|
2019-12-09 21:26:41 -05:00
|
|
|
}
|