Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Net 7571 #1880

Merged
merged 3 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions dependency/catalog_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ func (d *CatalogServicesQuery) Fetch(clients *ClientSet, opts *QueryOptions) (in
default:
}

// this overrides the query params present in the query with ones present while creating the query
// see bug [https://github.com/hashicorp/consul-template/pull/1842#issuecomment-1915723565]
// default to the query params present while creating NewCatalogServicesQuery
// and then merge with the query params present in the query
defaultOpts := &QueryOptions{
Expand Down Expand Up @@ -120,10 +118,22 @@ func (d *CatalogServicesQuery) CanShare() bool {

// String returns the human-friendly version of this dependency.
func (d *CatalogServicesQuery) String() string {
var name string
if d.dc != "" {
return fmt.Sprintf("catalog.services(@%s)", d.dc)
name = name + "@" + d.dc
kkavish marked this conversation as resolved.
Show resolved Hide resolved
}
return "catalog.services"
if d.namespace != "" {
name = name + "@" + d.namespace
kkavish marked this conversation as resolved.
Show resolved Hide resolved
}
if d.partition != "" {
name = name + "@" + d.partition
}

if len(name) == 0 {
return "catalog.services"
}

return fmt.Sprintf("catalog.services(%s)", name)
}

// Stop halts the dependency's fetch function.
Expand Down
20 changes: 20 additions & 0 deletions dependency/catalog_services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,26 @@ func TestCatalogServicesQuery_String(t *testing.T) {
"@dc1",
"catalog.services(@dc1)",
},
{
"datacenter+namespace",
"?ns=bar@dc1",
"catalog.services(@dc1@bar)",
},
{
"datacenter+namespace+partition",
"?partition=foo&ns=bar@dc1",
"catalog.services(@dc1@bar@foo)",
},
{
"namespace+partition",
"?partition=foo&ns=bar",
"catalog.services(@bar@foo)",
},
{
"dc+partition",
"?partition=foo@dc1",
"catalog.services(@dc1@foo)",
},
}

for i, tc := range cases {
Expand Down
Loading