configcommands/update_space.go
func (c *UpdateSpaceConfigurationCommand) Execute(args []string) error {
	c.initConfig()
	spaceConfig, err := c.ConfigManager.GetSpaceConfig(c.OrgName, c.SpaceName)
	if err != nil {
		return err
	}
	asgConfigs, err := c.ConfigManager.GetASGConfigs()
	if err != nil {
		return err
	}

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

	errorString := ""

	convertToBool("enable-remove-users", &spaceConfig.RemoveUsers, c.EnableRemoveUsers, &errorString)
	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
	}
	if c.ClearIsolationSegment {
		spaceConfig.IsoSegment = ""
	}

	spaceConfig.ASGs = removeFromSlice(addToSlice(spaceConfig.ASGs, c.ASGs, &errorString), c.ASGsToRemove)
	validateASGsExist(asgConfigs, spaceConfig.ASGs, &errorString)
	updateSpaceQuotaConfig(spaceConfig, c.Quota, &errorString)

	if c.NamedQuota != "" {
		spaceConfig.NamedQuota = c.NamedQuota
	}
	if c.ClearNamedQuota {
		spaceConfig.NamedQuota = ""
	}

	c.updateUsers(spaceConfig, &errorString)
	c.sshConfig(spaceConfig, &errorString)

	if errorString != "" {
		return errors.New(errorString)
	}

	if err := c.ConfigManager.SaveSpaceConfig(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 *UpdateSpaceConfigurationCommand) Execute(args []string) error {
	c.initConfig()
	spaceConfig, err := c.ConfigManager.GetSpaceConfig(c.OrgName, c.SpaceName)
	if err != nil {
		return err
	}
	asgConfigs, err := c.ConfigManager.GetASGConfigs()
	if err != nil {
		return err
	}

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

	errorString := ""

	convertToBool("enable-remove-users", &spaceConfig.RemoveUsers, c.EnableRemoveUsers, &errorString)
	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
	}
	if c.ClearIsolationSegment {
		spaceConfig.IsoSegment = ""
	}

	spaceConfig.ASGs = removeFromSlice(addToSlice(spaceConfig.ASGs, c.ASGs, &errorString), c.ASGsToRemove)
	validateASGsExist(asgConfigs, spaceConfig.ASGs, &errorString)
	updateSpaceQuotaConfig(spaceConfig, c.Quota, &errorString)

	if c.NamedQuota != "" {
		spaceConfig.NamedQuota = c.NamedQuota
	}
	if c.ClearNamedQuota {
		spaceConfig.NamedQuota = ""
	}

	c.updateUsers(spaceConfig, &errorString)
	c.sshConfig(spaceConfig, &errorString)

	if errorString != "" {
		return errors.New(errorString)
	}

	if err := c.ConfigManager.SaveSpaceConfig(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 * UpdateSpaceConfigurationCommand ) Execute ( args [ ] string ) error { c . initConfig ( ) spaceConfig , err := c . ConfigManager . GetSpaceConfig ( c . OrgName , c . SpaceName ) if err != nil { return err } asgConfigs , err := c . ConfigManager . GetASGConfigs ( ) if err != nil { return err } if c . Quota . EnableSpaceQuota == " " && c . NamedQuota != " " { return fmt . Errorf ( " " ) } errorString := " " convertToBool ( " " , & spaceConfig . RemoveUsers , c . EnableRemoveUsers , & errorString ) convertToBool ( " " , & spaceConfig . EnableSecurityGroup , c . EnableSecurityGroup , & errorString ) convertToBool ( " " , & spaceConfig . EnableUnassignSecurityGroup , c . EnableUnassignSecurityGroup , & errorString ) if c . IsoSegment != " " { spaceConfig . IsoSegment = c . IsoSegment } if c . ClearIsolationSegment { spaceConfig . IsoSegment = " " } spaceConfig . ASGs = removeFromSlice ( addToSlice ( spaceConfig . ASGs , c . ASGs , & errorString ) , c . ASGsToRemove ) validateASGsExist ( asgConfigs , spaceConfig . ASGs , & errorString ) updateSpaceQuotaConfig ( spaceConfig , c . Quota , & errorString ) if c . NamedQuota != " " { spaceConfig . NamedQuota = c . NamedQuota } if c . ClearNamedQuota { spaceConfig . NamedQuota = " " } c . updateUsers ( spaceConfig , & errorString ) c . sshConfig ( spaceConfig , & errorString ) if errorString != " " { return errors . New ( errorString ) } if err := c . ConfigManager . SaveSpaceConfig ( spaceConfig ) ; err != nil { return err } fmt . Println ( fmt . Sprintf ( " " , c . OrgName , c . SpaceName ) ) return nil }
//Execute - updates space configuration`
Execute - updates space configuration