func askInfraSelection()

in pkg/ecctl/init.go [375:412]


func askInfraSelection(cfg *Config, scanner *input.Scanner, writer, errWriter io.Writer, passFunc PassFunc) error {
	infraChoiceRaw := scanner.Scan(hostChoiceMsg)
	fmt.Fprintln(writer)
	infraChoice, err := strconv.Atoi(infraChoiceRaw)
	if err != nil {
		return err
	}

	cfg.Host = essHostAddress
	switch infraChoice {
	case essInfraChoice:
		fmt.Fprintf(writer, essChoiceMsg, essHostAddress)
		if err := askRegionSelection(cfg, scanner, writer, essRegions); err != nil {
			return err
		}
		fmt.Fprintln(writer, essAPIKeyCreateMsg)
		if err := askAPIKey(cfg, writer, passFunc); err != nil {
			return err
		}
	case eceInfraChoice:
		cfg.Host = scanner.Scan(eceHostMsg)
		if err := askAuthMechanism(cfg, scanner, writer, passFunc); err != nil {
			return err
		}
	case esspInfraChoice:
		cfg.Host = scanner.Scan(esspHostMsg)
		if err := askAPIKey(cfg, writer, passFunc); err != nil {
			return err
		}
		// For the time being the only available region for ESSP is us-west-2. Once more
		// regions have been added, this should be set in a similar way to essInfraChoice
		cfg.Region = "us-west-2"
	default:
		fmt.Fprintf(errWriter, "invalid choice, defaulting to %s", essHostAddress)
	}

	return nil
}