aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2018-03-01 06:49:52 -0800
committerGravatar GitHub <noreply@github.com> 2018-03-01 06:49:52 -0800
commitd67396dc7b87591ac07ac03554e57395c53d599b (patch)
tree0566bad866a0391c080880485d6c7aa10e5cfb42 /plugin
parent654b88d8c4dcf58717e7ee36e37200dabe9a307e (diff)
downloadcoredns-d67396dc7b87591ac07ac03554e57395c53d599b.tar.gz
coredns-d67396dc7b87591ac07ac03554e57395c53d599b.tar.zst
coredns-d67396dc7b87591ac07ac03554e57395c53d599b.zip
plugin/deprecated: add an easy way to error on deprecated plugin (#1575)
* plugin/deprecated: add an easy way to error on depcated plugin * lint * better docs * slightly more docs
Diffstat (limited to 'plugin')
-rw-r--r--plugin/deprecated/setup.go38
1 files changed, 38 insertions, 0 deletions
diff --git a/plugin/deprecated/setup.go b/plugin/deprecated/setup.go
new file mode 100644
index 000000000..cf415c1ae
--- /dev/null
+++ b/plugin/deprecated/setup.go
@@ -0,0 +1,38 @@
+// Package deprecated is used when we deprecated plugin. In plugin.cfg just go from
+//
+// startup:github.com/mholt/caddy/startupshutdown
+//
+// To:
+//
+// startup:deprecated
+//
+// And things should work as expected. This means starting CoreDNS will fail with an error. We can only
+// point to the release notes to details what next steps a user should take. I.e. there is no way to add this
+// to the error generated.
+package deprecated
+
+import (
+ "errors"
+
+ "github.com/coredns/coredns/plugin"
+
+ "github.com/mholt/caddy"
+)
+
+// removed has the names of the plugins that need to error on startup.
+var removed = []string{"startup", "shutdown"}
+
+func setup(c *caddy.Controller) error {
+ c.Next()
+ x := c.Val()
+ return plugin.Error(x, errors.New("this plugin has been deprecated"))
+}
+
+func init() {
+ for _, plugin := range removed {
+ caddy.RegisterPlugin(plugin, caddy.Plugin{
+ ServerType: "dns",
+ Action: setup,
+ })
+ }
+}