hub

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RepositoryMetadataFile represents the name of the file where the
	// Artifact Hub metadata for a given repository is stored.
	RepositoryMetadataFile = "artifacthub-repo"

	// RepositoryOCIPrefix represents the prefix expected in the url when the
	// repository is stored in a OCI registry.
	RepositoryOCIPrefix = "oci://"
)
View Source
const (
	// Tekton catalog versioning kinds
	TektonDirBasedVersioning = "directory"
	TektonGitBasedVersioning = "git"
)
View Source
const (
	// HasNotChanged is a snapshot digest value that indicates that the digest
	// has not changed.
	HasNotChanged = "has-not-changed"
)
View Source
const (
	// PackageMetadataFile represents the name of the file where the Artifact
	// Hub metadata for a given package is stored.
	PackageMetadataFile = "artifacthub-pkg"
)

Variables

View Source
var (
	// ErrInvalidInput indicates that the input provided is not valid.
	ErrInvalidInput = errors.New("invalid input")

	// ErrInsufficientPrivilege indicates that the user does not have the
	// required privilege to perform the operation.
	ErrInsufficientPrivilege = errors.New("insufficient_privilege")

	// ErrNotFound indicates that the requested item was not found.
	ErrNotFound = errors.New("not found")
)
View Source
var IndexMetaDescriptionKey = indexMetaDescriptionKey{}

IndexMetaDescriptionKey represents the key used for the description in the index metadata.

View Source
var IndexMetaTitleKey = indexMetaTitleKey{}

IndexMetaTitleKey represents the key used for the title in the index metadata.

View Source
var UserIDKey = userIDKey{}

UserIDKey represents the key used for the userID value inside a context.

Functions

func GetKindName added in v0.3.0

func GetKindName(kind RepositoryKind) string

GetKindName returns the name of the provided repository kind.

Types

type APIKey added in v0.2.0

type APIKey struct {
	APIKeyID  string `json:"api_key_id"`
	Name      string `json:"name"`
	Secret    string `json:"secret"`
	CreatedAt int64  `json:"created_at"`
	UserID    string `json:"user_id"`
}

APIKey represents a key used to interact with the HTTP API.

type APIKeyManager added in v0.2.0

type APIKeyManager interface {
	Add(ctx context.Context, ak *APIKey) (*APIKey, error)
	Check(ctx context.Context, apiKeyID, apiKeySecret string) (*CheckAPIKeyOutput, error)
	Delete(ctx context.Context, apiKeyID string) error
	GetJSON(ctx context.Context, apiKeyID string) ([]byte, error)
	GetOwnedByUserJSON(ctx context.Context, p *Pagination) (*JSONQueryResult, error)
	Update(ctx context.Context, ak *APIKey) error
}

APIKeyManager describes the methods an APIKeyManager implementation must provide.

type Action added in v0.6.0

type Action string

Action represents the kind of action a user intends to perform.

const (
	// AddOrganizationMember represents the action of adding a member to an
	// organization.
	AddOrganizationMember Action = "addOrganizationMember"

	// AddOrganizationRepository represents the action of adding a repository
	// to an organization.
	AddOrganizationRepository Action = "addOrganizationRepository"

	// DeleteOrganization represents the action of deleting an organization.
	DeleteOrganization Action = "deleteOrganization"

	// DeleteOrganizationMember represents the action of deleting a member from
	// an organization.
	DeleteOrganizationMember Action = "deleteOrganizationMember"

	// DeleteOrganizationRepository represents the action of deleting a
	// repository from an organization.
	DeleteOrganizationRepository Action = "deleteOrganizationRepository"

	// GetAuthorizationPolicy represents the action of getting an organization
	// authorization policy.
	GetAuthorizationPolicy Action = "getAuthorizationPolicy"

	// TransferOrganizationRepository represents the action of transferring a
	// repository that belongs to an organization.
	TransferOrganizationRepository Action = "transferOrganizationRepository"

	// UpdateAuthorizationPolicy represents the action of updating an
	// organization authorization policy.
	UpdateAuthorizationPolicy Action = "updateAuthorizationPolicy"

	// UpdateOrganization represents the action of updating the details of an
	// organization.
	UpdateOrganization Action = "updateOrganization"

	// UpdateOrganizationRepository represents the action of updating a
	// repository that belongs to an organization.
	UpdateOrganizationRepository Action = "updateOrganizationRepository"
)

type AuthorizationPolicy added in v0.6.0

type AuthorizationPolicy struct {
	AuthorizationEnabled bool            `json:"authorization_enabled"`
	PredefinedPolicy     string          `json:"predefined_policy"`
	CustomPolicy         string          `json:"custom_policy"`
	PolicyData           json.RawMessage `json:"policy_data"`
}

AuthorizationPolicy represents some information about the authorization policy for an organization.

type AuthorizeInput added in v0.6.0

