Commit graph

16 commits

Author SHA1 Message Date
Grant Spence
0ed689e2d0
Generate zplugin.go correctly with third-party plugins (#6692)
Previously, the generation of zplugin.go would not separate
third-party external plugins from CoreDNS plugins in the go
import block. This leads to the TestImportOrdering unit test
failing, as it requires that third-party imports paths to be
in a separate import block.

While this issue does not affect the main CoreDNS repo, it can cause
unit test failures in forks of CoreDNS that include external third-party
plugins.

Signed-off-by: Grant Spence <gspence@redhat.com>
2024-05-29 15:41:09 -04:00
Qasim Sarfraz
74b84a1377
update all +build statements (#5271)
* update all +build statements

Signed-off-by: MQasimSarfraz <syed.qasim.sarfraz@gmail.com>

* remove old +build style

Signed-off-by: MQasimSarfraz <syed.qasim.sarfraz@gmail.com>
2022-03-18 07:11:14 -07:00
Zou Nengren
5191959bd7
cleanup deprecated package io/ioutil (#4920)
Signed-off-by: zounengren <zouyee1989@gmail.com>
2021-10-13 09:30:31 +02:00
Yong Tang
9d87b953a0 Enhancement of external plugin enabling (#1392)
This fix is an enhancement of external plugin enabling.
Previously, it was already able to build a customerized
coredns with plugins enabled selectively, without changing
coredns source code. However, all default plugins are
actually bundled because of the import rule:
```
"github.com/coredns/coredns/coremain"
```

The issue is best described with the following:
```
root@localhost:/go/src/github.com/coredns/coredns/sample# cat sample.go
package main

import (
        _ "github.com/coredns/forward"

        "github.com/coredns/coredns/coremain"
        "github.com/coredns/coredns/core/dnsserver"
)

var directives = []string{
        "forward",
        "startup",
        "shutdown",
}

func init() {
        dnsserver.Directives = directives
}

func main() {
        coremain.Run()
}
root@localhost:/go/src/github.com/coredns/coredns/sample#
root@localhost:/go/src/github.com/coredns/coredns/sample# go build -v sample.go
root@localhost:/go/src/github.com/coredns/coredns/sample# ./sample -plugins
root@localhost:/go/src/github.com/coredns/coredns/sample# ./sample -plugins
Server types:
  dns

Caddyfile loaders:
  flag
  default

Other plugins:
  dns.auto
  dns.autopath
  dns.bind
  dns.cache
  dns.chaos
  dns.debug
  dns.dnssec
  dns.dnstap
  dns.erratic
  dns.errors
  dns.etcd
  dns.federation
  dns.file
  dns.forward
  dns.health
  dns.hosts
  dns.kubernetes
  dns.loadbalance
  dns.log
  dns.nsid
  dns.pprof
  dns.prometheus
  dns.proxy
  dns.reverse
  dns.rewrite
  dns.root
  dns.route53
  dns.secondary
  dns.template
....
```

This fix moves zplugins.go to a different package/directory so that
it is possible to "only import plugins as needed".

The following is the new output after this fix:
```
root@localhost:/go/src/github.com/coredns/coredns/sample# ./sample -plugins
Server types:
  dns

Caddyfile loaders:
  flag
  default

Other plugins:
  dns.forward
  dns.prometheus
  shutdown
  startup

root@localhost:/go/src/github.com/coredns/coredns/sample#
```

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2018-01-15 21:54:10 +00:00
Yong Tang
c6937b0bfc Expose directives in dnsserver to help external plugin developers (#1315)
This fix expose directives in dnsserver package, so that external
plugin developers could easily build customerized coredns+plugin
without changing the code base tree of coredns.

The following is an example that could bundle coredns+example,
in one simple file without modifying coredns codebase:

```
package main

import (
        _ "github.com/coredns/example"

        "github.com/coredns/coredns/coremain"
        "github.com/coredns/coredns/core/dnsserver"
)

var directives = []string{
        "example",
        "log",
        "errors",
        ...
        ...
        ...
        "whoami",
        "startup",
        "shutdown",
}

func init() {
        dnsserver.Directives = directives
}

func main() {
        coremain.Run()
}
```

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-12-15 07:26:36 +00:00
Miek Gieben
ea10a0d2f6 Don't number the plugins (#1146)
* Don't number the plugins

The number is not needed, because the ordering is already specified.
It's also annoying when you move plugins, because you need to renumber
them. Remove this.

'go gen' shows no changes in the generated files, meaning this just
works.

* better naming
2017-10-16 10:49:18 +02:00
Miek Gieben
c9bf91f1a7 core: don't always include all plugins (#1135)
Clean out the imports in coredns.go and just leave the server import.

Fixes #1119
2017-10-08 04:27:57 -07:00
Miek Gieben
d8714e64e4 Remove the word middleware (#1067)
* Rename middleware to plugin

first pass; mostly used 'sed', few spots where I manually changed
text.

This still builds a coredns binary.

* fmt error

* Rename AddMiddleware to AddPlugin

* Readd AddMiddleware to remain backwards compat
2017-09-14 09:36:06 +01:00
Yong Tang
c08497adee Misspell correction (#826)
Did a `misspell . | grep -v ^vendor` and fixed
several typos.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-08-04 09:06:06 -07:00
Mia Boulay
5798d708a0 middleware/directives: check if package exist on the file system (#767) 2017-07-01 13:13:27 -07:00
Miek Gieben
c5224b1048 Golint (#548)
* linter fixes

* Golint and format code

* fmt
2017-02-22 07:25:58 +00:00
Yong Tang
81af74aad0 Fix import path github.com/miekg/coredns -> github.com/coredns/coredns (#547)
This fix fixes import path from
`github.com/miekg/coredns`
->
`github.com/coredns/coredns`
2017-02-22 06:51:47 +00:00
Miek Gieben
26242cef1b Document fallthrough and fix rewrite (#537)
* Document fallthrough and fix *reverse*

While documenting the fallthrough behavior and testing it I noticed
the did not properly work. This PR does a tiny bit too much as it

- Documents fallthrough
- Fixes fallthrough in reverse
- Makes directives_generate complain on duplicate priorities
- Moved reverse *before* file in middleware.cfg
- Add a test that tests the reverse fallthrough behavior with a file
  backend

Fixes #515

* ....and fix the tests
2017-02-20 21:00:00 +00:00
Miek Gieben
ea38b642b8 All middleware equal (#535)
* all-middleware-equal

* Revert "all-middleware-equal"

This reverts commit ee77b2a981.

* middleware: treat external and local the same

Make the middleware generation simpler and also specify the local
middleware, meaning that it can now be removed as well. Simplify
the code a bit and regen everything.

* remove lineNR, not used
2017-02-19 20:34:29 +00:00
John Belamaric
84fb9b8469 Fix make gen (#526)
When using an external middleware, the generated file was failing to compile.
The issue is a typo in directives_generate.go that left imports with an
unterminated string.
2017-02-15 16:38:55 +00:00
Miek Gieben
98c86f3f9f go gen improvements (#524)
Remove the "gen" directory and move directives_generate.go out of it.
Add a build ignore tag so it isn't build by default. Cleanup the go gen
invocations so there are not seen as package docs.

Simplify the code a bit and don't run go gen twice.
2017-02-14 19:23:18 +00:00