Guard against nil panics

pull/8741/head
Thomas Stromberg 2020-07-16 19:50:00 -07:00
parent 7d7b9d6fb9
commit 2fd7492377
2 changed files with 7 additions and 1 deletions

View File

@ -155,7 +155,9 @@ func runStart(cmd *cobra.Command, args []string) {
exit.WithCodeT(exit.Data, "Unable to load config: {{.error}}", out.V{"error": err})
}
upgradeExistingConfig(existing)
if existing != nil {
upgradeExistingConfig(existing)
}
validateSpecifiedDriver(existing)
validateKubernetesVersion(existing)

View File

@ -359,6 +359,10 @@ func generateClusterConfig(cmd *cobra.Command, existing *config.ClusterConfig, k
// upgradeExistingConfig upgrades legacy configuration files
func upgradeExistingConfig(cc *config.ClusterConfig) {
if cc == nil {
return
}
if cc.VMDriver != "" && cc.Driver == "" {
glog.Infof("config upgrade: Driver=%s", cc.VMDriver)
cc.Driver = cc.VMDriver