2023-03-28 18:39:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2021-11-16 18:04:01 +00:00
|
|
|
//go:build !consulent
|
2020-01-24 15:04:58 +00:00
|
|
|
// +build !consulent
|
|
|
|
|
|
|
|
package structs
|
|
|
|
|
2022-03-13 03:55:53 +00:00
|
|
|
import (
|
2022-08-15 13:20:25 +00:00
|
|
|
"fmt"
|
|
|
|
|
2022-03-13 03:55:53 +00:00
|
|
|
"github.com/hashicorp/consul/acl"
|
|
|
|
)
|
|
|
|
|
2020-01-24 15:04:58 +00:00
|
|
|
// GetEnterpriseMeta is used to synthesize the EnterpriseMeta struct from
|
|
|
|
// fields in the ServiceRouteDestination
|
2022-03-13 03:55:53 +00:00
|
|
|
func (dest *ServiceRouteDestination) GetEnterpriseMeta(_ *acl.EnterpriseMeta) *acl.EnterpriseMeta {
|
2021-07-22 18:20:45 +00:00
|
|
|
return DefaultEnterpriseMetaInDefaultPartition()
|
2020-01-24 15:04:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetEnterpriseMeta is used to synthesize the EnterpriseMeta struct from
|
|
|
|
// fields in the ServiceSplit
|
2022-03-13 03:55:53 +00:00
|
|
|
func (split *ServiceSplit) GetEnterpriseMeta(_ *acl.EnterpriseMeta) *acl.EnterpriseMeta {
|
2021-07-22 18:20:45 +00:00
|
|
|
return DefaultEnterpriseMetaInDefaultPartition()
|
2020-01-24 15:04:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// GetEnterpriseMeta is used to synthesize the EnterpriseMeta struct from
|
|
|
|
// fields in the ServiceResolverRedirect
|
2022-03-13 03:55:53 +00:00
|
|
|
func (redir *ServiceResolverRedirect) GetEnterpriseMeta(_ *acl.EnterpriseMeta) *acl.EnterpriseMeta {
|
2021-07-22 18:20:45 +00:00
|
|
|
return DefaultEnterpriseMetaInDefaultPartition()
|
2020-01-24 15:04:58 +00:00
|
|
|
}
|
|
|
|
|
2022-08-15 13:20:25 +00:00
|
|
|
// ValidateEnterprise validates that enterprise fields are only set
|
|
|
|
// with enterprise binaries.
|
|
|
|
func (redir *ServiceResolverRedirect) ValidateEnterprise() error {
|
|
|
|
if redir.Partition != "" {
|
|
|
|
return fmt.Errorf("Setting Partition requires Consul Enterprise")
|
|
|
|
}
|
|
|
|
|
|
|
|
if redir.Namespace != "" {
|
|
|
|
return fmt.Errorf("Setting Namespace requires Consul Enterprise")
|
|
|
|
}
|
|
|
|
|
2023-03-17 14:48:06 +00:00
|
|
|
if redir.SamenessGroup != "" {
|
|
|
|
return fmt.Errorf("Setting SamenessGroup requires Consul Enterprise")
|
|
|
|
}
|
|
|
|
|
2022-08-15 13:20:25 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-01-24 15:04:58 +00:00
|
|
|
// GetEnterpriseMeta is used to synthesize the EnterpriseMeta struct from
|
|
|
|
// fields in the ServiceResolverFailover
|
2022-03-13 03:55:53 +00:00
|
|
|
func (failover *ServiceResolverFailover) GetEnterpriseMeta(_ *acl.EnterpriseMeta) *acl.EnterpriseMeta {
|
2021-07-22 18:20:45 +00:00
|
|
|
return DefaultEnterpriseMetaInDefaultPartition()
|
2020-01-24 15:04:58 +00:00
|
|
|
}
|
|
|
|
|
2022-08-15 13:20:25 +00:00
|
|
|
// ValidateEnterprise validates that enterprise fields are only set
|
|
|
|
// with enterprise binaries.
|
|
|
|
func (failover *ServiceResolverFailover) ValidateEnterprise() error {
|
|
|
|
if failover.Namespace != "" {
|
|
|
|
return fmt.Errorf("Setting Namespace requires Consul Enterprise")
|
|
|
|
}
|
|
|
|
|
2023-03-17 14:48:06 +00:00
|
|
|
if failover.SamenessGroup != "" {
|
|
|
|
return fmt.Errorf("Setting SamenessGroup requires Consul Enterprise")
|
|
|
|
}
|
|
|
|
|
2022-08-15 13:20:25 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetEnterpriseMeta is used to synthesize the EnterpriseMeta struct from
|
|
|
|
// fields in the ServiceResolverFailoverTarget
|
|
|
|
func (target *ServiceResolverFailoverTarget) GetEnterpriseMeta(_ *acl.EnterpriseMeta) *acl.EnterpriseMeta {
|
|
|
|
return DefaultEnterpriseMetaInDefaultPartition()
|
|
|
|
}
|
|
|
|
|
|
|
|
// ValidateEnterprise validates that enterprise fields are only set
|
|
|
|
// with enterprise binaries.
|
|
|
|
func (redir *ServiceResolverFailoverTarget) ValidateEnterprise() error {
|
|
|
|
if redir.Partition != "" {
|
|
|
|
return fmt.Errorf("Setting Partition requires Consul Enterprise")
|
|
|
|
}
|
|
|
|
|
|
|
|
if redir.Namespace != "" {
|
|
|
|
return fmt.Errorf("Setting Namespace requires Consul Enterprise")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-01-24 15:04:58 +00:00
|
|
|
// GetEnterpriseMeta is used to synthesize the EnterpriseMeta struct from
|
|
|
|
// fields in the DiscoveryChainRequest
|
2022-03-13 03:55:53 +00:00
|
|
|
func (req *DiscoveryChainRequest) GetEnterpriseMeta() *acl.EnterpriseMeta {
|
2021-07-22 18:20:45 +00:00
|
|
|
return DefaultEnterpriseMetaInDefaultPartition()
|
2020-01-24 15:04:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// WithEnterpriseMeta will populate the corresponding fields in the
|
|
|
|
// DiscoveryChainRequest from the EnterpriseMeta struct
|
2022-03-13 03:55:53 +00:00
|
|
|
func (req *DiscoveryChainRequest) WithEnterpriseMeta(_ *acl.EnterpriseMeta) {
|
2020-01-24 15:04:58 +00:00
|
|
|
// do nothing
|
|
|
|
}
|
2023-03-03 16:12:38 +00:00
|
|
|
|
|
|
|
// ValidateEnterprise validates that enterprise fields are only set
|
|
|
|
// with enterprise binaries.
|
|
|
|
func (f *ServiceResolverFailoverPolicy) ValidateEnterprise() error {
|
|
|
|
if f == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if f.Mode != "" {
|
|
|
|
return fmt.Errorf("Setting failover policies requires Consul Enterprise")
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2023-03-17 14:48:06 +00:00
|
|
|
|
|
|
|
// RelatedSamenessGroups doesn't return anything on open source.
|
|
|
|
func (e *ServiceResolverConfigEntry) RelatedSamenessGroups() []string {
|
|
|
|
return nil
|
|
|
|
}
|
2023-04-14 20:42:54 +00:00
|
|
|
|
|
|
|
func (pbl *ServiceResolverPrioritizeByLocality) validate() error {
|
|
|
|
var zero ServiceResolverPrioritizeByLocality
|
|
|
|
if pbl == nil || *pbl == zero {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return fmt.Errorf("Prioritize-by-locality requires Consul Enterprise ")
|
|
|
|
}
|