Documentation ¶
Index ¶
- Constants
- Variables
- func GetBranch(r *hub.Repository) string
- func SchemeIsHTTP(u *url.URL) bool
- func SchemeIsOCI(u *url.URL) bool
- func WithHelmIndexLoader(l hub.HelmIndexLoader) func(m *Manager)
- func WithOCIPuller(p hub.OCIPuller) func(m *Manager)
- func WithOCITagsGetter(tg hub.OCITagsGetter) func(m *Manager)
- type Cloner
- type ClonerMock
- type ErrorsCollector
- type ErrorsCollectorKind
- type ErrorsCollectorMock
- type HelmIndexLoader
- type HelmIndexLoaderMock
- type Manager
- func (m *Manager) Add(ctx context.Context, orgName string, r *hub.Repository) error
- func (m *Manager) CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error)
- func (m *Manager) ClaimOwnership(ctx context.Context, repoName, orgName string) error
- func (m *Manager) Delete(ctx context.Context, name string) error
- func (m *Manager) GetByID(ctx context.Context, repositoryID string, includeCredentials bool) (*hub.Repository, error)
- func (m *Manager) GetByName(ctx context.Context, name string, includeCredentials bool) (*hub.Repository, error)
- func (m *Manager) GetMetadata(r *hub.Repository, basePath string) (*hub.RepositoryMetadata, error)
- func (m *Manager) GetPackagesDigest(ctx context.Context, repositoryID string) (map[string]string, error)
- func (m *Manager) GetRemoteDigest(ctx context.Context, r *hub.Repository) (string, error)
- func (m *Manager) Search(ctx context.Context, input *hub.SearchRepositoryInput) (*hub.SearchRepositoryResult, error)
- func (m *Manager) SearchJSON(ctx context.Context, input *hub.SearchRepositoryInput) (*hub.JSONQueryResult, error)
- func (m *Manager) SetLastScanningResults(ctx context.Context, repositoryID, errs string) error
- func (m *Manager) SetLastTrackingResults(ctx context.Context, repositoryID, errs string) error
- func (m *Manager) SetVerifiedPublisher(ctx context.Context, repositoryID string, verified bool) error
- func (m *Manager) Transfer(ctx context.Context, repoName, orgName string, ownershipClaim bool) error
- func (m *Manager) Update(ctx context.Context, r *hub.Repository) error
- func (m *Manager) UpdateDigest(ctx context.Context, repositoryID, digest string) error
- type ManagerMock
- func (m *ManagerMock) Add(ctx context.Context, orgName string, r *hub.Repository) error
- func (m *ManagerMock) CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error)
- func (m *ManagerMock) ClaimOwnership(ctx context.Context, name, orgName string) error
- func (m *ManagerMock) Delete(ctx context.Context, name string) error
- func (m *ManagerMock) GetByID(ctx context.Context, repositoryID string, includeCredentials bool) (*hub.Repository, error)
- func (m *ManagerMock) GetByName(ctx context.Context, name string, includeCredentials bool) (*hub.Repository, error)
- func (m *ManagerMock) GetMetadata(r *hub.Repository, basePath string) (*hub.RepositoryMetadata, error)
- func (m *ManagerMock) GetPackagesDigest(ctx context.Context, repositoryID string) (map[string]string, error)
- func (m *ManagerMock) GetRemoteDigest(ctx context.Context, r *hub.Repository) (string, error)
- func (m *ManagerMock) Search(ctx context.Context, input *hub.SearchRepositoryInput) (*hub.SearchRepositoryResult, error)
- func (m *ManagerMock) SearchJSON(ctx context.Context, input *hub.SearchRepositoryInput) (*hub.JSONQueryResult, error)
- func (m *ManagerMock) SetLastScanningResults(ctx context.Context, repositoryID, errs string) error
- func (m *ManagerMock) SetLastTrackingResults(ctx context.Context, repositoryID, errs string) error
- func (m *ManagerMock) SetVerifiedPublisher(ctx context.Context, repositoryID string, verified bool) error
- func (m *ManagerMock) Transfer(ctx context.Context, name, orgName string, ownershipClaim bool) error
- func (m *ManagerMock) Update(ctx context.Context, r *hub.Repository) error
- func (m *ManagerMock) UpdateDigest(ctx context.Context, repositoryID, digest string) error
- type OLMOCIExporter
- type OLMOCIExporterMock
Constants ¶
const ( // DefaultBranch represents the branch used by default when cloning a // repository if no branch has been configured on it. DefaultBranch = "master" )
const ( // MetadataLayerMediaType represents the media type used for the layer that // contains the repository metadata in an OCI image. MetadataLayerMediaType = "application/vnd.cncf.artifacthub.repository-metadata.layer.v1.yaml" )
Variables ¶
var ( // ErrInvalidMetadata indicates that the repository metadata is not valid. ErrInvalidMetadata = errors.New("invalid metadata") // ErrMetadataNotFound indicates that the repository metadata was not found. ErrMetadataNotFound = errors.New("metadata not found") // ErrSchemeNotSupported error indicates that the scheme used in the // repository url is not supported. ErrSchemeNotSupported = errors.New("scheme not supported") // GitRepoURLRE is a regexp used to validate and parse an http based git // repository URL. GitRepoURLRE = regexp.MustCompile(`^(https:\/\/([A-Za-z0-9_.-]+)\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)\/?(.*)$`) )
Functions ¶
func GetBranch ¶
func GetBranch(r *hub.Repository) string
GetBranch returns the branch configured in the repository or the default one if none was provided.
func SchemeIsHTTP ¶
SchemeIsHTTP is a helper that checks if the scheme of the url provided is http or https.
func SchemeIsOCI ¶
SchemeIsOCI is a helper that checks if the scheme of the url provided is oci.
func WithHelmIndexLoader ¶
func WithHelmIndexLoader(l hub.HelmIndexLoader) func(m *Manager)
WithHelmIndexLoader allows providing a specific HelmIndexLoader implementation for a Manager instance.
func WithOCIPuller ¶
WithOCIPuller allows providing a specific OCIPuller implementation for a Manager instance.
func WithOCITagsGetter ¶
func WithOCITagsGetter(tg hub.OCITagsGetter) func(m *Manager)
WithOCITagsGetter allows providing a specific OCITagsGetter implementation for a Manager instance.
Types ¶
type Cloner ¶
type Cloner struct{}
Cloner is a hub.RepositoryCloner implementation.
func (*Cloner) CloneRepository ¶
CloneRepository implements the hub.RepositoryCloner interface.
type ClonerMock ¶
ClonerMock is a mock implementation of the RepositoryCloner interface.
func (*ClonerMock) CloneRepository ¶
func (m *ClonerMock) CloneRepository(ctx context.Context, r *hub.Repository) (string, string, error)
CloneRepository implements the RepositoryCloner interface.
type ErrorsCollector ¶
type ErrorsCollector struct {
// contains filtered or unexported fields
}
ErrorsCollector is in charge of collecting errors that happen while repositories are being processed. Once all the processing is done, the collected errors can be flushed, which will store them in the database.
func NewErrorsCollector ¶
func NewErrorsCollector(repoManager hub.RepositoryManager, kind ErrorsCollectorKind) *ErrorsCollector
NewErrorsCollector creates a new ErrorsCollector instance.
func (*ErrorsCollector) Append ¶
func (c *ErrorsCollector) Append(repositoryID string, err string)
Append adds the error provided to the repository's list of errors.
func (*ErrorsCollector) Flush ¶
func (c *ErrorsCollector) Flush()
Flush aggregates all errors collected per repository as a single text and stores it in the database.
func (*ErrorsCollector) Init ¶
func (c *ErrorsCollector) Init(repositoryID string)
Init initializes the list of errors for the repository provided. This will allow the errors collector to reset the errors from a previous tracker or scanner run when no errors have been collected from the current run.
type ErrorsCollectorKind ¶
type ErrorsCollectorKind int64
ErrorsCollectorKind represents the kind of a given errors collector.
const ( // Scanner represents an errors collector for a scanner instance. Scanner ErrorsCollectorKind = 0 // Tracker represents an errors collector for a tracker instance. Tracker ErrorsCollectorKind = 1 )
type ErrorsCollectorMock ¶
ErrorsCollectorMock is mock ErrorsCollector implementation.
func (*ErrorsCollectorMock) Append ¶
func (m *ErrorsCollectorMock) Append(repositoryID string, err string)
Append implements the ErrorsCollector interface.
func (*ErrorsCollectorMock) Flush ¶
func (m *ErrorsCollectorMock) Flush()
Flush implements the ErrorsCollector interface.
func (*ErrorsCollectorMock) Init ¶
func (m *ErrorsCollectorMock) Init(repositoryID string)
Init implements the ErrorsCollector interface.
type HelmIndexLoader ¶
type HelmIndexLoader struct{}
HelmIndexLoader provides a mechanism to load a Helm repository index file, verifying it is valid.
func (*HelmIndexLoader) LoadIndex ¶
func (l *HelmIndexLoader) LoadIndex(r *hub.Repository) (*helmrepo.IndexFile, string, error)
LoadIndex downloads and parses the index file of the provided repository.
type HelmIndexLoaderMock ¶
HelmIndexLoaderMock is a mock implementation of the HelmIndexLoader interface.
func (*HelmIndexLoaderMock) LoadIndex ¶
func (m *HelmIndexLoaderMock) LoadIndex(r *hub.Repository) (*repo.IndexFile, string, error)
LoadIndex implements the HelmIndexLoader interface.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides an API to manage repositories.
func NewManager ¶
func NewManager( cfg *viper.Viper, db hub.DB, az hub.Authorizer, hc hub.HTTPClient, opts ...func(m *Manager), ) *Manager
NewManager creates a new Manager instance.
func (*Manager) CheckAvailability ¶
CheckAvailability checks the availability of a given value for the provided resource kind.
func (*Manager) ClaimOwnership ¶
ClaimOwnership allows a user to claim the ownership of a given repository. The repository will be transferred to the destination entity requested if the user is listed as one of the owners in the repository metadata file.
func (*Manager) GetByID ¶
func (m *Manager) GetByID( ctx context.Context, repositoryID string, includeCredentials bool, ) (*hub.Repository, error)
GetByID returns the repository identified by the id provided.
func (*Manager) GetByName ¶
func (m *Manager) GetByName( ctx context.Context, name string, includeCredentials bool, ) (*hub.Repository, error)
GetByName returns the repository identified by the name provided.
func (*Manager) GetMetadata ¶
func (m *Manager) GetMetadata(r *hub.Repository, basePath string) (*hub.RepositoryMetadata, error)
GetMetadata reads and parses the metadata file of the repository provided. When needed, the repository must be previously cloned and the path pointing to the location of the packages must be provided (basePath).
func (*Manager) GetPackagesDigest ¶
func (m *Manager) GetPackagesDigest( ctx context.Context, repositoryID string, ) (map[string]string, error)
GetPackagesDigest returns the digests for all packages in the repository identified by the id provided.
func (*Manager) GetRemoteDigest ¶
GetRemoteDigest gets the repository's digest available in the remote.
func (*Manager) Search ¶
func (m *Manager) Search( ctx context.Context, input *hub.SearchRepositoryInput, ) (*hub.SearchRepositoryResult, error)
Search searches for repositories in the database that the criteria defined in the input provided.
func (*Manager) SearchJSON ¶
func (m *Manager) SearchJSON( ctx context.Context, input *hub.SearchRepositoryInput, ) (*hub.JSONQueryResult, error)
SearchJSON returns a json object with the search results produced by the input provided. The json object is built by the database.
func (*Manager) SetLastScanningResults ¶
SetLastScanningResults updates the timestamp and errors of the last scanning of the provided repository in the database.
func (*Manager) SetLastTrackingResults ¶
SetLastTrackingResults updates the timestamp and errors of the last tracking of the provided repository in the database.
func (*Manager) SetVerifiedPublisher ¶
func (m *Manager) SetVerifiedPublisher(ctx context.Context, repositoryID string, verified bool) error
SetVerifiedPublisher updates the verified publisher flag of the provided repository in the database.
func (*Manager) Transfer ¶
func (m *Manager) Transfer(ctx context.Context, repoName, orgName string, ownershipClaim bool) error
Transfer transfers the provided repository to a different owner. A user owned repo can be transferred to an organization the requesting user belongs to. An org owned repo can be transfer to the requesting user, provided the user belongs to the owning org, or to a different organization the user belongs to.
type ManagerMock ¶
ManagerMock is a mock implementation of the RepositoryManager interface.
func (*ManagerMock) Add ¶
func (m *ManagerMock) Add(ctx context.Context, orgName string, r *hub.Repository) error
Add implements the RepositoryManager interface.
func (*ManagerMock) CheckAvailability ¶
func (m *ManagerMock) CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error)
CheckAvailability implements the RepositoryManager interface.
func (*ManagerMock) ClaimOwnership ¶
func (m *ManagerMock) ClaimOwnership(ctx context.Context, name, orgName string) error
ClaimOwnership implements the RepositoryManager interface.
func (*ManagerMock) Delete ¶
func (m *ManagerMock) Delete(ctx context.Context, name string) error
Delete implements the RepositoryManager interface.
func (*ManagerMock) GetByID ¶
func (m *ManagerMock) GetByID( ctx context.Context, repositoryID string, includeCredentials bool, ) (*hub.Repository, error)
GetByID implements the RepositoryManager interface.
func (*ManagerMock) GetByName ¶
func (m *ManagerMock) GetByName( ctx context.Context, name string, includeCredentials bool, ) (*hub.Repository, error)
GetByName implements the RepositoryManager interface.
func (*ManagerMock) GetMetadata ¶
func (m *ManagerMock) GetMetadata(r *hub.Repository, basePath string) (*hub.RepositoryMetadata, error)
GetMetadata implements the RepositoryManager interface.
func (*ManagerMock) GetPackagesDigest ¶
func (m *ManagerMock) GetPackagesDigest( ctx context.Context, repositoryID string, ) (map[string]string, error)
GetPackagesDigest implements the RepositoryManager interface.
func (*ManagerMock) GetRemoteDigest ¶
func (m *ManagerMock) GetRemoteDigest(ctx context.Context, r *hub.Repository) (string, error)
GetRemoteDigest implements the RepositoryManager interface.
func (*ManagerMock) Search ¶
func (m *ManagerMock) Search( ctx context.Context, input *hub.SearchRepositoryInput, ) (*hub.SearchRepositoryResult, error)
Search implements the RepositoryManager interface.
func (*ManagerMock) SearchJSON ¶
func (m *ManagerMock) SearchJSON( ctx context.Context, input *hub.SearchRepositoryInput, ) (*hub.JSONQueryResult, error)
SearchJSON implements the RepositoryManager interface.
func (*ManagerMock) SetLastScanningResults ¶
func (m *ManagerMock) SetLastScanningResults(ctx context.Context, repositoryID, errs string) error
SetLastScanningResults implements the RepositoryManager interface.
func (*ManagerMock) SetLastTrackingResults ¶
func (m *ManagerMock) SetLastTrackingResults(ctx context.Context, repositoryID, errs string) error
SetLastTrackingResults implements the RepositoryManager interface.
func (*ManagerMock) SetVerifiedPublisher ¶
func (m *ManagerMock) SetVerifiedPublisher(ctx context.Context, repositoryID string, verified bool) error
SetVerifiedPublisher implements the RepositoryManager interface.
func (*ManagerMock) Transfer ¶
func (m *ManagerMock) Transfer(ctx context.Context, name, orgName string, ownershipClaim bool) error
Transfer implements the RepositoryManager interface.
func (*ManagerMock) Update ¶
func (m *ManagerMock) Update(ctx context.Context, r *hub.Repository) error
Update implements the RepositoryManager interface.
func (*ManagerMock) UpdateDigest ¶
func (m *ManagerMock) UpdateDigest(ctx context.Context, repositoryID, digest string) error
UpdateDigest implements the RepositoryManager interface.
type OLMOCIExporter ¶
type OLMOCIExporter struct{}
OLMOCIExporter provides a mechanism to export the packages available in an OLM repository stored in an OCI registry.
func (*OLMOCIExporter) ExportRepository ¶
func (e *OLMOCIExporter) ExportRepository(ctx context.Context, r *hub.Repository) (string, error)
ExportRepository exports the packages available in a repository stored in a OCI registry using the appregistry manifest format. It returns the temporary directory where the packages will be stored. It's the caller's responsibility to delete it when done.
type OLMOCIExporterMock ¶
OLMOCIExporterMock is a mock implementation of the OLMOCIExporter interface.
func (*OLMOCIExporterMock) ExportRepository ¶
func (m *OLMOCIExporterMock) ExportRepository(ctx context.Context, r *hub.Repository) (string, error)
ExportRepository implements the OLMOCIExporter interface.