Skip to content

Commit

Permalink
Adding a provider link field
Browse files Browse the repository at this point in the history
Signed-off-by: AbstractionFactory <[email protected]>
  • Loading branch information
abstractionfactory committed Dec 2, 2024
1 parent 195b729 commit 7585fe9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions backend/internal/providerindex/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func (d *documentationGenerator) scrape(ctx context.Context, providers []provide
if providerEntry == nil {
providerEntry = &providertypes.Provider{
Addr: providertypes.Addr(addr),
Link: "",
Description: "",
Versions: nil,
IsBlocked: blocked,
Expand Down Expand Up @@ -252,6 +253,15 @@ func (d *documentationGenerator) scrapeProvider(ctx context.Context, addr provid
return err
}

if meta.CustomRepository != "" {
providerData.Link = meta.CustomRepository
} else {
link, err := d.vcsClient.GetRepositoryBrowseURL(ctx, canonicalAddr.ToRepositoryAddr())
if err != nil {
providerData.Link = link
}
}

// Reverse the version order to ensure that the search index is updated with newer versions overriding older
// versions.
slices.Reverse(meta.Versions)
Expand Down
6 changes: 6 additions & 0 deletions backend/internal/providerindex/providertypes/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ type Provider struct {
//
// required: true
Addr ProviderAddr `json:"addr"`
// Link contains the link to the repository this provider was built from. Note that this may not match the
// Addr field since the repository may be different. Note that this field may not be available for all
// providers.
//
// required:false
Link string `json:"link"`
// CanonicalAddr stores the canonical address of the provider. If this is set, it signals that there
// is an alias in place. The canonical address describes the repository to ultimately fetch the data from.
//
Expand Down
6 changes: 6 additions & 0 deletions backend/internal/server/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,12 @@ definitions:
type: string
is_blocked:
type: boolean
link:
description: |-
Link contains the link to the repository this provider was built from. Note that this may not match the
Addr field since the repository may be different. Note that this field may not be available for all
providers.
type: string
popularity:
description: Popularity indicates how popular the underlying repository is in the VCS system.
format: int64
Expand Down

0 comments on commit 7585fe9

Please sign in to comment.