Files
coredns/plugin/errors/setup.go

56 lines
977 B
Go
Raw Normal View History

package errors
2016-03-18 20:57:35 +00:00
import (
"fmt"
2016-03-18 20:57:35 +00:00
"log"
"os"
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/plugin"
"github.com/mholt/caddy"
2016-03-18 20:57:35 +00:00
)
func init() {
caddy.RegisterPlugin("errors", caddy.Plugin{
ServerType: "dns",
Action: setup,
})
}
func setup(c *caddy.Controller) error {
2016-03-18 20:57:35 +00:00
handler, err := errorsParse(c)
if err != nil {
return plugin.Error("errors", err)
2016-03-18 20:57:35 +00:00
}
handler.Log = log.New(os.Stdout, "", 0)
2016-03-18 20:57:35 +00:00
dnsserver.GetConfig(c).AddPlugin(func(next plugin.Handler) plugin.Handler {
2016-03-18 20:57:35 +00:00
handler.Next = next
return handler
})
return nil
2016-03-18 20:57:35 +00:00
}
Golint2 (#280) * Fix linter errors * More linting fixes * More docs and making members private that dont need to be public * Fix linter errors * More linting fixes * More docs and making members private that dont need to be public * More lint fixes This leaves: ~~~ middleware/kubernetes/nametemplate/nametemplate.go:64:6: exported type NameTemplate should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:71:1: exported method NameTemplate.SetTemplate should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:108:1: exported method NameTemplate.GetZoneFromSegmentArray should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:116:1: exported method NameTemplate.GetNamespaceFromSegmentArray should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:120:1: exported method NameTemplate.GetServiceFromSegmentArray should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:124:1: exported method NameTemplate.GetTypeFromSegmentArray should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:135:1: exported method NameTemplate.GetSymbolFromSegmentArray should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:167:1: exported method NameTemplate.IsValid should have comment or be unexported middleware/kubernetes/nametemplate/nametemplate.go:182:6: exported type NameValues should have comment or be unexported middleware/kubernetes/util/util.go:1:1: package comment should be of the form "Package util ..." middleware/kubernetes/util/util.go:27:2: exported const WildcardStar should have comment (or a comment on this block) or be unexported middleware/proxy/lookup.go:66:1: exported method Proxy.Forward should have comment or be unexported middleware/proxy/proxy.go:24:6: exported type Client should have comment or be unexported middleware/proxy/proxy.go:107:1: exported function Clients should have comment or be unexported middleware/proxy/reverseproxy.go:10:6: exported type ReverseProxy should have comment or be unexported middleware/proxy/reverseproxy.go:16:1: exported method ReverseProxy.ServeDNS should have comment or be unexported middleware/proxy/upstream.go:42:6: exported type Options should have comment or be unexported ~~~ I plan on reworking the proxy anyway, so I'll leave that be.
2016-09-23 09:14:12 +01:00
func errorsParse(c *caddy.Controller) (errorHandler, error) {
handler := errorHandler{}
2016-03-18 20:57:35 +00:00
for c.Next() {
args := c.RemainingArgs()
switch len(args) {
case 0:
handler.LogFile = "stdout"
case 1:
if args[0] != "stdout" {
return handler, fmt.Errorf("invalid log file: %s", args[0])
2016-03-18 20:57:35 +00:00
}
handler.LogFile = args[0]
default:
return handler, c.ArgErr()
2016-03-18 20:57:35 +00:00
}
}
return handler, nil
}