summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2022-03-28 18:48:43 -0400
committerDave Henderson <dhenderson@gmail.com>2022-03-28 22:43:11 -0400
commit8767e64ff07c0ef9a40157380cd5ed58b1a6cf60 (patch)
tree11b0d7663f1bb951feb0549c311960d391c8a6b5 /internal
parent09ea51abb4b5fe2626847f168cb0a49c4cf94f32 (diff)
Log warning message when a deprecated function or datasource is used
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'internal')
-rw-r--r--internal/deprecated/deprecated.go14
-rw-r--r--internal/tests/integration/datasources_boltdb_test.go9
2 files changed, 19 insertions, 4 deletions
diff --git a/internal/deprecated/deprecated.go b/internal/deprecated/deprecated.go
new file mode 100644
index 00000000..c453ebbe
--- /dev/null
+++ b/internal/deprecated/deprecated.go
@@ -0,0 +1,14 @@
+package deprecated
+
+import (
+ "context"
+
+ "github.com/rs/zerolog"
+)
+
+// WarnDeprecated - use this to warn about deprecated template functions or
+// datasources
+func WarnDeprecated(ctx context.Context, msg string) {
+ logger := zerolog.Ctx(ctx)
+ logger.Warn().Msgf("Deprecated: %s", msg)
+}
diff --git a/internal/tests/integration/datasources_boltdb_test.go b/internal/tests/integration/datasources_boltdb_test.go
index fbae9782..848a3119 100644
--- a/internal/tests/integration/datasources_boltdb_test.go
+++ b/internal/tests/integration/datasources_boltdb_test.go
@@ -43,12 +43,13 @@ func setupDatasourcesBoltDBTest(t *testing.T) *fs.Dir {
func TestDatasources_BoltDB_Datasource(t *testing.T) {
tmpDir := setupDatasourcesBoltDBTest(t)
- o, e, err := cmd(t, "-d", "config=boltdb://"+tmpDir.Join("config.db#Bucket1"),
+ // ignore the stderr output, it'll contain boltdb deprecation warning
+ o, _, err := cmd(t, "-d", "config=boltdb://"+tmpDir.Join("config.db#Bucket1"),
"-i", `{{(ds "config" "foo")}}`).run()
- assertSuccess(t, o, e, err, "bar")
+ assertSuccess(t, o, "", err, "bar")
- o, e, err = cmd(t, "-d", "config=boltdb://"+tmpDir.Join("config.db#Bucket1"),
+ o, _, err = cmd(t, "-d", "config=boltdb://"+tmpDir.Join("config.db#Bucket1"),
"-d", "config2=boltdb://"+tmpDir.Join("config.db#Bucket2"),
"-i", `{{(ds "config" "foo")}}-{{(ds "config2" "foobar")}}`).run()
- assertSuccess(t, o, e, err, "bar-baz")
+ assertSuccess(t, o, "", err, "bar-baz")
}