middleware/directives: check if package exist on the file system
@@ -43,7 +43,7 @@ func main() {
md[priority] = items[1]
mi[items[1]] = middlewarePath + items[2] // Default, unless overriden by 3rd arg
- if strings.Contains(items[2], "/") { // External package has been given
+ if _, err := os.Stat(middlewareFSPath + items[2]); err != nil { // External package has been given
mi[items[1]] = items[2]
}
}
@@ -115,5 +115,6 @@ func fatalIfErr(err error) {
const (
middlewarePath = "github.com/coredns/coredns/middleware/"
middlewareFile = "middleware.cfg"
+ middlewareFSPath = "middleware/" // Where the middleware packages are located on the file system
header = "// generated by directives_generate.go; DO NOT EDIT\n\n"
)