type AuthorizeInput struct {
	// OrganizationName represents the name of the organization owning the
	// resource affected by the action.
	OrganizationName string

	// UserID represents the id of the user who intends to perform the action.
	UserID string

	// Action represents the action to perform.
	Action Action
}

AuthorizeInput represents the input required to call Authorize.

type Authorizer added in v0.6.0

type Authorizer interface {
	Authorize(ctx context.Context, input *AuthorizeInput) error
	GetAllowedActions(ctx context.Context, userID, orgName string) ([]Action, error)
	WillUserBeLockedOut(ctx context.Context, newPolicy *AuthorizationPolicy, userID string) (bool, error)
}

Authorizer describes the methods an Authorizer implementation must provide.

type Change added in v0.20.0

type Change struct {
	Kind        string  `json:"kind,omitempty"`
	Description string  `json:"description"`
	Links       []*Link `json:"links,omitempty"`
}

Change represents a change introduced in a package version.

type Changelog added in v1.4.0

type Changelog []*VersionChanges

Changelog represents a package's changelog.

type Channel added in v0.3.0

type Channel struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

Channel represents a package's channel.

type CheckAPIKeyOutput added in v0.2.0

type CheckAPIKeyOutput struct {
	Valid  bool   `json:"valid"`
	UserID string `json:"user_id"`
}

CheckAPIKeyOutput represents the output returned by the CheckApiKey method.

type CheckCredentialsOutput

type CheckCredentialsOutput struct {
	Valid  bool   `json:"valid"`
	UserID string `json:"user_id"`
}

CheckCredentialsOutput represents the output returned by the CheckCredentials method.

type CheckSessionOutput

type CheckSessionOutput struct {
	Valid  bool   `json:"valid"`
	UserID string `json:"user_id"`
}

CheckSessionOutput represents the output returned by the CheckSession method.

type ContainerImage added in v0.7.0

type ContainerImage struct {
	Name        string `json:"name" yaml:"name"`
	Image       string `json:"image" yaml:"image"`
	Whitelisted bool   `json:"whitelisted" yaml:"whitelisted"`
}

ContainerImage represents a container image associated with a package.

type ContainerImageData added in v1.6.0

type ContainerImageData struct {
	Tags []ContainerImageTag `json:"tags"`
}

ContainerImageData represents some data specific to repositories of the container image kind.

type ContainerImageTag added in v1.6.0

type ContainerImageTag struct {
	Name    string `json:"name"`
	Mutable bool   `json:"mutable"`
}

ContainerImageTag represents some information about a container image tag.

type DB

type DB interface {
	Acquire(ctx context.Context) (*pgxpool.Conn, error)
	Begin(ctx context.Context) (pgx.Tx, error)
	Exec(ctx context.Context, sql string, arguments ...interface{}) (pgconn.CommandTag, error)
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
}

DB defines the methods the database handler must provide.

type EmailSender

type EmailSender interface {
	SendEmail(data *email.Data) error
}

EmailSender defines the methods the email sender must provide.

type ErrorsCollector added in v0.14.0

type ErrorsCollector interface {
	Append(repositoryID string, err string)
	Flush()
	Init(repositoryID string)
}

ErrorsCollector interface defines the methods that an errors collector implementation should provide.

type Event

type Event struct {
	EventID        string                 `json:"event_id"`
	EventKind      EventKind              `json:"event_kind"`
	RepositoryID   string                 `json:"repository_id"`
	PackageID      string                 `json:"package_id"`
	PackageVersion string                 `json:"package_version"`
	Data           map[string]interface{} `json:"data"`
}

Event represents the details of an event.

type EventKind

type EventKind int64

EventKind represents the kind of an event.

const (
	// NewRelease represents an event for a new package release.
	NewRelease EventKind = 0

	// SecurityAlert represents an event for a security alert.
	SecurityAlert EventKind = 1

	// RepositoryTrackingErrors represents an event for errors that occur while
	// a repository is being tracked.
	RepositoryTrackingErrors EventKind = 2

	// RepositoryOwnershipClaim represents an event for a repository ownership
	// claim.
	RepositoryOwnershipClaim EventKind = 3

	// RepositoryScanningErrors represents an event for errors that occur while
	// a repository is being scanned.
	RepositoryScanningErrors EventKind = 4
)

type EventManager

type EventManager interface {
	GetPending(ctx context.Context, tx pgx.Tx) (*Event, error)
}

EventManager describes the methods an EventManager implementation must provide.

type GetPackageInput

type GetPackageInput struct {
	PackageID      string `json:"package_id"`
	RepositoryName string `json:"repository_name"`
	PackageName    string `json:"package_name"`
	Version        string `json:"version"`
}

GetPackageInput represents the input used to get a specific package.

type HTTPClient added in v0.14.0

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient defines the methods an HTTPClient implementation must provide.

type HelmIndexLoader added in v0.3.0

type HelmIndexLoader interface {
	LoadIndex(r *Repository) (*helmrepo.IndexFile, string, error)
}

