mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 02:41:25 +00:00
update corefile-migration library to 1.0.6
This commit is contained in:
parent
a980cb7ead
commit
cb12e8a059
4
go.mod
4
go.mod
@ -37,7 +37,7 @@ require (
|
|||||||
github.com/containerd/containerd v1.0.2 // indirect
|
github.com/containerd/containerd v1.0.2 // indirect
|
||||||
github.com/containerd/typeurl v0.0.0-20190228175220-2a93cfde8c20 // indirect
|
github.com/containerd/typeurl v0.0.0-20190228175220-2a93cfde8c20 // indirect
|
||||||
github.com/containernetworking/cni v0.7.1
|
github.com/containernetworking/cni v0.7.1
|
||||||
github.com/coredns/corefile-migration v1.0.4
|
github.com/coredns/corefile-migration v1.0.6
|
||||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e
|
||||||
github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea
|
github.com/coreos/pkg v0.0.0-20180108230652-97fdf19511ea
|
||||||
github.com/cpuguy83/go-md2man v1.0.10
|
github.com/cpuguy83/go-md2man v1.0.10
|
||||||
@ -232,7 +232,7 @@ replace (
|
|||||||
github.com/containerd/containerd => github.com/containerd/containerd v1.0.2
|
github.com/containerd/containerd => github.com/containerd/containerd v1.0.2
|
||||||
github.com/containerd/typeurl => github.com/containerd/typeurl v0.0.0-20190228175220-2a93cfde8c20
|
github.com/containerd/typeurl => github.com/containerd/typeurl v0.0.0-20190228175220-2a93cfde8c20
|
||||||
github.com/containernetworking/cni => github.com/containernetworking/cni v0.7.1
|
github.com/containernetworking/cni => github.com/containernetworking/cni v0.7.1
|
||||||
github.com/coredns/corefile-migration => github.com/coredns/corefile-migration v1.0.4
|
github.com/coredns/corefile-migration => github.com/coredns/corefile-migration v1.0.6
|
||||||
github.com/coreos/etcd => github.com/coreos/etcd v3.3.10+incompatible
|
github.com/coreos/etcd => github.com/coreos/etcd v3.3.10+incompatible
|
||||||
github.com/coreos/go-etcd => github.com/coreos/go-etcd v2.0.0+incompatible
|
github.com/coreos/go-etcd => github.com/coreos/go-etcd v2.0.0+incompatible
|
||||||
github.com/coreos/go-oidc => github.com/coreos/go-oidc v2.1.0+incompatible
|
github.com/coreos/go-oidc => github.com/coreos/go-oidc v2.1.0+incompatible
|
||||||
|
4
go.sum
4
go.sum
@ -106,8 +106,8 @@ github.com/containerd/typeurl v0.0.0-20190228175220-2a93cfde8c20 h1:14r0i3IeJj6z
|
|||||||
github.com/containerd/typeurl v0.0.0-20190228175220-2a93cfde8c20/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc=
|
github.com/containerd/typeurl v0.0.0-20190228175220-2a93cfde8c20/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc=
|
||||||
github.com/containernetworking/cni v0.7.1 h1:fE3r16wpSEyaqY4Z4oFrLMmIGfBYIKpPrHK31EJ9FzE=
|
github.com/containernetworking/cni v0.7.1 h1:fE3r16wpSEyaqY4Z4oFrLMmIGfBYIKpPrHK31EJ9FzE=
|
||||||
github.com/containernetworking/cni v0.7.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY=
|
github.com/containernetworking/cni v0.7.1/go.mod h1:LGwApLUm2FpoOfxTDEeq8T9ipbpZ61X79hmU3w8FmsY=
|
||||||
github.com/coredns/corefile-migration v1.0.4 h1:GpAwsgzgLA9HOnt3+Z69xsMVLl0doNnyVfBX79d/P5A=
|
github.com/coredns/corefile-migration v1.0.6 h1:hB6vclp2g/KeXe9n1oz/PafgieUahsOYeHMQA+RJ4Hg=
|
||||||
github.com/coredns/corefile-migration v1.0.4/go.mod h1:OFwBp/Wc9dJt5cAZzHWMNhK1r5L0p0jDwIBc6j8NC8E=
|
github.com/coredns/corefile-migration v1.0.6/go.mod h1:OFwBp/Wc9dJt5cAZzHWMNhK1r5L0p0jDwIBc6j8NC8E=
|
||||||
github.com/coreos/etcd v3.3.10+incompatible h1:jFneRYjIvLMLhDLCzuTuU4rSJUjRplcJQ7pD7MnhC04=
|
github.com/coreos/etcd v3.3.10+incompatible h1:jFneRYjIvLMLhDLCzuTuU4rSJUjRplcJQ7pD7MnhC04=
|
||||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||||
|
1
vendor/github.com/coredns/corefile-migration/migration/BUILD
generated
vendored
1
vendor/github.com/coredns/corefile-migration/migration/BUILD
generated
vendored
@ -5,6 +5,7 @@ go_library(
|
|||||||
srcs = [
|
srcs = [
|
||||||
"migrate.go",
|
"migrate.go",
|
||||||
"notice.go",
|
"notice.go",
|
||||||
|
"plugins.go",
|
||||||
"versions.go",
|
"versions.go",
|
||||||
],
|
],
|
||||||
importmap = "k8s.io/kubernetes/vendor/github.com/coredns/corefile-migration/migration",
|
importmap = "k8s.io/kubernetes/vendor/github.com/coredns/corefile-migration/migration",
|
||||||
|
4
vendor/github.com/coredns/corefile-migration/migration/corefile/corefile.go
generated
vendored
4
vendor/github.com/coredns/corefile-migration/migration/corefile/corefile.go
generated
vendored
@ -152,7 +152,7 @@ NextPlugin:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *Option) FindMatch(def []*Option) (*Option, bool) {
|
func (o *Option) FindMatch(def []*Option) (*Option, bool) {
|
||||||
NextPlugin:
|
NextOption:
|
||||||
for _, oDef := range def {
|
for _, oDef := range def {
|
||||||
if oDef.Name != o.Name {
|
if oDef.Name != o.Name {
|
||||||
continue
|
continue
|
||||||
@ -165,7 +165,7 @@ NextPlugin:
|
|||||||
return oDef, true
|
return oDef, true
|
||||||
}
|
}
|
||||||
if i >= len(o.Args) || arg != o.Args[i] {
|
if i >= len(o.Args) || arg != o.Args[i] {
|
||||||
continue NextPlugin
|
continue NextOption
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(oDef.Args) != len(o.Args) {
|
if len(oDef.Args) != len(o.Args) {
|
||||||
|
59
vendor/github.com/coredns/corefile-migration/migration/migrate.go
generated
vendored
59
vendor/github.com/coredns/corefile-migration/migration/migrate.go
generated
vendored
@ -7,6 +7,7 @@ package migration
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/coredns/corefile-migration/migration/corefile"
|
"github.com/coredns/corefile-migration/migration/corefile"
|
||||||
@ -43,17 +44,14 @@ func getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, status string)
|
|||||||
for _, s := range cf.Servers {
|
for _, s := range cf.Servers {
|
||||||
for _, p := range s.Plugins {
|
for _, p := range s.Plugins {
|
||||||
vp, present := Versions[v].plugins[p.Name]
|
vp, present := Versions[v].plugins[p.Name]
|
||||||
if status == unsupported {
|
if status == unsupported && !present {
|
||||||
if present {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
notices = append(notices, Notice{Plugin: p.Name, Severity: status, Version: v})
|
notices = append(notices, Notice{Plugin: p.Name, Severity: status, Version: v})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if !present {
|
if !present {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if vp.status != "" && vp.status != newdefault {
|
if vp.status != "" && vp.status != newdefault && status != unsupported {
|
||||||
notices = append(notices, Notice{
|
notices = append(notices, Notice{
|
||||||
Plugin: p.Name,
|
Plugin: p.Name,
|
||||||
Severity: vp.status,
|
Severity: vp.status,
|
||||||
@ -64,7 +62,7 @@ func getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, status string)
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
for _, o := range p.Options {
|
for _, o := range p.Options {
|
||||||
vo, present := Versions[v].plugins[p.Name].options[o.Name]
|
vo, present := matchOption(o.Name, Versions[v].plugins[p.Name])
|
||||||
if status == unsupported {
|
if status == unsupported {
|
||||||
if present {
|
if present {
|
||||||
continue
|
continue
|
||||||
@ -74,8 +72,6 @@ func getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, status string)
|
|||||||
Option: o.Name,
|
Option: o.Name,
|
||||||
Severity: status,
|
Severity: status,
|
||||||
Version: v,
|
Version: v,
|
||||||
ReplacedBy: vo.replacedBy,
|
|
||||||
Additional: vo.additional,
|
|
||||||
})
|
})
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -89,7 +85,7 @@ func getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, status string)
|
|||||||
}
|
}
|
||||||
if status != unsupported {
|
if status != unsupported {
|
||||||
CheckForNewOptions:
|
CheckForNewOptions:
|
||||||
for name, vo := range Versions[v].plugins[p.Name].options {
|
for name, vo := range Versions[v].plugins[p.Name].namedOptions {
|
||||||
if vo.status != newdefault {
|
if vo.status != newdefault {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -156,19 +152,9 @@ func Migrate(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string, deprecati
|
|||||||
newPlugs = append(newPlugs, p)
|
newPlugs = append(newPlugs, p)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if vp.action != nil {
|
|
||||||
p, err := vp.action(p)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
if p == nil {
|
|
||||||
// remove plugin, skip options processing
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newOpts := []*corefile.Option{}
|
newOpts := []*corefile.Option{}
|
||||||
for _, o := range p.Options {
|
for _, o := range p.Options {
|
||||||
vo, present := Versions[v].plugins[p.Name].options[o.Name]
|
vo, present := matchOption(o.Name, Versions[v].plugins[p.Name])
|
||||||
if !present {
|
if !present {
|
||||||
newOpts = append(newOpts, o)
|
newOpts = append(newOpts, o)
|
||||||
continue
|
continue
|
||||||
@ -191,13 +177,23 @@ func Migrate(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string, deprecati
|
|||||||
}
|
}
|
||||||
newOpts = append(newOpts, o)
|
newOpts = append(newOpts, o)
|
||||||
}
|
}
|
||||||
|
if vp.action != nil {
|
||||||
|
p, err := vp.action(p)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if p == nil {
|
||||||
|
// remove plugin, skip options processing
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
newPlug := &corefile.Plugin{
|
newPlug := &corefile.Plugin{
|
||||||
Name: p.Name,
|
Name: p.Name,
|
||||||
Args: p.Args,
|
Args: p.Args,
|
||||||
Options: newOpts,
|
Options: newOpts,
|
||||||
}
|
}
|
||||||
CheckForNewOptions:
|
CheckForNewOptions:
|
||||||
for name, vo := range Versions[v].plugins[p.Name].options {
|
for name, vo := range Versions[v].plugins[p.Name].namedOptions {
|
||||||
if vo.status != newdefault {
|
if vo.status != newdefault {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -294,7 +290,7 @@ func MigrateDown(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string) (stri
|
|||||||
|
|
||||||
newOpts := []*corefile.Option{}
|
newOpts := []*corefile.Option{}
|
||||||
for _, o := range p.Options {
|
for _, o := range p.Options {
|
||||||
vo, present := Versions[v].plugins[p.Name].options[o.Name]
|
vo, present := matchOption(o.Name, Versions[v].plugins[p.Name])
|
||||||
if !present {
|
if !present {
|
||||||
newOpts = append(newOpts, o)
|
newOpts = append(newOpts, o)
|
||||||
continue
|
continue
|
||||||
@ -446,3 +442,22 @@ func validDownMigration(fromCoreDNSVersion, toCoreDNSVersion string) error {
|
|||||||
}
|
}
|
||||||
return fmt.Errorf("cannot migrate down to '%v' from '%v'", toCoreDNSVersion, fromCoreDNSVersion)
|
return fmt.Errorf("cannot migrate down to '%v' from '%v'", toCoreDNSVersion, fromCoreDNSVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func matchOption(oName string, p plugin) (*option, bool) {
|
||||||
|
o, exists := p.namedOptions[oName]
|
||||||
|
if exists {
|
||||||
|
o.name = oName
|
||||||
|
return &o, exists
|
||||||
|
}
|
||||||
|
for pattern, o := range p.patternOptions {
|
||||||
|
matched, err := regexp.MatchString(pattern, oName)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if matched {
|
||||||
|
o.name = oName
|
||||||
|
return &o, true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil, false
|
||||||
|
}
|
||||||
|
499
vendor/github.com/coredns/corefile-migration/migration/plugins.go
generated
vendored
Normal file
499
vendor/github.com/coredns/corefile-migration/migration/plugins.go
generated
vendored
Normal file
@ -0,0 +1,499 @@
|
|||||||
|
package migration
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
|
||||||
|
"github.com/coredns/corefile-migration/migration/corefile"
|
||||||
|
)
|
||||||
|
|
||||||
|
type plugin struct {
|
||||||
|
status string
|
||||||
|
replacedBy string
|
||||||
|
additional string
|
||||||
|
namedOptions map[string]option
|
||||||
|
patternOptions map[string]option
|
||||||
|
action pluginActionFn // action affecting this plugin only
|
||||||
|
add serverActionFn // action to add a new plugin to the server block
|
||||||
|
downAction pluginActionFn // downgrade action affecting this plugin only
|
||||||
|
}
|
||||||
|
|
||||||
|
type option struct {
|
||||||
|
name string
|
||||||
|
status string
|
||||||
|
replacedBy string
|
||||||
|
additional string
|
||||||
|
action optionActionFn // action affecting this option only
|
||||||
|
add pluginActionFn // action to add the option to the plugin
|
||||||
|
downAction optionActionFn // downgrade action affecting this option only
|
||||||
|
}
|
||||||
|
|
||||||
|
type corefileAction func(*corefile.Corefile) (*corefile.Corefile, error)
|
||||||
|
type serverActionFn func(*corefile.Server) (*corefile.Server, error)
|
||||||
|
type pluginActionFn func(*corefile.Plugin) (*corefile.Plugin, error)
|
||||||
|
type optionActionFn func(*corefile.Option) (*corefile.Option, error)
|
||||||
|
|
||||||
|
// plugins holds a map of plugin names and their migration rules per "version". "Version" here is meaningless outside
|
||||||
|
// of the context of this code. Each change in options or migration actions for a plugin requires a new "version"
|
||||||
|
// containing those new/removed options and migration actions. Plugins in CoreDNS are not versioned.
|
||||||
|
var plugins = map[string]map[string]plugin{
|
||||||
|
"kubernetes": {
|
||||||
|
"v1": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"resyncperiod": {},
|
||||||
|
"endpoint": {},
|
||||||
|
"tls": {},
|
||||||
|
"namespaces": {},
|
||||||
|
"labels": {},
|
||||||
|
"pods": {},
|
||||||
|
"endpoint_pod_names": {},
|
||||||
|
"upstream": {},
|
||||||
|
"ttl": {},
|
||||||
|
"noendpoints": {},
|
||||||
|
"transfer": {},
|
||||||
|
"fallthrough": {},
|
||||||
|
"ignore": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"v2": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"resyncperiod": {},
|
||||||
|
"endpoint": {},
|
||||||
|
"tls": {},
|
||||||
|
"namespaces": {},
|
||||||
|
"labels": {},
|
||||||
|
"pods": {},
|
||||||
|
"endpoint_pod_names": {},
|
||||||
|
"upstream": {},
|
||||||
|
"ttl": {},
|
||||||
|
"noendpoints": {},
|
||||||
|
"transfer": {},
|
||||||
|
"fallthrough": {},
|
||||||
|
"ignore": {},
|
||||||
|
"kubeconfig": {}, // new option
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"v3": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"resyncperiod": {},
|
||||||
|
"endpoint": { // new deprecation
|
||||||
|
status: deprecated,
|
||||||
|
action: useFirstArgumentOnly,
|
||||||
|
},
|
||||||
|
"tls": {},
|
||||||
|
"kubeconfig": {},
|
||||||
|
"namespaces": {},
|
||||||
|
"labels": {},
|
||||||
|
"pods": {},
|
||||||
|
"endpoint_pod_names": {},
|
||||||
|
"upstream": {},
|
||||||
|
"ttl": {},
|
||||||
|
"noendpoints": {},
|
||||||
|
"transfer": {},
|
||||||
|
"fallthrough": {},
|
||||||
|
"ignore": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"v4": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"resyncperiod": {},
|
||||||
|
"endpoint": {
|
||||||
|
status: ignored,
|
||||||
|
action: useFirstArgumentOnly,
|
||||||
|
},
|
||||||
|
"tls": {},
|
||||||
|
"kubeconfig": {},
|
||||||
|
"namespaces": {},
|
||||||
|
"labels": {},
|
||||||
|
"pods": {},
|
||||||
|
"endpoint_pod_names": {},
|
||||||
|
"upstream": { // new deprecation
|
||||||
|
status: deprecated,
|
||||||
|
action: removeOption,
|
||||||
|
},
|
||||||
|
"ttl": {},
|
||||||
|
"noendpoints": {},
|
||||||
|
"transfer": {},
|
||||||
|
"fallthrough": {},
|
||||||
|
"ignore": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"v5": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"resyncperiod": { // new deprecation
|
||||||
|
status: deprecated,
|
||||||
|
action: removeOption,
|
||||||
|
},
|
||||||
|
"endpoint": {
|
||||||
|
status: ignored,
|
||||||
|
action: useFirstArgumentOnly,
|
||||||
|
},
|
||||||
|
"tls": {},
|
||||||
|
"kubeconfig": {},
|
||||||
|
"namespaces": {},
|
||||||
|
"labels": {},
|
||||||
|
"pods": {},
|
||||||
|
"endpoint_pod_names": {},
|
||||||
|
"upstream": {
|
||||||
|
status: ignored,
|
||||||
|
action: removeOption,
|
||||||
|
},
|
||||||
|
"ttl": {},
|
||||||
|
"noendpoints": {},
|
||||||
|
"transfer": {},
|
||||||
|
"fallthrough": {},
|
||||||
|
"ignore": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"v6": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"resyncperiod": { // new removal
|
||||||
|
status: removed,
|
||||||
|
action: removeOption,
|
||||||
|
},
|
||||||
|
"endpoint": {
|
||||||
|
status: ignored,
|
||||||
|
action: useFirstArgumentOnly,
|
||||||
|
},
|
||||||
|
"tls": {},
|
||||||
|
"kubeconfig": {},
|
||||||
|
"namespaces": {},
|
||||||
|
"labels": {},
|
||||||
|
"pods": {},
|
||||||
|
"endpoint_pod_names": {},
|
||||||
|
"upstream": {
|
||||||
|
status: ignored,
|
||||||
|
action: removeOption,
|
||||||
|
},
|
||||||
|
"ttl": {},
|
||||||
|
"noendpoints": {},
|
||||||
|
"transfer": {},
|
||||||
|
"fallthrough": {},
|
||||||
|
"ignore": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"v7": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
// resyncperiod removed
|
||||||
|
"endpoint": {
|
||||||
|
status: ignored,
|
||||||
|
action: useFirstArgumentOnly,
|
||||||
|
},
|
||||||
|
"tls": {},
|
||||||
|
"kubeconfig": {},
|
||||||
|
"namespaces": {},
|
||||||
|
"labels": {},
|
||||||
|
"pods": {},
|
||||||
|
"endpoint_pod_names": {},
|
||||||
|
"upstream": {
|
||||||
|
status: ignored,
|
||||||
|
action: removeOption,
|
||||||
|
},
|
||||||
|
"ttl": {},
|
||||||
|
"noendpoints": {},
|
||||||
|
"transfer": {},
|
||||||
|
"fallthrough": {},
|
||||||
|
"ignore": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
"errors": {
|
||||||
|
"v1": plugin{},
|
||||||
|
"v2": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"consolidate": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
"health": {
|
||||||
|
"v1": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"lameduck": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"v1 add lameduck": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"lameduck": {
|
||||||
|
status: newdefault,
|
||||||
|
add: func(c *corefile.Plugin) (*corefile.Plugin, error) {
|
||||||
|
return addOptionToPlugin(c, &corefile.Option{Name: "lameduck 5s"})
|
||||||
|
},
|
||||||
|
downAction: removeOption,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
"hosts": {
|
||||||
|
"v1": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"ttl": {},
|
||||||
|
"no_reverse": {},
|
||||||
|
"reload": {},
|
||||||
|
"fallthrough": {},
|
||||||
|
},
|
||||||
|
patternOptions: map[string]option{
|
||||||
|
`\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}`: {}, // close enough
|
||||||
|
`[0-9A-Fa-f]{1,4}:[:0-9A-Fa-f]+:[0-9A-Fa-f]{1,4}`: {}, // less close, but still close enough
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
"rewrite": {
|
||||||
|
"v1": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"type": {},
|
||||||
|
"class": {},
|
||||||
|
"name": {},
|
||||||
|
"answer name": {},
|
||||||
|
"edns0": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"v2": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"type": {},
|
||||||
|
"class": {},
|
||||||
|
"name": {},
|
||||||
|
"answer name": {},
|
||||||
|
"edns0": {},
|
||||||
|
"ttl": {}, // new option
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
"log": {
|
||||||
|
"v1": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"class": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
"cache": {
|
||||||
|
"v1": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"success": {},
|
||||||
|
"denial": {},
|
||||||
|
"prefetch": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"v2": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"success": {},
|
||||||
|
"denial": {},
|
||||||
|
"prefetch": {},
|
||||||
|
"serve_stale": {}, // new option
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
"forward": {
|
||||||
|
"v1": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"except": {},
|
||||||
|
"force_tcp": {},
|
||||||
|
"expire": {},
|
||||||
|
"max_fails": {},
|
||||||
|
"tls": {},
|
||||||
|
"tls_servername": {},
|
||||||
|
"policy": {},
|
||||||
|
"health_check": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"v2": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"except": {},
|
||||||
|
"force_tcp": {},
|
||||||
|
"prefer_udp": {},
|
||||||
|
"expire": {},
|
||||||
|
"max_fails": {},
|
||||||
|
"tls": {},
|
||||||
|
"tls_servername": {},
|
||||||
|
"policy": {},
|
||||||
|
"health_check": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
"k8s_external": {
|
||||||
|
"v1": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"apex": {},
|
||||||
|
"ttl": {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
"proxy": {
|
||||||
|
"v1": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"policy": {},
|
||||||
|
"fail_timeout": {},
|
||||||
|
"max_fails": {},
|
||||||
|
"health_check": {},
|
||||||
|
"except": {},
|
||||||
|
"spray": {},
|
||||||
|
"protocol": { // https_google option ignored
|
||||||
|
status: ignored,
|
||||||
|
action: proxyRemoveHttpsGoogleProtocol,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"v2": plugin{
|
||||||
|
namedOptions: map[string]option{
|
||||||
|
"policy": {},
|
||||||
|
"fail_timeout": {},
|
||||||
|
"max_fails": {},
|
||||||
|
"health_check": {},
|
||||||
|
"except": {},
|
||||||
|
"spray": {},
|
||||||
|
"protocol": { // https_google option removed
|
||||||
|
status: removed,
|
||||||
|
action: proxyRemoveHttpsGoogleProtocol,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"deprecation": plugin{ // proxy -> forward deprecation migration
|
||||||
|
status: deprecated,
|
||||||
|
replacedBy: "forward",
|
||||||
|
action: proxyToForwardPluginAction,
|
||||||
|
namedOptions: proxyToForwardOptionsMigrations,
|
||||||
|
},
|
||||||
|
"removal": plugin{ // proxy -> forward forced migration
|
||||||
|
status: removed,
|
||||||
|
replacedBy: "forward",
|
||||||
|
action: proxyToForwardPluginAction,
|
||||||
|
namedOptions: proxyToForwardOptionsMigrations,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func removePlugin(*corefile.Plugin) (*corefile.Plugin, error) { return nil, nil }
|
||||||
|
func removeOption(*corefile.Option) (*corefile.Option, error) { return nil, nil }
|
||||||
|
|
||||||
|
func renamePlugin(p *corefile.Plugin, to string) (*corefile.Plugin, error) {
|
||||||
|
p.Name = to
|
||||||
|
return p, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func addToServerBlockWithPlugins(sb *corefile.Server, newPlugin *corefile.Plugin, with []string) (*corefile.Server, error) {
|
||||||
|
if len(with) == 0 {
|
||||||
|
// add to all blocks
|
||||||
|
sb.Plugins = append(sb.Plugins, newPlugin)
|
||||||
|
return sb, nil
|
||||||
|
}
|
||||||
|
for _, p := range sb.Plugins {
|
||||||
|
for _, w := range with {
|
||||||
|
if w == p.Name {
|
||||||
|
// add to this block
|
||||||
|
sb.Plugins = append(sb.Plugins, newPlugin)
|
||||||
|
return sb, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func addToKubernetesServerBlocks(sb *corefile.Server, newPlugin *corefile.Plugin) (*corefile.Server, error) {
|
||||||
|
return addToServerBlockWithPlugins(sb, newPlugin, []string{"kubernetes"})
|
||||||
|
}
|
||||||
|
|
||||||
|
func addToForwardingServerBlocks(sb *corefile.Server, newPlugin *corefile.Plugin) (*corefile.Server, error) {
|
||||||
|
return addToServerBlockWithPlugins(sb, newPlugin, []string{"forward", "proxy"})
|
||||||
|
}
|
||||||
|
|
||||||
|
func addToAllServerBlocks(sb *corefile.Server, newPlugin *corefile.Plugin) (*corefile.Server, error) {
|
||||||
|
return addToServerBlockWithPlugins(sb, newPlugin, []string{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func addOptionToPlugin(pl *corefile.Plugin, newOption *corefile.Option) (*corefile.Plugin, error) {
|
||||||
|
pl.Options = append(pl.Options, newOption)
|
||||||
|
return pl, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var proxyToForwardOptionsMigrations = map[string]option{
|
||||||
|
"policy": {
|
||||||
|
action: func(o *corefile.Option) (*corefile.Option, error) {
|
||||||
|
if len(o.Args) == 1 && o.Args[0] == "least_conn" {
|
||||||
|
o.Name = "force_tcp"
|
||||||
|
o.Args = nil
|
||||||
|
}
|
||||||
|
return o, nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"except": {},
|
||||||
|
"fail_timeout": {action: removeOption},
|
||||||
|
"max_fails": {action: removeOption},
|
||||||
|
"health_check": {action: removeOption},
|
||||||
|
"spray": {action: removeOption},
|
||||||
|
"protocol": {
|
||||||
|
action: func(o *corefile.Option) (*corefile.Option, error) {
|
||||||
|
if len(o.Args) >= 2 && o.Args[0] == "force_tcp" {
|
||||||
|
o.Name = "force_tcp"
|
||||||
|
o.Args = nil
|
||||||
|
return o, nil
|
||||||
|
}
|
||||||
|
return nil, nil
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var proxyToForwardPluginAction = func(p *corefile.Plugin) (*corefile.Plugin, error) {
|
||||||
|
return renamePlugin(p, "forward")
|
||||||
|
}
|
||||||
|
|
||||||
|
var useFirstArgumentOnly = func(o *corefile.Option) (*corefile.Option, error) {
|
||||||
|
if len(o.Args) < 1 {
|
||||||
|
return o, nil
|
||||||
|
}
|
||||||
|
o.Args = o.Args[:1]
|
||||||
|
return o, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var proxyRemoveHttpsGoogleProtocol = func(o *corefile.Option) (*corefile.Option, error) {
|
||||||
|
if len(o.Args) > 0 && o.Args[0] == "https_google" {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return o, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func breakForwardStubDomainsIntoServerBlocks(cf *corefile.Corefile) (*corefile.Corefile, error) {
|
||||||
|
for _, sb := range cf.Servers {
|
||||||
|
for j, fwd := range sb.Plugins {
|
||||||
|
if fwd.Name != "forward" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(fwd.Args) == 0 {
|
||||||
|
return nil, errors.New("found invalid forward plugin declaration")
|
||||||
|
}
|
||||||
|
if fwd.Args[0] == "." {
|
||||||
|
// dont move the default upstream
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(sb.DomPorts) != 1 {
|
||||||
|
return cf, errors.New("unhandled migration of multi-domain/port server block")
|
||||||
|
}
|
||||||
|
if sb.DomPorts[0] != "." && sb.DomPorts[0] != ".:53" {
|
||||||
|
return cf, errors.New("unhandled migration of non-default domain/port server block")
|
||||||
|
}
|
||||||
|
|
||||||
|
newSb := &corefile.Server{} // create a new server block
|
||||||
|
newSb.DomPorts = []string{fwd.Args[0]} // copy the forward zone to the server block domain
|
||||||
|
fwd.Args[0] = "." // the plugin's zone changes to "." for brevity
|
||||||
|
newSb.Plugins = append(newSb.Plugins, fwd) // add the plugin to its new server block
|
||||||
|
|
||||||
|
// Add appropriate addtl plugins to new server block
|
||||||
|
newSb.Plugins = append(newSb.Plugins, &corefile.Plugin{Name: "loop"})
|
||||||
|
newSb.Plugins = append(newSb.Plugins, &corefile.Plugin{Name: "errors"})
|
||||||
|
newSb.Plugins = append(newSb.Plugins, &corefile.Plugin{Name: "cache", Args: []string{"30"}})
|
||||||
|
|
||||||
|
//add new server block to corefile
|
||||||
|
cf.Servers = append(cf.Servers, newSb)
|
||||||
|
|
||||||
|
//remove the forward plugin from the original server block
|
||||||
|
sb.Plugins = append(sb.Plugins[:j], sb.Plugins[j+1:]...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cf, nil
|
||||||
|
}
|
1655
vendor/github.com/coredns/corefile-migration/migration/versions.go
generated
vendored
1655
vendor/github.com/coredns/corefile-migration/migration/versions.go
generated
vendored
File diff suppressed because it is too large
Load Diff
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -186,7 +186,7 @@ github.com/containernetworking/cni/pkg/types
|
|||||||
github.com/containernetworking/cni/pkg/types/020
|
github.com/containernetworking/cni/pkg/types/020
|
||||||
github.com/containernetworking/cni/pkg/types/current
|
github.com/containernetworking/cni/pkg/types/current
|
||||||
github.com/containernetworking/cni/pkg/version
|
github.com/containernetworking/cni/pkg/version
|
||||||
# github.com/coredns/corefile-migration v1.0.4 => github.com/coredns/corefile-migration v1.0.4
|
# github.com/coredns/corefile-migration v1.0.6 => github.com/coredns/corefile-migration v1.0.6
|
||||||
github.com/coredns/corefile-migration/migration
|
github.com/coredns/corefile-migration/migration
|
||||||
github.com/coredns/corefile-migration/migration/corefile
|
github.com/coredns/corefile-migration/migration/corefile
|
||||||
# github.com/coreos/go-oidc v2.1.0+incompatible => github.com/coreos/go-oidc v2.1.0+incompatible
|
# github.com/coreos/go-oidc v2.1.0+incompatible => github.com/coreos/go-oidc v2.1.0+incompatible
|
||||||
|
Loading…
Reference in New Issue
Block a user