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
- Variables
- func AsHandlerRegistrationRegistry(r Registry) registrations.HandlerRegistrationRegistry[Target, HandlerOption]
- func DownloadResource(ctx cpi.ContextProvider, r cpi.ResourceAccess, path string, opts ...Option) (string, error)
- func Logger(ctx logging.ContextProvider, messageContext ...logging.MessageContext) logging.Logger
- func Register(hdlr Handler, olist ...HandlerOption)
- func RegisterHandlerByName(ctx cpi.ContextProvider, name string, config HandlerConfig, ...) error
- func RegisterHandlerRegistrationHandler(path string, handler HandlerRegistrationHandler)
- func SetFor(ctx datacontext.Context, registry Registry)
- type Handler
- type HandlerConfig
- type HandlerKey
- type HandlerOption
- type HandlerOptions
- type HandlerRegistrationHandler
- type HandlerRegistrationRegistry
- type MultiHandler
- type Option
- type Options
- type PrioHandler
- type RegistrationHandlerInfo
- type Registry
- type Target
Constants ¶
const ALL = "*"
const ATTR_DOWNLOADER_HANDLERS = "ocm.software/ocm-core/api/ocm/extensions/download"
const DEFAULT_BLOBHANDLER_PRIO = 100
Variables ¶
var DefaultRegistry = NewRegistry()
var REALM = ocmlog.DefineSubRealm("Downloaders", "downloader")
Functions ¶
func AsHandlerRegistrationRegistry ¶
func AsHandlerRegistrationRegistry(r Registry) registrations.HandlerRegistrationRegistry[Target, HandlerOption]
func DownloadResource ¶
func DownloadResource(ctx cpi.ContextProvider, r cpi.ResourceAccess, path string, opts ...Option) (string, error)
func Logger ¶
func Logger(ctx logging.ContextProvider, messageContext ...logging.MessageContext) logging.Logger
func Register ¶
func Register(hdlr Handler, olist ...HandlerOption)
func RegisterHandlerByName ¶
func RegisterHandlerByName(ctx cpi.ContextProvider, name string, config HandlerConfig, opts ...HandlerOption) error
func RegisterHandlerRegistrationHandler ¶
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 ¶
type HandlerConfig = registrations.HandlerConfig
type HandlerKey ¶
type HandlerKey struct { ArtifactType string `json:"artifactType,omitempty"` MimeType string `json:"mimeType,omitempty"` }
HandlerKey is the registration key for download handlers.
func NewHandlerKey ¶
func NewHandlerKey(artifactType, mimetype string) HandlerKey
func (HandlerKey) ApplyHandlerOptionTo ¶
func (k HandlerKey) ApplyHandlerOptionTo(opts *HandlerOptions)
type HandlerOption ¶
type HandlerOption interface {
ApplyHandlerOptionTo(*HandlerOptions)
}
func ForArtifactType ¶
func ForArtifactType(artifacttype string) HandlerOption
func ForCombi ¶
func ForCombi(artifacttype string, mimetype string) HandlerOption
func ForMimeType ¶
func ForMimeType(mimetype string) HandlerOption
func WithPrio ¶
func WithPrio(p int) HandlerOption
type HandlerOptions ¶
type HandlerOptions struct { HandlerKey `json:",inline"` Priority int `json:"priority,omitempty"` }
func NewHandlerOptions ¶
func NewHandlerOptions(olist ...HandlerOption) *HandlerOptions
func (*HandlerOptions) ApplyHandlerOptionTo ¶
func (o *HandlerOptions) ApplyHandlerOptionTo(opts *HandlerOptions)
type HandlerRegistrationHandler ¶
type HandlerRegistrationHandler = registrations.HandlerRegistrationHandler[Target, HandlerOption]
type HandlerRegistrationRegistry ¶
type HandlerRegistrationRegistry = registrations.HandlerRegistrationRegistry[Target, HandlerOption]
func NewHandlerRegistrationRegistry ¶
func NewHandlerRegistrationRegistry(base ...HandlerRegistrationRegistry) HandlerRegistrationRegistry
type MultiHandler ¶
type MultiHandler []Handler
MultiHandler is a Handler consisting of a sequence of handlers.
func (MultiHandler) Download ¶
func (m MultiHandler) Download(p common.Printer, racc cpi.ResourceAccess, path string, fs vfs.FileSystem) (bool, string, error)
func (MultiHandler) Len ¶
func (m MultiHandler) Len() int
func (MultiHandler) Less ¶
func (m MultiHandler) Less(i, j int) bool
func (MultiHandler) Swap ¶
func (m MultiHandler) Swap(i, j int)
type Option ¶
type Option = optionutils.Option[*Options]
func WithFileSystem ¶
func WithFileSystem(fs vfs.FileSystem) Option
func WithPrinter ¶
type PrioHandler ¶
type RegistrationHandlerInfo ¶
type RegistrationHandlerInfo = registrations.RegistrationHandlerInfo[Target, HandlerOption]
func NewRegistrationHandlerInfo ¶
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