mirror of
https://github.com/notherealmarco/coredns-deployment.git
synced 2025-05-06 04:42:36 +02:00
kubernetes/migration: Add new default plugins/options (#155)
* add new defaults * i think this works better
This commit is contained in:
parent
d26b5fbfcb
commit
2821bdd6c4
4 changed files with 136 additions and 24 deletions
|
@ -101,6 +101,7 @@ func getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, status string)
|
|||
}
|
||||
|
||||
// Migrate returns version of the Corefile migrated to toCoreDNSVersion, or an error if it cannot.
|
||||
// TODO: add newdefault bool parameter?
|
||||
func Migrate(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string, deprecations bool) (string, error) {
|
||||
err := validateVersions(fromCoreDNSVersion, toCoreDNSVersion)
|
||||
if err != nil {
|
||||
|
@ -161,19 +162,50 @@ func Migrate(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string, deprecati
|
|||
}
|
||||
newOpts = append(newOpts, o)
|
||||
}
|
||||
newPlugs = append(newPlugs,
|
||||
&corefile.Plugin{
|
||||
Name: p.Name,
|
||||
Args: p.Args,
|
||||
Options: newOpts,
|
||||
})
|
||||
newPlug := &corefile.Plugin{
|
||||
Name: p.Name,
|
||||
Args: p.Args,
|
||||
Options: newOpts,
|
||||
}
|
||||
CheckForNewOptions:
|
||||
for name, vo := range Versions[v].plugins[p.Name].options {
|
||||
if vo.status != newdefault {
|
||||
continue
|
||||
}
|
||||
for _, o := range p.Options {
|
||||
if name == o.Name {
|
||||
continue CheckForNewOptions
|
||||
}
|
||||
}
|
||||
newPlug, err = vo.add(newPlug)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
newPlugs = append(newPlugs, newPlug)
|
||||
}
|
||||
newSrvs = append(newSrvs,
|
||||
&corefile.Server{
|
||||
DomPorts: s.DomPorts,
|
||||
Plugins: newPlugs,
|
||||
},
|
||||
)
|
||||
newSrv := &corefile.Server{
|
||||
DomPorts: s.DomPorts,
|
||||
Plugins: newPlugs,
|
||||
}
|
||||
CheckForNewPlugins:
|
||||
for name, vp := range Versions[v].plugins {
|
||||
if vp.status != newdefault {
|
||||
continue
|
||||
}
|
||||
for _, p := range s.Plugins {
|
||||
if name == p.Name {
|
||||
continue CheckForNewPlugins
|
||||
}
|
||||
}
|
||||
newSrv, err = vp.add(newSrv)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
newSrvs = append(newSrvs, newSrv)
|
||||
}
|
||||
cf = corefile.Corefile{Servers: newSrvs}
|
||||
if v == toCoreDNSVersion {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue