package embedded

import "github.com/purpleidea/mgmt/lang/embedded"

Package embedded embeds mcl modules into the system import namespace. Typically these are made available via an `import "embedded/foo"` style stmt.

Index

Constants

const (
	// Scheme is the string used to represent the scheme used by the
	// embedded filesystem URI.
	Scheme = "embeddedfs"
)

Functions

func FullModuleName

func FullModuleName(moduleName string) string

FullModuleName is a helper function that returns the embedded module name. This is the parent directory that an embedded code base should use as prefix.

func Lookup

func Lookup(module string) (engine.Fs, error)

Lookup pulls out an embedded filesystem module which will contain a valid URI method. The returned fs is read-only. XXX: Update the interface to remove the afero part leaving this all read-only

func MergeFS

func MergeFS(filesystems ...fs.ReadFileFS) fs.ReadFileFS

MergeFS merges multiple filesystems and returns an fs.FS. It is provided as a helper function to abstract away the underlying implementation in case we ever wish to replace it with something more performant or ergonomic. TODO: add a new interface that combines ReadFileFS and ReadDirFS and use that as the signature everywhere so we could catch those issues at the very start!

func ModuleRegister

func ModuleRegister(module string, fs fs.ReadFileFS)

ModuleRegister takes a filesystem and stores a reference to it in our embedded module system along with a name. Future lookups to that name will pull out that filesystem.

Source Files

embedded.go

Version
v0.0.0-20250322185616-c50a578426f1 (latest)
Published
Mar 22, 2025
Platform
linux/amd64
Imports
8 packages
Last checked
4 days ago

Tools for package owners.