update corefile-migration library to 1.0.8
This commit is contained in:
22
vendor/github.com/coredns/corefile-migration/migration/corefile/corefile.go
generated
vendored
22
vendor/github.com/coredns/corefile-migration/migration/corefile/corefile.go
generated
vendored
@@ -76,7 +76,7 @@ func (c *Corefile) ToString() (out string) {
|
||||
}
|
||||
|
||||
func (s *Server) ToString() (out string) {
|
||||
str := strings.Join(s.DomPorts, " ")
|
||||
str := strings.Join(escapeArgs(s.DomPorts), " ")
|
||||
strs := []string{}
|
||||
for _, p := range s.Plugins {
|
||||
strs = append(strs, strings.Repeat(" ", indent)+p.ToString())
|
||||
@@ -88,7 +88,7 @@ func (s *Server) ToString() (out string) {
|
||||
}
|
||||
|
||||
func (p *Plugin) ToString() (out string) {
|
||||
str := strings.Join(append([]string{p.Name}, p.Args...), " ")
|
||||
str := strings.Join(append([]string{p.Name}, escapeArgs(p.Args)...), " ")
|
||||
strs := []string{}
|
||||
for _, o := range p.Options {
|
||||
strs = append(strs, strings.Repeat(" ", indent*2)+o.ToString())
|
||||
@@ -100,10 +100,26 @@ func (p *Plugin) ToString() (out string) {
|
||||
}
|
||||
|
||||
func (o *Option) ToString() (out string) {
|
||||
str := strings.Join(append([]string{o.Name}, o.Args...), " ")
|
||||
str := strings.Join(append([]string{o.Name}, escapeArgs(o.Args)...), " ")
|
||||
return str
|
||||
}
|
||||
|
||||
// escapeArgs returns the arguments list escaping and wrapping any argument containing whitespace in quotes
|
||||
func escapeArgs(args []string) []string {
|
||||
var escapedArgs []string
|
||||
for _, a := range args {
|
||||
// if there is white space, wrap argument with quotes
|
||||
if len(strings.Fields(a)) > 1 {
|
||||
// escape quotes
|
||||
a = strings.Replace(a, "\"", "\\\"", -1)
|
||||
// wrap with quotes
|
||||
a = "\"" + a + "\""
|
||||
}
|
||||
escapedArgs = append(escapedArgs, a)
|
||||
}
|
||||
return escapedArgs
|
||||
}
|
||||
|
||||
func (s *Server) FindMatch(def []*Server) (*Server, bool) {
|
||||
NextServer:
|
||||
for _, sDef := range def {
|
||||
|
31
vendor/github.com/coredns/corefile-migration/migration/migrate.go
generated
vendored
31
vendor/github.com/coredns/corefile-migration/migration/migrate.go
generated
vendored
@@ -6,6 +6,7 @@ package migration
|
||||
// helper functions that make this easier to implement.
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"sort"
|
||||
@@ -27,7 +28,7 @@ func Unsupported(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string) ([]No
|
||||
}
|
||||
|
||||
func getStatus(fromCoreDNSVersion, toCoreDNSVersion, corefileStr, status string) ([]Notice, error) {
|
||||
err := validUpMigration(fromCoreDNSVersion, toCoreDNSVersion)
|
||||
err := ValidUpMigration(fromCoreDNSVersion, toCoreDNSVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -128,7 +129,7 @@ func Migrate(fromCoreDNSVersion, toCoreDNSVersion, corefileStr string, deprecati
|
||||
if fromCoreDNSVersion == toCoreDNSVersion {
|
||||
return corefileStr, nil
|
||||
}
|
||||
err := validUpMigration(fromCoreDNSVersion, toCoreDNSVersion)
|
||||
err := ValidUpMigration(fromCoreDNSVersion, toCoreDNSVersion)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -394,6 +395,16 @@ func Released(dockerImageSHA string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// VersionFromSHA returns the version string matching the dockerImageSHA.
|
||||
func VersionFromSHA(dockerImageSHA string) (string, error) {
|
||||
for vStr, v := range Versions {
|
||||
if v.dockerImageSHA == dockerImageSHA {
|
||||
return vStr, nil
|
||||
}
|
||||
}
|
||||
return "", errors.New("sha unsupported")
|
||||
}
|
||||
|
||||
// ValidVersions returns a list of all versions defined
|
||||
func ValidVersions() []string {
|
||||
var vStrs []string
|
||||
@@ -404,14 +415,7 @@ func ValidVersions() []string {
|
||||
return vStrs
|
||||
}
|
||||
|
||||
func validateVersion(fromCoreDNSVersion string) error {
|
||||
if _, ok := Versions[fromCoreDNSVersion]; !ok {
|
||||
return fmt.Errorf("start version '%v' not supported", fromCoreDNSVersion)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validUpMigration(fromCoreDNSVersion, toCoreDNSVersion string) error {
|
||||
func ValidUpMigration(fromCoreDNSVersion, toCoreDNSVersion string) error {
|
||||
|
||||
err := validateVersion(fromCoreDNSVersion)
|
||||
if err != nil {
|
||||
@@ -429,6 +433,13 @@ func validUpMigration(fromCoreDNSVersion, toCoreDNSVersion string) error {
|
||||
return fmt.Errorf("cannot migrate up to '%v' from '%v'", toCoreDNSVersion, fromCoreDNSVersion)
|
||||
}
|
||||
|
||||
func validateVersion(fromCoreDNSVersion string) error {
|
||||
if _, ok := Versions[fromCoreDNSVersion]; !ok {
|
||||
return fmt.Errorf("start version '%v' not supported", fromCoreDNSVersion)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validDownMigration(fromCoreDNSVersion, toCoreDNSVersion string) error {
|
||||
err := validateVersion(fromCoreDNSVersion)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user