From 8d8c1f9d5e96a9b08887fc414fa989c34b391ac9 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Fri, 17 Sep 2021 19:24:51 -0400 Subject: [PATCH] structs: remove another helper We already have a helper funtion. --- agent/consul/state/catalog.go | 8 ++++---- agent/consul/state/config_entry.go | 8 ++++---- agent/structs/structs_oss.go | 4 ---- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/agent/consul/state/catalog.go b/agent/consul/state/catalog.go index 8308183afa..72b4ba5645 100644 --- a/agent/consul/state/catalog.go +++ b/agent/consul/state/catalog.go @@ -3451,8 +3451,8 @@ func updateMeshTopology(tx WriteTxn, idx uint64, node string, svc *structs.NodeS oldUpstreams := make(map[structs.ServiceName]bool) if e, ok := existing.(*structs.ServiceNode); ok { for _, u := range e.ServiceProxy.Upstreams { - upstreamMeta := e.NewEnterpriseMetaInPartition(u.DestinationNamespace) - sn := structs.NewServiceName(u.DestinationName, upstreamMeta) + upstreamMeta := structs.NewEnterpriseMetaWithPartition(e.PartitionOrDefault(), u.DestinationNamespace) + sn := structs.NewServiceName(u.DestinationName, &upstreamMeta) oldUpstreams[sn] = true } @@ -3467,8 +3467,8 @@ func updateMeshTopology(tx WriteTxn, idx uint64, node string, svc *structs.NodeS } // TODO (freddy): Account for upstream datacenter - upstreamMeta := svc.NewEnterpriseMetaInPartition(u.DestinationNamespace) - upstream := structs.NewServiceName(u.DestinationName, upstreamMeta) + upstreamMeta := structs.NewEnterpriseMetaWithPartition(svc.PartitionOrDefault(), u.DestinationNamespace) + upstream := structs.NewServiceName(u.DestinationName, &upstreamMeta) obj, err := tx.First(tableMeshTopology, indexID, upstream, downstream) if err != nil { diff --git a/agent/consul/state/config_entry.go b/agent/consul/state/config_entry.go index c6f568e7a4..1dc00e0463 100644 --- a/agent/consul/state/config_entry.go +++ b/agent/consul/state/config_entry.go @@ -402,8 +402,8 @@ func (s *Store) discoveryChainTargetsTxn(tx ReadTxn, ws memdb.WatchSet, dc, serv var resp []structs.ServiceName for _, t := range chain.Targets { - em := entMeta.NewEnterpriseMetaInPartition(t.Namespace) - target := structs.NewServiceName(t.Service, em) + em := structs.NewEnterpriseMetaWithPartition(entMeta.PartitionOrDefault(), t.Namespace) + target := structs.NewServiceName(t.Service, &em) // TODO (freddy): Allow upstream DC and encode in response if t.Datacenter == dc { @@ -459,8 +459,8 @@ func (s *Store) discoveryChainSourcesTxn(tx ReadTxn, ws memdb.WatchSet, dc strin } for _, t := range chain.Targets { - em := sn.NewEnterpriseMetaInPartition(t.Namespace) - candidate := structs.NewServiceName(t.Service, em) + em := structs.NewEnterpriseMetaWithPartition(sn.PartitionOrDefault(), t.Namespace) + candidate := structs.NewServiceName(t.Service, &em) if !candidate.Matches(destination) { continue diff --git a/agent/structs/structs_oss.go b/agent/structs/structs_oss.go index 8faecb1164..7a72d0cab4 100644 --- a/agent/structs/structs_oss.go +++ b/agent/structs/structs_oss.go @@ -46,10 +46,6 @@ func (m *EnterpriseMeta) WildcardEnterpriseMetaForPartition() *EnterpriseMeta { return &emptyEnterpriseMeta } -func (m *EnterpriseMeta) NewEnterpriseMetaInPartition(_ string) *EnterpriseMeta { - return &emptyEnterpriseMeta -} - // TODO(partition): stop using this func NewEnterpriseMetaInDefaultPartition(_ string) EnterpriseMeta { return emptyEnterpriseMeta