Documentation
¶
Overview ¶
Package modules implements all logic needed for interacting with stencil modules and their interaction with a service generated by stencil.
Index ¶
- Constants
- func CacheDir(cacheType, moduleID string) string
- func FSCacheDir(moduleID string) string
- func FSLockDir(moduleID string) string
- func PathSlug(uri, version string) string
- func StencilCacheDir() string
- func VersionCacheDir(moduleID string) string
- func VersionLockDir(moduleID string) string
- type Module
- func (m *Module) FSCacheDir() string
- func (m *Module) GetFS(ctx context.Context) (billy.Filesystem, error)
- func (m *Module) GetTemplate() *template.Template
- func (m *Module) Manifest(ctx context.Context) (configuration.TemplateRepositoryManifest, error)
- func (m *Module) PathSlug() string
- func (m *Module) RegisterExtensions(ctx context.Context, log logrus.FieldLogger, ext *extensions.Host) error
- type ModuleResolveOptions
Constants ¶
const ModuleCacheTTL = 30 * time.Minute
ModuleCacheTTL defines the time-to-live duration for the module cache.
Variables ¶
This section is empty.
Functions ¶
func CacheDir ¶ added in v1.43.0
CacheDir returns the cache directory for a module based on its type and ID.
func FSCacheDir ¶ added in v1.43.0
FSCacheDir returns the cache directory for a module based on its ID.
func FSLockDir ¶ added in v1.43.0
FSLockDir returns the lock directory for a module filesystem based on its ID.
func PathSlug ¶ added in v1.43.0
PathSlug returns a unique identifier for a module using the given URI and versioning constraints.
func StencilCacheDir ¶ added in v1.43.0
func StencilCacheDir() string
StencilCacheDir returns the directory where stencil caches its data.
func VersionCacheDir ¶ added in v1.43.0
VersionCacheDir returns the version cache directory for a module based on its ID.
func VersionLockDir ¶ added in v1.43.0
VersionLockDir returns the lock directory for a module version based on its ID.
Types ¶
type Module ¶
type Module struct {
// Name is the name of a module. This should be a valid go
// import path. For example: github.com/getoutreach/stencil-base
Name string
// URI is the underlying URI being used to download this module
URI string
// Version is the version of this module
Version string
// contains filtered or unexported fields
}
Module is a stencil module that contains template files.
func GetModulesForService ¶
func GetModulesForService(ctx context.Context, opts *ModuleResolveOptions) ([]*Module, error)
GetModulesForService returns a list of modules that have been resolved from the provided service manifest, respecting constraints and channels as needed.
func New ¶
func New(ctx context.Context, uri string, tr *configuration.TemplateRepository) (*Module, error)
New creates a new module from a TemplateRepository. Version must be set and can be obtained via the gobox/pkg/cli/updater/resolver package, or by using the GetModulesForService function.
uri is the URI for the module. If it is an empty string https://+name is used instead.
func NewWithFS ¶
NewWithFS creates a module with the specified file system. This is generally only meant to be used in tests.
func (*Module) FSCacheDir ¶ added in v1.43.0
func (*Module) GetFS ¶
GetFS returns a billy.Filesystem that contains the contents of this module. If the module URI starts with file://, it uses the local filesystem at the given path. Otherwise, it clones the module from a remote git repository into a temporary cache directory on the OS filesystem. This allows the module to be used as a billy.Filesystem.
func (*Module) GetTemplate ¶
GetTemplate returns the go template for this module
func (*Module) Manifest ¶
func (m *Module) Manifest(ctx context.Context) (configuration.TemplateRepositoryManifest, error)
Manifest downloads the module if not already downloaded and returns a parsed configuration.TemplateRepositoryManifest of this module.
func (*Module) RegisterExtensions ¶
func (m *Module) RegisterExtensions(ctx context.Context, log logrus.FieldLogger, ext *extensions.Host) error
RegisterExtensions registers all extensions provided by the given module. If the module is a local file URI then extensions will be sourced from the `./bin` directory of the base of the path.
type ModuleResolveOptions ¶ added in v1.29.0
type ModuleResolveOptions struct {
// Token is the token to use to resolve modules
Token cfg.SecretData
// Log is the logger to use
Log logrus.FieldLogger
// ServiceManifest is the manifest to resolve modules for.
// This can only be supplied if Module is not set.
ServiceManifest *configuration.ServiceManifest
// Module is the module to resolve dependencies for.
// This can only be supplied if ServiceManifest is not
// set. This module is automatically added as a
// Replacement.
Module *Module
// Replacements is a map of modules to use instead of ones specified
// in the manifest. This is mainly meant for tests/importing of stencil
// as this is not resolved and instead requires a module type to be
// passed.
Replacements map[string]*Module
// ConcurrentResolvers is the number of concurrent resolvers to use
// when resolving modules.
ConcurrentResolvers int
}
ModuleResolveOptions contains options for resolving modules
Directories
¶
| Path | Synopsis |
|---|---|
|
Package modulestest contains code for interacting with modules in tests.
|
Package modulestest contains code for interacting with modules in tests. |