Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/list-fix' into test-latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Anjani Kumar Srivastava committed Apr 30, 2024
2 parents 7c5a688 + f8f132b commit ec26380
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions internal/provider/services/version_manager/version_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ func (s *VersionManagerService) ListProviders(ctx context.Context, request *serv

span := trace.SpanFromContext(ctx)

var providersList []*services.ListProviderItem
// Initialize a map to store providers uniquely
uniqueProviders := make(map[string]*services.ListProviderItem)

Expand Down Expand Up @@ -450,19 +451,15 @@ func (s *VersionManagerService) ListProviders(ctx context.Context, request *serv
} else {
key := providerMetadata.Name
// Check if the provider already exists in the map
if _, ok := uniqueProviders[key]; !ok {
if _, exists := uniqueProviders[key]; !exists {
// Add the provider to the map if it doesn't exist
uniqueProviders[key] = providerMetadata
providersList = append(providersList, providerMetadata)
}
}
}
}

providersList := make([]*services.ListProviderItem, 0, len(uniqueProviders))
for _, provider := range uniqueProviders {
providersList = append(providersList, provider)
}

grpcResponse := services.ListProvidersResponse{
Providers: providersList,
}
Expand Down

0 comments on commit ec26380

Please sign in to comment.