func (s SubnetInfos) GetBySpaceID(spaceID string) (SubnetInfos, error) {
	var subsInSpace SubnetInfos
	for _, sub := range s {
		if sub.SpaceID == spaceID {
			subsInSpace = append(subsInSpace, sub)
		}
	}

	var spaceOverlays SubnetInfos
	for _, sub := range subsInSpace {
		// If we picked up an overlay because the space was already set,
		// don't try to find subnets for which it is an underlay.
		if sub.FanInfo != nil {
			continue
		}

		// TODO (manadart 2020-05-13): See comment for GetByUnderlayCIDR.
		// This will only be correct for unique CIDRs.
		overlays, err := s.GetByUnderlayCIDR(sub.CIDR)
		if err != nil {
			return nil, errors.Trace(err)
		}

		// Don't include overlays that already have a space ID.
		// They will have been retrieved as subsInSpace.
		for _, overlay := range overlays {
			if overlay.SpaceID == "" {
				overlay.SpaceID = spaceID
				spaceOverlays = append(spaceOverlays, overlay)
			}
		}
	}

	return append(subsInSpace, spaceOverlays...), nil
}
// GetBySpaceID returns all subnets with the input space ID,
// including those inferred by being overlays of subnets in the space.
GetBySpaceID returns all subnets with the input space ID,
including those inferred by being overlays of subnets in the space.
// GetBySpaceID returns all subnets with the input space ID // including those inferred by being overlays of subnets in the space .
func (s SubnetInfos) GetBySpaceID(spaceID string) (SubnetInfos, error) {
	var subsInSpace SubnetInfos
	for _, sub := range s {
		if sub.SpaceID == spaceID {
			subsInSpace = append(subsInSpace, sub)
		}
	}
	var spaceOverlays SubnetInfos
	for _, sub := range subsInSpace {
		if sub.FanInfo != nil {
			continue
		}
		overlays, err := s.GetByUnderlayCIDR(sub.CIDR)
		if err != nil {
			return nil, errors.Trace(err)
		}
		for _, overlay := range overlays {
			if overlay.SpaceID == "" {
				overlay.SpaceID = spaceID
				spaceOverlays = append(spaceOverlays, overlay)
			}
		}
	}
	return append(subsInSpace, spaceOverlays...), nil
}
func ( s SubnetInfos ) GetBySpaceID ( spaceID string ) ( SubnetInfos , error ) { var subsInSpace SubnetInfos for _ , sub := range s { if sub . SpaceID == spaceID { subsInSpace = append ( subsInSpace , sub ) } } var spaceOverlays SubnetInfos for _ , sub := range subsInSpace { if sub . FanInfo != nil { continue } overlays , err := s . GetByUnderlayCIDR ( sub . CIDR ) if err != nil { return nil , errors . Trace ( err ) } for _ , overlay := range overlays { if overlay . SpaceID == " " { overlay . SpaceID = spaceID spaceOverlays = append ( spaceOverlays , overlay ) } } } return append ( subsInSpace , spaceOverlays ... ) , nil }
GetBySpaceID returns all subnets with the input space ID,
including those inferred by being overlays of subnets in the space.
GetBySpaceID returns all subnets with the input space ID including those inferred by being overlays of subnets in the space .
// If we picked up an overlay because the space was already set, // don't try to find subnets for which it is an underlay. // TODO (manadart 2020-05-13): See comment for GetByUnderlayCIDR. // This will only be correct for unique CIDRs. // Don't include overlays that already have a space ID. // They will have been retrieved as subsInSpace.