open-consul/agent/proxycfg-glue/intentions_oss.go
Ronald dd0e8eec14
copyright headers for agent folder (#16704)
* copyright headers for agent folder

* Ignore test data files

* fix proto files and remove headers in agent/uiserver folder

* ignore deep-copy files
2023-03-28 14:39:22 -04:00

43 lines
1.1 KiB
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
//go:build !consulent
// +build !consulent
package proxycfgglue
import (
"github.com/hashicorp/consul/acl"
"github.com/hashicorp/consul/agent/structs"
"github.com/hashicorp/consul/proto/private/pbsubscribe"
)
func (s serverIntentions) buildSubjects(serviceName string, entMeta acl.EnterpriseMeta) []*pbsubscribe.NamedSubject {
// Based on getIntentionPrecedenceMatchServiceNames in the state package.
if serviceName == structs.WildcardSpecifier {
return []*pbsubscribe.NamedSubject{
{
Key: structs.WildcardSpecifier,
Namespace: entMeta.NamespaceOrDefault(),
Partition: entMeta.PartitionOrDefault(),
PeerName: structs.DefaultPeerKeyword,
},
}
}
return []*pbsubscribe.NamedSubject{
{
Key: serviceName,
Namespace: entMeta.NamespaceOrDefault(),
Partition: entMeta.PartitionOrDefault(),
PeerName: structs.DefaultPeerKeyword,
},
{
Key: structs.WildcardSpecifier,
Namespace: entMeta.NamespaceOrDefault(),
Partition: entMeta.PartitionOrDefault(),
PeerName: structs.DefaultPeerKeyword,
},
}
}