Adding CLI for the migration tool (#154)

* Initial commit for the corefile-tool cli for the migration tool

* cleanup implementation

* nit

* add fn to get corefile path

* add released command and improve readme
This commit is contained in:
Sandeep Rajan 2019-04-24 11:22:13 -04:00 committed by Chris O'Haver
parent 631694b4e3
commit 37f5d0dad4
12 changed files with 495 additions and 3 deletions

View file

@ -7,6 +7,8 @@ package migration
import (
"fmt"
"sort"
"github.com/coredns/deployment/kubernetes/migration/corefile"
)
@ -243,9 +245,10 @@ func Released(dockerImageID string) bool {
// ValidVersions returns a list of all versions defined
func ValidVersions() []string {
var vStrs []string
for vStr, _ := range Versions {
for vStr := range Versions {
vStrs = append(vStrs, vStr)
}
sort.Strings(vStrs)
return vStrs
}
@ -261,11 +264,11 @@ func validateVersions(fromCoreDNSVersion, toCoreDNSVersion string) error {
if err != nil {
return err
}
for next := Versions[fromCoreDNSVersion].nextVersion; next != ""; next = Versions[next].nextVersion {
for next := Versions[fromCoreDNSVersion].nextVersion; next != ""; next = Versions[next].nextVersion {
if next != toCoreDNSVersion {
continue
}
return nil
}
return fmt.Errorf("cannot migrate to '%v' from '%v'", toCoreDNSVersion, fromCoreDNSVersion)
}
}