func FromNetworkSpaceInfos(allInfos network.SpaceInfos) SpaceInfos {
	res := SpaceInfos{
		Infos: make([]SpaceInfo, len(allInfos)),
	}

	for i, si := range allInfos {
		mappedSubnets := make([]SubnetV3, len(si.Subnets))
		for j, subnetInfo := range si.Subnets {
			var mappedFanInfo *FanConfigEntry
			if subnetInfo.FanInfo != nil {
				mappedFanInfo = &FanConfigEntry{
					Underlay: subnetInfo.FanInfo.FanLocalUnderlay,
					Overlay:  subnetInfo.FanInfo.FanOverlay,
				}
			}

			mappedSubnets[j] = SubnetV3{
				SpaceID:  subnetInfo.SpaceID,
				FanInfo:  mappedFanInfo,
				IsPublic: subnetInfo.IsPublic,

				SubnetV2: SubnetV2{
					ID: string(subnetInfo.ID),
					Subnet: Subnet{
						CIDR:              subnetInfo.CIDR,
						ProviderId:        string(subnetInfo.ProviderId),
						ProviderNetworkId: string(subnetInfo.ProviderNetworkId),
						ProviderSpaceId:   string(subnetInfo.ProviderSpaceId),
						VLANTag:           subnetInfo.VLANTag,
						Zones:             subnetInfo.AvailabilityZones,
						// NOTE(achilleasa): the SpaceTag is not populated
						// as we can grab the space name from the parent
						// SpaceInfo when unmarshaling.
					},
				},
			}
		}

		res.Infos[i] = SpaceInfo{
			ID:         si.ID,
			Name:       string(si.Name),
			ProviderID: string(si.ProviderId),
			Subnets:    mappedSubnets,
		}
	}

	return res
}
// FromNetworkSpaceInfos converts a network.SpaceInfos into a serializable
// payload that can be sent over the wire.
FromNetworkSpaceInfos converts a network.SpaceInfos into a serializable
payload that can be sent over the wire.
// FromNetworkSpaceInfos converts a network . SpaceInfos into a serializable // payload that can be sent over the wire .
func FromNetworkSpaceInfos(allInfos network.SpaceInfos) SpaceInfos {
	res := SpaceInfos{
		Infos: make([]SpaceInfo, len(allInfos)),
	}
	for i, si := range allInfos {
		mappedSubnets := make([]SubnetV3, len(si.Subnets))
		for j, subnetInfo := range si.Subnets {
			var mappedFanInfo *FanConfigEntry
			if subnetInfo.FanInfo != nil {
				mappedFanInfo = &FanConfigEntry{
					Underlay: subnetInfo.FanInfo.FanLocalUnderlay,
					Overlay:  subnetInfo.FanInfo.FanOverlay,
				}
			}
			mappedSubnets[j] = SubnetV3{
				SpaceID:  subnetInfo.SpaceID,
				FanInfo:  mappedFanInfo,
				IsPublic: subnetInfo.IsPublic,
				SubnetV2: SubnetV2{
					ID: string(subnetInfo.ID),
					Subnet: Subnet{
						CIDR:              subnetInfo.CIDR,
						ProviderId:        string(subnetInfo.ProviderId),
						ProviderNetworkId: string(subnetInfo.ProviderNetworkId),
						ProviderSpaceId:   string(subnetInfo.ProviderSpaceId),
						VLANTag:           subnetInfo.VLANTag,
						Zones:             subnetInfo.AvailabilityZones,
					},
				},
			}
		}
		res.Infos[i] = SpaceInfo{
			ID:         si.ID,
			Name:       string(si.Name),
			ProviderID: string(si.ProviderId),
			Subnets:    mappedSubnets,
		}
	}
	return res
}
func FromNetworkSpaceInfos ( allInfos network . SpaceInfos ) SpaceInfos { res := SpaceInfos { Infos : make ( [ ] SpaceInfo , len ( allInfos ) ) , } for i , si := range allInfos { mappedSubnets := make ( [ ] SubnetV3 , len ( si . Subnets ) ) for j , subnetInfo := range si . Subnets { var mappedFanInfo * FanConfigEntry if subnetInfo . FanInfo != nil { mappedFanInfo = & FanConfigEntry { Underlay : subnetInfo . FanInfo . FanLocalUnderlay , Overlay : subnetInfo . FanInfo . FanOverlay , } } mappedSubnets [ j ] = SubnetV3 { SpaceID : subnetInfo . SpaceID , FanInfo : mappedFanInfo , IsPublic : subnetInfo . IsPublic , SubnetV2 : SubnetV2 { ID : string ( subnetInfo . ID ) , Subnet : Subnet { CIDR : subnetInfo . CIDR , ProviderId : string ( subnetInfo . ProviderId ) , ProviderNetworkId : string ( subnetInfo . ProviderNetworkId ) , ProviderSpaceId : string ( subnetInfo . ProviderSpaceId ) , VLANTag : subnetInfo . VLANTag , Zones : subnetInfo . AvailabilityZones , } , } , } } res . Infos [ i ] = SpaceInfo { ID : si . ID , Name : string ( si . Name ) , ProviderID : string ( si . ProviderId ) , Subnets : mappedSubnets , } } return res }
FromNetworkSpaceInfos converts a network.SpaceInfos into a serializable
payload that can be sent over the wire.
FromNetworkSpaceInfos converts a network . SpaceInfos into a serializable payload that can be sent over the wire .
// NOTE(achilleasa): the SpaceTag is not populated // as we can grab the space name from the parent // SpaceInfo when unmarshaling.