repo

package
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2021 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultBranch represents the branch used by default when cloning a
	// repository if no branch has been configured on it.
	DefaultBranch = "master"
)

Variables

View Source
var (

	// ErrInvalidMetadata indicates that the repository metadata is not valid.
	ErrInvalidMetadata = errors.New("invalid metadata")

	// 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 a git based
	// repository URL.
	GitRepoURLRE = regexp.MustCompile(`^(https:\/\/(github|gitlab)\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)\/?(.*)$`)
)

Functions

func GetBranch added in v0.15.0

func GetBranch(r *hub.Repository) string

GetBranch returns the branch configured in the repository or the default one if none was provided.

func SchemeIsHTTP added in v0.10.0

func SchemeIsHTTP(u *url.URL) bool

SchemeIsHTTP is a helper that checks if the scheme of the url provided is http or https.

func WithHelmIndexLoader added in v0.5.0

func WithHelmIndexLoader(l hub.HelmIndexLoader) func(m *Manager)

WithHelmIndexLoader allows providing a specific HelmIndexLoader implementation for a Manager instance.

Types

type Cloner

type Cloner struct{}

Cloner is a hub.RepositoryCloner implementation.

func (*Cloner) CloneRepository

func (c *Cloner) CloneRepository(ctx context.Context, r *hub.Repository) (string, string, error)

CloneRepository implements the hub.RepositoryCloner interface.

type ClonerMock

type ClonerMock struct {
	mock.Mock
}

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 HTTPGetter added in v0.6.0

type HTTPGetter interface {
	Get(url string) (*http.Response, error)
}

HTTPGetter defines the methods an HTTPGetter implementation must provide.

type HelmIndexLoader

type HelmIndexLoader struct{}

HelmIndexLoader provides a mechanism to load a Helm repository index file, verifying it is valid.

func (*HelmIndexLoader) LoadIndex

LoadIndex downloads and parses the index file of the provided repository.

type HelmIndexLoaderMock

type HelmIndexLoaderMock struct {
	mock.Mock
}

HelmIndexLoaderMock is a mock implementation of the HelmIndexLoader interface.

func (*HelmIndexLoaderMock) LoadIndex

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, opts ...func(m *Manager)) *Manager

NewManager creates a new Manager instance.

func (*Manager) Add

func (m *Manager) Add(ctx context.Context, orgName string, r *hub.Repository) error

Add adds the provided repository to the database.

func (*Manager) CheckAvailability

func (m *Manager) CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error)

CheckAvailability checks the availability of a given value for the provided resource kind.

func (*Manager) ClaimOwnership added in v0.6.0

func (m *Manager) ClaimOwnership(ctx context.Context, repoName, orgName string) error

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) Delete

func (m *Manager) Delete(ctx context.Context, name string) error

Delete deletes the provided repository from the database.

func (*Manager) GetAll added in v0.4.0

func (m *Manager) GetAll(ctx context.Context, includeCredentials bool) ([]*hub.Repository, error)

GetAll returns all available repositories.

func (*Manager) GetAllJSON added in v0.6.0

func (m *Manager) GetAllJSON(ctx context.Context, includeCredentials bool) ([]byte, error)

GetAllJSON returns all available repositories as a json array, which is built by the database.

func (*Manager) GetByID added in v0.5.0

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) GetByKind

func (m *Manager) GetByKind(
	ctx context.Context,
	kind hub.RepositoryKind,
	includeCredentials bool,
) ([]*hub.Repository, error)

GetByKind returns all available repositories of the provided kind.

func (*Manager) GetByKindJSON added in v0.6.0

func (m *Manager) GetByKindJSON(
	ctx context.Context,
	kind hub.RepositoryKind,
	includeCredentials bool,
) ([]byte, error)

GetByKindJSON returns all available repositories of the provided kind as a json array, which is built by the database.

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 added in v0.6.0

func (m *Manager) GetMetadata(mdFile string) (*hub.RepositoryMetadata, error)

GetMetadata reads and parses the repository metadata file provided, which can be a remote URL or a local file path. The .yml and .yaml extensions will be implicitly appended to the given path.

func (*Manager) GetOwnedByOrgJSON

func (m *Manager) GetOwnedByOrgJSON(
	ctx context.Context,
	orgName string,
	includeCredentials bool,
) ([]byte, error)

GetOwnedByOrgJSON returns all repositories that belong to the organization provided.

func (*Manager) GetOwnedByUserJSON

func (m *Manager) GetOwnedByUserJSON(ctx context.Context, includeCredentials bool) ([]byte, error)

GetOwnedByUserJSON returns all repositories that belong to the user making the request.

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 added in v0.11.0

