adapter

package
v0.0.0-...-cda7d01 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 6 Imported by: 370

Documentation

Index

Constants

View Source
const (
	UserAgentReplication = "harbor-replication-service"
	MaxConcurrency       = 100
)

const definition

Variables

This section is empty.

Functions

func HasFactory

func HasFactory(t model.RegistryType) bool

HasFactory checks whether there is given type adapter factory

func ListAdapterInfos

func ListAdapterInfos() map[model.RegistryType]*model.AdapterPattern

ListAdapterInfos list the adapter infos

func ListRegisteredAdapterTypes

func ListRegisteredAdapterTypes() []model.RegistryType

ListRegisteredAdapterTypes lists the registered Adapter type

func RegisterFactory

func RegisterFactory(t model.RegistryType, factory Factory) error

RegisterFactory registers one adapter factory to the registry

Types

type Adapter

type Adapter interface {
	// Info return the information of this adapter
	Info() (*model.RegistryInfo, error)
	// PrepareForPush does the prepare work that needed for pushing/uploading the resources
	// eg: create the namespace or repository
	PrepareForPush([]*model.Resource) error
	// HealthCheck checks health status of registry
	HealthCheck() (model.HealthStatus, error)
}

Adapter interface defines the capabilities of registry

type ChartRegistry

type ChartRegistry interface {
	FetchCharts(filters []*model.Filter) ([]*model.Resource, error)
	ChartExist(name, version string) (bool, error)
	DownloadChart(name, version string) (io.ReadCloser, error)
	UploadChart(name, version string, chart io.Reader) error
	DeleteChart(name, version string) error
}

ChartRegistry defines the capabilities that a chart registry should have

type Factory

type Factory interface {
	Create(*model.Registry) (Adapter, error)
	AdapterPattern() *model.AdapterPattern
}

Factory creates a specific Adapter according to the params

func GetFactory

func GetFactory(t model.RegistryType) (Factory, error)

GetFactory gets the adapter factory by the specified name

type ImageRegistry

type ImageRegistry interface {
	FetchImages(filters []*model.Filter) ([]*model.Resource, error)
	ManifestExist(repository, reference string) (exist bool, digest string, err error)
	PullManifest(repository, reference string, accepttedMediaTypes []string) (manifest distribution.Manifest, digest string, err error)
	PushManifest(repository, reference, mediaType string, payload []byte) error
	// the "reference" can be "tag" or "digest", the function needs to handle both
	DeleteManifest(repository, reference string) error
	BlobExist(repository, digest string) (exist bool, err error)
	PullBlob(repository, digest string) (size int64, blob io.ReadCloser, err error)
	PushBlob(repository, digest string, size int64, blob io.Reader) error
}

ImageRegistry defines the capabilities that an image registry should have

type Repository

type Repository struct {
	ResourceType string `json:"resource_type"`
	Name         string `json:"name"`
}

Repository defines an repository object, it can be image repository, chart repository and etc.

func (*Repository) GetFilterableType

func (r *Repository) GetFilterableType() filter.FilterableType

GetFilterableType returns the filterable type

func (*Repository) GetLabels

func (r *Repository) GetLabels() []string

GetLabels returns the labels

func (*Repository) GetName

func (r *Repository) GetName() string

GetName returns the name

func (*Repository) GetResourceType

func (r *Repository) GetResourceType() string

GetResourceType returns the resource type

type VTag

type VTag struct {
	ResourceType string   `json:"resource_type"`
	Name         string   `json:"name"`
	Labels       []string `json:"labels"`
}

VTag defines an vTag object, it can be image tag, chart version and etc.

func (*VTag) GetFilterableType

func (v *VTag) GetFilterableType() filter.FilterableType

GetFilterableType returns the filterable type

func (*VTag) GetLabels

func (v *VTag) GetLabels() []string

GetLabels returns the labels

func (*VTag) GetName

func (v *VTag) GetName() string

GetName returns the name

func (*VTag) GetResourceType

func (v *VTag) GetResourceType() string

GetResourceType returns the resource type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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