Skip to content

Commit

Permalink
addressing abstractionFactory comments
Browse files Browse the repository at this point in the history
Signed-off-by: Diogenes Fernandes <[email protected]>
  • Loading branch information
diofeher committed Jan 5, 2025
1 parent 67a731c commit 135643a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 5 additions & 3 deletions backend/internal/providerindex/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/opentofu/registry-ui/internal/search/searchtypes"
)

const indexPrefix = "providers"

type providerSearch struct {
searchAPI search.API
}
Expand All @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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()))
}

0 comments on commit 135643a

Please sign in to comment.