HelmIndexLoader interface defines the methods a Helm index loader implementation should provide.

type JSONQueryResult added in v1.0.0

type JSONQueryResult struct {
	Data       []byte `json:"data"`
	TotalCount int    `json:"total_count"`
}

JSONQueryResult represents the result of a database query that returns json data alongside some metadata.

type Link struct {
	Name string `json:"name" yaml:"name"`
	URL  string `json:"url" yaml:"url"`
}

Link represents a url associated with a package.

type Maintainer

type Maintainer struct {
	MaintainerID string `json:"maintainer_id"`
	Name         string `json:"name" yaml:"name"`
	Email        string `json:"email" yaml:"email"`
}

Maintainer represents a package's maintainer.

type Notification

type Notification struct {
	NotificationID string   `json:"notification_id"`
	Event          *Event   `json:"event"`
	User           *User    `json:"user"`
	Webhook        *Webhook `json:"webhook"`
}

Notification represents the details of a notification pending to be delivered.

type NotificationManager

type NotificationManager interface {
	Add(ctx context.Context, tx pgx.Tx, n *Notification) error
	GetPending(ctx context.Context, tx pgx.Tx) (*Notification, error)
	UpdateStatus(
		ctx context.Context,
		tx pgx.Tx,
		notificationID string,
		delivered bool,
		deliveryErr error,
	) error
}

NotificationManager describes the methods an NotificationManager implementation must provide.

type OCIPuller added in v1.3.0

type OCIPuller interface {
	PullLayer(
		ctx context.Context,
		ref,
		mediaType,
		username,
		password string,
	) (ocispec.Descriptor, []byte, error)
}

OCIPuller defines the methods an OCIPuller implementation must provide.

type OCISignatureChecker added in v1.5.0

type OCISignatureChecker interface {
	HasCosignSignature(ctx context.Context, ref, username, password string) (bool, error)
}

SignatureChecker is the interface that wraps the HasCosignSignature method, used to check if the OCI artifact identified by the reference provided has a cosign (sigstore) signature.

type OCITagsGetter added in v0.14.0

type OCITagsGetter interface {
	Tags(ctx context.Context, r *Repository, onlySemver bool) ([]string, error)
}

OCITagsGetter is the interface that wraps the Tags method, used to get all the tags available for a given repository in a OCI registry.

type OLMOCIExporter added in v0.14.0

type OLMOCIExporter interface {
	ExportRepository(ctx context.Context, r *Repository) (tmpDir string, err error)
}

OLMOCIExporter describes the methods an OLMOCIExporter implementation must must provide.

type OptOut added in v0.5.0

type OptOut struct {
	OptOutID     string    `json:"opt_out_id"`
	UserID       string    `json:"user_id"`
	RepositoryID string    `json:"repository_id"`
	EventKind    EventKind `json:"event_kind"`
}

OptOut represents a user's opt-out entry to stop receiving notifications about a given repository and event kind.

type Organization

type Organization struct {
	OrganizationID string `json:"organization_id"`
	Name           string `json:"name"`
	DisplayName    string `json:"display_name"`
	Description    string `json:"description"`
	HomeURL        string `json:"home_url"`
	LogoImageID    string `json:"logo_image_id"`
}

Organization represents an entity with one or more users associated that can own repositories and other entities like webhooks.

type OrganizationManager

type OrganizationManager interface {
	Add(ctx context.Context, org *Organization) error
	AddMember(ctx context.Context, orgName, userAlias string) error
	CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error)
	ConfirmMembership(ctx context.Context, orgName string) error
	Delete(ctx context.Context, orgName string) error
	DeleteMember(ctx context.Context, orgName, userAlias string) error
	GetJSON(ctx context.Context, orgName string) ([]byte, error)
	GetByUserJSON(ctx context.Context, p *Pagination) (*JSONQueryResult, error)
	GetAuthorizationPolicyJSON(ctx context.Context, orgName string) ([]byte, error)
	GetMembersJSON(ctx context.Context, orgName string, p *Pagination) (*JSONQueryResult, error)
	Update(ctx context.Context, orgName string, org *Organization) error
	UpdateAuthorizationPolicy(ctx context.Context, orgName string, policy *AuthorizationPolicy) error
}

OrganizationManager describes the methods an OrganizationManager implementation must provide.

type Owner added in v0.6.0

type Owner struct {
	Name  string `yaml:"name"`
	Email string `yaml:"email"`
}

Owner represents some details about a repository's owner.

type Package

