Update corefile-migration to v1.0.12.

The coredns/corefile-migration project switched to a fork of
coredns/caddy to remove dependencies it doesn't actually need. Picking
up this update here in k/k results in a significantly smaller go.mod.

Signed-off-by: Dan Lorenc <dlorenc@google.com>
This commit is contained in:
Dan Lorenc
2021-06-12 23:49:01 -05:00
parent 52eea971c5
commit 8748f3105b
14 changed files with 115 additions and 113 deletions

View File

@@ -48,6 +48,9 @@ func (l *lexer) load(input io.Reader) error {
// discard byte order mark, if present
firstCh, _, err := l.reader.ReadRune()
if err != nil {
if err == io.EOF {
return nil
}
return err
}
if firstCh != 0xFEFF {

View File

@@ -3,7 +3,7 @@ package corefile
import (
"strings"
"github.com/caddyserver/caddy/caddyfile"
"github.com/coredns/caddy/caddyfile"
)
type Corefile struct {

View File

@@ -18,13 +18,13 @@ import (
// any deprecated, removed, or ignored plugins/directives present in the Corefile. Notifications are also returned for
// any new default plugins that would be added in a migration.
func Deprecated(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string) ([]Notice, error) {
return getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, all)
return getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, SevAll)
}
// Unsupported returns a list notifications of plugins/options that are not handled supported by this migration tool,
// but may still be valid in CoreDNS.
func Unsupported(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string) ([]Notice, error) {
return getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, unsupported)
return getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, SevUnsupported)
}
func getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, status string) ([]Notice, error) {
@@ -45,14 +45,14 @@ func getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, status string)
for _, s := range cf.Servers {
for _, p := range s.Plugins {
vp, present := Versions[v].plugins[p.Name]
if status == unsupported && !present {
if status == SevUnsupported && !present {
notices = append(notices, Notice{Plugin: p.Name, Severity: status, Version: v})
continue
}
if !present {
continue
}
if vp.status != "" && vp.status != newdefault && status != unsupported {
if vp.status != "" && vp.status != SevNewDefault && status != SevUnsupported {
notices = append(notices, Notice{
Plugin: p.Name,
Severity: vp.status,
@@ -64,7 +64,7 @@ func getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, status string)
}
for _, o := range p.Options {
vo, present := matchOption(o.Name, Versions[v].plugins[p.Name])
if status == unsupported {
if status == SevUnsupported {
if present {
continue
}
@@ -79,15 +79,15 @@ func getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, status string)
if !present {
continue
}
if vo.status != "" && vo.status != newdefault {
if vo.status != "" && vo.status != SevNewDefault {
notices = append(notices, Notice{Plugin: p.Name, Option: o.Name, Severity: vo.status, Version: v})
continue
}
}
if status != unsupported {
if status != SevUnsupported {
CheckForNewOptions:
for name, vo := range Versions[v].plugins[p.Name].namedOptions {
if vo.status != newdefault {
if vo.status != SevNewDefault {
continue
}
for _, o := range p.Options {
@@ -95,14 +95,14 @@ func getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, status string)
continue CheckForNewOptions
}
}
notices = append(notices, Notice{Plugin: p.Name, Option: name, Severity: newdefault, Version: v})
notices = append(notices, Notice{Plugin: p.Name, Option: name, Severity: SevNewDefault, Version: v})
}
}
}
if status != unsupported {
if status != SevUnsupported {
CheckForNewPlugins:
for name, vp := range Versions[v].plugins {
if vp.status != newdefault {
if vp.status != SevNewDefault {
continue
}
for _, p := range s.Plugins {
@@ -110,7 +110,7 @@ func getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, status string)
continue CheckForNewPlugins
}
}
notices = append(notices, Notice{Plugin: name, Option: "", Severity: newdefault, Version: v})
notices = append(notices, Notice{Plugin: name, Option: "", Severity: SevNewDefault, Version: v})
}
}
}
@@ -158,7 +158,7 @@ func Migrate(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string, deprecati
newPlugs = append(newPlugs, p)
continue
}
if !deprecations && vp.status == deprecated {
if !deprecations && vp.status == SevDeprecated {
newPlugs = append(newPlugs, p)
continue
}
@@ -169,7 +169,7 @@ func Migrate(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string, deprecati
newOpts = append(newOpts, o)
continue
}
if !deprecations && vo.status == deprecated {
if !deprecations && vo.status == SevDeprecated {
newOpts = append(newOpts, o)
continue
}
@@ -204,7 +204,7 @@ func Migrate(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string, deprecati
}
CheckForNewOptions:
for name, vo := range Versions[v].plugins[p.Name].namedOptions {
if vo.status != newdefault {
if vo.status != SevNewDefault {
continue
}
for _, o := range p.Options {
@@ -226,7 +226,7 @@ func Migrate(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string, deprecati
}
CheckForNewPlugins:
for name, vp := range Versions[v].plugins {
if vp.status != newdefault {
if vp.status != SevNewDefault {
continue
}
for _, p := range s.Plugins {

View File

@@ -19,9 +19,9 @@ func (n *Notice) ToString() string {
} else {
s += fmt.Sprintf(`Option "%v" in plugin "%v" `, n.Option, n.Plugin)
}
if n.Severity == unsupported {
if n.Severity == SevUnsupported {
s += "is unsupported by this migration tool in " + n.Version + "."
} else if n.Severity == newdefault {
} else if n.Severity == SevNewDefault {
s += "is added as a default in " + n.Version + "."
} else {
s += "is " + n.Severity + " in " + n.Version + "."
@@ -37,12 +37,12 @@ func (n *Notice) ToString() string {
const (
// The following statuses are used to indicate the state of support/deprecation in a given release.
deprecated = "deprecated" // deprecated, but still completely functional
ignored = "ignored" // if included in the corefile, it will be ignored by CoreDNS
removed = "removed" // completely removed from CoreDNS, and would cause CoreDNS to exit if present in the Corefile
newdefault = "newdefault" // added to the default corefile. CoreDNS may not function properly if it is not present in the corefile.
unsupported = "unsupported" // the plugin/option is not supported by the migration tool
SevDeprecated = "deprecated" // deprecated, but still completely functional
SevIgnored = "ignored" // if included in the corefile, it will be ignored by CoreDNS
SevRemoved = "removed" // completely removed from CoreDNS, and would cause CoreDNS to exit if present in the Corefile
SevNewDefault = "newdefault" // added to the default corefile. CoreDNS may not function properly if it is not present in the corefile.
SevUnsupported = "unsupported" // the plugin/option is not supported by the migration tool
// The following statuses are used for selecting/filtering notifications
all = "all" // show all statuses
SevAll = "all" // show all statuses
)

View File

@@ -76,7 +76,7 @@ var plugins = map[string]map[string]plugin{
namedOptions: map[string]option{
"resyncperiod": {},
"endpoint": { // new deprecation
status: deprecated,
status: SevDeprecated,
action: useFirstArgumentOnly,
},
"tls": {},
@@ -97,7 +97,7 @@ var plugins = map[string]map[string]plugin{
namedOptions: map[string]option{
"resyncperiod": {},
"endpoint": {
status: ignored,
status: SevIgnored,
action: useFirstArgumentOnly,
},
"tls": {},
@@ -107,7 +107,7 @@ var plugins = map[string]map[string]plugin{
"pods": {},
"endpoint_pod_names": {},
"upstream": { // new deprecation
status: deprecated,
status: SevDeprecated,
action: removeOption,
},
"ttl": {},
@@ -120,11 +120,11 @@ var plugins = map[string]map[string]plugin{
"v5": plugin{
namedOptions: map[string]option{
"resyncperiod": { // new deprecation
status: deprecated,
status: SevDeprecated,
action: removeOption,
},
"endpoint": {
status: ignored,
status: SevIgnored,
action: useFirstArgumentOnly,
},
"tls": {},
@@ -134,7 +134,7 @@ var plugins = map[string]map[string]plugin{
"pods": {},
"endpoint_pod_names": {},
"upstream": {
status: ignored,
status: SevIgnored,
action: removeOption,
},
"ttl": {},
@@ -147,11 +147,11 @@ var plugins = map[string]map[string]plugin{
"v6": plugin{
namedOptions: map[string]option{
"resyncperiod": { // now ignored
status: ignored,
status: SevIgnored,
action: removeOption,
},
"endpoint": {
status: ignored,
status: SevIgnored,
action: useFirstArgumentOnly,
},
"tls": {},
@@ -161,7 +161,7 @@ var plugins = map[string]map[string]plugin{
"pods": {},
"endpoint_pod_names": {},
"upstream": {
status: ignored,
status: SevIgnored,
action: removeOption,
},
"ttl": {},
@@ -174,11 +174,11 @@ var plugins = map[string]map[string]plugin{
"v7": plugin{
namedOptions: map[string]option{
"resyncperiod": { // new removal
status: removed,
status: SevRemoved,
action: removeOption,
},
"endpoint": {
status: ignored,
status: SevIgnored,
action: useFirstArgumentOnly,
},
"tls": {},
@@ -188,7 +188,7 @@ var plugins = map[string]map[string]plugin{
"pods": {},
"endpoint_pod_names": {},
"upstream": { // new removal
status: removed,
status: SevRemoved,
action: removeOption,
},
"ttl": {},
@@ -201,7 +201,7 @@ var plugins = map[string]map[string]plugin{
"v8 remove transfer option": plugin{
namedOptions: map[string]option{
"endpoint": {
status: ignored,
status: SevIgnored,
action: useFirstArgumentOnly,
},
"tls": {},
@@ -213,7 +213,7 @@ var plugins = map[string]map[string]plugin{
"ttl": {},
"noendpoints": {},
"transfer": {
status: removed,
status: SevRemoved,
action: removeOption,
},
"fallthrough": {},
@@ -223,7 +223,7 @@ var plugins = map[string]map[string]plugin{
"v8": plugin{
namedOptions: map[string]option{
"endpoint": {
status: ignored,
status: SevIgnored,
action: useFirstArgumentOnly,
},
"tls": {},
@@ -258,7 +258,7 @@ var plugins = map[string]map[string]plugin{
"v1 add lameduck": plugin{
namedOptions: map[string]option{
"lameduck": {
status: newdefault,
status: SevNewDefault,
add: func(c *corefile.Plugin) (*corefile.Plugin, error) {
return addOptionToPlugin(c, &corefile.Option{Name: "lameduck 5s"})
},
@@ -383,7 +383,7 @@ var plugins = map[string]map[string]plugin{
"policy": {},
"health_check": {},
"max_concurrent": { // new option
status: newdefault,
status: SevNewDefault,
add: func(c *corefile.Plugin) (*corefile.Plugin, error) {
return addOptionToPlugin(c, &corefile.Option{Name: "max_concurrent 1000"})
},
@@ -412,7 +412,7 @@ var plugins = map[string]map[string]plugin{
"except": {},
"spray": {},
"protocol": { // https_google option ignored
status: ignored,
status: SevIgnored,
action: proxyRemoveHttpsGoogleProtocol,
},
},
@@ -426,19 +426,19 @@ var plugins = map[string]map[string]plugin{
"except": {},
"spray": {},
"protocol": { // https_google option removed
status: removed,
status: SevRemoved,
action: proxyRemoveHttpsGoogleProtocol,
},
},
},
"deprecation": plugin{ // proxy -> forward deprecation migration
status: deprecated,
status: SevDeprecated,
replacedBy: "forward",
action: proxyToForwardPluginAction,
namedOptions: proxyToForwardOptionsMigrations,
},
"removal": plugin{ // proxy -> forward forced migration
status: removed,
status: SevRemoved,
replacedBy: "forward",
action: proxyToForwardPluginAction,
namedOptions: proxyToForwardOptionsMigrations,

View File

@@ -16,7 +16,7 @@ type release struct {
// tasks that dont fit well into the modular plugin/option migration framework. For example, when the
// action on a plugin would need to extend beyond the scope of that plugin (affecting other plugins, or
// server blocks, etc). e.g. Splitting plugins out into separate server blocks.
preProcess corefileAction
preProcess corefileAction
postProcess corefileAction
// defaultConf holds the default Corefile template packaged with the corresponding k8sReleases.
@@ -30,9 +30,56 @@ type release struct {
// Versions holds a map of plugin/option migrations per CoreDNS release (since 1.1.4)
var Versions = map[string]release{
"1.8.4": {
priorVersion: "1.8.3",
dockerImageSHA: "6e5a02c21641597998b4be7cb5eb1e7b02c0d8d23cce4dd09f4682d463798890",
plugins: map[string]plugin{
"errors": plugins["errors"]["v2"],
"log": plugins["log"]["v1"],
"health": plugins["health"]["v1"],
"ready": {},
"autopath": {},
"kubernetes": plugins["kubernetes"]["v8"],
"k8s_external": plugins["k8s_external"]["v1"],
"prometheus": {},
"forward": plugins["forward"]["v3"],
"cache": plugins["cache"]["v1"],
"loop": {},
"reload": {},
"loadbalance": {},
"hosts": plugins["hosts"]["v1"],
"rewrite": plugins["rewrite"]["v2"],
"transfer": plugins["transfer"]["v1"],
},
},
"1.8.3": {
nextVersion: "1.8.4",
priorVersion: "1.8.0", // CoreDNS 1.8.2 is not a valid version and 1.8.1 docker images were never released.
dockerImageSHA: "642ff9910da6ea9a8624b0234eef52af9ca75ecbec474c5507cb096bdfbae4e5",
plugins: map[string]plugin{
"errors": plugins["errors"]["v2"],
"log": plugins["log"]["v1"],
"health": plugins["health"]["v1"],
"ready": {},
"autopath": {},
"kubernetes": plugins["kubernetes"]["v8"],
"k8s_external": plugins["k8s_external"]["v1"],
"prometheus": {},
"forward": plugins["forward"]["v3"],
"cache": plugins["cache"]["v1"],
"loop": {},
"reload": {},
"loadbalance": {},
"hosts": plugins["hosts"]["v1"],
"rewrite": plugins["rewrite"]["v2"],
"transfer": plugins["transfer"]["v1"],
},
},
"1.8.0": {
nextVersion: "1.8.3", // CoreDNS 1.8.2 is not a valid version and 1.8.1 docker images were never released.
priorVersion: "1.7.1",
dockerImageSHA: "TBD",
k8sReleases: []string{"1.21"},
dockerImageSHA: "cc8fb77bc2a0541949d1d9320a641b82fd392b0d3d8145469ca4709ae769980e",
plugins: map[string]plugin{
"errors": plugins["errors"]["v2"],
"log": plugins["log"]["v1"],
@@ -78,7 +125,7 @@ var Versions = map[string]release{
"1.7.0": {
nextVersion: "1.7.1",
priorVersion: "1.6.9",
k8sReleases: []string{"1.19"},
k8sReleases: []string{"1.19", "1.20"},
dockerImageSHA: "73ca82b4ce829766d4f1f10947c3a338888f876fbed0540dc849c89ff256e90c",
defaultConf: `.:53 {
errors
@@ -424,7 +471,7 @@ var Versions = map[string]release{
"log": plugins["log"]["v1"],
"health": plugins["health"]["v1"],
"ready": {
status: newdefault,
status: SevNewDefault,
add: func(c *corefile.Server) (*corefile.Server, error) {
return addToKubernetesServerBlocks(c, &corefile.Plugin{Name: "ready"})
},
@@ -681,7 +728,7 @@ var Versions = map[string]release{
"forward": plugins["forward"]["v2"],
"cache": plugins["cache"]["v1"],
"loop": {
status: newdefault,
status: SevNewDefault,
add: func(s *corefile.Server) (*corefile.Server, error) {
return addToForwardingServerBlocks(s, &corefile.Plugin{Name: "loop"})
},