Fix/rename endpoint migration (#143)

* fix and rename endpoint action to be more general

* test
This commit is contained in:
Chris O'Haver 2019-04-10 16:01:57 -04:00 committed by GitHub
parent cf59f40250
commit a464e20ac1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 8 deletions

View file

@ -6,10 +6,10 @@ import (
func TestMigrate(t *testing.T) {
startCorefile := `.:53 {
#mycomment
errors
health
kubernetes cluster.local in-addr.arpa ip6.arpa {
endpoint thing1 thing2
pods insecure
upstream
fallthrough in-addr.arpa ip6.arpa
@ -27,6 +27,7 @@ func TestMigrate(t *testing.T) {
errors
health
kubernetes cluster.local in-addr.arpa ip6.arpa {
endpoint thing1
pods insecure
fallthrough in-addr.arpa ip6.arpa
}

View file

@ -64,7 +64,7 @@ var Versions = map[string]release{
},
"endpoint": {
status: ignored,
action: removeExtraEndpoints,
action: useFirstArgumentOnly,
},
"tls": {},
"kubeconfig": {},
@ -125,7 +125,7 @@ var Versions = map[string]release{
"resyncperiod": {},
"endpoint": {
status: ignored,
action: removeExtraEndpoints,
action: useFirstArgumentOnly,
},
"tls": {},
"kubeconfig": {},
@ -202,7 +202,7 @@ var Versions = map[string]release{
"resyncperiod": {},
"endpoint": {
status: deprecated,
action: removeExtraEndpoints,
action: useFirstArgumentOnly,
},
"tls": {},
"kubeconfig": {},
@ -272,10 +272,10 @@ var proxyToForwardPluginAction = func(p *corefile.Plugin) (*corefile.Plugin, err
return renamePlugin(p, "forward")
}
var removeExtraEndpoints = func(o *corefile.Option) (*corefile.Option, error) {
if len(o.Args) > 1 {
o.Args = o.Args[:1]
var useFirstArgumentOnly = func(o *corefile.Option) (*corefile.Option, error) {
if len(o.Args) < 1 {
return o, nil
}
return nil, nil
o.Args = o.Args[:1]
return o, nil
}