type Package struct {
	PackageID                      string                 `json:"package_id"`
	Name                           string                 `json:"name"`
	NormalizedName                 string                 `json:"normalized_name"`
	LogoURL                        string                 `json:"logo_url"`
	LogoImageID                    string                 `json:"logo_image_id"`
	IsOperator                     bool                   `json:"is_operator"`
	Official                       bool                   `json:"official"`
	Channels                       []*Channel             `json:"channels"`
	DefaultChannel                 string                 `json:"default_channel"`
	DisplayName                    string                 `json:"display_name"`
	Description                    string                 `json:"description"`
	Keywords                       []string               `json:"keywords"`
	HomeURL                        string                 `json:"home_url"`
	Readme                         string                 `json:"readme"`
	Install                        string                 `json:"install"`
	Links                          []*Link                `json:"links"`
	Capabilities                   string                 `json:"capabilities"`
	CRDs                           []interface{}          `json:"crds"`
	CRDsExamples                   []interface{}          `json:"crds_examples"`
	SecurityReportSummary          *SecurityReportSummary `json:"security_report_summary"`
	SecurityReportCreatedAt        int64                  `json:"security_report_created_at,omitempty"`
	Data                           map[string]interface{} `json:"data"`
	Version                        string                 `json:"version"`
	AvailableVersions              []*Version             `json:"available_versions"`
	AppVersion                     string                 `json:"app_version"`
	Digest                         string                 `json:"digest"`
	Deprecated                     bool                   `json:"deprecated"`
	License                        string                 `json:"license"`
	Signed                         bool                   `json:"signed"`
	Signatures                     []string               `json:"signatures"`
	ContentURL                     string                 `json:"content_url"`
	ContainersImages               []*ContainerImage      `json:"containers_images"`
	AllContainersImagesWhitelisted bool                   `json:"all_containers_images_whitelisted"`
	Provider                       string                 `json:"provider"`
	HasValuesSchema                bool                   `json:"has_values_schema"`
	ValuesSchema                   json.RawMessage        `json:"values_schema,omitempty"`
	HasChangelog                   bool                   `json:"has_changelog"`
	Changes                        []*Change              `json:"changes"`
	ContainsSecurityUpdates        bool                   `json:"contains_security_updates"`
	Prerelease                     bool                   `json:"prerelease"`
	Maintainers                    []*Maintainer          `json:"maintainers"`
	Recommendations                []*Recommendation      `json:"recommendations"`
	Screenshots                    []*Screenshot          `json:"screenshots"`
	SignKey                        *SignKey               `json:"sign_key"`
	Repository                     *Repository            `json:"repository"`
	TS                             int64                  `json:"ts,omitempty"`
	Stats                          *PackageStats          `json:"stats"`
	ProductionOrganizations        []*Organization        `json:"production_organizations"`
	RelativePath                   string                 `json:"relative_path"`
}

Package represents a Kubernetes package.

type PackageManager

type PackageManager interface {
	AddProductionUsage(ctx context.Context, repoName, pkgName, orgName string) error
	DeleteProductionUsage(ctx context.Context, repoName, pkgName, orgName string) error
	Get(ctx context.Context, input *GetPackageInput) (*Package, error)
	GetChangelog(ctx context.Context, pkgID string) (*Changelog, error)
	GetHarborReplicationDumpJSON(ctx context.Context) ([]byte, error)
	GetHelmExporterDumpJSON(ctx context.Context) ([]byte, error)
	GetJSON(ctx context.Context, input *GetPackageInput) ([]byte, error)
	GetProductionUsageJSON(ctx context.Context, repoName, pkgName string) ([]byte, error)
	GetRandomJSON(ctx context.Context) ([]byte, error)
	GetSnapshotSecurityReportJSON(ctx context.Context, pkgID, version string) ([]byte, error)
	GetSnapshotsToScan(ctx context.Context) ([]*SnapshotToScan, error)
	GetStarredByUserJSON(ctx context.Context, p *Pagination) (*JSONQueryResult, error)
	GetStarsJSON(ctx context.Context, packageID string) ([]byte, error)
	GetStatsJSON(ctx context.Context) ([]byte, error)
	GetSummaryJSON(ctx context.Context, input *GetPackageInput) ([]byte, error)
	GetValuesSchemaJSON(ctx context.Context, pkgID, version string) ([]byte, error)
	GetViewsJSON(ctx context.Context, packageID string) ([]byte, error)
	Register(ctx context.Context, pkg *Package) error
	SearchJSON(ctx context.Context, input *SearchPackageInput) (*JSONQueryResult, error)
	SearchMonocularJSON(ctx context.Context, baseURL, tsQueryWeb string) ([]byte, error)
	ToggleStar(ctx context.Context, packageID string) error
	UpdateSnapshotSecurityReport(ctx context.Context, r *SnapshotSecurityReport) error
	Unregister(ctx context.Context, pkg *Package) error
}

PackageManager describes the methods a PackageManager implementation must provide.

type PackageMetadata added in v0.4.0

