config/yaml_config.go
func (m *yamlManager) AddSpaceToConfig(spaceConfig *SpaceConfig) error {
	orgName := spaceConfig.Org
	spaceFileName := filepath.Join(m.ConfigDir, orgName, "spaces.yml")
	spaceList := &Spaces{}
	spaceName := spaceConfig.Space

	if err := LoadFile(spaceFileName, spaceList); err != nil {
		return err
	}
	if spaceList.Contains(spaceName) {
		return fmt.Errorf("space [%s] already added to config -> [%v]", spaceName, spaceList.Spaces)
	}
	lo.G.Infof("Adding space: %s ", spaceName)
	spaceList.Spaces = append(spaceList.Spaces, spaceName)
	if err := WriteFile(spaceFileName, spaceList); err != nil {
		return err
	}

	if err := m.SaveSpaceConfig(spaceConfig); err != nil {
		return err
	}
	if err := WriteFileBytes(fmt.Sprintf("%s/%s/%s/security-group.json", m.ConfigDir, orgName, spaceName), []byte("[]")); err != nil {
		return err
	}
	return nil
}
func (m *yamlManager) AddSpaceToConfig(spaceConfig *SpaceConfig) error {
	orgName := spaceConfig.Org
	spaceFileName := filepath.Join(m.ConfigDir, orgName, "spaces.yml")
	spaceList := &Spaces{}
	spaceName := spaceConfig.Space

	if err := LoadFile(spaceFileName, spaceList); err != nil {
		return err
	}
	if spaceList.Contains(spaceName) {
		return fmt.Errorf("space [%s] already added to config -> [%v]", spaceName, spaceList.Spaces)
	}
	lo.G.Infof("Adding space: %s ", spaceName)
	spaceList.Spaces = append(spaceList.Spaces, spaceName)
	if err := WriteFile(spaceFileName, spaceList); err != nil {
		return err
	}

	if err := m.SaveSpaceConfig(spaceConfig); err != nil {
		return err
	}
	if err := WriteFileBytes(fmt.Sprintf("%s/%s/%s/security-group.json", m.ConfigDir, orgName, spaceName), []byte("[]")); err != nil {
		return err
	}
	return nil
}
func ( m * yamlManager ) AddSpaceToConfig ( spaceConfig * SpaceConfig ) error { orgName := spaceConfig . Org spaceFileName := filepath . Join ( m . ConfigDir , orgName , " " ) spaceList := & Spaces { } spaceName := spaceConfig . Space if err := LoadFile ( spaceFileName , spaceList ) ; err != nil { return err } if spaceList . Contains ( spaceName ) { return fmt . Errorf ( " " , spaceName , spaceList . Spaces ) } lo . G . Infof ( " " , spaceName ) spaceList . Spaces = append ( spaceList . Spaces , spaceName ) if err := WriteFile ( spaceFileName , spaceList ) ; err != nil { return err } if err := m . SaveSpaceConfig ( spaceConfig ) ; err != nil { return err } if err := WriteFileBytes ( fmt . Sprintf ( " " , m . ConfigDir , orgName , spaceName ) , [ ] byte ( " " ) ) ; err != nil { return err } return nil }
// AddSpaceToConfig adds a space to the cf-mgmt configuration, so long as a
// space with the specified name doesn't already exist.
AddSpaceToConfig adds a space to the cf - mgmt configuration so long as a space with the specified name doesn t already exist .