diff --git a/models/resources/interfaces.go b/models/resources/interfaces.go index 258beee..a8afcdc 100755 --- a/models/resources/interfaces.go +++ b/models/resources/interfaces.go @@ -25,6 +25,7 @@ type ResourceInstanceITF interface { GetPricingsProfiles(peerID string, groups []string) []pricing.PricingProfileITF GetPeerGroups() ([]ResourcePartnerITF, []map[string][]string) ClearPeerGroups() + GetPartnerships(peerID string, groups []string) []ResourcePartnerITF } type ResourcePartnerITF interface { diff --git a/models/resources/resource.go b/models/resources/resource.go index f0bce28..090d9fe 100755 --- a/models/resources/resource.go +++ b/models/resources/resource.go @@ -159,6 +159,20 @@ func (ri *ResourceInstance[T]) ClearEnv() { ri.Outputs = []models.Param{} } +func (ri *ResourceInstance[T]) GetPartnerships(peerID string, groups []string) []ResourcePartnerITF { + partners := []ResourcePartnerITF{} + for _, p := range ri.Partnerships { + if p.GetPeerGroups()[peerID] != nil { + for _, g := range p.GetPeerGroups()[peerID] { + if slices.Contains(groups, g) { + partners = append(partners, p) + } + } + } + } + return partners +} + func (ri *ResourceInstance[T]) GetPricingsProfiles(peerID string, groups []string) []pricing.PricingProfileITF { pricings := []pricing.PricingProfileITF{} for _, p := range ri.Partnerships {