Documentation
¶
Overview ¶
Package backends adapts the shared snippet protocol to registered script tools.
Index ¶
- func AllowsModule(name, requested string, explicit *hostprocess.CommandOptions) bool
- func Configure(registration contract.Registration) contract.Registration
- func LoadConfiguredModule(name, requested string, explicit *hostprocess.CommandOptions, ...) (scriptengine.Backend, error)
- func Module(name, requested string, explicit *hostprocess.CommandOptions, ...) *tools.Module
- func PathContext(scope *scriptanalysis.Scope) configuration.PathContext
- func ProcessOptions(name, requested string, explicit *hostprocess.CommandOptions, ...) *hostprocess.CommandOptions
- func ProjectMayEnable(name string, config, projectConfig *configuration.Config) (bool, error)
- func ProjectMayNeedProcess(name string, config, projectConfig *configuration.Config, command string, ...) (bool, error)
- func ProjectMayNeedProcessFor(name string, config, projectConfig *configuration.Config, ...) (bool, error)
- func RecordSources(sourceReader *files.Reader, paths []string, directory string) error
- func Register(descriptor rule.Descriptor, shells []string, backend scriptengine.Backend) (contract.Registration, error)
- func RegisterEngine(descriptor scriptengine.Descriptor, backend scriptengine.Backend) (contract.Registration, error)
- func RegisterProvider(p Provider) (contract.Registration, error)
- func RequireProcessOptIn(name, requested string, explicit *hostprocess.CommandOptions, ...) error
- func WithConfiguredEngine(registration contract.Registration, ...) contract.Registration
- func WithScriptInputs(registration contract.Registration, descriptor scriptengine.Descriptor, ...) (contract.Registration, error)
- type Provider
- type ScriptEngines
- type ToolSelection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllowsModule ¶
func AllowsModule(name, requested string, explicit *hostprocess.CommandOptions) bool
AllowsModule reports whether invocation settings permit configured Wasm selection.
func Configure ¶
func Configure(registration contract.Registration) contract.Registration
Configure binds configured-engine routing once at an entrypoint composition root.
func LoadConfiguredModule ¶
func LoadConfiguredModule(name, requested string, explicit *hostprocess.CommandOptions, cfg *configuration.Config, load func(string) (scriptengine.Backend, error)) (scriptengine.Backend, error)
LoadConfiguredModule resolves a configured WebAssembly module through the invocation loader.
func Module ¶
func Module(name, requested string, explicit *hostprocess.CommandOptions, cfg *configuration.Config) *tools.Module
Module returns the configured module unless an explicit process choice overrides it.
func PathContext ¶
func PathContext(scope *scriptanalysis.Scope) configuration.PathContext
PathContext uses the scope's configuration source, workspace and runner action path.
func ProcessOptions ¶
func ProcessOptions(name, requested string, explicit *hostprocess.CommandOptions, cfg *configuration.Config, cwd string) *hostprocess.CommandOptions
ProcessOptions applies repository backend settings unless the caller made an explicit choice.
func ProjectMayEnable ¶
func ProjectMayEnable(name string, config, projectConfig *configuration.Config) (bool, error)
ProjectMayEnable preserves a tool when a calling workflow or composite can enable it.
func ProjectMayNeedProcess ¶
func ProjectMayNeedProcess(name string, config, projectConfig *configuration.Config, command string, explicit *hostprocess.CommandOptions) (bool, error)
ProjectMayNeedProcess checks possible composite overrides without parsing workflow inputs.
func ProjectMayNeedProcessFor ¶
func ProjectMayNeedProcessFor(name string, config, projectConfig *configuration.Config, needsProcess func(*configuration.Config) bool) (bool, error)
ProjectMayNeedProcessFor resolves a host's process choice for each enabled candidate.
func RecordSources ¶
RecordSources records files a tool read, relative to directory, with files, including symlinks along their paths. A nil reader records nothing.
func Register ¶
func Register(descriptor rule.Descriptor, shells []string, backend scriptengine.Backend) (contract.Registration, error)
Register selects scripts by the supplied shell names. Backends with language-specific preparation can supply their own registration.
func RegisterEngine ¶
func RegisterEngine(descriptor scriptengine.Descriptor, backend scriptengine.Backend) (contract.Registration, error)
RegisterEngine routes both shell snippets and declared action-input sites.
func RegisterProvider ¶
func RegisterProvider(p Provider) (contract.Registration, error)
RegisterProvider registers a script tool provider from its process manifest and selection. The manifest's preparation profile selects and prepares scripts, its selectors route shells and action inputs, its capabilities admit fixes and reported sources, format messages and map severities, and tools.<name> configures the tool. A repository's tools.<name>.backend may select a WebAssembly engine or, with --allow-config-processes, another process for the default command.
func RequireProcessOptIn ¶
func RequireProcessOptIn(name, requested string, explicit *hostprocess.CommandOptions, cfg *configuration.Config, allowed bool) error
RequireProcessOptIn rejects repository-selected executables without host authorization.
func WithConfiguredEngine ¶
func WithConfiguredEngine(registration contract.Registration, load func(contract.Context) (scriptengine.Backend, error)) contract.Registration
WithConfiguredEngine discovers routes through the same invocation-owned loader used by the native adapter, including each composite's effective configuration.
func WithScriptInputs ¶
func WithScriptInputs(registration contract.Registration, descriptor scriptengine.Descriptor, backend scriptengine.Backend) (contract.Registration, error)
WithScriptInputs routes run steps through the registration and action inputs through the supplied engine.
Types ¶
type Provider ¶
type Provider struct {
Manifest toolmanifest.Manifest
// Programs resolves the manifest's transform digests.
Programs toolmanifest.Programs
Selection ToolSelection
// Bind completes a registration, such as with a managed document
// analyzer route; nil leaves it as is. RegisterProvider applies it to every
// registration it derives.
Bind func(contract.Registration, Provider) contract.Registration
}
Provider is a manifest bound to how it runs.
type ScriptEngines ¶
type ScriptEngines struct {
// contains filtered or unexported fields
}
ScriptEngines caches module loads. Failed and in-flight loads count toward the four-path session limit.
func NewScriptEngines ¶
func NewScriptEngines(load func(context.Context, string) (scriptengine.Backend, error)) *ScriptEngines
NewScriptEngines wraps a loader. A nil loader rejects every configured engine.
func (*ScriptEngines) Close ¶
func (s *ScriptEngines) Close(ctx context.Context) error
Close releases every loaded engine that can be closed and rejects further loads.
func (*ScriptEngines) LoadModuleBackend ¶
func (s *ScriptEngines) LoadModuleBackend(ctx context.Context, path string) (scriptengine.Backend, error)
LoadModuleBackend returns the engine for a module path, loading it on first use. Loaders for distinct paths may run concurrently.
type ToolSelection ¶
type ToolSelection struct {
// Command is the process command line. The provider's rule name selects
// the manifest's entry on PATH and lets repository configuration choose
// a backend; empty disables the process unless Process names an
// executable.
Command string
// Process adds arguments and environment to Command, or replaces it with
// Process.Executable. Optional makes the selection a default that is
// skipped, with a warning, when it cannot run.
Process *hostprocess.CommandOptions
// Backend replaces the process with a snippet engine.
Backend scriptengine.Backend
// Runner replaces the process with an in-process function that has no
// filesystem, such as an embedding program's ShellCheck build.
Runner func(args []string, stdin string) ([]byte, error)
// ManagedOnly permits a managed document analyzer without the native
// fallback.
ManagedOnly bool
}
ToolSelection chooses how a tool provider runs. The zero value disables it.