structs: rename the last helper method.

This one gets used a bunch, but we can rename it to make the behaviour more obvious.
This commit is contained in:
Daniel Nephin 2021-09-17 19:36:20 -04:00
parent 8d8c1f9d5e
commit eb632c53a2
13 changed files with 14 additions and 14 deletions

View File

@ -108,7 +108,7 @@ func (c *CheckAlias) runLocal(stopCh chan struct{}) {
} }
updateStatus := func() { updateStatus := func() {
checks := c.Notify.Checks(c.WildcardEnterpriseMetaForPartition()) checks := c.Notify.Checks(c.WithWildcardNamespace())
checksList := make([]*structs.HealthCheck, 0, len(checks)) checksList := make([]*structs.HealthCheck, 0, len(checks))
for _, chk := range checks { for _, chk := range checks {
checksList = append(checksList, chk) checksList = append(checksList, chk)

View File

@ -479,7 +479,7 @@ func (c *ConfigEntry) ResolveServiceConfig(args *structs.ServiceConfigRequest, r
cfgMap := make(map[string]interface{}) cfgMap := make(map[string]interface{})
upstreamDefaults.MergeInto(cfgMap) upstreamDefaults.MergeInto(cfgMap)
wildcard := structs.NewServiceID(structs.WildcardSpecifier, args.WildcardEnterpriseMetaForPartition()) wildcard := structs.NewServiceID(structs.WildcardSpecifier, args.WithWildcardNamespace())
usConfigs[wildcard] = cfgMap usConfigs[wildcard] = cfgMap
} }
} }

View File

@ -863,7 +863,7 @@ func aclTokenDeleteTxn(tx WriteTxn, idx uint64, value, index string, entMeta *st
func aclTokenDeleteAllForAuthMethodTxn(tx WriteTxn, idx uint64, methodName string, methodGlobalLocality bool, methodMeta *structs.EnterpriseMeta) error { func aclTokenDeleteAllForAuthMethodTxn(tx WriteTxn, idx uint64, methodName string, methodGlobalLocality bool, methodMeta *structs.EnterpriseMeta) error {
// collect all the tokens linked with the given auth method. // collect all the tokens linked with the given auth method.
iter, err := aclTokenListByAuthMethod(tx, methodName, methodMeta, methodMeta.WildcardEnterpriseMetaForPartition()) iter, err := aclTokenListByAuthMethod(tx, methodName, methodMeta, methodMeta.WithWildcardNamespace())
if err != nil { if err != nil {
return fmt.Errorf("failed acl token lookup: %v", err) return fmt.Errorf("failed acl token lookup: %v", err)
} }

View File

@ -1540,7 +1540,7 @@ func (s *Store) EnsureCheck(idx uint64, hc *structs.HealthCheck) error {
func updateAllServiceIndexesOfNode(tx WriteTxn, idx uint64, nodeID string, entMeta *structs.EnterpriseMeta) error { func updateAllServiceIndexesOfNode(tx WriteTxn, idx uint64, nodeID string, entMeta *structs.EnterpriseMeta) error {
services, err := tx.Get(tableServices, indexNode, Query{ services, err := tx.Get(tableServices, indexNode, Query{
Value: nodeID, Value: nodeID,
EnterpriseMeta: *entMeta.WildcardEnterpriseMetaForPartition(), EnterpriseMeta: *entMeta.WithWildcardNamespace(),
}) })
if err != nil { if err != nil {
return fmt.Errorf("failed updating services for node %s: %s", nodeID, err) return fmt.Errorf("failed updating services for node %s: %s", nodeID, err)
@ -2359,7 +2359,7 @@ func parseCheckServiceNodes(
q := NodeServiceQuery{ q := NodeServiceQuery{
Node: sn.Node, Node: sn.Node,
Service: "", // node checks have no service Service: "", // node checks have no service
EnterpriseMeta: *sn.EnterpriseMeta.WildcardEnterpriseMetaForPartition(), EnterpriseMeta: *sn.EnterpriseMeta.WithWildcardNamespace(),
} }
iter, err := tx.Get(tableChecks, indexNodeService, q) iter, err := tx.Get(tableChecks, indexNodeService, q)
if err != nil { if err != nil {

View File

@ -491,7 +491,7 @@ func validateProposedConfigEntryInServiceGraph(
enforceIngressProtocolsMatch bool enforceIngressProtocolsMatch bool
) )
wildcardEntMeta := kindName.WildcardEnterpriseMetaForPartition() wildcardEntMeta := kindName.WithWildcardNamespace()
switch kindName.Kind { switch kindName.Kind {
case structs.ProxyDefaults: case structs.ProxyDefaults:

View File

@ -128,7 +128,7 @@ func configIntentionsListTxn(tx ReadTxn, ws memdb.WatchSet, entMeta *structs.Ent
idx := maxIndexTxn(tx, tableConfigEntries) idx := maxIndexTxn(tx, tableConfigEntries)
iter, err := getConfigEntryKindsWithTxn(tx, structs.ServiceIntentions, entMeta.WildcardEnterpriseMetaForPartition()) iter, err := getConfigEntryKindsWithTxn(tx, structs.ServiceIntentions, entMeta.WithWildcardNamespace())
if err != nil { if err != nil {
return 0, nil, false, fmt.Errorf("failed config entry lookup: %s", err) return 0, nil, false, fmt.Errorf("failed config entry lookup: %s", err)
} }

View File

@ -1017,7 +1017,7 @@ func (s *Store) intentionTopologyTxn(tx ReadTxn, ws memdb.WatchSet,
return true return true
} }
return false return false
}, target.WildcardEnterpriseMetaForPartition()) }, target.WithWildcardNamespace())
if err != nil { if err != nil {
return index, nil, fmt.Errorf("failed to fetch catalog service list: %v", err) return index, nil, fmt.Errorf("failed to fetch catalog service list: %v", err)
} }

View File

@ -417,7 +417,7 @@ func (d *DNSServer) handlePtr(resp dns.ResponseWriter, req *dns.Msg) {
AllowStale: cfg.AllowStale, AllowStale: cfg.AllowStale,
}, },
ServiceAddress: serviceAddress, ServiceAddress: serviceAddress,
EnterpriseMeta: *d.defaultEnterpriseMeta.WildcardEnterpriseMetaForPartition(), EnterpriseMeta: *d.defaultEnterpriseMeta.WithWildcardNamespace(),
} }
var sout structs.IndexedServiceNodes var sout structs.IndexedServiceNodes

View File

@ -989,7 +989,7 @@ func (l *State) updateSyncState() error {
AllowStale: true, AllowStale: true,
MaxStaleDuration: fullSyncReadMaxStale, MaxStaleDuration: fullSyncReadMaxStale,
}, },
EnterpriseMeta: *l.agentEnterpriseMeta.WildcardEnterpriseMetaForPartition(), EnterpriseMeta: *l.agentEnterpriseMeta.WithWildcardNamespace(),
} }
var out1 structs.IndexedNodeServiceList var out1 structs.IndexedNodeServiceList

View File

@ -235,7 +235,7 @@ func (s *handlerConnectProxy) handleUpdate(ctx context.Context, u cache.UpdateEv
// Use the centralized upstream defaults if they exist and there isn't specific configuration for this upstream // Use the centralized upstream defaults if they exist and there isn't specific configuration for this upstream
// This is only relevant to upstreams from intentions because for explicit upstreams the defaulting is handled // This is only relevant to upstreams from intentions because for explicit upstreams the defaulting is handled
// by the ResolveServiceConfig endpoint. // by the ResolveServiceConfig endpoint.
wildcardSID := structs.NewServiceID(structs.WildcardSpecifier, s.proxyID.WildcardEnterpriseMetaForPartition()) wildcardSID := structs.NewServiceID(structs.WildcardSpecifier, s.proxyID.WithWildcardNamespace())
defaults, ok := snap.ConnectProxy.UpstreamConfig[wildcardSID.String()] defaults, ok := snap.ConnectProxy.UpstreamConfig[wildcardSID.String()]
if ok { if ok {
u = defaults u = defaults

View File

@ -29,7 +29,7 @@ func (s *handlerMeshGateway) initialize(ctx context.Context) (ConfigSnapshot, er
return snap, err return snap, err
} }
wildcardEntMeta := s.proxyID.WildcardEnterpriseMetaForPartition() wildcardEntMeta := s.proxyID.WithWildcardNamespace()
// Watch for all services // Watch for all services
err = s.cache.Notify(ctx, cachetype.CatalogServiceListName, &structs.DCSpecificRequest{ err = s.cache.Notify(ctx, cachetype.CatalogServiceListName, &structs.DCSpecificRequest{

View File

@ -42,7 +42,7 @@ func (m *EnterpriseMeta) LessThan(_ *EnterpriseMeta) bool {
return false return false
} }
func (m *EnterpriseMeta) WildcardEnterpriseMetaForPartition() *EnterpriseMeta { func (m *EnterpriseMeta) WithWildcardNamespace() *EnterpriseMeta {
return &emptyEnterpriseMeta return &emptyEnterpriseMeta
} }

View File

@ -633,7 +633,7 @@ func (s *HTTPHandlers) UIMetricsProxy(resp http.ResponseWriter, req *http.Reques
// //
// TODO(partitions,acls): need to revisit this // TODO(partitions,acls): need to revisit this
var authzContext acl.AuthorizerContext var authzContext acl.AuthorizerContext
entMeta.WildcardEnterpriseMetaForPartition().FillAuthzContext(&authzContext) entMeta.WithWildcardNamespace().FillAuthzContext(&authzContext)
if authz.NodeReadAll(&authzContext) != acl.Allow || authz.ServiceReadAll(&authzContext) != acl.Allow { if authz.NodeReadAll(&authzContext) != acl.Allow || authz.ServiceReadAll(&authzContext) != acl.Allow {
return nil, acl.ErrPermissionDenied return nil, acl.ErrPermissionDenied