exec

package
v0.1.101 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package exec registers the "exec" query provider, which runs a command and reads its JSON stdout as rows.

The provider executes whatever command a profile names, so it is opt-in: it is registered with every host through query/providers, but refuses to run until the host sets EnabledProperty (-P query.exec.enabled=true), or calls Enable because it trusts every profile it runs. A server that accepts inline profiles opts in only when it trusts every caller that can post one.

Index

Constants

View Source
const EnabledProperty = "query.exec.enabled"

EnabledProperty opts a host in to running exec profiles; it defaults to off.

Variables

This section is empty.

Functions

func Enable

func Enable()

Enable opts this host in, for hosts that trust every profile they run (CLI and fixture runners). An explicit EnabledProperty, such as -P query.exec.enabled=false, still wins.

Types

type ExecOptions

type ExecOptions struct {
	// Command is the executable, resolved on PATH. It is never run through a
	// shell, so templated arguments cannot inject commands.
	Command string `json:"command"`

	// Args are the command's arguments, passed as argv.
	Args []string `json:"args,omitempty"`

	// Env are variables set for the command.
	Env []types.EnvVar `json:"env,omitempty"`

	// PassthroughEnv names host variables handed to the command; the rest of
	// the host environment is withheld.
	PassthroughEnv []string `json:"passthroughEnv,omitempty"`

	// Dir is the working directory; empty runs in a fresh temporary directory.
	Dir string `json:"dir,omitempty"`

	// Format is how stdout is read: json (exactly one value), ndjson (one
	// object per line) or auto (one or more values, the default).
	Format string `json:"format,omitempty"`

	// JSONPath extracts an inner array/object from each value, e.g. "$.items".
	JSONPath string `json:"jsonpath,omitempty"`

	// Timeout is a Go duration after which the command is killed; empty waits
	// for the command or the request's own deadline.
	Timeout string `json:"timeout,omitempty"`
}

ExecOptions are decoded from ProviderRequest.Options.

func (ExecOptions) Validate

func (o ExecOptions) Validate() error

Validate refuses options the provider cannot run, before any process starts.

Jump to

Keyboard shortcuts

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