From 135643a54e0513a10cbb0158ce4feaebb4b8b33a Mon Sep 17 00:00:00 2001 From: Diogenes Fernandes Date: Sun, 5 Jan 2025 09:23:01 -0300 Subject: [PATCH] addressing abstractionFactory comments Signed-off-by: Diogenes Fernandes --- .../providerindex/providerdocsource/scrape_test.go | 4 +++- backend/internal/providerindex/search.go | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/backend/internal/providerindex/providerdocsource/scrape_test.go b/backend/internal/providerindex/providerdocsource/scrape_test.go index 90305b9..df989ec 100644 --- a/backend/internal/providerindex/providerdocsource/scrape_test.go +++ b/backend/internal/providerindex/providerdocsource/scrape_test.go @@ -148,7 +148,9 @@ Manages projects. } t.Run(tt.name, func(t *testing.T) { doc := &docItem{} - s.ExtractFrontmatterPermissively(context.Background(), []byte(tt.input), doc) //nolint:all + if err := s.ExtractFrontmatterPermissively(context.Background(), []byte(tt.input), doc); err != nil { + t.Errorf("Failed to extract frontmatter: (%v)", err) + } if doc.Name != tt.expected.Name { t.Errorf("expected %q, got %q", tt.expected.Name, doc.Name) diff --git a/backend/internal/providerindex/search.go b/backend/internal/providerindex/search.go index 9edd647..f0b11a3 100644 --- a/backend/internal/providerindex/search.go +++ b/backend/internal/providerindex/search.go @@ -11,6 +11,8 @@ import ( "github.com/opentofu/registry-ui/internal/search/searchtypes" ) +const indexPrefix = "providers" + type providerSearch struct { searchAPI search.API } @@ -23,7 +25,7 @@ func (p providerSearch) indexProviderVersion(ctx context.Context, providerAddr p popularity = providerDetails.UpstreamPopularity } providerItem := searchtypes.IndexItem{ - ID: searchtypes.IndexID("providers/" + providerAddr.String()), + ID: searchtypes.IndexID(indexPrefix + "/" + providerAddr.String()), Type: searchtypes.IndexTypeProvider, Addr: providerAddr.String(), Version: string(version), @@ -67,7 +69,7 @@ func (p providerSearch) indexProviderVersion(ctx context.Context, providerAddr p for _, docItem := range item.items { title := docItem.Title if err := p.searchAPI.AddItem(ctx, searchtypes.IndexItem{ - ID: searchtypes.IndexID("providers/" + providerAddr.String() + "/" + item.typeName + "s/" + string(docItem.Name)), + ID: searchtypes.IndexID(indexPrefix + "/" + providerAddr.String() + "/" + item.typeName + "s/" + string(docItem.Name)), Type: item.indexType, Addr: providerAddr.String(), Version: string(version), @@ -104,5 +106,5 @@ func (p providerSearch) removeProviderVersionFromSearchIndex(ctx context.Context } func (p providerSearch) removeModuleFromSearchIndex(ctx context.Context, addr module.Addr) error { //nolint:unused - return p.searchAPI.RemoveItem(ctx, searchtypes.IndexID("providers/"+addr.String())) + return p.searchAPI.RemoveItem(ctx, searchtypes.IndexID(indexPrefix+"/"+addr.String())) }