configcommands/add_org.go
func (c *AddOrgToConfigurationCommand) Execute([]string) error {
	orgConfig := &config.OrgConfig{
		Org: c.OrgName,
	}

	c.initConfig()

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

	if c.DefaultIsolationSegment != "" {
		orgConfig.DefaultIsoSegment = c.DefaultIsolationSegment
	}
	orgConfig.RemoveUsers = true
	orgConfig.RemovePrivateDomains = true
	orgConfig.PrivateDomains = addToSlice(orgConfig.PrivateDomains, c.PrivateDomains, &errorString)

	orgConfig.RemoveSharedPrivateDomains = true
	orgConfig.SharedPrivateDomains = addToSlice(orgConfig.SharedPrivateDomains, c.SharedPrivateDomains, &errorString)

	updateOrgQuotaConfig(orgConfig, c.Quota, &errorString)
	orgConfig.NamedQuota = c.NamedQuota

	c.updateUsers(orgConfig, &errorString)

	orgConfig.ServiceAccess = make(map[string][]string)
	for _, service := range c.ServiceAccess.ServiceNames {
		orgConfig.ServiceAccess[service] = []string{"*"}
	}

	orgSpaces := &config.Spaces{Org: orgConfig.Org, EnableDeleteSpaces: true}
	convertToBool("enable-remove-spaces", &orgSpaces.EnableDeleteSpaces, c.EnableRemoveSpaces, &errorString)
	if errorString != "" {
		return errors.New(errorString)
	}

	if err := config.NewManager(c.ConfigDirectory).AddOrgToConfig(orgConfig, orgSpaces); err != nil {
		return err
	}
	fmt.Println(fmt.Sprintf("The org [%s] has been added", c.OrgName))
	return nil
}
func (c *AddOrgToConfigurationCommand) Execute([]string) error {
	orgConfig := &config.OrgConfig{
		Org: c.OrgName,
	}

	c.initConfig()

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

	if c.DefaultIsolationSegment != "" {
		orgConfig.DefaultIsoSegment = c.DefaultIsolationSegment
	}
	orgConfig.RemoveUsers = true
	orgConfig.RemovePrivateDomains = true
	orgConfig.PrivateDomains = addToSlice(orgConfig.PrivateDomains, c.PrivateDomains, &errorString)

	orgConfig.RemoveSharedPrivateDomains = true
	orgConfig.SharedPrivateDomains = addToSlice(orgConfig.SharedPrivateDomains, c.SharedPrivateDomains, &errorString)

	updateOrgQuotaConfig(orgConfig, c.Quota, &errorString)
	orgConfig.NamedQuota = c.NamedQuota

	c.updateUsers(orgConfig, &errorString)

	orgConfig.ServiceAccess = make(map[string][]string)
	for _, service := range c.ServiceAccess.ServiceNames {
		orgConfig.ServiceAccess[service] = []string{"*"}
	}

	orgSpaces := &config.Spaces{Org: orgConfig.Org, EnableDeleteSpaces: true}
	convertToBool("enable-remove-spaces", &orgSpaces.EnableDeleteSpaces, c.EnableRemoveSpaces, &errorString)
	if errorString != "" {
		return errors.New(errorString)
	}

	if err := config.NewManager(c.ConfigDirectory).AddOrgToConfig(orgConfig, orgSpaces); err != nil {
		return err
	}
	fmt.Println(fmt.Sprintf("The org [%s] has been added", c.OrgName))
	return nil
}
func ( c * AddOrgToConfigurationCommand ) Execute ( [ ] string ) error { orgConfig := & config . OrgConfig { Org : c . OrgName , } c . initConfig ( ) if c . Quota . EnableOrgQuota == " " && c . NamedQuota != " " { return fmt . Errorf ( " " ) } errorString := " " if c . DefaultIsolationSegment != " " { orgConfig . DefaultIsoSegment = c . DefaultIsolationSegment } orgConfig . RemoveUsers = true orgConfig . RemovePrivateDomains = true orgConfig . PrivateDomains = addToSlice ( orgConfig . PrivateDomains , c . PrivateDomains , & errorString ) orgConfig . RemoveSharedPrivateDomains = true orgConfig . SharedPrivateDomains = addToSlice ( orgConfig . SharedPrivateDomains , c . SharedPrivateDomains , & errorString ) updateOrgQuotaConfig ( orgConfig , c . Quota , & errorString ) orgConfig . NamedQuota = c . NamedQuota c . updateUsers ( orgConfig , & errorString ) orgConfig . ServiceAccess = make ( map [ string ] [ ] string ) for _ , service := range c . ServiceAccess . ServiceNames { orgConfig . ServiceAccess [ service ] = [ ] string { " " } } orgSpaces := & config . Spaces { Org : orgConfig . Org , EnableDeleteSpaces : true } convertToBool ( " " , & orgSpaces . EnableDeleteSpaces , c . EnableRemoveSpaces , & errorString ) if errorString != " " { return errors . New ( errorString ) } if err := config . NewManager ( c . ConfigDirectory ) . AddOrgToConfig ( orgConfig , orgSpaces ) ; err != nil { return err } fmt . Println ( fmt . Sprintf ( " " , c . OrgName ) ) return nil }
//Execute - adds a named org to the configuration
Execute - adds a named org to the configuration