func (sas SpaceAddresses) ToProviderAddresses(lookup SpaceLookup) (ProviderAddresses, error) {
	if sas == nil {
		return nil, nil
	}

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

	pas := make(ProviderAddresses, len(sas))
	for i, sa := range sas {
		pas[i] = ProviderAddress{MachineAddress: sa.MachineAddress}
		if sa.SpaceID != "" {
			info := spaces.GetByID(sa.SpaceID)
			if info == nil {
				return nil, errors.NotFoundf("space with ID %q", sa.SpaceID)
			}
			pas[i].SpaceName = info.Name
			pas[i].ProviderSpaceID = info.ProviderId
		}
	}
	return pas, nil
}
// ToProviderAddresses transforms the SpaceAddresses to ProviderAddresses by using
// the input lookup for conversion of space ID to space info.
ToProviderAddresses transforms the SpaceAddresses to ProviderAddresses by using
the input lookup for conversion of space ID to space info.
// ToProviderAddresses transforms the SpaceAddresses to ProviderAddresses by using // the input lookup for conversion of space ID to space info .
func (sas SpaceAddresses) ToProviderAddresses(lookup SpaceLookup) (ProviderAddresses, error) {
	if sas == nil {
		return nil, nil
	}
	var spaces SpaceInfos
	if len(sas) > 0 {
		var err error
		if spaces, err = lookup.AllSpaceInfos(); err != nil {
			return nil, errors.Trace(err)
		}
	}
	pas := make(ProviderAddresses, len(sas))
	for i, sa := range sas {
		pas[i] = ProviderAddress{MachineAddress: sa.MachineAddress}
		if sa.SpaceID != "" {
			info := spaces.GetByID(sa.SpaceID)
			if info == nil {
				return nil, errors.NotFoundf("space with ID %q", sa.SpaceID)
			}
			pas[i].SpaceName = info.Name
			pas[i].ProviderSpaceID = info.ProviderId
		}
	}
	return pas, nil
}
func ( sas SpaceAddresses ) ToProviderAddresses ( lookup SpaceLookup ) ( ProviderAddresses , error ) { if sas == nil { return nil , nil } var spaces SpaceInfos if len ( sas ) > 0 { var err error if spaces , err = lookup . AllSpaceInfos ( ) ; err != nil { return nil , errors . Trace ( err ) } } pas := make ( ProviderAddresses , len ( sas ) ) for i , sa := range sas { pas [ i ] = ProviderAddress { MachineAddress : sa . MachineAddress } if sa . SpaceID != " " { info := spaces . GetByID ( sa . SpaceID ) if info == nil { return nil , errors . NotFoundf ( " " , sa . SpaceID ) } pas [ i ] . SpaceName = info . Name pas [ i ] . ProviderSpaceID = info . ProviderId } } return pas , nil }
ToProviderAddresses transforms the SpaceAddresses to ProviderAddresses by using
the input lookup for conversion of space ID to space info.
ToProviderAddresses transforms the SpaceAddresses to ProviderAddresses by using the input lookup for conversion of space ID to space info .