resourcehandlers

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

type Registry interface {
	Load(rhs ...ResourceHandler)
	Get(uri string) ResourceHandler
	Remove(rh ...ResourceHandler)
}

Registry can register and return resource handlers for a url

func NewRegistry

func NewRegistry(resourceHandlers ...ResourceHandler) Registry

NewRegistry creates Registry object, optionally loading it with resourceHandlers if provided

type ResourceHandler

type ResourceHandler interface {
	// Accepts manifests if this ResourceHandler can manage the type of resources
	// identified by the URI scheme of uri.
	Accept(uri string) bool
	// ResolveNodeSelector resolves the NodeSelector rules of a Node into subnodes
	// hierarchy (Node.Nodes)
	ResolveNodeSelector(ctx context.Context, node *api.Node) error
	// Read a resource content at uri into a byte array
	Read(ctx context.Context, uri string) ([]byte, error)
	// Name resolves the name of the resource from a URI
	// Example: https://github.com/owner/repo/tree/master/a/b/c.md -> c.md
	Name(uri string) string
	// BuildAbsLink should return an absolute path of a relative link in regards of the provided
	// source
	BuildAbsLink(source, link string) (string, error)
	// GetRawFormatLink returns a link to an embedable object (image) in raw format.
	// If the provided link is not referencing an embedable object, the function
	// returns absLink without changes.
	GetRawFormatLink(absLink string) (string, error)
	// GetLocalityDomainCandidate ...
	GetLocalityDomainCandidate(source string) (key, path, version string, err error)
	// SetVersion sets version to absLink according to the API scheme. For GitHub
	// for example this would replace e.g. the 'master' segment in the path with version
	SetVersion(absLink, version string) (string, error)
}

ResourceHandler does resource specific operations on a type of objects identified by an uri schema that it accepts to handle

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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