2019-10-24 14:38:09 -04:00
|
|
|
// +build !consulent
|
|
|
|
|
|
|
|
package structs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"hash"
|
|
|
|
|
|
|
|
"github.com/hashicorp/consul/acl"
|
2020-01-03 15:51:19 -05:00
|
|
|
"github.com/hashicorp/consul/types"
|
2019-10-24 14:38:09 -04:00
|
|
|
)
|
|
|
|
|
2019-12-06 14:01:34 -05:00
|
|
|
var emptyEnterpriseMeta = EnterpriseMeta{}
|
|
|
|
|
2019-10-24 14:38:09 -04:00
|
|
|
// EnterpriseMeta stub
|
|
|
|
type EnterpriseMeta struct{}
|
|
|
|
|
|
|
|
func (m *EnterpriseMeta) estimateSize() int {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2019-12-06 14:01:34 -05:00
|
|
|
func (m *EnterpriseMeta) addToHash(_ hash.Hash, _ bool) {
|
2019-10-24 14:38:09 -04:00
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
2019-12-18 13:46:53 -05:00
|
|
|
func (m *EnterpriseMeta) Merge(_ *EnterpriseMeta) {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
2020-01-24 10:04:58 -05:00
|
|
|
func (m *EnterpriseMeta) MergeNoWildcard(_ *EnterpriseMeta) {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
2019-12-09 21:26:41 -05:00
|
|
|
func (m *EnterpriseMeta) Matches(_ *EnterpriseMeta) bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *EnterpriseMeta) IsSame(_ *EnterpriseMeta) bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *EnterpriseMeta) LessThan(_ *EnterpriseMeta) bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-09-17 19:36:20 -04:00
|
|
|
func (m *EnterpriseMeta) WithWildcardNamespace() *EnterpriseMeta {
|
2021-07-22 13:20:45 -05:00
|
|
|
return &emptyEnterpriseMeta
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(partition): stop using this
|
|
|
|
func NewEnterpriseMetaInDefaultPartition(_ string) EnterpriseMeta {
|
|
|
|
return emptyEnterpriseMeta
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewEnterpriseMetaWithPartition(_, _ string) EnterpriseMeta {
|
|
|
|
return emptyEnterpriseMeta
|
|
|
|
}
|
|
|
|
|
2020-01-24 10:04:58 -05:00
|
|
|
func (m *EnterpriseMeta) NamespaceOrDefault() string {
|
2020-03-31 09:59:10 -07:00
|
|
|
return IntentionDefaultNamespace
|
2020-01-24 10:04:58 -05:00
|
|
|
}
|
|
|
|
|
2021-06-25 16:47:47 -05:00
|
|
|
func NamespaceOrDefault(_ string) string {
|
|
|
|
return IntentionDefaultNamespace
|
|
|
|
}
|
|
|
|
|
2020-06-26 16:59:15 -05:00
|
|
|
func (m *EnterpriseMeta) NamespaceOrEmpty() string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:40:47 +01:00
|
|
|
func (m *EnterpriseMeta) InDefaultNamespace() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2021-03-31 16:21:21 -04:00
|
|
|
func (m *EnterpriseMeta) PartitionOrDefault() string {
|
2021-08-12 14:31:37 -07:00
|
|
|
return "default"
|
2021-03-31 16:21:21 -04:00
|
|
|
}
|
|
|
|
|
2021-10-26 15:08:55 -05:00
|
|
|
func EqualPartitions(_, _ string) bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
func IsDefaultPartition(partition string) bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2021-06-25 16:47:47 -05:00
|
|
|
func PartitionOrDefault(_ string) string {
|
2021-08-12 14:31:37 -07:00
|
|
|
return "default"
|
2021-06-25 16:47:47 -05:00
|
|
|
}
|
|
|
|
|
2021-03-31 16:21:21 -04:00
|
|
|
func (m *EnterpriseMeta) PartitionOrEmpty() string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2021-08-25 13:40:47 +01:00
|
|
|
func (m *EnterpriseMeta) InDefaultPartition() bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2019-10-24 14:38:09 -04:00
|
|
|
// ReplicationEnterpriseMeta stub
|
|
|
|
func ReplicationEnterpriseMeta() *EnterpriseMeta {
|
2019-12-06 14:01:34 -05:00
|
|
|
return &emptyEnterpriseMeta
|
2019-10-24 14:38:09 -04:00
|
|
|
}
|
|
|
|
|
2021-07-22 13:20:45 -05:00
|
|
|
// TODO(partition): stop using this
|
|
|
|
func DefaultEnterpriseMetaInDefaultPartition() *EnterpriseMeta {
|
|
|
|
return &emptyEnterpriseMeta
|
|
|
|
}
|
|
|
|
|
|
|
|
// DefaultEnterpriseMetaInPartition stub
|
|
|
|
func DefaultEnterpriseMetaInPartition(_ string) *EnterpriseMeta {
|
|
|
|
return &emptyEnterpriseMeta
|
|
|
|
}
|
|
|
|
|
|
|
|
func NodeEnterpriseMetaInPartition(_ string) *EnterpriseMeta {
|
|
|
|
return &emptyEnterpriseMeta
|
|
|
|
}
|
|
|
|
|
2021-07-22 14:33:22 -05:00
|
|
|
// TODO(partition): stop using this
|
2021-07-22 13:20:45 -05:00
|
|
|
func NodeEnterpriseMetaInDefaultPartition() *EnterpriseMeta {
|
|
|
|
return &emptyEnterpriseMeta
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(partition): stop using this
|
|
|
|
func WildcardEnterpriseMetaInDefaultPartition() *EnterpriseMeta {
|
2019-12-06 14:01:34 -05:00
|
|
|
return &emptyEnterpriseMeta
|
2019-10-24 14:38:09 -04:00
|
|
|
}
|
|
|
|
|
2021-07-22 13:20:45 -05:00
|
|
|
// WildcardEnterpriseMetaInPartition stub
|
|
|
|
func WildcardEnterpriseMetaInPartition(_ string) *EnterpriseMeta {
|
2019-12-06 14:01:34 -05:00
|
|
|
return &emptyEnterpriseMeta
|
|
|
|
}
|
2019-10-24 14:38:09 -04:00
|
|
|
|
|
|
|
// FillAuthzContext stub
|
2019-12-18 13:43:24 -05:00
|
|
|
func (_ *EnterpriseMeta) FillAuthzContext(_ *acl.AuthorizerContext) {}
|
2019-11-01 16:48:44 -04:00
|
|
|
|
2021-08-25 13:43:11 -05:00
|
|
|
func (_ *Node) FillAuthzContext(_ *acl.AuthorizerContext) {}
|
|
|
|
|
|
|
|
func (_ *Coordinate) FillAuthzContext(_ *acl.AuthorizerContext) {}
|
|
|
|
|
|
|
|
func (_ *NodeInfo) FillAuthzContext(_ *acl.AuthorizerContext) {}
|
|
|
|
|
2019-12-09 21:26:41 -05:00
|
|
|
func (_ *EnterpriseMeta) Normalize() {}
|
|
|
|
|
|
|
|
// FillAuthzContext stub
|
2019-12-18 13:43:24 -05:00
|
|
|
func (_ *DirEntry) FillAuthzContext(_ *acl.AuthorizerContext) {}
|
2019-12-09 21:26:41 -05:00
|
|
|
|
2019-11-01 16:48:44 -04:00
|
|
|
// FillAuthzContext stub
|
2019-12-18 13:43:24 -05:00
|
|
|
func (_ *RegisterRequest) FillAuthzContext(_ *acl.AuthorizerContext) {}
|
2019-12-09 21:26:41 -05:00
|
|
|
|
|
|
|
func (_ *RegisterRequest) GetEnterpriseMeta() *EnterpriseMeta {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// OSS Stub
|
2019-12-18 13:43:24 -05:00
|
|
|
func (op *TxnNodeOp) FillAuthzContext(ctx *acl.AuthorizerContext) {}
|
2019-12-09 21:26:41 -05:00
|
|
|
|
|
|
|
// OSS Stub
|
2019-12-18 13:43:24 -05:00
|
|
|
func (_ *TxnServiceOp) FillAuthzContext(_ *acl.AuthorizerContext) {}
|
2019-12-09 21:26:41 -05:00
|
|
|
|
|
|
|
// OSS Stub
|
2019-12-18 13:43:24 -05:00
|
|
|
func (_ *TxnCheckOp) FillAuthzContext(_ *acl.AuthorizerContext) {}
|
2019-12-09 21:26:41 -05:00
|
|
|
|
2021-08-25 13:43:11 -05:00
|
|
|
func NodeNameString(node string, _ *EnterpriseMeta) string {
|
|
|
|
return node
|
|
|
|
}
|
|
|
|
|
2019-12-09 21:26:41 -05:00
|
|
|
func ServiceIDString(id string, _ *EnterpriseMeta) string {
|
|
|
|
return id
|
|
|
|
}
|
|
|
|
|
2020-01-24 10:04:58 -05:00
|
|
|
func ParseServiceIDString(input string) (string, *EnterpriseMeta) {
|
2021-07-22 13:20:45 -05:00
|
|
|
return input, DefaultEnterpriseMetaInDefaultPartition()
|
2020-01-24 10:04:58 -05:00
|
|
|
}
|
|
|
|
|
2020-12-11 16:10:00 -05:00
|
|
|
func (sid ServiceID) String() string {
|
2019-12-09 21:26:41 -05:00
|
|
|
return sid.ID
|
|
|
|
}
|
|
|
|
|
2020-01-24 10:04:58 -05:00
|
|
|
func ServiceIDFromString(input string) ServiceID {
|
|
|
|
id, _ := ParseServiceIDString(input)
|
|
|
|
return ServiceID{ID: id}
|
|
|
|
}
|
|
|
|
|
2020-06-12 08:57:41 -06:00
|
|
|
func ParseServiceNameString(input string) (string, *EnterpriseMeta) {
|
2021-07-22 13:20:45 -05:00
|
|
|
return input, DefaultEnterpriseMetaInDefaultPartition()
|
2020-06-12 08:57:41 -06:00
|
|
|
}
|
|
|
|
|
2020-12-11 16:10:00 -05:00
|
|
|
func (n ServiceName) String() string {
|
2020-06-12 08:57:41 -06:00
|
|
|
return n.Name
|
|
|
|
}
|
|
|
|
|
|
|
|
func ServiceNameFromString(input string) ServiceName {
|
|
|
|
id, _ := ParseServiceNameString(input)
|
|
|
|
return ServiceName{Name: id}
|
|
|
|
}
|
|
|
|
|
2020-12-11 16:10:00 -05:00
|
|
|
func (cid CheckID) String() string {
|
2019-12-09 21:26:41 -05:00
|
|
|
return string(cid.ID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (_ *HealthCheck) Validate() error {
|
|
|
|
return nil
|
|
|
|
}
|
2020-01-03 15:51:19 -05:00
|
|
|
|
2020-10-09 14:57:29 -05:00
|
|
|
func enterpriseRequestType(m MessageType) (string, bool) {
|
|
|
|
return "", false
|
|
|
|
}
|
|
|
|
|
2020-01-03 15:51:19 -05:00
|
|
|
// CheckIDs returns the IDs for all checks associated with a session, regardless of type
|
|
|
|
func (s *Session) CheckIDs() []types.CheckID {
|
|
|
|
// Merge all check IDs into a single slice, since they will be handled the same way
|
|
|
|
checks := make([]types.CheckID, 0, len(s.Checks)+len(s.NodeChecks)+len(s.ServiceChecks))
|
|
|
|
checks = append(checks, s.Checks...)
|
|
|
|
|
|
|
|
for _, c := range s.NodeChecks {
|
|
|
|
checks = append(checks, types.CheckID(c))
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, c := range s.ServiceChecks {
|
|
|
|
checks = append(checks, types.CheckID(c.ID))
|
|
|
|
}
|
|
|
|
return checks
|
|
|
|
}
|
2021-03-17 22:15:48 -06:00
|
|
|
|
|
|
|
func (t *Intention) HasWildcardSource() bool {
|
|
|
|
return t.SourceName == WildcardSpecifier
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *Intention) HasWildcardDestination() bool {
|
|
|
|
return t.DestinationName == WildcardSpecifier
|
|
|
|
}
|
2021-07-22 14:33:22 -05:00
|
|
|
|
|
|
|
func (s *ServiceNode) NodeIdentity() Identity {
|
|
|
|
return Identity{ID: s.Node}
|
|
|
|
}
|