type PackageMetadata struct {
	Version                 string            `yaml:"version"`
	Name                    string            `yaml:"name"`
	DisplayName             string            `yaml:"displayName"`
	CreatedAt               string            `yaml:"createdAt"`
	Description             string            `yaml:"description"`
	LogoPath                string            `yaml:"logoPath"`
	LogoURL                 string            `yaml:"logoURL"`
	Digest                  string            `yaml:"digest"`
	License                 string            `yaml:"license"`
	HomeURL                 string            `yaml:"homeURL"`
	AppVersion              string            `yaml:"appVersion"`
	PublisherID             string            `yaml:"publisherID"`
	ContainersImages        []*ContainerImage `yaml:"containersImages"`
	Operator                bool              `yaml:"operator"`
	Deprecated              bool              `yaml:"deprecated"`
	Keywords                []string          `yaml:"keywords"`
	Links                   []*Link           `yaml:"links"`
	Readme                  string            `yaml:"readme"`
	Install                 string            `yaml:"install"`
	Changes                 []*Change         `yaml:"changes"`
	ContainsSecurityUpdates bool              `yaml:"containsSecurityUpdates"`
	Prerelease              bool              `yaml:"prerelease"`
	Maintainers             []*Maintainer     `yaml:"maintainers"`
	Provider                *Provider         `yaml:"provider"`
	Ignore                  []string          `yaml:"ignore"`
	Recommendations         []*Recommendation `yaml:"recommendations"`
	Screenshots             []*Screenshot     `yaml:"screenshots"`
	Annotations             map[string]string `yaml:"annotations"`
}

PackageMetadata represents some metadata about a given package. It's usually provided by repositories publishers, to provide the required information about the content they'd like to be indexed.

type PackageNotificationTemplateData added in v0.5.0

type PackageNotificationTemplateData struct {
	BaseURL string                 `json:"base_url"`
	Event   map[string]interface{} `json:"event"`
	Package map[string]interface{} `json:"package"`
	Theme   map[string]string      `json:"theme"`
}

PackageNotificationTemplateData represents some details of a notification about a given package that will be exposed to notification templates.

type PackageStats added in v0.20.0

type PackageStats struct {
	Subscriptions int `json:"subscriptions"`
	Webhooks      int `json:"webhooks"`
}

PackageStats represents some statistics about a package.

type Pagination added in v1.0.0

type Pagination struct {
	Limit  int `json:"limit"`
	Offset int `json:"offset"`
}

Pagination defines some information about the results page to fetch.

type Provider added in v0.4.0

type Provider struct {
	Name string `yaml:"name"`
}

Provider represents a package's provider.

type Recommendation added in v0.15.0

type Recommendation struct {
	URL string `json:"url" yaml:"url"`
}

Recommendation represents some information about a recommended package.

type Repository added in v0.3.0

type Repository struct {
	RepositoryID            string          `json:"repository_id"`
	Name                    string          `json:"name"`
	DisplayName             string          `json:"display_name"`
	URL                     string          `json:"url"`
	Branch                  string          `json:"branch"`
	Private                 bool            `json:"private"`
	AuthUser                string          `json:"auth_user"`
	AuthPass                string          `json:"auth_pass"`
	Digest                  string          `json:"digest"`
	Kind                    RepositoryKind  `json:"kind"`
	UserID                  string          `json:"user_id"`
	UserAlias               string          `json:"user_alias"`
	OrganizationID          string          `json:"organization_id"`
	OrganizationName        string          `json:"organization_name"`
	OrganizationDisplayName string          `json:"organization_display_name"`
	LastScanningErrors      string          `json:"last_scanning_errors"`
	LastTrackingErrors      string          `json:"last_tracking_errors"`
	VerifiedPublisher       bool            `json:"verified_publisher"`
	Official                bool            `json:"official"`
	Disabled                bool            `json:"disabled"`
	ScannerDisabled         bool            `json:"scanner_disabled"`
	Data                    json.RawMessage `json:"data,omitempty"`
}

Repository represents a packages repository.

type RepositoryCloner added in v0.3.0

type RepositoryCloner interface {
	// CloneRepository clones the packages repository provided in a temporary
	// dir, returning the temporary directory path and the path where the
	// packages are located. It's the caller's responsibility to delete the
	// temporary dir when done.
	CloneRepository(ctx context.Context, r *Repository) (tmpDir string, packagesPath string, err error)
}

RepositoryCloner describes the methods a RepositoryCloner implementation must provide.

type RepositoryIgnoreEntry added in v0.12.0

type RepositoryIgnoreEntry struct {
	Name    string `yaml:"name"`
	Version string `yaml:"version"`
}

RepositoryIgnoreEntry represents an entry in the ignore list. This list is meant to be used as a way to exclude packages from being indexed by Artifact Hub. The name corresponds to a package name, and it must be an exact match. The version field is a regular expression.

type RepositoryKind added in v0.3.0

type RepositoryKind int64

RepositoryKind represents the kind of a given repository.

