func addLocations()

in cmd/auth/main.go [92:118]


func addLocations(locations, jsonKeyPath, hostPattern string) {
	if strings.Count(hostPattern, "%s") != 1 {
		errMsg := "-host_pattern must have one and only one %%s in it."
		log.Println(errMsg)
		return
	}
	if locations == "" {
		log.Println("-locations is required.")
		return
	}
	ll := strings.Split(locations, ",")
	p, config, err := netrc.Load()
	if err != nil {
		log.Println(err)
		os.Exit(1)
	}
	newCfg, err := netrc.AddConfigs(ll, config, hostPattern, jsonKeyPath)
	if err != nil {
		log.Println(err)
		os.Exit(1)
	}
	if err := netrc.Save(newCfg, p); err != nil {
		log.Println(err)
		os.Exit(1)
	}
	log.Println("Add locations completed.")
}