Example #1
0
func DoConfigWizard(cs *cstore.CStore) error {
	chosenRegion, err := peco.Choose("AWS region", "Please select default AWS region", "", AWSRegionList)
	if err != nil {
		return fmt.Errorf("region choose error:%s", err.Error())
	}

	region := ""
	for _, c := range chosenRegion {
		region = c.Value()
		break
	}

	c := &Config{
		Default: RnzooConfig{
			AWSRegion: region,
		},
	}

	if err := cs.Save(c); err != nil {
		return err
	}

	return nil
}
Example #2
0
func DoConfigWizard(cs *cstore.CStore) error {

	chosenResourceType, err := peco.Choose("rnssh ResourceType option", "Please select resource type", "", ResourceTypeList)
	if err != nil {
		return fmt.Errorf("ResourceType choose error:%s", err.Error())
	}

	resourceType := "ec2"
	// later win
	for _, c := range chosenResourceType {
		resourceType = c.Value()
	}

	var c *Config
	var region, hostType string
	var useSshConfig bool
	var strictHostKeyChecking int
	switch resourceType {
	case "ec2":
		region, hostType, err = Ec2ConfigWizard()
		if err != nil {
			return err
		}

		strictHostKeyChecking, err = StrictHostKeyCheckingWizard()
		if err != nil {
			return err
		}

		useSshConfig = false

	case "ssh_config":
		strictHostKeyChecking, err = StrictHostKeyCheckingWizard()
		if err != nil {
			return err
		}

		chosenContinue, err := peco.Choose("next setting", "next, continue to AWS settings?", "", ContinueList)
		if err != nil {
			return err
		}

		chosen := ""
		for _, c := range chosenContinue {
			chosen = c.Value()
		}

		if chosen == "yes" {
			region, hostType, err = Ec2ConfigWizard()
			if err != nil {
				return err
			}
		}

		useSshConfig = true
	}

	c = &Config{
		Default: RnsshConfig{
			AWSRegion:                  region,
			HostType:                   hostType,
			UseSshConfig:               useSshConfig,
			SshStrictHostKeyCheckingNo: strictHostKeyChecking,
		},
	}

	if err := cs.Save(c); err != nil {
		return err
	}

	return nil
}