const (
	// Helm represents a repository with Helm charts.
	Helm RepositoryKind = 0

	// Falco represents a repository with Falco rules.
	Falco RepositoryKind = 1

	// OPA represents a repository with OPA policies.
	OPA RepositoryKind = 2

	// OLM represents a repository with OLM operators.
	OLM RepositoryKind = 3

	// TBAction represents a repository with Tinkerbell actions.
	TBAction RepositoryKind = 4

	// Krew represents a repository with kubectl plugins that can be managed by
	// the Krew plugin manager.
	Krew RepositoryKind = 5

	// HelmPlugin represents a repository with Helm plugins.
	HelmPlugin RepositoryKind = 6

	// TektonTask represents a repository with Tekton tasks.
	TektonTask RepositoryKind = 7

	// KedaScaler represents a repository with KEDA scalers.
	KedaScaler RepositoryKind = 8

	// CoreDNS represents a repository with CoreDNS plugins.
	CoreDNS RepositoryKind = 9

	// Keptn represents a repository with Keptn integrations.
	Keptn RepositoryKind = 10

	// TektonPipeline represents a repository with Tekton pipelines.
	TektonPipeline RepositoryKind = 11

	// Container represents a repository with containers images.
	Container RepositoryKind = 12

	// Kubewarden represents a repository with Kubewarden policies.
	Kubewarden RepositoryKind = 13

	// Gatekeeper represents a repository with Gatekeeper policies.
	Gatekeeper RepositoryKind = 14
)

func GetKindFromName added in v0.5.0

func GetKindFromName(kind string) (RepositoryKind, error)

GetKindFromName returns the kind of the provided repository from the name provided.

type RepositoryManager added in v0.3.0

type RepositoryManager interface {
	Add(ctx context.Context, orgName string, r *Repository) error
	CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error)
	ClaimOwnership(ctx context.Context, name, orgName string) error
	Delete(ctx context.Context, name string) error
	GetByID(ctx context.Context, repositoryID string, includeCredentials bool) (*Repository, error)
	GetByName(ctx context.Context, name string, includeCredentials bool) (*Repository, error)
	GetMetadata(r *Repository, basePath string) (*RepositoryMetadata, error)
	GetPackagesDigest(ctx context.Context, repositoryID string) (map[string]string, error)
	GetRemoteDigest(ctx context.Context, r *Repository) (string, error)
	Search(ctx context.Context, input *SearchRepositoryInput) (*SearchRepositoryResult, error)
	SearchJSON(ctx context.Context, input *SearchRepositoryInput) (*JSONQueryResult, error)
	SetLastScanningResults(ctx context.Context, repositoryID, errs string) error
	SetLastTrackingResults(ctx context.Context, repositoryID, errs string) error
	SetVerifiedPublisher(ctx context.Context, repositoryID string, verified bool) error
	Transfer(ctx context.Context, name, orgName string, ownershipClaim bool) error
	Update(ctx context.Context, r *Repository) error
	UpdateDigest(ctx context.Context, repositoryID, digest string) error
}

RepositoryManager describes the methods an RepositoryManager implementation must provide.

type RepositoryMetadata added in v0.5.0

type RepositoryMetadata struct {
	RepositoryID string                   `yaml:"repositoryID"`
	Owners       []*Owner                 `yaml:"owners,omitempty"`
	Ignore       []*RepositoryIgnoreEntry `yaml:"ignore,omitempty"`
}

RepositoryMetadata represents some metadata about a given repository. It's usually provided by repositories publishers, to provide some extra context about the repository they'd like to publish.

type RepositoryNotificationTemplateData added in v0.5.0

type RepositoryNotificationTemplateData struct {
	BaseURL    string                 `json:"base_url"`
	Event      map[string]interface{} `json:"event"`
	Repository map[string]interface{} `json:"repository"`
	Theme      map[string]string      `json:"theme"`
}

RepositoryNotificationTemplateData represents some details of a notification about a given repository that will be exposed to notification templates.

type Screenshot added in v1.3.0

type Screenshot struct {
	Title string `json:"title" yaml:"title"`
	URL   string `json:"url" yaml:"url"`
}

Screenshot represents a screenshot associated with a package.

type SearchPackageInput

type SearchPackageInput struct {
	Limit             int              `json:"limit,omitempty"`
	Offset            int              `json:"offset,omitempty"`
	Facets            bool             `json:"facets"`
	TSQueryWeb        string           `json:"ts_query_web,omitempty"`
	TSQuery           string           `json:"ts_query,omitempty"`
	Users             []string         `json:"users,omitempty"`
	Orgs              []string         `json:"orgs,omitempty"`
	Repositories      []string         `json:"repositories,omitempty"`
	RepositoryKinds   []RepositoryKind `json:"repository_kinds,omitempty"`
	VerifiedPublisher bool             `json:"verified_publisher"`
	Official          bool             `json:"official"`
	Operators         bool             `json:"operators"`
	Deprecated        bool             `json:"deprecated"`
	Licenses          []string         `json:"licenses,omitempty"`
	Capabilities      []string         `json:"capabilities,omitempty"`
	Sort              string           `json:"sort,omitempty"`
}

SearchPackageInput represents the query input when searching for packages.

type SearchRepositoryInput added in v1.0.0

