download

package
v2.0.0-...-98cc131 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

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/v2/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 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 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 PrioHandler

type PrioHandler struct {
	Handler
	Prio int
}

type Registry

type Registry interface {
	registrations.HandlerRegistrationRegistry[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

type Target = cpi.Context

Directories

Path Synopsis
blueprint
// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Open Component Model contributors.
// SPDX-FileCopyrightText: 2023 SAP SE or an SAP affiliate company and Open Component Model contributors.

Jump to

Keyboard shortcuts

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