isosegment/isolation_segment.go
func (u *Updater) UpdateOrgs() error {
	ocs, err := u.Cfg.GetOrgConfigs()
	if err != nil {
		return err
	}
	for _, oc := range ocs {
		org, err := u.OrgManager.FindOrg(oc.Org)
		if err != nil {
			return errors.Wrap(err, "finding org for org configs in update orgs")
		}
		isolationSegmentMap, err := u.isolationSegmentMap()
		if err != nil {
			return err
		}

		isolationSegmentGUID, err := u.getIsolationSegmentGUID(oc.DefaultIsoSegment, isolationSegmentMap)
		if err != nil {
			return err
		}

		if org.DefaultIsolationSegmentGuid != isolationSegmentGUID {
			if u.Peek {
				if isolationSegmentGUID != "" {
					lo.G.Infof("[dry-run]: set default isolation segment for org %s to %s", oc.Org, oc.DefaultIsoSegment)
				} else {
					lo.G.Infof("[dry-run]: reset default isolation segment for org %s", oc.Org)
				}
				continue
			}

			if isolationSegmentGUID != "" {
				lo.G.Infof("set default isolation segment for org %s to %s", oc.Org, oc.DefaultIsoSegment)
				err = u.Client.DefaultIsolationSegmentForOrg(org.Guid, isolationSegmentGUID)
				if err != nil {
					return err
				}
			} else {
				lo.G.Infof("reset default isolation segment for org %s", oc.Org)
				err = u.Client.ResetDefaultIsolationSegmentForOrg(org.Guid)
				if err != nil {
					return err
				}
			}

		}
	}
	return nil
}
func (u *Updater) UpdateOrgs() error {
	ocs, err := u.Cfg.GetOrgConfigs()
	if err != nil {
		return err
	}
	for _, oc := range ocs {
		org, err := u.OrgManager.FindOrg(oc.Org)
		if err != nil {
			return errors.Wrap(err, "finding org for org configs in update orgs")
		}
		isolationSegmentMap, err := u.isolationSegmentMap()
		if err != nil {
			return err
		}

		isolationSegmentGUID, err := u.getIsolationSegmentGUID(oc.DefaultIsoSegment, isolationSegmentMap)
		if err != nil {
			return err
		}

		if org.DefaultIsolationSegmentGuid != isolationSegmentGUID {
			if u.Peek {
				if isolationSegmentGUID != "" {
					lo.G.Infof("[dry-run]: set default isolation segment for org %s to %s", oc.Org, oc.DefaultIsoSegment)
				} else {
					lo.G.Infof("[dry-run]: reset default isolation segment for org %s", oc.Org)
				}
				continue
			}

			if isolationSegmentGUID != "" {
				lo.G.Infof("set default isolation segment for org %s to %s", oc.Org, oc.DefaultIsoSegment)
				err = u.Client.DefaultIsolationSegmentForOrg(org.Guid, isolationSegmentGUID)
				if err != nil {
					return err
				}
			} else {
				lo.G.Infof("reset default isolation segment for org %s", oc.Org)
				err = u.Client.ResetDefaultIsolationSegmentForOrg(org.Guid)
				if err != nil {
					return err
				}
			}

		}
	}
	return nil
}
func ( u * Updater ) UpdateOrgs ( ) error { ocs , err := u . Cfg . GetOrgConfigs ( ) if err != nil { return err } for _ , oc := range ocs { org , err := u . OrgManager . FindOrg ( oc . Org ) if err != nil { return errors . Wrap ( err , " " ) } isolationSegmentMap , err := u . isolationSegmentMap ( ) if err != nil { return err } isolationSegmentGUID , err := u . getIsolationSegmentGUID ( oc . DefaultIsoSegment , isolationSegmentMap ) if err != nil { return err } if org . DefaultIsolationSegmentGuid != isolationSegmentGUID { if u . Peek { if isolationSegmentGUID != " " { lo . G . Infof ( " " , oc . Org , oc . DefaultIsoSegment ) } else { lo . G . Infof ( " " , oc . Org ) } continue } if isolationSegmentGUID != " " { lo . G . Infof ( " " , oc . Org , oc . DefaultIsoSegment ) err = u . Client . DefaultIsolationSegmentForOrg ( org . Guid , isolationSegmentGUID ) if err != nil { return err } } else { lo . G . Infof ( " " , oc . Org ) err = u . Client . ResetDefaultIsolationSegmentForOrg ( org . Guid ) if err != nil { return err } } } } return nil }
// UpdateOrgs sets the default isolation segment for each org,
// as specified in the cf-mgmt config.
UpdateOrgs sets the default isolation segment for each org as specified in the cf - mgmt config .