configcommands/add_space.go
func (c *AddSpaceToConfigurationCommand) Execute([]string) error {
	c.initConfig()
	spaceConfig := &config.SpaceConfig{
		Org:   c.OrgName,
		Space: c.SpaceName,
	}

	if c.Quota.EnableSpaceQuota == "true" && c.NamedQuota != "" {
		return fmt.Errorf("cannot enable space quota and use named quotas")
	}

	asgConfigs, err := c.ConfigManager.GetASGConfigs()
	if err != nil {
		return err
	}
	errorString := ""

	spaceConfig.RemoveUsers = true

	convertToBool("enable-security-group", &spaceConfig.EnableSecurityGroup, c.EnableSecurityGroup, &errorString)
	convertToBool("enable-unassign-security-group", &spaceConfig.EnableUnassignSecurityGroup, c.EnableUnassignSecurityGroup, &errorString)
	if c.IsoSegment != "" {
		spaceConfig.IsoSegment = c.IsoSegment
	}

	updateSpaceQuotaConfig(spaceConfig, c.Quota, &errorString)
	spaceConfig.NamedQuota = c.NamedQuota

	spaceConfig.ASGs = addToSlice(spaceConfig.ASGs, c.ASGs, &errorString)
	validateASGsExist(asgConfigs, spaceConfig.ASGs, &errorString)
	c.updateUsers(spaceConfig, &errorString)

	c.sshConfig(spaceConfig, &errorString)
	if errorString != "" {
		return errors.New(errorString)
	}

	if err := config.NewManager(c.ConfigDirectory).AddSpaceToConfig(spaceConfig); err != nil {
		return err
	}
	fmt.Println(fmt.Sprintf("The org/space [%s/%s] has been updated", c.OrgName, c.SpaceName))
	return nil
}
func (c *AddSpaceToConfigurationCommand) Execute([]string) error {
	c.initConfig()
	spaceConfig := &config.SpaceConfig{
		Org:   c.OrgName,
		Space: c.SpaceName,
	}

	if c.Quota.EnableSpaceQuota == "true" && c.NamedQuota != "" {
		return fmt.Errorf("cannot enable space quota and use named quotas")
	}

	asgConfigs, err := c.ConfigManager.GetASGConfigs()
	if err != nil {
		return err
	}
	errorString := ""

	spaceConfig.RemoveUsers = true

	convertToBool("enable-security-group", &spaceConfig.EnableSecurityGroup, c.EnableSecurityGroup, &errorString)
	convertToBool("enable-unassign-security-group", &spaceConfig.EnableUnassignSecurityGroup, c.EnableUnassignSecurityGroup, &errorString)
	if c.IsoSegment != "" {
		spaceConfig.IsoSegment = c.IsoSegment
	}

	updateSpaceQuotaConfig(spaceConfig, c.Quota, &errorString)
	spaceConfig.NamedQuota = c.NamedQuota

	spaceConfig.ASGs = addToSlice(spaceConfig.ASGs, c.ASGs, &errorString)
	validateASGsExist(asgConfigs, spaceConfig.ASGs, &errorString)
	c.updateUsers(spaceConfig, &errorString)

	c.sshConfig(spaceConfig, &errorString)
	if errorString != "" {
		return errors.New(errorString)
	}

	if err := config.NewManager(c.ConfigDirectory).AddSpaceToConfig(spaceConfig); err != nil {
		return err
	}
	fmt.Println(fmt.Sprintf("The org/space [%s/%s] has been updated", c.OrgName, c.SpaceName))
	return nil
}
func ( c * AddSpaceToConfigurationCommand ) Execute ( [ ] string ) error { c . initConfig ( ) spaceConfig := & config . SpaceConfig { Org : c . OrgName , Space : c . SpaceName , } if c . Quota . EnableSpaceQuota == " " && c . NamedQuota != " " { return fmt . Errorf ( " " ) } asgConfigs , err := c . ConfigManager . GetASGConfigs ( ) if err != nil { return err } errorString := " " spaceConfig . RemoveUsers = true convertToBool ( " " , & spaceConfig . EnableSecurityGroup , c . EnableSecurityGroup , & errorString ) convertToBool ( " " , & spaceConfig . EnableUnassignSecurityGroup , c . EnableUnassignSecurityGroup , & errorString ) if c . IsoSegment != " " { spaceConfig . IsoSegment = c . IsoSegment } updateSpaceQuotaConfig ( spaceConfig , c . Quota , & errorString ) spaceConfig . NamedQuota = c . NamedQuota spaceConfig . ASGs = addToSlice ( spaceConfig . ASGs , c . ASGs , & errorString ) validateASGsExist ( asgConfigs , spaceConfig . ASGs , & errorString ) c . updateUsers ( spaceConfig , & errorString ) c . sshConfig ( spaceConfig , & errorString ) if errorString != " " { return errors . New ( errorString ) } if err := config . NewManager ( c . ConfigDirectory ) . AddSpaceToConfig ( spaceConfig ) ; err != nil { return err } fmt . Println ( fmt . Sprintf ( " " , c . OrgName , c . SpaceName ) ) return nil }
//Execute - adds a named space to the configuration
Execute - adds a named space to the configuration