asset

package
v5.10.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2019 License: MIT, MIT Imports: 25 Imported by: 24

Documentation

Overview

Package asset provides a mechanism for installing, managing, and utilizing Sensu Assets.

Access to assets are serialized. When an asset is first encountered, getting the asset from the manager blocks until the asset has been fetched, verified, and expanded on the host filesystem (or deemed unnecessary due to asset filters).

The first goroutine to get an asset will cause the installation, and subsequent calling goroutines will simply block while installation completes. If the initial installation fails, the next goroutine to unblock will attempt reinstallation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAssets

func GetAssets(ctx context.Context, store store.Store, assetList []string) []types.Asset

GetAssets retrieves all Assets from the store if contained in the list of asset names

func NewFilteredManager

func NewFilteredManager(getter Getter, entity *types.Entity) *filteredManager

NewFilteredManager returns an asset Getter that filters assets based on the given entity. Assets that aren't filtered get passed to the underlying getter, allowing composition with other asset managers.

Types

type Expander

type Expander interface {
	Expand(archive io.ReadSeeker, targetDirectory string) error
}

An Expander expands the provided *os.File to the target direcrtory.

type Fetcher

type Fetcher interface {
	Fetch(ctx context.Context, source string) (*os.File, error)
}

A Fetcher fetches a file from the specified source and returns an *os.File with the contents of the file found at source.

type Getter

type Getter interface {
	Get(context.Context, *types.Asset) (*RuntimeAsset, error)
}

A Getter is responsible for fetching (based on fitler selection), verifying, and expanding an asset. Calls to the Get method block until the Asset has fetched, verified, and expanded or it returns an error indicating why getting the asset failed.

If the context is canceled while Get is in progress, then the operation will be canceled and the error from the context will be returned.

func NewBoltDBGetter

func NewBoltDBGetter(db *bolt.DB,
	localStorage string,
	fetcher Fetcher,
	verifier Verifier,
	expander Expander) Getter

NewBoltDBGetter returns a new default asset Getter. If fetcher, verifier, or expander are nil, the getter will use the built-in components.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager ...

func NewManager

func NewManager(cacheDir string, entity *types.Entity, wg *sync.WaitGroup) *Manager

NewManager ...

func (*Manager) StartAssetManager

func (m *Manager) StartAssetManager(ctx context.Context) (Getter, error)

StartAssetManager starts the asset manager for a backend or agent.

type RuntimeAsset

type RuntimeAsset struct {
	// Path is the absolute path to the asset's base directory.
	Path string
	// SHA512 is the hash of the asset tarball.
	SHA512 string
}

A RuntimeAsset is a locally expanded Asset.

func (*RuntimeAsset) BinDir

func (r *RuntimeAsset) BinDir() string

BinDir returns the full path to the asset's bin directory.

func (*RuntimeAsset) IncludeDir

func (r *RuntimeAsset) IncludeDir() string

IncludeDir returns the full path to the asset's include directory.

func (*RuntimeAsset) LibDir

func (r *RuntimeAsset) LibDir() string

LibDir returns the full path to the asset's lib directory.

type RuntimeAssetSet

type RuntimeAssetSet []*RuntimeAsset

RuntimeAssetSet is a set of runtime assets.

func GetAll

func GetAll(ctx context.Context, getter Getter, assets []types.Asset) (RuntimeAssetSet, error)

GetAll gets a list of assets with the provided getter.

func (*RuntimeAssetSet) Env

func (r *RuntimeAssetSet) Env() []string

Env returns a list of environment variables (e.g. 'PATH=...', 'CPATH=...') with asset-specific paths prepended to the parent environment paths for each variable, allowing an asset to be used during check execution.

func (RuntimeAssetSet) Key

func (r RuntimeAssetSet) Key() string

Key gets a unique key for the RuntimeAssetSet.

func (RuntimeAssetSet) Scripts

func (r RuntimeAssetSet) Scripts() (map[string]io.ReadCloser, error)

Scripts retrieves all the js files in the lib directory.

type Verifier

type Verifier interface {
	Verify(file io.ReadSeeker, sha512 string) error
}

A Verifier verifies that a file's SHA-512 matches the specified SHA-512.

Jump to

Keyboard shortcuts

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