func (m *Manager) GetRemoteDigest(ctx context.Context, r *hub.Repository) (string, error)

GetRemoteDigest gets the repository's digest available in the remote.

func (*Manager) SetLastTrackingResults

func (m *Manager) SetLastTrackingResults(ctx context.Context, repositoryID, errs string) error

SetLastTrackingResults updates the timestamp and errors of the last tracking of the provided repository in the database.

func (*Manager) SetVerifiedPublisher added in v0.5.0

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.

func (*Manager) Update

func (m *Manager) Update(ctx context.Context, r *hub.Repository) error

Update updates the provided repository in the database.

func (*Manager) UpdateDigest added in v0.11.0

func (m *Manager) UpdateDigest(ctx context.Context, repositoryID, digest string) error

UpdateDigest updates the digest of the provided repository in the database.

type ManagerMock

type ManagerMock struct {
	mock.Mock
}

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 added in v0.6.0

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) GetAll added in v0.4.0

func (m *ManagerMock) GetAll(ctx context.Context, includeCredentials bool) ([]*hub.Repository, error)

GetAll implements the RepositoryManager interface.

func (*ManagerMock) GetAllJSON added in v0.6.0

func (m *ManagerMock) GetAllJSON(ctx context.Context, includeCredentials bool) ([]byte, error)

GetAllJSON implements the RepositoryManager interface.

func (*ManagerMock) GetByID added in v0.5.0

func (m *ManagerMock) GetByID(
	ctx context.Context,
	repositoryID string,
	includeCredentials bool,
) (*hub.Repository, error)

GetByID implements the RepositoryManager interface.

func (*ManagerMock) GetByKind

func (m *ManagerMock) GetByKind(
	ctx context.Context,
	kind hub.RepositoryKind,
	includeCredentials bool,
) ([]*hub.Repository, error)

GetByKind implements the RepositoryManager interface.

func (*ManagerMock) GetByKindJSON added in v0.6.0

func (m *ManagerMock) GetByKindJSON(
	ctx context.Context,
	kind hub.RepositoryKind,
	includeCredentials bool,
) ([]byte, error)

GetByKindJSON 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 added in v0.6.0

func (m *ManagerMock) GetMetadata(mdFile string) (*hub.RepositoryMetadata, error)

GetMetadata implements the RepositoryManager interface.

func (*ManagerMock) GetOwnedByOrgJSON

func (m *ManagerMock) GetOwnedByOrgJSON(
	ctx context.Context,
	orgName string,
	includeCredentials bool,
) ([]byte, error)

GetOwnedByOrgJSON implements the RepositoryManager interface.

func (*ManagerMock) GetOwnedByUserJSON

func (m *ManagerMock) GetOwnedByUserJSON(ctx context.Context, includeCredentials bool) ([]byte, error)

GetOwnedByUserJSON 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 added in v0.11.0

func (m *ManagerMock) GetRemoteDigest(ctx context.Context, r *hub.Repository) (string, error)

GetRemoteDigest 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 added in v0.5.0

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 added in v0.11.0

func (m *ManagerMock) UpdateDigest(ctx context.Context, repositoryID, digest string) error

UpdateDigest implements the RepositoryManager interface.

type OCITagsGetter added in v0.14.0

type OCITagsGetter struct{}

OCITagsGetter provides a mechanism to get all the version tags available for a given repository in a OCI registry. Tags that aren't valid semver versions will be filtered out.

func (*OCITagsGetter) Tags added in v0.14.0

func (tg *OCITagsGetter) Tags(ctx context.Context, r *hub.Repository) ([]string, error)

Tags returns a list with the tags available for the provided repository.

type OCITagsGetterMock added in v0.14.0

type OCITagsGetterMock struct {
	mock.Mock
}

OCITagsGetterMock is a mock implementation of the OCITagsGetter interface.

func (*OCITagsGetterMock) Tags added in v0.14.0

func (m *OCITagsGetterMock) Tags(ctx context.Context, r *hub.Repository) ([]string, error)

Tags implements the OCITagsGetter interface.

type OLMOCIExporter added in v0.14.0

type OLMOCIExporter struct{}

OLMOCIExporter provides a mechanism to export the packages available in an OLM repository stored in an OCI registry.

func (*OLMOCIExporter) ExportRepository added in v0.14.0

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 added in v0.14.0

type OLMOCIExporterMock struct {
	mock.Mock
}

OLMOCIExporterMock is a mock implementation of the OLMOCIExporter interface.

func (*OLMOCIExporterMock) ExportRepository added in v0.14.0

func (m *OLMOCIExporterMock) ExportRepository(ctx context.Context, r *hub.Repository) (string, error)

ExportRepository implements the OLMOCIExporter interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL