func (pas ProviderAddresses) ToSpaceAddresses(lookup SpaceLookup) (SpaceAddresses, error) {
	if pas == nil {
		return nil, nil
	}

	var spaceInfos SpaceInfos
	if len(pas) > 0 {
		var err error
		if spaceInfos, err = lookup.AllSpaceInfos(); err != nil {
			return nil, errors.Trace(err)
		}
	}

	sas := make(SpaceAddresses, len(pas))
	for i, pa := range pas {
		sas[i] = SpaceAddress{MachineAddress: pa.MachineAddress}
		if pa.SpaceName != "" {
			info := spaceInfos.GetByName(string(pa.SpaceName))
			if info == nil {
				return nil, errors.NotFoundf("space with name %q", pa.SpaceName)
			}
			sas[i].SpaceID = info.ID
		}
	}
	return sas, nil
}
// ToSpaceAddresses transforms the ProviderAddresses to SpaceAddresses by using
// the input lookup for conversion of space name to space ID.
ToSpaceAddresses transforms the ProviderAddresses to SpaceAddresses by using
the input lookup for conversion of space name to space ID.
// ToSpaceAddresses transforms the ProviderAddresses to SpaceAddresses by using // the input lookup for conversion of space name to space ID .
func (pas ProviderAddresses) ToSpaceAddresses(lookup SpaceLookup) (SpaceAddresses, error) {
	if pas == nil {
		return nil, nil
	}
	var spaceInfos SpaceInfos
	if len(pas) > 0 {
		var err error
		if spaceInfos, err = lookup.AllSpaceInfos(); err != nil {
			return nil, errors.Trace(err)
		}
	}
	sas := make(SpaceAddresses, len(pas))
	for i, pa := range pas {
		sas[i] = SpaceAddress{MachineAddress: pa.MachineAddress}
		if pa.SpaceName != "" {
			info := spaceInfos.GetByName(string(pa.SpaceName))
			if info == nil {
				return nil, errors.NotFoundf("space with name %q", pa.SpaceName)
			}
			sas[i].SpaceID = info.ID
		}
	}
	return sas, nil
}
func ( pas ProviderAddresses ) ToSpaceAddresses ( lookup SpaceLookup ) ( SpaceAddresses , error ) { if pas == nil { return nil , nil } var spaceInfos SpaceInfos if len ( pas ) > 0 { var err error if spaceInfos , err = lookup . AllSpaceInfos ( ) ; err != nil { return nil , errors . Trace ( err ) } } sas := make ( SpaceAddresses , len ( pas ) ) for i , pa := range pas { sas [ i ] = SpaceAddress { MachineAddress : pa . MachineAddress } if pa . SpaceName != " " { info := spaceInfos . GetByName ( string ( pa . SpaceName ) ) if info == nil { return nil , errors . NotFoundf ( " " , pa . SpaceName ) } sas [ i ] . SpaceID = info . ID } } return sas , nil }
ToSpaceAddresses transforms the ProviderAddresses to SpaceAddresses by using
the input lookup for conversion of space name to space ID.
ToSpaceAddresses transforms the ProviderAddresses to SpaceAddresses by using the input lookup for conversion of space name to space ID .