diff --git a/backend/internal/providerindex/generator.go b/backend/internal/providerindex/generator.go index c40f5de..bfb544f 100644 --- a/backend/internal/providerindex/generator.go +++ b/backend/internal/providerindex/generator.go @@ -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, @@ -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) diff --git a/backend/internal/providerindex/providertypes/provider.go b/backend/internal/providerindex/providertypes/provider.go index d3a8a37..e2e54eb 100644 --- a/backend/internal/providerindex/providertypes/provider.go +++ b/backend/internal/providerindex/providertypes/provider.go @@ -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. // diff --git a/backend/internal/server/openapi.yml b/backend/internal/server/openapi.yml index 6c8f90c..d074db4 100644 --- a/backend/internal/server/openapi.yml +++ b/backend/internal/server/openapi.yml @@ -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