loader

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register added in v1.3.0

func Register(dep Dependency)

Register registers a dependency with the loader.

Types

type Dependency added in v1.3.0

type Dependency interface {
	// Fetch downloads the source of this dependency.
	// Fetch must be idempotent.
	Fetch() error

	// Name returns the name of this dependency.
	Name() string

	// Version returns the version of this dependency.
	Version() string

	// LocalDir returns the path to the directory storing the source.
	LocalDir() string
}

Dependency defines a remote Isopod module to be loaded to the local project.

type Module

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

Module represents a starlark modules.

func (*Module) Version added in v1.3.2

func (m *Module) Version() string

Version returns the version of a loaded module

type ModuleReaderFactory

type ModuleReaderFactory func(module string) (r io.Reader, closeFn func(), err error)

ModuleReaderFactory is a factory function returning reader for the module.

func NewFileReaderFactory

func NewFileReaderFactory(baseDir string) ModuleReaderFactory

NewFileReaderFactory returns new ModuleReaderFactory function for reading from disk using path relative to baseDir. It will try to follow symlink to avoid module cycles. TODO(dmitry-ilyevskiy): Support git:// source.

type ModulesLoader

type ModulesLoader interface {
	// Load implements module loading. Repeated calls with the same module name
	// returns the same module.
	Load(t *starlark.Thread, module string) (starlark.StringDict, error)

	// GetLoaded returns a mapping of loaded module paths to their text context.
	GetLoaded() map[string]string

	// GetLoadedModule returns the module given the module name.
	GetLoadedModule(moduleName string) *Module
}

ModulesLoader defines the interface to interact with a ModulesLoader.

func NewFakeModulesLoader

func NewFakeModulesLoader(
	predeclaredPkgs starlark.StringDict,
	modReaderFn ModuleReaderFactory,
) ModulesLoader

NewFakeModulesLoader creates a fake loader for modules with predeclared packages.

func NewModulesLoader

func NewModulesLoader(baseDir string) ModulesLoader

NewModulesLoader creates a new loader for modules.

func NewModulesLoaderWithPredeclaredPkgs

func NewModulesLoaderWithPredeclaredPkgs(
	baseDir string,
	predeclaredPkgs starlark.StringDict,
) ModulesLoader

NewModulesLoaderWithPredeclaredPkgs creates a new loader for modules with predeclared packages.

Jump to

Keyboard shortcuts

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