func UpdateCachedInstances(viperConfig *viper.Viper, instanceList []ProvisionedInstance) error {
	viperConfig.Set("ProvisionedInstances", instanceList)
	err := viperConfig.WriteConfig()
	if err != nil {
		return err
	}
	return nil
}
UpdateCachedInstances saves the contents of instanceList to a configuration file
package config
import (
	"fmt"
	"os"
	"path/filepath"
	homedir "github.com/mitchellh/go-homedir"
	log "github.com/sirupsen/logrus"
	"github.com/spf13/viper"
)
var Defaults *viper.Viper
var LoadedDefaults DefaultSettings
var Registries *viper.Viper
var ProvisionedInstances *viper.Viper
func InitJSONConfig(configDir string, configName string) (config *viper.Viper, isNewConfig bool) {
	var configPath string
	viperConfig := viper.New()
	viperConfig.SetConfigType("json")
	if configDir != "" {
		viperConfig.AddConfigPath(configDir)
		configPath = configDir
	} else {
		home, err := homedir.Dir()
		if err != nil {
			log.Error(err)
			os.Exit(1)
		}
		configPath = filepath.Join(home, ".apb")
	}
	viperConfig.AddConfigPath(configPath)
	viperConfig.SetConfigName(configName)
	filePath := configPath + fmt.Sprintf("/%s.json", configName)
	if err := viperConfig.ReadInConfig(); err != nil {
		isNewConfig = true
		log.Warningf("Didn't find config file %s, creating.", filePath)
		os.MkdirAll(configPath, 0755)
		file, err := os.Create(filePath)
		if err != nil {
			log.Error(err)
			os.Exit(1)
		}
		file.WriteString("{}")
	}
	if err := viperConfig.ReadInConfig(); err != nil {
		log.Error("Can't read config: ", err)
		os.Exit(1)
	}
	return viperConfig, isNewConfig
}