Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
roncodingenthusiast committed Nov 21, 2023
1 parent c639cbb commit d95a388
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dependency/catalog_node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestNewCatalogNodeQuery(t *testing.T) {
},
{
"invalid query param (unsupported key)",
"key?unsupported=foo",
"node?unsupported=foo",
nil,
true,
},
Expand Down
28 changes: 25 additions & 3 deletions docs/templating-language.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,19 @@ To learn how [`safeLs`](#safels) was born see [CT-1131](https://github.com/hashi
Query [Consul][consul] for a node in the catalog.

```golang
{{node "<NAME>@<DATACENTER>"}}
{{node "<NAME>?<QUERY>@<DATACENTER>"}}
```

The `<NAME>` attribute is optional; if omitted, the local agent node is used.

The `<QUERY>` attribute is optional; if omitted, the `default` Consul namespace, `default` partition will be queried. `<QUERY>` can be used to set the Consul [namespace](https://developer.hashicorp.com/consul/api-docs/health#ns-2) or partition. `<QUERY>` accepts a url query-parameter format, e.g.:

```golang
{{ with node "node?ns=default&partition=default" }}
{{ .Node.Address }}
{{ end }}
```

The `<DATACENTER>` attribute is optional; if omitted, the local datacenter is
used.

Expand Down Expand Up @@ -441,7 +449,13 @@ To access map data such as `TaggedAddresses` or `Meta`, use
Query [Consul][consul] for all nodes in the catalog.

```golang
{{ nodes "@<DATACENTER>~<NEAR>" }}
{{ nodes "?<QUERY>@<DATACENTER>~<NEAR>" }}
```
The `<QUERY>` attribute is optional; if omitted, the `default` Consul namespace, `default` partition will be queried. `<QUERY>` can be used to set the Consul [namespace](https://developer.hashicorp.com/consul/api-docs/health#ns-2) or partition. `<QUERY>` accepts a url query-parameter format, e.g.:

```golang
{{ range nodes "?ns=namespace&partition=partition" }}
{{ .Address }}{{ end }}
```

The `<DATACENTER>` attribute is optional; if omitted, the local datacenter is
Expand Down Expand Up @@ -777,7 +791,15 @@ argument instead.
Query [Consul][consul] for all services in the catalog.

```golang
{{ services "@<DATACENTER>" }}
{{ services "?<QUERY>@<DATACENTER>" }}
```

The `<QUERY>` attribute is optional; if omitted, the `default` Consul namespace, `default` partition will be queried. `<QUERY>` can be used to set the Consul [namespace](https://developer.hashicorp.com/consul/api-docs/health#ns-2) or partition. `<QUERY>` accepts a url query-parameter format, e.g.:

```golang
{{ range services "?ns=default&partition=default" }}
{{ .Name }}
{{ end }}
```

The `<DATACENTER>` attribute is optional; if omitted, the local datacenter is
Expand Down

0 comments on commit d95a388

Please sign in to comment.