Abstract the caddy call and make it simpler. See #3261 for some part of the discussion. Go from: ~~~ go func init() { caddy.RegisterPlugin("any", caddy.Plugin{ ServerType: "dns", Action: setup, }) } ~~~ To: ~~~ go func init() { plugin.Register("any", setup) } ~~~ This requires some external documents in coredns.io to be updated as well; the old way still works, so it's backwards compatible. Signed-off-by: Miek Gieben <miek@miek.nl>
35 lines
854 B
Go
35 lines
854 B
Go
// Package deprecated is used when we deprecated plugin. In plugin.cfg just go from
|
|
//
|
|
// startup:github.com/caddyserver/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/caddyserver/caddy"
|
|
)
|
|
|
|
// removed has the names of the plugins that need to error on startup.
|
|
var removed = []string{""}
|
|
|
|
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 _, plug := range removed {
|
|
plugin.Register(plug, setup)
|
|
}
|
|
}
|