func InitConf()

in cli/pkg/config/config.go [85:125]


func InitConf(cfgFile string) *Config {
	conf := &Config{}
	var err error

	// if cfgFile is *not* set, prompts the user for a project ID, + reads / validates the default config
	if cfgFile == "" {
		conf, err = InitWithDefaults()
		if err != nil {
			log.Error(err)
			os.Exit(1)
		}
	} else {
		// if cfgFile is set, reads in + validates the user's config.
		conf, err = readConf(cfgFile)
		if err != nil {
			log.Error(err)
			os.Exit(1)
		}
	}
	// Enable GCP APIs - Temporarily adding all apis needed to deal with flakes in the enable service TF module
	serviceIds := []string{
		"compute.googleapis.com",
	}
	enableService(conf.ClustersProjectID, serviceIds)

	// Validate config
	err = ValidateConf(conf)
	if err != nil {
		log.Error(err)
		os.Exit(1)
	}

	// Set Tf Module Repo and Branch
	err = setTfModuleRepo(conf.TFModuleRepo, conf.TFModuleBranch)
	if err != nil {
		log.Error(err)
		os.Exit(1)
	}

	return conf
}