assets

package
v0.0.0-...-5152f1c Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFilesRecursively

func LoadFilesRecursively(dir string, predicates ...FileInfoPredicate) (map[string][]byte, error)

LoadFilesRecursively returns a map from relative path names to file content.

func OnlyYaml

func OnlyYaml(_ string, info os.FileInfo) (bool, error)

OnlyYaml is a predicate for LoadFilesRecursively filters out non-yaml files.

Types

type Asset

type Asset struct {
	Name           string
	FilePermission Permission
	Data           []byte
}

Asset defines a single static asset.

func MustCreateAssetFromTemplate

func MustCreateAssetFromTemplate(name string, template []byte, config interface{}) Asset

MustCreateAssetFromTemplate process the given template using and return an asset.

func (Asset) WriteFile

func (a Asset) WriteFile(path string) error

WriteFile writes a single asset into specified path.

type Assets

type Assets []Asset

Assets is a list of assets.

func New

func New(dir string, data interface{}, manifestPredicates []FileContentsPredicate, predicates ...FileInfoPredicate) (Assets, error)

New walks through a directory recursively and renders each file as asset. Only those files are rendered that make all predicates true.

func (Assets) WriteFiles

func (as Assets) WriteFiles(path string) error

WriteFiles writes the assets to specified path.

type FileContentsPredicate

type FileContentsPredicate func(manifest []byte) (bool, error)

func InstallerFeatureSet

func InstallerFeatureSet(featureSet string) FileContentsPredicate

InstallerFeatureSet returns a predicate for LoadFilesRecursively that filters manifests based on the specified FeatureSet.

type FileInfoPredicate

type FileInfoPredicate func(path string, info os.FileInfo) (bool, error)

type Permission

type Permission os.FileMode
const (
	PermissionDirectoryDefault Permission = 0755
	PermissionFileDefault      Permission = 0644
	PermissionFileRestricted   Permission = 0600
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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