From 6124d3dfd274ac24e5da0817ae172aca58c22d4e Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Thu, 3 May 2018 21:50:37 -0400 Subject: Adding datasourceReachable function Signed-off-by: Dave Henderson --- docs/content/functions/data.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/content/functions/data.md b/docs/content/functions/data.md index 654e45af..277daafb 100644 --- a/docs/content/functions/data.md +++ b/docs/content/functions/data.md @@ -319,13 +319,24 @@ defined. Note: this does _not_ verify if the datasource is reachable. -Useful when used in an `if`/`else` block +Useful when used in an `if`/`else` block. ```console $ echo '{{if (datasourceExists "test")}}{{datasource "test"}}{{else}}no worries{{end}}' | gomplate no worries ``` +## `datasourceReachable` + +Tests whether or not a given datasource is defined and reachable, where the definition of "reachable" differs by datasource, but generally means the data is able to be read successfully. + +Useful when used in an `if`/`else` block. + +```console +$ gomplate -i '{{if (datasourceReachable "test")}}{{datasource "test"}}{{else}}no worries{{end}}' -d test=https://bogus.example.com/wontwork.json +no worries +``` + ## `ds` Alias to [`datasource`](#datasource) -- cgit v1.2.3