Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
be477092
Commit
be477092
authored
Sep 16, 2017
by
Miek Gieben
Committed by
GitHub
Sep 16, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More Middleware -> Plugin conversions (#1088)
Forgot about these.
parent
6f874f0b
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
23 additions
and
23 deletions
+23
-23
plugin.md
plugin.md
+3
-3
plugin/autopath/autopath.go
plugin/autopath/autopath.go
+1
-1
plugin/autopath/setup.go
plugin/autopath/setup.go
+3
-3
plugin/autopath/setup_test.go
plugin/autopath/setup_test.go
+1
-1
plugin/etcd/cname_test.go
plugin/etcd/cname_test.go
+1
-1
plugin/etcd/group_test.go
plugin/etcd/group_test.go
+1
-1
plugin/etcd/lookup_test.go
plugin/etcd/lookup_test.go
+2
-2
plugin/etcd/multi_test.go
plugin/etcd/multi_test.go
+1
-1
plugin/etcd/other_test.go
plugin/etcd/other_test.go
+1
-1
plugin/etcd/stub_test.go
plugin/etcd/stub_test.go
+1
-1
plugin/health/healther.go
plugin/health/healther.go
+1
-1
plugin/health/setup.go
plugin/health/setup.go
+1
-1
test/etcd_cache_test.go
test/etcd_cache_test.go
+1
-1
test/etcd_test.go
test/etcd_test.go
+2
-2
test/external_test.go
test/external_test.go
+3
-3
No files found.
plugin.md
View file @
be477092
#
Middleware
#
Plugins
## Writing
Middleware
## Writing
Plugins
From the Caddy docs:
From the Caddy docs:
...
@@ -136,7 +136,7 @@ compute.internal. 3600 IN MX 10 mx.compute.internal.
...
@@ -136,7 +136,7 @@ compute.internal. 3600 IN MX 10 mx.compute.internal.
## Qualifying for main repo
## Qualifying for main repo
Middleware
for CoreDNS can live out-of-tree,
`plugin.cfg`
defaults to CoreDNS' repo but other
Plugins
for CoreDNS can live out-of-tree,
`plugin.cfg`
defaults to CoreDNS' repo but other
repos work just as well. So when do we consider the inclusion of a new plugin in the main repo?
repos work just as well. So when do we consider the inclusion of a new plugin in the main repo?
*
First, the plugin should be useful for other people. "Useful" is a subjective term. We will
*
First, the plugin should be useful for other people. "Useful" is a subjective term. We will
...
...
plugin/autopath/autopath.go
View file @
be477092
...
@@ -25,7 +25,7 @@ autopath.Func. Note the searchpath must be ending with the empty string.
...
@@ -25,7 +25,7 @@ autopath.Func. Note the searchpath must be ending with the empty string.
I.e:
I.e:
func (m
Middleware
) AutoPath(state request.Request) []string {
func (m
Plugins
) AutoPath(state request.Request) []string {
return []string{"first", "second", "last", ""}
return []string{"first", "second", "last", ""}
}
}
*/
*/
...
...
plugin/autopath/setup.go
View file @
be477092
...
@@ -49,8 +49,8 @@ func setup(c *caddy.Controller) error {
...
@@ -49,8 +49,8 @@ func setup(c *caddy.Controller) error {
return
nil
return
nil
}
}
// allowed
Middleware
has a list of plugin that can be used by autopath.
// allowed
Plugins
has a list of plugin that can be used by autopath.
var
allowed
Middleware
=
map
[
string
]
bool
{
var
allowed
Plugins
=
map
[
string
]
bool
{
"@kubernetes"
:
true
,
"@kubernetes"
:
true
,
"@erratic"
:
true
,
"@erratic"
:
true
,
}
}
...
@@ -66,7 +66,7 @@ func autoPathParse(c *caddy.Controller) (*AutoPath, string, error) {
...
@@ -66,7 +66,7 @@ func autoPathParse(c *caddy.Controller) (*AutoPath, string, error) {
}
}
resolv
:=
zoneAndresolv
[
len
(
zoneAndresolv
)
-
1
]
resolv
:=
zoneAndresolv
[
len
(
zoneAndresolv
)
-
1
]
if
resolv
[
0
]
==
'@'
{
if
resolv
[
0
]
==
'@'
{
_
,
ok
:=
allowed
Middleware
[
resolv
]
_
,
ok
:=
allowed
Plugins
[
resolv
]
if
ok
{
if
ok
{
mw
=
resolv
[
1
:
]
mw
=
resolv
[
1
:
]
}
}
...
...
plugin/autopath/setup_test.go
View file @
be477092
...
@@ -55,7 +55,7 @@ func TestSetupAutoPath(t *testing.T) {
...
@@ -55,7 +55,7 @@ func TestSetupAutoPath(t *testing.T) {
}
}
if
!
test
.
shouldErr
&&
mw
!=
test
.
expectedMw
{
if
!
test
.
shouldErr
&&
mw
!=
test
.
expectedMw
{
t
.
Errorf
(
"Test %d,
Middleware
not correctly set for input %s. Expected: %s, actual: %s"
,
i
,
test
.
input
,
test
.
expectedMw
,
mw
)
t
.
Errorf
(
"Test %d,
Plugin
not correctly set for input %s. Expected: %s, actual: %s"
,
i
,
test
.
input
,
test
.
expectedMw
,
mw
)
}
}
if
!
test
.
shouldErr
&&
ap
.
search
!=
nil
{
if
!
test
.
shouldErr
&&
ap
.
search
!=
nil
{
if
!
reflect
.
DeepEqual
(
test
.
expectedSearch
,
ap
.
search
)
{
if
!
reflect
.
DeepEqual
(
test
.
expectedSearch
,
ap
.
search
)
{
...
...
plugin/etcd/cname_test.go
View file @
be477092
...
@@ -16,7 +16,7 @@ import (
...
@@ -16,7 +16,7 @@ import (
// Check the ordering of returned cname.
// Check the ordering of returned cname.
func
TestCnameLookup
(
t
*
testing
.
T
)
{
func
TestCnameLookup
(
t
*
testing
.
T
)
{
etc
:=
newEtcd
Middleware
()
etc
:=
newEtcd
Plugin
()
for
_
,
serv
:=
range
servicesCname
{
for
_
,
serv
:=
range
servicesCname
{
set
(
t
,
etc
,
serv
.
Key
,
0
,
serv
)
set
(
t
,
etc
,
serv
.
Key
,
0
,
serv
)
...
...
plugin/etcd/group_test.go
View file @
be477092
...
@@ -13,7 +13,7 @@ import (
...
@@ -13,7 +13,7 @@ import (
)
)
func
TestGroupLookup
(
t
*
testing
.
T
)
{
func
TestGroupLookup
(
t
*
testing
.
T
)
{
etc
:=
newEtcd
Middleware
()
etc
:=
newEtcd
Plugin
()
for
_
,
serv
:=
range
servicesGroup
{
for
_
,
serv
:=
range
servicesGroup
{
set
(
t
,
etc
,
serv
.
Key
,
0
,
serv
)
set
(
t
,
etc
,
serv
.
Key
,
0
,
serv
)
...
...
plugin/etcd/lookup_test.go
View file @
be477092
...
@@ -221,7 +221,7 @@ var dnsTestCases = []test.Case{
...
@@ -221,7 +221,7 @@ var dnsTestCases = []test.Case{
},
},
}
}
func
newEtcd
Middleware
()
*
Etcd
{
func
newEtcd
Plugin
()
*
Etcd
{
ctxt
=
context
.
TODO
()
ctxt
=
context
.
TODO
()
endpoints
:=
[]
string
{
"http://localhost:2379"
}
endpoints
:=
[]
string
{
"http://localhost:2379"
}
...
@@ -253,7 +253,7 @@ func delete(t *testing.T, e *Etcd, k string) {
...
@@ -253,7 +253,7 @@ func delete(t *testing.T, e *Etcd, k string) {
}
}
func
TestLookup
(
t
*
testing
.
T
)
{
func
TestLookup
(
t
*
testing
.
T
)
{
etc
:=
newEtcd
Middleware
()
etc
:=
newEtcd
Plugin
()
for
_
,
serv
:=
range
services
{
for
_
,
serv
:=
range
services
{
set
(
t
,
etc
,
serv
.
Key
,
0
,
serv
)
set
(
t
,
etc
,
serv
.
Key
,
0
,
serv
)
defer
delete
(
t
,
etc
,
serv
.
Key
)
defer
delete
(
t
,
etc
,
serv
.
Key
)
...
...
plugin/etcd/multi_test.go
View file @
be477092
...
@@ -13,7 +13,7 @@ import (
...
@@ -13,7 +13,7 @@ import (
)
)
func
TestMultiLookup
(
t
*
testing
.
T
)
{
func
TestMultiLookup
(
t
*
testing
.
T
)
{
etc
:=
newEtcd
Middleware
()
etc
:=
newEtcd
Plugin
()
etc
.
Zones
=
[]
string
{
"skydns.test."
,
"miek.nl."
}
etc
.
Zones
=
[]
string
{
"skydns.test."
,
"miek.nl."
}
etc
.
Fallthrough
=
true
etc
.
Fallthrough
=
true
etc
.
Next
=
test
.
ErrorHandler
()
etc
.
Next
=
test
.
ErrorHandler
()
...
...
plugin/etcd/other_test.go
View file @
be477092
...
@@ -17,7 +17,7 @@ import (
...
@@ -17,7 +17,7 @@ import (
)
)
func
TestOtherLookup
(
t
*
testing
.
T
)
{
func
TestOtherLookup
(
t
*
testing
.
T
)
{
etc
:=
newEtcd
Middleware
()
etc
:=
newEtcd
Plugin
()
for
_
,
serv
:=
range
servicesOther
{
for
_
,
serv
:=
range
servicesOther
{
set
(
t
,
etc
,
serv
.
Key
,
0
,
serv
)
set
(
t
,
etc
,
serv
.
Key
,
0
,
serv
)
...
...
plugin/etcd/stub_test.go
View file @
be477092
...
@@ -39,7 +39,7 @@ func TestStubLookup(t *testing.T) {
...
@@ -39,7 +39,7 @@ func TestStubLookup(t *testing.T) {
exampleNetStub
:=
&
msg
.
Service
{
Host
:
host
,
Port
:
port
,
Key
:
"a.example.net.stub.dns.skydns.test."
}
exampleNetStub
:=
&
msg
.
Service
{
Host
:
host
,
Port
:
port
,
Key
:
"a.example.net.stub.dns.skydns.test."
}
servicesStub
=
append
(
servicesStub
,
exampleNetStub
)
servicesStub
=
append
(
servicesStub
,
exampleNetStub
)
etc
:=
newEtcd
Middleware
()
etc
:=
newEtcd
Plugin
()
for
_
,
serv
:=
range
servicesStub
{
for
_
,
serv
:=
range
servicesStub
{
set
(
t
,
etc
,
serv
.
Key
,
0
,
serv
)
set
(
t
,
etc
,
serv
.
Key
,
0
,
serv
)
...
...
plugin/health/healther.go
View file @
be477092
...
@@ -37,6 +37,6 @@ func (h *health) poll() {
...
@@ -37,6 +37,6 @@ func (h *health) poll() {
h
.
SetOk
(
true
)
h
.
SetOk
(
true
)
}
}
//
Middleware
that implements the Healther interface.
//
Plugins
that implements the Healther interface.
// TODO(miek): none yet.
// TODO(miek): none yet.
var
healthers
=
map
[
string
]
bool
{}
var
healthers
=
map
[
string
]
bool
{}
plugin/health/setup.go
View file @
be477092
...
@@ -49,7 +49,7 @@ func setup(c *caddy.Controller) error {
...
@@ -49,7 +49,7 @@ func setup(c *caddy.Controller) error {
c
.
OnStartup
(
h
.
Startup
)
c
.
OnStartup
(
h
.
Startup
)
c
.
OnFinalShutdown
(
h
.
Shutdown
)
c
.
OnFinalShutdown
(
h
.
Shutdown
)
// Don't do Add
Middleware
, as health is not *really* a plugin just a separate webserver running.
// Don't do Add
Plugin
, as health is not *really* a plugin just a separate webserver running.
return
nil
return
nil
}
}
...
...
test/etcd_cache_test.go
View file @
be477092
...
@@ -32,7 +32,7 @@ func TestEtcdCache(t *testing.T) {
...
@@ -32,7 +32,7 @@ func TestEtcdCache(t *testing.T) {
}
}
defer
ex
.
Stop
()
defer
ex
.
Stop
()
etc
:=
etcd
Middleware
()
etc
:=
etcd
Plugin
()
log
.
SetOutput
(
ioutil
.
Discard
)
log
.
SetOutput
(
ioutil
.
Discard
)
var
ctx
=
context
.
TODO
()
var
ctx
=
context
.
TODO
()
...
...
test/etcd_test.go
View file @
be477092
...
@@ -20,7 +20,7 @@ import (
...
@@ -20,7 +20,7 @@ import (
"golang.org/x/net/context"
"golang.org/x/net/context"
)
)
func
etcd
Middleware
()
*
etcd
.
Etcd
{
func
etcd
Plugin
()
*
etcd
.
Etcd
{
etcdCfg
:=
etcdc
.
Config
{
etcdCfg
:=
etcdc
.
Config
{
Endpoints
:
[]
string
{
"http://localhost:2379"
},
Endpoints
:
[]
string
{
"http://localhost:2379"
},
}
}
...
@@ -53,7 +53,7 @@ func TestEtcdStubAndProxyLookup(t *testing.T) {
...
@@ -53,7 +53,7 @@ func TestEtcdStubAndProxyLookup(t *testing.T) {
}
}
defer
ex
.
Stop
()
defer
ex
.
Stop
()
etc
:=
etcd
Middleware
()
etc
:=
etcd
Plugin
()
log
.
SetOutput
(
ioutil
.
Discard
)
log
.
SetOutput
(
ioutil
.
Discard
)
var
ctx
=
context
.
TODO
()
var
ctx
=
context
.
TODO
()
...
...
test/external_test.go
View file @
be477092
...
@@ -12,8 +12,8 @@ import (
...
@@ -12,8 +12,8 @@ import (
// and check if it is really there, but running coredns -plugins.
// and check if it is really there, but running coredns -plugins.
// Dangerous test as it messes with your git tree, maybe use tag?
// Dangerous test as it messes with your git tree, maybe use tag?
func
testExternal
Middleware
Compile
(
t
*
testing
.
T
)
{
func
testExternal
Plugin
Compile
(
t
*
testing
.
T
)
{
if
err
:=
addExample
Middleware
();
err
!=
nil
{
if
err
:=
addExample
Plugin
();
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
defer
run
(
t
,
gitReset
)
defer
run
(
t
,
gitReset
)
...
@@ -50,7 +50,7 @@ func run(t *testing.T, c *exec.Cmd) ([]byte, error) {
...
@@ -50,7 +50,7 @@ func run(t *testing.T, c *exec.Cmd) ([]byte, error) {
}
}
func
addExample
Middleware
()
error
{
func
addExample
Plugin
()
error
{
f
,
err
:=
os
.
OpenFile
(
"../plugin.cfg"
,
os
.
O_APPEND
|
os
.
O_WRONLY
,
os
.
ModeAppend
)
f
,
err
:=
os
.
OpenFile
(
"../plugin.cfg"
,
os
.
O_APPEND
|
os
.
O_WRONLY
,
os
.
ModeAppend
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment