isosegment/isolation_segment.go
func (u *Updater) UpdateSpaces() error {
	scs, err := u.Cfg.GetSpaceConfigs()
	if err != nil {
		return err
	}

	isolationSegmentMap, err := u.isolationSegmentMap()
	if err != nil {
		return err
	}
	for _, sc := range scs {
		space, err := u.SpaceManager.FindSpace(sc.Org, sc.Space)
		if err != nil {
			return err
		}
		isolationSegmentGUID, err := u.getIsolationSegmentGUID(sc.IsoSegment, isolationSegmentMap)
		if err != nil {
			return err
		}
		if space.IsolationSegmentGuid != isolationSegmentGUID {
			if u.Peek {
				if sc.IsoSegment != "" {
					lo.G.Infof("[dry-run]: set isolation segment for space %s to %s (org %s)", sc.Space, sc.IsoSegment, sc.Org)
				} else {
					lo.G.Infof("[dry-run]: reset isolation segment for space %s (org %s)", sc.Space, sc.Org)
				}
				continue
			}
			if sc.IsoSegment != "" {
				lo.G.Infof("set isolation segment for space %s to %s (org %s)", sc.Space, sc.IsoSegment, sc.Org)
				err = u.Client.IsolationSegmentForSpace(space.Guid, isolationSegmentGUID)
				if err != nil {
					return err
				}
			} else {
				lo.G.Infof("reset isolation segment for space %s (org %s)", sc.Space, sc.Org)
				err = u.Client.ResetIsolationSegmentForSpace(space.Guid)
				if err != nil {
					return err
				}
			}
		}

	}
	return nil
}
func (u *Updater) UpdateSpaces() error {
	scs, err := u.Cfg.GetSpaceConfigs()
	if err != nil {
		return err
	}

	isolationSegmentMap, err := u.isolationSegmentMap()
	if err != nil {
		return err
	}
	for _, sc := range scs {
		space, err := u.SpaceManager.FindSpace(sc.Org, sc.Space)
		if err != nil {
			return err
		}
		isolationSegmentGUID, err := u.getIsolationSegmentGUID(sc.IsoSegment, isolationSegmentMap)
		if err != nil {
			return err
		}
		if space.IsolationSegmentGuid != isolationSegmentGUID {
			if u.Peek {
				if sc.IsoSegment != "" {
					lo.G.Infof("[dry-run]: set isolation segment for space %s to %s (org %s)", sc.Space, sc.IsoSegment, sc.Org)
				} else {
					lo.G.Infof("[dry-run]: reset isolation segment for space %s (org %s)", sc.Space, sc.Org)
				}
				continue
			}
			if sc.IsoSegment != "" {
				lo.G.Infof("set isolation segment for space %s to %s (org %s)", sc.Space, sc.IsoSegment, sc.Org)
				err = u.Client.IsolationSegmentForSpace(space.Guid, isolationSegmentGUID)
				if err != nil {
					return err
				}
			} else {
				lo.G.Infof("reset isolation segment for space %s (org %s)", sc.Space, sc.Org)
				err = u.Client.ResetIsolationSegmentForSpace(space.Guid)
				if err != nil {
					return err
				}
			}
		}

	}
	return nil
}
func ( u * Updater ) UpdateSpaces ( ) error { scs , err := u . Cfg . GetSpaceConfigs ( ) if err != nil { return err } isolationSegmentMap , err := u . isolationSegmentMap ( ) if err != nil { return err } for _ , sc := range scs { space , err := u . SpaceManager . FindSpace ( sc . Org , sc . Space ) if err != nil { return err } isolationSegmentGUID , err := u . getIsolationSegmentGUID ( sc . IsoSegment , isolationSegmentMap ) if err != nil { return err } if space . IsolationSegmentGuid != isolationSegmentGUID { if u . Peek { if sc . IsoSegment != " " { lo . G . Infof ( " " , sc . Space , sc . IsoSegment , sc . Org ) } else { lo . G . Infof ( " " , sc . Space , sc . Org ) } continue } if sc . IsoSegment != " " { lo . G . Infof ( " " , sc . Space , sc . IsoSegment , sc . Org ) err = u . Client . IsolationSegmentForSpace ( space . Guid , isolationSegmentGUID ) if err != nil { return err } } else { lo . G . Infof ( " " , sc . Space , sc . Org ) err = u . Client . ResetIsolationSegmentForSpace ( space . Guid ) if err != nil { return err } } } } return nil }
// UpdateSpaces sets the isolation segment for each space,
// as specified in the cf-mgmt config.
UpdateSpaces sets the isolation segment for each space as specified in the cf - mgmt config .