From 0ca223237a0714eebe4e8f3da10e09031999537f Mon Sep 17 00:00:00 2001 From: jeevansai Date: Sat, 5 Feb 2022 19:52:00 +0530 Subject: Add function to list datasources (#1287) * Add function to list datasources * Sort datasources in ascending order and return in listDatasources * Fix lint error Signed-off-by: Dave Henderson Co-authored-by: Dave Henderson --- docs/content/functions/data.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'docs') diff --git a/docs/content/functions/data.md b/docs/content/functions/data.md index 4845de60..31d2b27c 100644 --- a/docs/content/functions/data.md +++ b/docs/content/functions/data.md @@ -97,6 +97,24 @@ $ gomplate -i '{{if (datasourceReachable "test")}}{{datasource "test"}}{{else}}n no worries ``` +## `listDatasources` + +Lists all the datasources defined, list returned will be sorted in ascending order. + +### Usage + +```go +listDatasources +``` + +### Examples + +```console +$ gomplate -d person=env:///FOO -d bar=env:///BAR -i '{{range (listDatasources)}} Datasource-{{.}} {{end}}' +Datasource-bar +Datasource-person +``` + ## `defineDatasource` Define a datasource alias with target URL inside the template. Overridden by the [`--datasource/-d`](../../usage/#datasource-d) flag. -- cgit v1.2.3