configcommands/update_org.go
func (c *UpdateOrgConfigurationCommand) Execute(args []string) error {
	c.initConfig()
	orgConfig, err := c.ConfigManager.GetOrgConfig(c.OrgName)
	if err != nil {
		return err
	}

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

	orgSpaces, err := c.ConfigManager.OrgSpaces(c.OrgName)
	if err != nil {
		return err
	}
	errorString := ""

	convertToBool("enable-remove-spaces", &orgSpaces.EnableDeleteSpaces, c.EnableRemoveSpaces, &errorString)
	if c.DefaultIsolationSegment != "" {
		orgConfig.DefaultIsoSegment = c.DefaultIsolationSegment
	}
	if c.ClearDefaultIsolationSegment {
		orgConfig.DefaultIsoSegment = ""
	}
	convertToBool("enable-remove-users", &orgConfig.RemoveUsers, c.EnableRemoveUsers, &errorString)
	orgConfig.PrivateDomains = removeFromSlice(addToSlice(orgConfig.PrivateDomains, c.PrivateDomains, &errorString), c.PrivateDomainsToRemove)
	convertToBool("enable-remove-private-domains", &orgConfig.RemovePrivateDomains, c.EnableRemovePrivateDomains, &errorString)

	orgConfig.SharedPrivateDomains = removeFromSlice(addToSlice(orgConfig.SharedPrivateDomains, c.SharedPrivateDomains, &errorString), c.SharedPrivateDomainsToRemove)
	convertToBool("enable-remove-shared-private-domains", &orgConfig.RemoveSharedPrivateDomains, c.EnableRemoveSharedPrivateDomains, &errorString)

	updateOrgQuotaConfig(orgConfig, c.Quota, &errorString)
	if c.NamedQuota != "" {
		orgConfig.NamedQuota = c.NamedQuota
	}
	if c.ClearNamedQuota {
		orgConfig.NamedQuota = ""
	}
	c.updateUsers(orgConfig, &errorString)

	if c.ServiceAccess.ServiceNameToRemove != "" {
		delete(orgConfig.ServiceAccess, c.ServiceAccess.ServiceNameToRemove)
	}

	if c.ServiceAccess.ServiceName != "" {
		if len(c.ServiceAccess.Plans) > 0 {
			orgConfig.ServiceAccess[c.ServiceAccess.ServiceName] = c.ServiceAccess.Plans
		} else {
			orgConfig.ServiceAccess[c.ServiceAccess.ServiceName] = []string{"*"}
		}
	}

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

	if err := c.ConfigManager.SaveOrgConfig(orgConfig); err != nil {
		return err
	}

	if err := c.ConfigManager.SaveOrgSpaces(orgSpaces); err != nil {
		return err
	}

	fmt.Println(fmt.Sprintf("The org [%s] has been updated", c.OrgName))
	return nil
}
func (c *UpdateOrgConfigurationCommand) Execute(args []string) error {
	c.initConfig()
	orgConfig, err := c.ConfigManager.GetOrgConfig(c.OrgName)
	if err != nil {
		return err
	}

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

	orgSpaces, err := c.ConfigManager.OrgSpaces(c.OrgName)
	if err != nil {
		return err
	}
	errorString := ""

	convertToBool("enable-remove-spaces", &orgSpaces.EnableDeleteSpaces, c.EnableRemoveSpaces, &errorString)
	if c.DefaultIsolationSegment != "" {
		orgConfig.DefaultIsoSegment = c.DefaultIsolationSegment
	}
	if c.ClearDefaultIsolationSegment {
		orgConfig.DefaultIsoSegment = ""
	}
	convertToBool("enable-remove-users", &orgConfig.RemoveUsers, c.EnableRemoveUsers, &errorString)
	orgConfig.PrivateDomains = removeFromSlice(addToSlice(orgConfig.PrivateDomains, c.PrivateDomains, &errorString), c.PrivateDomainsToRemove)
	convertToBool("enable-remove-private-domains", &orgConfig.RemovePrivateDomains, c.EnableRemovePrivateDomains, &errorString)

	orgConfig.SharedPrivateDomains = removeFromSlice(addToSlice(orgConfig.SharedPrivateDomains, c.SharedPrivateDomains, &errorString), c.SharedPrivateDomainsToRemove)
	convertToBool("enable-remove-shared-private-domains", &orgConfig.RemoveSharedPrivateDomains, c.EnableRemoveSharedPrivateDomains, &errorString)

	updateOrgQuotaConfig(orgConfig, c.Quota, &errorString)
	if c.NamedQuota != "" {
		orgConfig.NamedQuota = c.NamedQuota
	}
	if c.ClearNamedQuota {
		orgConfig.NamedQuota = ""
	}
	c.updateUsers(orgConfig, &errorString)

	if c.ServiceAccess.ServiceNameToRemove != "" {
		delete(orgConfig.ServiceAccess, c.ServiceAccess.ServiceNameToRemove)
	}

	if c.ServiceAccess.ServiceName != "" {
		if len(c.ServiceAccess.Plans) > 0 {
			orgConfig.ServiceAccess[c.ServiceAccess.ServiceName] = c.ServiceAccess.Plans
		} else {
			orgConfig.ServiceAccess[c.ServiceAccess.ServiceName] = []string{"*"}
		}
	}

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

	if err := c.ConfigManager.SaveOrgConfig(orgConfig); err != nil {
		return err
	}

	if err := c.ConfigManager.SaveOrgSpaces(orgSpaces); err != nil {
		return err
	}

	fmt.Println(fmt.Sprintf("The org [%s] has been updated", c.OrgName))
	return nil
}
func ( c * UpdateOrgConfigurationCommand ) Execute ( args [ ] string ) error { c . initConfig ( ) orgConfig , err := c . ConfigManager . GetOrgConfig ( c . OrgName ) if err != nil { return err } if c . Quota . EnableOrgQuota == " " && c . NamedQuota != " " { return fmt . Errorf ( " " ) } orgSpaces , err := c . ConfigManager . OrgSpaces ( c . OrgName ) if err != nil { return err } errorString := " " convertToBool ( " " , & orgSpaces . EnableDeleteSpaces , c . EnableRemoveSpaces , & errorString ) if c . DefaultIsolationSegment != " " { orgConfig . DefaultIsoSegment = c . DefaultIsolationSegment } if c . ClearDefaultIsolationSegment { orgConfig . DefaultIsoSegment = " " } convertToBool ( " " , & orgConfig . RemoveUsers , c . EnableRemoveUsers , & errorString ) orgConfig . PrivateDomains = removeFromSlice ( addToSlice ( orgConfig . PrivateDomains , c . PrivateDomains , & errorString ) , c . PrivateDomainsToRemove ) convertToBool ( " " , & orgConfig . RemovePrivateDomains , c . EnableRemovePrivateDomains , & errorString ) orgConfig . SharedPrivateDomains = removeFromSlice ( addToSlice ( orgConfig . SharedPrivateDomains , c . SharedPrivateDomains , & errorString ) , c . SharedPrivateDomainsToRemove ) convertToBool ( " " , & orgConfig . RemoveSharedPrivateDomains , c . EnableRemoveSharedPrivateDomains , & errorString ) updateOrgQuotaConfig ( orgConfig , c . Quota , & errorString ) if c . NamedQuota != " " { orgConfig . NamedQuota = c . NamedQuota } if c . ClearNamedQuota { orgConfig . NamedQuota = " " } c . updateUsers ( orgConfig , & errorString ) if c . ServiceAccess . ServiceNameToRemove != " " { delete ( orgConfig . ServiceAccess , c . ServiceAccess . ServiceNameToRemove ) } if c . ServiceAccess . ServiceName != " " { if len ( c . ServiceAccess . Plans ) > 0 { orgConfig . ServiceAccess [ c . ServiceAccess . ServiceName ] = c . ServiceAccess . Plans } else { orgConfig . ServiceAccess [ c . ServiceAccess . ServiceName ] = [ ] string { " " } } } if errorString != " " { return errors . New ( errorString ) } if err := c . ConfigManager . SaveOrgConfig ( orgConfig ) ; err != nil { return err } if err := c . ConfigManager . SaveOrgSpaces ( orgSpaces ) ; err != nil { return err } fmt . Println ( fmt . Sprintf ( " " , c . OrgName ) ) return nil }
//Execute - updates org configuration`
Execute - updates org configuration