type SearchRepositoryInput struct {
	Name               string           `json:"name,omitempty"`
	Kinds              []RepositoryKind `json:"kinds,omitempty"`
	Orgs               []string         `json:"orgs,omitempty"`
	Users              []string         `json:"users,omitempty"`
	IncludeCredentials bool             `json:"include_credentials"`
	Limit              int              `json:"limit,omitempty"`
	Offset             int              `json:"offset,omitempty"`
}

SearchRepositoryInput represents the query input when searching for repositories.

type SearchRepositoryResult added in v1.0.0

type SearchRepositoryResult struct {
	Repositories []*Repository
	TotalCount   int
}

SearchRepositoryResult represents the result of a repositories search.

type SecurityReportSummary added in v0.7.0

type SecurityReportSummary struct {
	Critical int `json:"critical"`
	High     int `json:"high"`
	Medium   int `json:"medium"`
	Low      int `json:"low"`
	Unknown  int `json:"unknown"`
}

SecurityReportSummary represents a summary of the security report.

type Session

type Session struct {
	SessionID string `json:"session_id"`
	UserID    string `json:"user_id"`
	IP        string `json:"ip"`
	UserAgent string `json:"user_agent"`
	Approved  bool   `json:"approved"`
}

Session represents some information about a user session.

type SetupTFAOutput added in v0.20.0

type SetupTFAOutput struct {
	QRCode        string   `json:"qr_code"`
	RecoveryCodes []string `json:"recovery_codes"`
	Secret        string   `json:"secret"`
}

SetupTFAOutput represents the output returned by the SetupTFA method.

type SignKey added in v1.0.0

type SignKey struct {
	Fingerprint string `json:"fingerprint" yaml:"fingerprint"`
	URL         string `json:"url" yaml:"url"`
}

SignKey represents a key used to sign a package version.

type SnapshotSecurityReport added in v0.7.0

type SnapshotSecurityReport struct {
	PackageID     string                   `json:"package_id"`
	Version       string                   `json:"version"`
	AlertDigest   string                   `json:"alert_digest"`
	ImagesReports map[string]*trivy.Report `json:"images_reports"`
	Summary       *SecurityReportSummary   `json:"summary"`
}

SnapshotSecurityReport represents some information about the security vulnerabilities the images used by a given package's snapshot may have.

type SnapshotToScan added in v0.7.0

type SnapshotToScan struct {
	RepositoryID     string            `json:"repository_id"`
	PackageID        string            `json:"package_id"`
	PackageName      string            `json:"package_name"`
	Version          string            `json:"version"`
	ContainersImages []*ContainerImage `json:"containers_images"`
}

SnapshotToScan represents some information about a package's snapshot that needs to be scanned for security vulnerabilities.

type StatsManager added in v0.18.0

type StatsManager interface {
	GetJSON(ctx context.Context) ([]byte, error)
}

StatsManager describes the methods an StatsManager implementation must provide.

type Subscription

type Subscription struct {
	UserID    string    `json:"user_id"`
	PackageID string    `json:"package_id"`
	EventKind EventKind `json:"event_kind"`
}

Subscription represents a user's subscription to receive notifications about a given package and event kind.

type SubscriptionManager

type SubscriptionManager interface {
	Add(ctx context.Context, s *Subscription) error
	AddOptOut(ctx context.Context, o *OptOut) error
	Delete(ctx context.Context, s *Subscription) error
	DeleteOptOut(ctx context.Context, optOutID string) error
	GetByPackageJSON(ctx context.Context, packageID string) ([]byte, error)
	GetByUserJSON(ctx context.Context, p *Pagination) (*JSONQueryResult, error)
	GetOptOutListJSON(ctx context.Context, p *Pagination) (*JSONQueryResult, error)
	GetSubscriptors(ctx context.Context, e *Event) ([]*User, error)
}

SubscriptionManager describes the methods a SubscriptionManager implementation must provide.

type TFAConfig added in v0.20.0

type TFAConfig struct {
	Enabled       bool     `json:"enabled"`
	RecoveryCodes []string `json:"recovery_codes"`
	URL           string   `json:"url"`
}

TFAConfig represents the TFA configuration for a given user.

type TektonData added in v1.10.0

type TektonData struct {
	Versioning string `json:"versioning"` // Options: directory or git
}

TektonData represents some data specific to repositories of the Tekton tasks or pipelines kinds.

type TrackerServices added in v0.14.0

TrackerServices represents a set of services that must be provided to a Tracker instance so that it can perform its tasks.

type TrackerSource added in v0.14.0

type TrackerSource interface {
	// GetPackagesAvailable represents a function that returns a list of
	// available packages in a given repository. Each repository kind will
	// require using a specific TrackerSource implementation that will know
	// best how to get the available packages in the repository. The key used
	// in the returned map is expected to be built using the BuildKey helper
	// function in the pkg package.
	GetPackagesAvailable() (map[string]*Package, error)
}

TrackerSource defines the methods a TrackerSource implementation must provide.

