Skip to content

Commit

Permalink
structs: remove EnterpriseMeta.GetNamespace
Browse files Browse the repository at this point in the history
I added this recently without realizing that the method already existed and was named
NamespaceOrEmpty. Replace all calls to GetNamespace with NamespaceOrEmpty or NamespaceOrDefault
as appropriate.
  • Loading branch information
dnephin committed Feb 22, 2021
1 parent 4f9b35b commit 60abc94
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion agent/cache-types/streaming_health_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (c *StreamingHealthServices) Fetch(opts cache.FetchOptions, req cache.Reque
Token: srvReq.Token,
Datacenter: srvReq.Datacenter,
Index: index,
Namespace: srvReq.EnterpriseMeta.GetNamespace(),
Namespace: srvReq.EnterpriseMeta.NamespaceOrEmpty(),
}
if srvReq.Connect {
req.Topic = pbsubscribe.Topic_ServiceHealthConnect
Expand Down
2 changes: 1 addition & 1 deletion agent/cache-types/streaming_health_services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func requireResultsSame(t *testing.T, want, got *structs.IndexedCheckServiceNode
// without duplicating the tests.
func getNamespace(ns string) string {
meta := structs.NewEnterpriseMeta(ns)
return meta.GetNamespace()
return meta.NamespaceOrEmpty()
}

func TestOrderingConsistentWithMemDb(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion agent/consul/state/catalog_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (e EventPayloadCheckServiceNode) MatchesKey(key, namespace string) bool {
if e.key != "" {
name = e.key
}
ns := e.Value.Service.EnterpriseMeta.GetNamespace()
ns := e.Value.Service.EnterpriseMeta.NamespaceOrDefault()
return (key == "" || key == name) && (namespace == "" || namespace == ns)
}

Expand Down
2 changes: 1 addition & 1 deletion agent/rpc/subscribe/subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func toStreamSubscribeRequest(req *pbsubscribe.SubscribeRequest, entMeta structs
Key: req.Key,
Token: req.Token,
Index: req.Index,
Namespace: entMeta.GetNamespace(),
Namespace: entMeta.NamespaceOrEmpty(),
}
}

Expand Down
5 changes: 0 additions & 5 deletions agent/structs/structs_oss.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ func (_ *EnterpriseMeta) FillAuthzContext(_ *acl.AuthorizerContext) {}

func (_ *EnterpriseMeta) Normalize() {}

// GetNamespace always returns the empty string.
func (_ *EnterpriseMeta) GetNamespace() string {
return ""
}

// FillAuthzContext stub
func (_ *DirEntry) FillAuthzContext(_ *acl.AuthorizerContext) {}

Expand Down

0 comments on commit 60abc94

Please sign in to comment.