manifest

package
v0.0.0-...-b1d9b20 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultMetadataFile = "bundle.json"

Variables

View Source
var DefaultMatcher = filepath.Match

Functions

This section is empty.

Types

type Bundle

type Bundle struct {
	// Prefix contains the prefix for a subtree of the FS.
	Prefix string
	// Matcher is an implementation of PatternMatcher interface used by Bundle.Glob().
	Matcher PatternMatcher
	// Metadata includes optional metadata for content bundled in Bundle.FS.
	Metadata

	FS
}

func New

func New(fs FS, opts ...BundleFn) (*Bundle, error)

New returns a new Bundle object which encapsulates the provided FS and filepath.Match as the default pattern matcher. List of BundleFn are applied if provided.

func (*Bundle) Glob

func (b *Bundle) Glob(pattern string) ([]string, error)

func (*Bundle) Open

func (b *Bundle) Open(name string) (fs.File, error)

Open opens the named file. Implements fs.FS interface.

func (*Bundle) ReadDir

func (b *Bundle) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir reads the named directory and returns a list of directory entries sorted by filename. Implements fs.ReadDirFS interface.

func (*Bundle) ReadFile

func (b *Bundle) ReadFile(name string) ([]byte, error)

ReadFile reads the named file and returns its contents. Implements fs.ReadFileFS interface.

func (*Bundle) Stat

func (b *Bundle) Stat(path string) (fs.FileInfo, error)

func (*Bundle) Sub

func (b *Bundle) Sub(dir string) (*Bundle, error)

func (*Bundle) WalkDir

func (b *Bundle) WalkDir(root string, fn fs.WalkDirFunc) error

type BundleFn

type BundleFn func(*Bundle) error

BundleFn defines transformer function for Bundle.

func WithDefaultMetadataFile

func WithDefaultMetadataFile() BundleFn

WithDefaultMetadataFile lookup for bundle.json in root of Bundle.FS to populate Bundle.Metadata.

func WithMatcher

func WithMatcher(m PatternMatcher) BundleFn

WithMatcher sets the PatternMatcher to be used by Bundle.Glob().

func WithMetadata

func WithMetadata(meta Metadata) BundleFn

WithMetadata uses meta to populate Bundle.Metadata.

func WithMetadataFile

func WithMetadataFile(path string) BundleFn

WithDefaultMetadataFile lookup for bundle.json at path in Bundle.FS to populate Bundle.Metadata.

func WithMetadataResolver

func WithMetadataResolver(resolver MetadataResolver) BundleFn

WithMetadataResolver invokes the MetadataResolver to populate the Bundle.Metadata.

func WithPrefix

func WithPrefix(prefix string) BundleFn

WithPrefix set the filesystem prefix for fs.FS which alters the path used for lookup operations. It comes handy in cases where only a subtree of the FS is expected to be access without exposing the whole filesystem structure.

type Bundler

type Bundler interface {
	fs.StatFS
	fs.SubFS
	fs.GlobFS

	FS
}

type FS

type FS interface {
	fs.ReadDirFS
	fs.ReadFileFS
}

type Maintainer

type Maintainer struct {
	Name  string `json:"name"`
	Email string `json:"email"`
	URL   string `json:"url"`
}

Maintainer contains the contact information for a maintainer defined in Metadata.

type Metadata

type Metadata struct {
	Name        string       `json:"name"`
	Version     string       `json:"version"`
	Description string       `json:"description"`
	License     string       `json:"license,omitempty"`
	Maintainers []Maintainer `json:"maintainers,omitempty"`

	Parameters map[string]interface{} `json:"parameters,omitempty"`
}

Metadata contains information about the package bundled in Bundle.FS. It partially implements the format defined by the Cloud Native Application Bundle specification, however it is not limited to it.

func NewMetadataFromRawBytes

func NewMetadataFromRawBytes(b []byte) (*Metadata, error)

func NewMetadataFromStream

func NewMetadataFromStream(r io.Reader) (*Metadata, error)

type MetadataResolver

type MetadataResolver func(*Bundle) (*Metadata, error)

MetadataResolver returns a Metadata object by reading the content of the Bundle. It is meant to be used to retrieve metadata for Bundle in formats other than bundle.json supported by default.

type PatternMatcher

type PatternMatcher func(pattern, path string) (bool, error)

PatternMatcher custom file path pattern matcher for use-cases where the default filepath.Match is not sufficient.

Jump to

Keyboard shortcuts

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