Documentation ¶
Index ¶
- Constants
- Variables
- func GetKindName(kind RepositoryKind) string
- type APIKey
- type APIKeyManager
- type Action
- type AuthorizationPolicy
- type AuthorizeInput
- type Authorizer
- type Channel
- type CheckAPIKeyOutput
- type CheckCredentialsOutput
- type CheckSessionOutput
- type ContainerImage
- type DB
- type EmailSender
- type Event
- type EventKind
- type EventManager
- type GetPackageInput
- type HelmIndexLoader
- type Link
- type Maintainer
- type Notification
- type NotificationManager
- type OptOut
- type Organization
- type OrganizationManager
- type Owner
- type Package
- type PackageManager
- type PackageMetadata
- type PackageNotificationTemplateData
- type Provider
- type Repository
- type RepositoryCloner
- type RepositoryKind
- type RepositoryManager
- type RepositoryMetadata
- type RepositoryNotificationTemplateData
- type SearchPackageInput
- type SecurityReportSummary
- type Session
- type SnapshotSecurityReport
- type SnapshotToScan
- type Subscription
- type SubscriptionManager
- type User
- type UserManager
- type Version
- type Webhook
- type WebhookManager
Constants ¶
const ( // PackageMetadataFile represents the name of the file where the Artifact // Hub metadata for a given package is stored. PackageMetadataFile = "artifacthub-pkg.yml" )
const ( // RepositoryMetadataFile represents the name of the file where the // Artifact Hub metadata for a given repository is stored. RepositoryMetadataFile = "artifacthub-repo.yml" )
Variables ¶
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") )
var IndexMetaDescriptionKey = indexMetaDescriptionKey{}
IndexMetaDescriptionKey represents the key used for the description in the index metadata.
var IndexMetaTitleKey = indexMetaTitleKey{}
IndexMetaTitleKey represents the key used for the title in the index metadata.
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"` 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) ([]byte, error) Delete(ctx context.Context, apiKeyID string) error GetJSON(ctx context.Context, apiKeyID string) ([]byte, error) GetOwnedByUserJSON(ctx context.Context) ([]byte, 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" // 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 CheckAPIKeyOutput ¶ added in v0.2.0
CheckAPIKeyOutput represents the output returned by the CheckApiKey method.
type CheckCredentialsOutput ¶
CheckCredentialsOutput represents the output returned by the CheckCredentials method.
type CheckSessionOutput ¶
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"` }
ContainerImage represents a container image associated with a package.
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 ¶
EmailSender defines the methods the email sender must 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 )
type EventManager ¶
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 HelmIndexLoader ¶ added in v0.3.0
type HelmIndexLoader interface {
LoadIndex(r *Repository) (*helmrepo.IndexFile, error)
}
HelmIndexLoader interface defines the methods a Helm index loader implementation should provide.
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 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, baseURL string) error CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error) ConfirmMembership(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) ([]byte, error) GetAuthorizationPolicyJSON(ctx context.Context, orgName string) ([]byte, error) GetMembersJSON(ctx context.Context, orgName string) ([]byte, error) Update(ctx context.Context, org *Organization) error UpdateAuthorizationPolicy(ctx context.Context, orgName string, policy *AuthorizationPolicy) error }
OrganizationManager describes the methods an OrganizationManager implementation must provide.
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"` 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"` 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"` ContentURL string `json:"content_url"` ContainersImages []*ContainerImage `json:"containers_images"` Provider string `json:"provider"` Maintainers []*Maintainer `json:"maintainers"` Repository *Repository `json:"repository"` CreatedAt int64 `json:"created_at,omitempty"` }
Package represents a Kubernetes package.
type PackageManager ¶
type PackageManager interface { Get(ctx context.Context, input *GetPackageInput) (*Package, error) GetJSON(ctx context.Context, input *GetPackageInput) ([]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) ([]byte, error) GetStarsJSON(ctx context.Context, packageID string) ([]byte, error) GetStatsJSON(ctx context.Context) ([]byte, error) Register(ctx context.Context, pkg *Package) error SearchJSON(ctx context.Context, input *SearchPackageInput) ([]byte, 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"` 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"` Maintainers []*Maintainer `yaml:"maintainers"` Provider *Provider `yaml:"provider"` Ignore []string `yaml:"ignore"` }
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"` }
PackageNotificationTemplateData represents some details of a notification about a given package that will be exposed to notification templates.
type Provider ¶ added in v0.4.0
type Provider struct {
Name string `yaml:"name"`
}
Provider represents a package's provider.
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"` 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"` LastTrackingErrors string `json:"last_tracking_errors"` VerifiedPublisher bool `json:"verified_publisher"` Official bool `json:"official"` }
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 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 )
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 GetAll(ctx context.Context) ([]*Repository, error) GetAllJSON(ctx context.Context) ([]byte, error) GetByID(ctx context.Context, repositorID string) (*Repository, error) GetByKind(ctx context.Context, kind RepositoryKind) ([]*Repository, error) GetByKindJSON(ctx context.Context, kind RepositoryKind) ([]byte, error) GetByName(ctx context.Context, name string) (*Repository, error) GetMetadata(mdFile string) (*RepositoryMetadata, error) GetPackagesDigest(ctx context.Context, repositoryID string) (map[string]string, error) GetOwnedByOrgJSON(ctx context.Context, orgName string) ([]byte, error) GetOwnedByUserJSON(ctx context.Context) ([]byte, error) SetLastTrackingResults(ctx context.Context, repositoryID, errs string) error SetVerifiedPublisher(ctx context.Context, repositorID string, verified bool) error Transfer(ctx context.Context, name, orgName string, ownershipClaim bool) error Update(ctx context.Context, r *Repository) 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"` }
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"` }
RepositoryNotificationTemplateData represents some details of a notification about a given repository that will be exposed to notification templates.
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"` }
SearchPackageInput represents the query input when searching for packages.
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"` }
Session represents some information about a user session.
type SnapshotSecurityReport ¶ added in v0.7.0
type SnapshotSecurityReport struct { PackageID string `json:"package_id"` Version string `json:"version"` Summary *SecurityReportSummary `json:"summary"` Full map[string][]interface{} `json:"full"` }
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 { PackageID string `json:"package_id"` 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 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) ([]byte, error) GetOptOutListJSON(ctx context.Context) ([]byte, error) GetSubscriptors(ctx context.Context, e *Event) ([]*User, error) }
SubscriptionManager describes the methods a SubscriptionManager implementation must provide.
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"` }
User represents a Hub user.
type UserManager ¶
type UserManager interface { CheckAPIKey(ctx context.Context, key []byte) (*CheckAPIKeyOutput, error) CheckAvailability(ctx context.Context, resourceKind, value string) (bool, error) CheckCredentials(ctx context.Context, email, password string) (*CheckCredentialsOutput, error) CheckSession(ctx context.Context, sessionID []byte, duration time.Duration) (*CheckSessionOutput, error) DeleteSession(ctx context.Context, sessionID []byte) error GetProfile(ctx context.Context) (*User, error) GetProfileJSON(ctx context.Context) ([]byte, error) GetUserID(ctx context.Context, email string) (string, error) RegisterSession(ctx context.Context, session *Session) ([]byte, error) RegisterUser(ctx context.Context, user *User, baseURL string) error UpdatePassword(ctx context.Context, old, new string) error UpdateProfile(ctx context.Context, user *User) error VerifyEmail(ctx context.Context, code string) (bool, error) }
UserManager describes the methods a UserManager 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) ([]byte, error) GetOwnedByUserJSON(ctx context.Context) ([]byte, 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.