type TrackerSourceInput added in v0.14.0

type TrackerSourceInput struct {
	Repository         *Repository
	RepositoryDigest   string
	PackagesRegistered map[string]string
	BasePath           string
	Svc                *TrackerSourceServices
}

TrackerSourceInput represents the input provided to a TrackerSource to get the packages available in a repository when tracking it.

type TrackerSourceLoader added in v0.14.0

type TrackerSourceLoader func(i *TrackerSourceInput) TrackerSource

TrackerSourceLoader represents a function that sets up the appropriate tracker source for a given repository.

type TrackerSourceServices added in v0.14.0

type TrackerSourceServices struct {
	Ctx    context.Context
	Cfg    *viper.Viper
	Ec     ErrorsCollector
	Hc     HTTPClient
	Op     OCIPuller
	Is     img.Store
	Sc     OCISignatureChecker
	Logger zerolog.Logger
}

TrackerSourceServices represents a set of services that will be provided to a TrackerSource instance so that it can perform its tasks.

type User

type User struct {
	UserID         string `json:"user_id"`
	Alias          string `json:"alias"`
	FirstName      string `json:"first_name"`
	LastName       string `json:"last_name"`
	Email          string `json:"email"`
	EmailVerified  bool   `json:"email_verified"`
	Password       string `json:"password"`
	ProfileImageID string `json:"profile_image_id"`
	PasswordSet    bool   `json:"password_set"`
	TFAEnabled     bool   `json:"tfa_enabled"`
}

User represents a Hub user.

type UserManager

type UserManager interface {
	ApproveSession(ctx context.Context, sessionID, passcode string) error
	CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error)
	CheckCredentials(ctx context.Context, email, password string) (*CheckCredentialsOutput, error)
	CheckSession(ctx context.Context, sessionID string, duration time.Duration) (*CheckSessionOutput, error)
	DeleteSession(ctx context.Context, sessionID string) error
	DeleteUser(ctx context.Context, code string) error
	DisableTFA(ctx context.Context, passcode string) error
	EnableTFA(ctx context.Context, passcode string) error
	GetProfile(ctx context.Context) (*User, error)
	GetProfileJSON(ctx context.Context) ([]byte, error)
	GetUserID(ctx context.Context, email string) (string, error)
	RegisterDeleteUserCode(ctx context.Context) error
	RegisterPasswordResetCode(ctx context.Context, userEmail string) error
	RegisterSession(ctx context.Context, session *Session) (*Session, error)
	RegisterUser(ctx context.Context, user *User) error
	ResetPassword(ctx context.Context, code, newPassword string) error
	SetupTFA(ctx context.Context) ([]byte, error)
	UpdatePassword(ctx context.Context, old, new string) error
	UpdateProfile(ctx context.Context, user *User) error
	VerifyEmail(ctx context.Context, code string) (bool, error)
	VerifyPasswordResetCode(ctx context.Context, code string) error
}

UserManager describes the methods a UserManager implementation must provide.

type Version added in v0.3.0

type Version struct {
	Version string `json:"version"`
	TS      int64  `json:"ts"`
}

Version represents a package's version.

type VersionChanges added in v1.4.0

type VersionChanges struct {
	Version                 string    `json:"version"`
	Changes                 []*Change `json:"changes"`
	TS                      int64     `json:"ts"`
	ContainsSecurityUpdates bool      `json:"contains_security_updates"`
	Prerelease              bool      `json:"prerelease"`
}

VersionChanges represents the changes introduced by a given package's version along with some extra metadata.

type ViewsTracker added in v1.5.0

type ViewsTracker interface {
	TrackView(packageID, version string) error
}

ViewsTracker describes the methods a ViewsTracker implementation must provide.

type Webhook

type Webhook struct {
	WebhookID   string      `json:"webhook_id"`
	Name        string      `json:"name"`
	Description string      `json:"description"`
	URL         string      `json:"url"`
	Secret      string      `json:"secret"`
	ContentType string      `json:"content_type"`
	Template    string      `json:"template"`
	Active      bool        `json:"active"`
	EventKinds  []EventKind `json:"event_kinds"`
	Packages    []*Package  `json:"packages"`
}

Webhook represents the configuration of a webhook where notifications will be posted to.

type WebhookManager

type WebhookManager interface {
	Add(ctx context.Context, orgName string, wh *Webhook) error
	Delete(ctx context.Context, webhookID string) error
	GetJSON(ctx context.Context, webhookID string) ([]byte, error)
	GetOwnedByOrgJSON(ctx context.Context, orgName string, p *Pagination) (*JSONQueryResult, error)
	GetOwnedByUserJSON(ctx context.Context, p *Pagination) (*JSONQueryResult, error)
	GetSubscribedTo(ctx context.Context, e *Event) ([]*Webhook, error)
	Update(ctx context.Context, wh *Webhook) error
}

WebhookManager describes the methods a WebhookManager implementation must provide.

Jump to

Keyboard shortcuts

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