download

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Overview

Package download provides an API for resource download handlers. A download handler is used for downloading resoures. By default the native blob as provided by the access method is the resukt of a download. A download handler can influence the outbound blob format according to the concrete type of the resource. For example, a helm download for a helm artifact stored as oci artifact will not provide the oci format chosen for representing the artifact in OCI but a regular helm archive according to its specification. The sub package handlers provides dedicated packages for standard handlers.

A downloader registry is stores as attribute ATTR_DOWNLOADER_HANDLERS for the OCM context, it is not a static part of the OCM context. The downloaders are basically used by clients requiring access to the effective resource content.

Index

Constants

View Source
const ALL = "*"
View Source
const ATTR_DOWNLOADER_HANDLERS = "github.com/open-component-model/ocm/pkg/contexts/ocm/download"
View Source
const DEFAULT_BLOBHANDLER_PRIO = 100

Variables

View Source
var DefaultRegistry = NewRegistry()
View Source
var REALM = ocmlog.DefineSubRealm("Downloaders", "downloader")

Functions

func AsHandlerRegistrationRegistry added in v0.4.1

func AsHandlerRegistrationRegistry(r Registry) registrations.HandlerRegistrationRegistry[Target, HandlerOption]

func DownloadResource added in v0.5.0

func DownloadResource(ctx cpi.ContextProvider, r cpi.ResourceAccess, path string, opts ...Option) (string, error)

func Logger added in v0.3.0

func Logger(ctx logging.ContextProvider, messageContext ...logging.MessageContext) logging.Logger

func Register

func Register(hdlr Handler, olist ...HandlerOption)

func RegisterHandlerByName added in v0.3.0

func RegisterHandlerByName(ctx cpi.ContextProvider, name string, config HandlerConfig, opts ...HandlerOption) error

func RegisterHandlerRegistrationHandler added in v0.3.0

func RegisterHandlerRegistrationHandler(path string, handler HandlerRegistrationHandler)

func SetFor

func SetFor(ctx datacontext.Context, registry Registry)

Types

type Handler

type Handler interface {
	Download(p common.Printer, racc cpi.ResourceAccess, path string, fs vfs.FileSystem) (bool, string, error)
}

type HandlerConfig added in v0.3.0

type HandlerConfig = registrations.HandlerConfig

type HandlerKey added in v0.3.0

type HandlerKey struct {
	ArtifactType string `json:"artifactType,omitempty"`
	MimeType     string `json:"mimeType,omitempty"`
}

HandlerKey is the registration key for download handlers.

func NewHandlerKey added in v0.3.0

func NewHandlerKey(artifactType, mimetype string) HandlerKey

func (HandlerKey) ApplyHandlerOptionTo added in v0.3.0

func (k HandlerKey) ApplyHandlerOptionTo(opts *HandlerOptions)

type HandlerOption added in v0.3.0

type HandlerOption interface {
	ApplyHandlerOptionTo(*HandlerOptions)
}

func ForArtifactType added in v0.3.0

func ForArtifactType(artifacttype string) HandlerOption

func ForCombi added in v0.3.0

func ForCombi(artifacttype string, mimetype string) HandlerOption

func ForMimeType added in v0.3.0

func ForMimeType(mimetype string) HandlerOption

func WithPrio added in v0.3.0

func WithPrio(p int) HandlerOption

type HandlerOptions added in v0.3.0

type HandlerOptions struct {
	HandlerKey `json:",inline"`
	Priority   int `json:"priority,omitempty"`
}

func NewHandlerOptions added in v0.3.0

func NewHandlerOptions(olist ...HandlerOption) *HandlerOptions

func (*HandlerOptions) ApplyHandlerOptionTo added in v0.3.0

func (o *HandlerOptions) ApplyHandlerOptionTo(opts *HandlerOptions)

type HandlerRegistrationHandler added in v0.3.0

type HandlerRegistrationHandler = registrations.HandlerRegistrationHandler[Target, HandlerOption]

type HandlerRegistrationRegistry added in v0.3.0

type HandlerRegistrationRegistry = registrations.HandlerRegistrationRegistry[Target, HandlerOption]

func NewHandlerRegistrationRegistry added in v0.3.0

func NewHandlerRegistrationRegistry(base ...HandlerRegistrationRegistry) HandlerRegistrationRegistry

type MultiHandler added in v0.3.0

type MultiHandler []Handler

MultiHandler is a Handler consisting of a sequence of handlers.

func (MultiHandler) Download added in v0.3.0

func (m MultiHandler) Download(p common.Printer, racc cpi.ResourceAccess, path string, fs vfs.FileSystem) (bool, string, error)

func (MultiHandler) Len added in v0.3.0

func (m MultiHandler) Len() int

func (MultiHandler) Less added in v0.3.0

func (m MultiHandler) Less(i, j int) bool

func (MultiHandler) Swap added in v0.3.0

func (m MultiHandler) Swap(i, j int)

type Option added in v0.5.0

type Option = optionutils.Option[*Options]

func WithFileSystem added in v0.5.0

func WithFileSystem(fs vfs.FileSystem) Option

func WithPrinter added in v0.5.0

func WithPrinter(pr common.Printer) Option

type Options added in v0.5.0

type Options struct {
	Printer    common.Printer
	FileSystem vfs.FileSystem
}

func (*Options) ApplyTo added in v0.5.0

func (o *Options) ApplyTo(opts *Options)

type PrioHandler added in v0.3.0

type PrioHandler struct {
	Handler
	Prio int
}

type RegistrationHandlerInfo added in v0.3.0

type RegistrationHandlerInfo = registrations.RegistrationHandlerInfo[Target, HandlerOption]

func NewRegistrationHandlerInfo added in v0.3.0

func NewRegistrationHandlerInfo(path string, handler HandlerRegistrationHandler) *RegistrationHandlerInfo

type Registry

type Registry interface {
	Copy() Registry
	AsHandlerRegistrationRegistry() registrations.HandlerRegistrationRegistry[Target, HandlerOption]

	registrations.HandlerRegistrationRegistryAccess[Target, HandlerOption]

	Register(hdlr Handler, olist ...HandlerOption)
	LookupHandler(art, media string) MultiHandler
	Handler
	DownloadAsBlob(p common.Printer, racc cpi.ResourceAccess, path string, fs vfs.FileSystem) (bool, string, error)
}

func For

func For(ctx cpi.ContextProvider) Registry

func NewRegistry

func NewRegistry(base ...Registry) Registry

type Target added in v0.3.0

type Target = cpi.Context

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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