summaryrefslogtreecommitdiff
path: root/data/datasource.go
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2018-05-03 21:50:37 -0400
committerDave Henderson <dhenderson@gmail.com>2018-05-03 22:57:25 -0400
commit6124d3dfd274ac24e5da0817ae172aca58c22d4e (patch)
tree22acb5a6e7bbf59dd1337953445e036b06da94b5 /data/datasource.go
parent195a6dc75ddbc6f4899176d006c6dfba39e08f1a (diff)
Adding datasourceReachable function
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'data/datasource.go')
-rw-r--r--data/datasource.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/data/datasource.go b/data/datasource.go
index e4336fb5..6370bd5f 100644
--- a/data/datasource.go
+++ b/data/datasource.go
@@ -257,6 +257,17 @@ func (d *Data) Datasource(alias string, args ...string) (interface{}, error) {
return nil, errors.Errorf("Datasources of type %s not yet supported", source.Type)
}
+// DatasourceReachable - Determines if the named datasource is reachable with
+// the given arguments. Reads from the datasource, and discards the returned data.
+func (d *Data) DatasourceReachable(alias string, args ...string) bool {
+ source, ok := d.Sources[alias]
+ if !ok {
+ return false
+ }
+ _, err := d.ReadSource(source, args...)
+ return err == nil
+}
+
// Include -
func (d *Data) Include(alias string, args ...string) (string, error) {
source, ok := d.Sources[alias]